-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from McTavishLab/repeat
Repeat
- Loading branch information
Showing
10 changed files
with
104 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
from opentree import OT | ||
|
||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-t","--taxon_name", help="Name of search taxon") | ||
parser.add_argument("-ott","--ott_id", help="Name of search taxon") | ||
parser.add_argument("-tb","--treebase", action = 'store_true', help="Rturn studies with treebase data only") | ||
parser.add_argument("-o","--output", help="Output file path") | ||
args = parser.parse_args() | ||
|
||
|
||
if args.taxon_name: | ||
try: | ||
ottid = OT.get_ottid_from_name(args.taxon_name) | ||
except: | ||
sys.stdout.write("no match to taxon name. Try finding your taxon on tree.opentreeoflife.org and inputting the taxon id using -ott") | ||
|
||
|
||
#sys.stdout.write("OTT id of {}") | ||
phylesystem_studies_resp = OT.find_trees(ottid, search_property ='ot:ottId') | ||
|
||
|
||
studies = dict() | ||
trees = dict() | ||
treebase_studies = set() | ||
for study in phylesystem_studies_resp.response_dict['matched_studies']: | ||
study_id = study['ot:studyId'] | ||
studies[study_id] = dict() | ||
study_info = OT.get_study(study_id) | ||
nexson = study_info.response_dict['data'] | ||
data_deposit = nexson['nexml'].get(u'^ot:dataDeposit') | ||
data_deposit_url = 'None' | ||
if data_deposit: | ||
data_deposit_url = data_deposit[u'@href'] | ||
studies[study_id]['data_deposit_url'] = data_deposit_url | ||
if 'treebase' in data_deposit_url: | ||
treebase_studies.add(study_id) | ||
trees[study_id] = [] | ||
for tree in study['matched_trees']: | ||
treeid = tree['ot:treeId'] | ||
trees[study_id].append(treeid) | ||
cites = [] | ||
studies[study_id]['opentree_url'] = "https://tree.opentreeoflife.org/curator/study/view/{}".format(study_id) | ||
studies[study_id]['reference'] = nexson['nexml'].get('^ot:studyPublicationReference', 'no ref') | ||
studies[study_id]['doi'] = nexson['nexml'].get('^ot:studyPublication', 'no study pub') | ||
|
||
|
||
cites_phyl = "Members of {} present in the following studies in the OpenTree Phylesystem\n".format(args.taxon_name) | ||
|
||
|
||
if args.treebase: | ||
cites_phyl = cites_phyl + "Only returning studies with TreeBase links\n" | ||
|
||
for study_id in studies: | ||
if args.treebase and study_id not in treebase_studies: | ||
continue | ||
cites_phyl = cites_phyl + "\nStudy {} tree(s) {}\n".format(study_id, ', '.join(trees[study_id])) | ||
cites_phyl = cites_phyl + "OpenTreeUrl: " + studies[study_id]['opentree_url'] + '\n' | ||
cites_phyl = cites_phyl + "Reference: " + studies[study_id]['reference'] + '\n' | ||
cites_phyl = cites_phyl + "Data Deposit URL: " + studies[study_id]['data_deposit_url'] + '\n' | ||
|
||
|
||
if args.output: | ||
ofi = open(args.output, 'w') | ||
ofi.write(cites_phyl) | ||
else: | ||
print(cites_phyl) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
How to start | ||
============ | ||
|
||
.. mdinclude:: ../../cruft/How_to_start.md | ||
.. mdinclude:: ../Tutorial.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ pytest | |
pytest-cov | ||
pytest-xdist | ||
|
||
m2r; python_version > '2.7.13' | ||
m2r | ||
recommonmark | ||
|
||
#past | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters