@@ -95,8 +95,8 @@ def yield_studies(
95
95
for study_dict in studies_dict ["matched_studies" ][study_slice ]:
96
96
study_id = study_dict ["ot:studyId" ]
97
97
study_dict = pyopentree .get_study_meta (study_id )["nexml" ]
98
- citation = study_dict .get (' ^ot:studyPublicationReference' , None )
99
- doi_dict = study_dict .get (' ^ot:studyPublication' , None )
98
+ citation = study_dict .get (" ^ot:studyPublicationReference" , None )
99
+ doi_dict = study_dict .get (" ^ot:studyPublication" , None )
100
100
if doi_dict is not None :
101
101
doi = doi_dict ["@href" ]
102
102
else :
@@ -127,6 +127,16 @@ def list_studies(self,
127
127
study .doi ,
128
128
study .citation ))
129
129
130
+ def get_trees (self ,
131
+ doi ,
132
+ schema = "nexml" ):
133
+ # verbose
134
+ tree_ids = self .studies_find_trees (
135
+ study_property = "ot:studyPublication" ,
136
+ value = doi ,
137
+ exact = True )
138
+ print (tree_ids )
139
+
130
140
def main ():
131
141
"""
132
142
Main CLI handler.
@@ -135,31 +145,34 @@ def main():
135
145
parser = argparse .ArgumentParser (description = __description__ )
136
146
subparsers = parser .add_subparsers (help = 'commands' , dest = "subparser_name" )
137
147
138
- # A list command
139
- list_studies_parser = subparsers .add_parser (' list-studies' , help = ' List contents' )
148
+ # list studies
149
+ list_studies_parser = subparsers .add_parser (" list-studies" , help = " List contents" )
140
150
list_studies_parser .add_argument ("--filter-for-taxon" ,
141
151
action = "append" ,
142
152
default = False ,
143
- help = "Filter for studies with specific taxa" )
153
+ help = "Filter for studies with specific taxa (multiple filters will be OR'd together). " )
144
154
list_studies_parser .add_argument ("--list-from" ,
145
155
type = int ,
146
156
default = None ,
147
157
help = "First study to list (default: first)" )
148
158
list_studies_parser .add_argument ("--max-studies" ,
149
159
type = int ,
150
160
default = None ,
151
- help = "Maximum number of studies to list" )
161
+ help = "Maximum number of studies to list. " )
152
162
list_studies_parser .add_argument ("--as-table" ,
153
163
action = "store_true" ,
154
164
default = False ,
155
- help = "Format as (tab-delimited) rows" )
156
-
157
- # A create command
158
- # create_parser = subparsers.add_parser('create', help='Create a directory')
159
- # create_parser.add_argument('dirname', action='store', help='New directory to create')
160
- # create_parser.add_argument('--read-only', default=False, action='store_true',
161
- # help='Set permissions to prevent writing to the directory',
162
- # )
165
+ help = "Format as (tab-delimited) rows." )
166
+
167
+ # get trees
168
+ get_trees_parser = subparsers .add_parser ("get-trees" , help = "Retrieve trees" )
169
+ get_trees_parser .add_argument ("doi" ,
170
+ help = "DOI of the study containing the trees to retrieve" )
171
+ get_trees_parser .add_argument ("-f" , "--format" ,
172
+ dest = "schema" ,
173
+ choices = ["nexus" , "newick" , "nexml" ],
174
+ default = "nexml" ,
175
+ help = "DOI of the study containing the trees to retrieve (default: '%(default)s')." )
163
176
164
177
# # A delete command
165
178
# delete_parser = subparsers.add_parser('delete', help='Remove a directory')
@@ -178,6 +191,11 @@ def main():
178
191
max_studies = args .max_studies ,
179
192
as_table = args .as_table ,
180
193
)
194
+ elif args .subparser_name == "get-trees" :
195
+ # http://dx.doi.org/10.1111/j.1365-294X.2012.05606.x
196
+ ots .get_trees (
197
+ doi = args .doi ,
198
+ schema = args .schema )
181
199
else :
182
200
parser .print_usage (sys .stderr )
183
201
sys .exit (1 )
0 commit comments