Skip to content

Commit

Permalink
Finalized docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraluebbert committed May 15, 2023
1 parent 858133d commit a254c9a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/src/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Function to install/download third-party dependencies for a specified gget modul

**Positional argument**
`module`
gget module for which dependencies should be installed (currently only "alphafold").
gget module for which dependencies should be installed ("alphafold", "gpt" or "cellxgene").

### Example
```bash
Expand Down
5 changes: 4 additions & 1 deletion docs/src/updates.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## ✨ What's new
**Version ≥ 0.27.6** (May 1, 2023):
**Version ≥ 0.27.7** (May 15, 2023):
- Moved dependencies for modules [`gget gpt`](./gpt.md) and [`gget cellxgene`](./cellxgene.md) from automatically installed requirements to [`gget setup`](./setup.md).

**Version ≥ 0.27.6** (May 1, 2023) (YANKED):
- Thanks to PR by [Tomás Di Domenico](https://github.com/tdido): [`gget search`](./search.md) can now also query plant 🌱 Ensembl IDs.
- New module: [`gget cellxgene`](./cellxgene.md)

Expand Down
48 changes: 31 additions & 17 deletions gget/gget_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
PARAMS_PATH = os.path.join(PARAMS_DIR, "params_temp.tar")


def setup(module):
def setup(module, verbose=True):
"""
Function to install third-party dependencies for a specified gget module.
Requires pip to be installed (https://pip.pypa.io/en/stable/installation).
Args:
- module (str) gget module for which dependencies should be installed, e.g. "alphafold", "cellxgene" or "gpt".
- verbose True/False whether to print progress information. Default True.
"""
supported_modules = ["alphafold", "cellxgene", "gpt"]
if module not in supported_modules:
Expand All @@ -49,7 +50,8 @@ def setup(module):
)

if module == "gpt":
logging.info("Installing openai package (requires pip).")
if verbose:
logging.info("Installing openai package (requires pip).")
command = "pip install -q -U openai"
with subprocess.Popen(command, shell=True, stderr=subprocess.PIPE) as process:
stderr = process.stderr.read().decode("utf-8")
Expand All @@ -67,15 +69,17 @@ def setup(module):
try:
import openai

logging.info(f"openai installed succesfully.")
if verbose:
logging.info(f"openai installed succesfully.")
except ImportError as e:
logging.error(
f"openai installation with pip (https://pypi.org/project/openai) failed. Import error:\n{e}"
)
return

if module == "cellxgene":
logging.info("Installing cellxgene-census package (requires pip).")
if verbose:
logging.info("Installing cellxgene-census package (requires pip).")
command = "pip install -q -U cellxgene-census"
with subprocess.Popen(command, shell=True, stderr=subprocess.PIPE) as process:
stderr = process.stderr.read().decode("utf-8")
Expand All @@ -93,7 +97,8 @@ def setup(module):
try:
import cellxgene_census

logging.info(f"cellxgene_census installed succesfully.")
if verbose:
logging.info(f"cellxgene_census installed succesfully.")
except ImportError as e:
logging.error(
f"cellxgene-census installation with pip (https://pypi.org/project/cellxgene-census) failed. Import error:\n{e}"
Expand All @@ -102,7 +107,7 @@ def setup(module):

if module == "alphafold":
if platform.system() == "Windows":
logging.warning(
logging.error(
"gget setup alphafold and gget alphafold are not supported on Windows OS."
)

Expand All @@ -118,7 +123,8 @@ def setup(module):
# if openmm.__version__ != "7.5.1":
# raise ImportError()

# logging.info(f"openmm v{openmm.__version__} already installed.")
# if verbose:
# logging.info(f"openmm v{openmm.__version__} already installed.")

except ImportError as e:
raise ImportError(
Expand All @@ -133,7 +139,8 @@ def setup(module):
)

## Install py3Dmol
logging.info("Installing py3Dmol (requires pip).")
if verbose:
logging.info("Installing py3Dmol (requires pip).")
command = "pip install -q py3Dmol"
with subprocess.Popen(command, shell=True, stderr=subprocess.PIPE) as process:
stderr = process.stderr.read().decode("utf-8")
Expand All @@ -151,15 +158,17 @@ def setup(module):
try:
import py3Dmol

logging.info(f"py3Dmol installed succesfully.")
if verbose:
logging.info(f"py3Dmol installed succesfully.")
except ImportError as e:
logging.error(
f"py3Dmol installation with pip (https://pypi.org/project/py3Dmol/) failed. Import error:\n{e}"
)
return

## Install Alphafold if not already installed
logging.info("Installing AlphaFold from source (requires pip and git).")
if verbose:
logging.info("Installing AlphaFold from source (requires pip and git).")

## Install AlphaFold and change jackhmmer directory where database chunks are saved in
# Define AlphaFold folder name and location
Expand Down Expand Up @@ -226,7 +235,8 @@ def setup(module):
try:
import alphafold as AlphaFold

logging.info(f"AlphaFold installed succesfully.")
if verbose:
logging.info(f"AlphaFold installed succesfully.")
except ImportError as e:
logging.error(f"AlphaFold installation failed. Import error:\n{e}")
return
Expand All @@ -237,7 +247,8 @@ def setup(module):
sys.path.append(alphafold_path)

## Install pdbfixer
logging.info("Installing pdbfixer from source (requires pip and git).")
if verbose:
logging.info("Installing pdbfixer from source (requires pip and git).")

pdbfixer_folder = os.path.join(
PACKAGE_PATH, "tmp_pdbfixer_" + str(uuid.uuid4())
Expand Down Expand Up @@ -288,9 +299,10 @@ def setup(module):
os.makedirs(os.path.join(PARAMS_DIR, "params/"), exist_ok=True)

if len(os.listdir(os.path.join(PARAMS_DIR, "params/"))) < 12:
logging.info(
"Downloading AlphaFold model parameters (requires 4.1 GB of storage). This might take a few minutes."
)
if verbose:
logging.info(
"Downloading AlphaFold model parameters (requires 4.1 GB of storage). This might take a few minutes."
)
if platform.system() == "Windows":
# The double-quotation marks allow white spaces in the path, but this does not work for Windows
command = f"""
Expand All @@ -317,6 +329,8 @@ def setup(module):
logging.error("Model parameter download failed.")
return
else:
logging.info("Model parameter download complete.")
if verbose:
logging.info("Model parameter download complete.")
else:
logging.info("AlphaFold model parameters already downloaded.")
if verbose:
logging.info("AlphaFold model parameters already downloaded.")
23 changes: 21 additions & 2 deletions gget/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,15 @@ def main():
help="gget module for which dependencies should be installed, e.g. 'alphafold'",
)

parser_setup.add_argument(
"-q",
"--quiet",
default=True,
action="store_false",
required=False,
help="Does not print progress information.",
)

## gget alphafold subparser
alphafold_desc = "Predicts the structure of a protein using a simplified version of AlphaFold v2.3.0 (https://doi.org/10.1038/s41586-021-03819-2)."
parser_alphafold = parent_subparsers.add_parser(
Expand Down Expand Up @@ -1148,6 +1157,14 @@ def main():
required=False,
help="The file name to save the generated text to (defaults to printing the output to the console)",
)
parser_gpt.add_argument(
"-q",
"--quiet",
default=True,
action="store_false",
required=False,
help="Do not print progress information.",
)

# cellxgene parser arguments
cellxgene_desc = (
Expand Down Expand Up @@ -1501,6 +1518,7 @@ def main():
frequency_penalty=args.frequency_penalty,
logit_bias=args.logit_bias,
out=args.out,
verbose=args.quiet,
)

if args.out is None:
Expand Down Expand Up @@ -1677,7 +1695,7 @@ def main():
if not args.fasta_deprecated and not args.fasta:
parser_muscle.error("the following arguments are required: fasta")

muscle(fasta=args.fasta, super5=args.super5, out=args.out)
muscle(fasta=args.fasta, super5=args.super5, out=args.out, verbose=args.quiet)

## ref return
if args.command == "ref":
Expand Down Expand Up @@ -2047,7 +2065,7 @@ def main():

## setup return
if args.command == "setup":
setup(args.module)
setup(args.module, verbose=args.quiet)

## alphafold return
if args.command == "alphafold":
Expand All @@ -2067,6 +2085,7 @@ def main():
relax=args.relax,
plot=False,
show_sidechains=False,
verbose=args.quiet,
)

## pdb return
Expand Down

0 comments on commit a254c9a

Please sign in to comment.