Skip to content

Commit

Permalink
fixed search taxa list when using --coreTaxa
Browse files Browse the repository at this point in the history
  • Loading branch information
trvinh committed Feb 12, 2024
1 parent 82acd82 commit 91edb37
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
31 changes: 31 additions & 0 deletions fdog/libs/orthosearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,34 @@ def run_hamstr(args):

### return
return({**{seed_id_mod:seed_seq}, **hamstr_out})


def get_search_taxa_ids(searchTaxa, searchpath):
""" Get taxonomy IDs for search taxa
Either from searchTaxa_dir, or from user input list (--searchTaxa)
Return dictionary {taxID:<TaxName>@<TaxID>@Ver}
"""
tax_ids = {}
if not searchTaxa == '' and not len(searchTaxa) == 0:
ignored_taxa = []
if os.path.exists(os.path.abspath(searchTaxa)):
search_taxa = general_fn.read_file(searchTaxa)
else:
search_taxa = searchTaxa.split(',')

for search_taxon in search_taxa:
if not os.path.exists(
os.path.abspath(
'%s/%s/%s.fa' % (searchpath,search_taxon,search_taxon))):
ignored_taxa.append(search_taxon)
else:
id = search_taxon.split('@')[1]
if not id in tax_ids:
tax_ids[id] = search_taxon
if len(ignored_taxa) > 0:
print(
'WARNING: %s taxa cannot be found at %s\n%s'
% (len(ignored_taxa), searchpath, ignored_taxa))
else:
tax_ids = general_fn.get_ids_from_folder(searchpath, 'searchTaxa_dir')
return(tax_ids)
4 changes: 3 additions & 1 deletion fdog/runMulti.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ def main():
check_fas = fas_fn.check_fas_executable()
if check_fas == 0:
sys.exit('ERROR: FAS is not executable! You still can use fDOG with --fasOff!')
check_time = time.time()
print('==> Preparation finished in ' + '{:5.3f}s'.format(check_time - begin))

### START
Path(outpath).mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -401,7 +403,7 @@ def main():
exit('ERROR: Taxon group "%s" invalid!' % group)
### create taxonomy tree from list of search taxa
searchTaxa = []
tax_ids = core_fn.get_core_taxa_ids(coreTaxa, corepath)
tax_ids = ortho_fn.get_search_taxa_ids(searchTaxa, searchpath)

for tax_id in tax_ids.keys():
check = tree_fn.check_taxon_group(group_id[group][0], tax_id, ncbi)
Expand Down
4 changes: 3 additions & 1 deletion fdog/runSingle.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def main():
check_fas = fas_fn.check_fas_executable()
if check_fas == 0:
sys.exit('ERROR: FAS is not executable! You still can use fDOG with --fasOff!')
check_time = time.time()
print('==> Preparation finished in ' + '{:5.3f}s'.format(check_time - begin))

##### Identify seed ID from refspec genome
if reuseCore:
Expand Down Expand Up @@ -265,7 +267,7 @@ def main():
exit('ERROR: Taxon group "%s" invalid!' % group)
### create taxonomy tree from list of search taxa
searchTaxa = []
tax_ids = core_fn.get_core_taxa_ids(coreTaxa, corepath)
tax_ids = ortho_fn.get_search_taxa_ids(searchTaxa, searchpath)

for tax_id in tax_ids.keys():
check = tree_fn.check_taxon_group(group_id[group][0], tax_id, ncbi)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name="fdog",
version="0.1.26",
version="0.1.27",
python_requires='>=3.7.0',
description="Feature-aware Directed OrtholoG search tool",
long_description=long_description,
Expand Down

0 comments on commit 91edb37

Please sign in to comment.