Commit ee39414f authored by Sean Solari's avatar Sean Solari
Browse files

Add flexibility in specifying phylogeny path

parent f6ad2d64
......@@ -7,4 +7,4 @@ readthedocs-sphinx-search==0.1.1
sphinxcontrib-mermaid==0.7.1
Cython
numpy
numpy>=1.22.0
......@@ -44,7 +44,7 @@ Welcome to the **expam** documentation!
.. raw:: html
<p>
<a class="reference internal" href="https://figshare.com/s/3475c3a9aa926a40c722" target="_blank">Database</a>
<a class="reference internal" href="https://doi.org/10.26180/19653840" target="_blank">Database</a>
</p>
.. container:: colsix
......
......@@ -15,7 +15,7 @@ Get the database
.. raw:: html
<p>
<a class="reference internal" href="https://drive.google.com/file/d/1K1sVA4LGgmGBVg_0GeUppVa_xcfWxxGL/view?usp=sharing" target="_blank">Test Database (110.7 Mb)</a>
<a class="reference internal" href="https://drive.google.com/file/d/1KRrEvG5Sr28wvkEFW5CXKwcYqLHAu6f7/view?usp=sharing" target="_blank">Test Database (110.7 Mb)</a>
</p>
.. container:: coltwo
......@@ -23,7 +23,7 @@ Get the database
.. raw:: html
<p>
<a class="reference internal" href="https://figshare.com/s/3475c3a9aa926a40c722" target="_blank">expam RefSeq (122.35 Gb)</a>
<a class="reference internal" href="https://doi.org/10.26180/19653840" target="_blank">expam RefSeq (122.35 Gb)</a>
</p>
* Unzip the compressed file. For instance, if you downloaded :code:`Test Database` (:code:`test.tar.gz`) into your home directory :code:`~`, run
......
......@@ -8,7 +8,7 @@ then
exit 1
fi
rsync -vaRP docs src/expam src/benchmark test .gitignore .pyirc .readthedocs.yaml LICENSE MANIFEST.in pyproject.toml README.md setup.cfg setup.py buildandtwine.sh requirements.txt $EXPAM_PUBLIC_DIR
rsync -vaRP docs src/expam src/benchmark/*.py src/benchmark/database_access_profiling/*.py test .gitignore .pyirc .readthedocs.yaml LICENSE MANIFEST.in pyproject.toml README.md setup.cfg setup.py buildandtwine.sh requirements.txt $EXPAM_PUBLIC_DIR
echo "\nbuildandtwine.sh" >> $EXPAM_PUBLIC_DIR/.gitignore
echo "\n==================================\nLocal push completed successfully!\n==================================\n\nNow run build and run twine :)"
__version__ = (1, 0, 7)
__version__ = (1, 0, 8)
......@@ -98,7 +98,6 @@ class BuildCommand(CommandGroup):
# Read configuration file.
k, n, phylogeny, genome_paths, pile = conf.get_build_params()
phylogeny_path = make_path_absolute(phylogeny, self.config.phylogeny)
clear_logs(self.config.logs)
......@@ -108,7 +107,7 @@ class BuildCommand(CommandGroup):
expam(
db_path=self.config.base,
genome_paths=genome_paths,
phylogeny_path=phylogeny_path,
phylogeny_path=phylogeny,
k=k,
n=n - 1, # Account for main process.
pile_size=pile,
......
......@@ -168,7 +168,7 @@ class ClassifyCommand(CommandGroup):
die("Run command `download_taxonomy` first to collect taxa for your genomes!")
config = JSONConfig(self.config.conf)
phylogeny_path = make_path_absolute(config["phylogeny_path"], self.config.conf)
_, _, phylogeny_path, _, _ = config.get_build_params()
index, phylogenyIndex = name_to_id(phylogeny_path)
......
......@@ -176,8 +176,7 @@ class TreeCommand(CommandGroup):
def phylotree(self):
self.check_results_exist()
config: JSONConfig = self.get_conf()
phylogeny_path = make_path_absolute(config["phylogeny_path"], self.config.database)
_, _, phylogeny_path, _, _ = config.get_build_params()
index, phylogenyIndex = name_to_id(phylogeny_path)
try:
......@@ -216,9 +215,9 @@ class TreeCommand(CommandGroup):
die("First install ete3 tools...`pip install ete3`.")
config: JSONConfig = self.get_conf()
try:
phylogeny_path = make_path_absolute(config["phylogeny_path"], self.config.database)
except TypeError:
_, _, phylogeny_path, _, _ = config.get_build_params()
if phylogeny_path is None:
die("Phylogeny not set!")
try:
......
import json
import os
from posixpath import isabs
import numpy as np
from expam.database import ACCESSION_ID_RELATIVE_PATH, CONF_RELATIVE_PATH, DATABASE_FILE_RELATIVE_PATH, DATABASE_RELATIVE_PATH, LCA_MATRIX_RELATIVE_PATH, LOG_RELATIVE_PATH, PHYLOGENY_RELATIVE_PATH, TAXID_LINEAGE_MAP_RELATIVE_PATH, TAXON_RANK_MAP_RELATIVE_PATH, FileLocationConfig
......@@ -94,10 +95,28 @@ class JSONConfig:
def set(self, **kwargs):
for arg in kwargs:
if arg in self.params and arg != 'groups':
if arg in self.params and arg != 'groups' and arg != 'phylogeny_path':
if kwargs[arg] is not None:
self.params[arg] = kwargs[arg]
elif arg == "phylogeny_path":
phylogeny_path = kwargs[arg]
if phylogeny_path is not None:
if not os.path.isabs(phylogeny_path):
abs_path = os.path.abspath(phylogeny_path)
if not os.path.exists(abs_path) and self.url is not None:
db_path = self.url.rstrip(CONF_RELATIVE_PATH)
phy_db_rel_path = os.path.join(db_path, phylogeny_path)
if not os.path.exists(phy_db_rel_path):
die("Can't find path %s." % kwargs[arg])
elif not os.path.exists(abs_path) and self.url is None:
die("Can't find path %s." % kwargs[arg])
else:
phylogeny_path = abs_path
self.params[arg] = phylogeny_path
else:
raise ValueError("Unknown configuration category %s!" % arg)
......@@ -191,6 +210,18 @@ class JSONConfig:
def get_build_params(self):
"""Returns k, n, phylogeny_path, genome_paths, pile_size"""
genome_paths, phylogeny_path, k, n, pile_size = self.get_paths(), self["phylogeny_path"], int(self["k"]), int(self["n"]), self["pile"]
if not os.path.exists(phylogeny_path):
assert self.url is not None
db_path = self.url.rstrip(CONF_RELATIVE_PATH)
print(CONF_RELATIVE_PATH)
full_path = os.path.join(db_path, phylogeny_path)
if not os.path.join(full_path):
die("Can't find phylogeny! Original path is %s." % phylogeny_path)
else:
phylogeny_path = full_path
return k, n, phylogeny_path, genome_paths, pile_size
def get_groups(self, input_group: str = None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment