Skip to content

Commit ae0adef

Browse files
committed
Merge branch 'trees-report' of github.com:OpenTreeOfLife/germinator into trees-report
2 parents c32ed91 + a88d37a commit ae0adef

File tree

3 files changed

+23
-49
lines changed

3 files changed

+23
-49
lines changed

trees_report/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ shards/phylesystem-1:
2424

2525
conflict: work/conflict.csv
2626

27-
work/conflict.csv: conflict.py
27+
work/conflict.csv: conflict.py shards/phylesystem-1
2828
@mkdir -p work
2929
$(JYTHON) conflict.py \
3030
--out $@ \
31-
--shard $(REPOS)/phylesystem-1 \
31+
--shard shards/phylesystem-1 \
3232
--ref $(SYNTH)/labelled_supertree/labelled_supertree.tre
3333

3434
# smaller, for testing
@@ -48,3 +48,6 @@ work/taxa_in_synthesis.txt:
4848
$(JYTHON) taxa_in_synthesis.py \
4949
$(SYNTH)/grafted_solution/grafted_solution.tre \
5050
$@
51+
52+
clean:
53+
rm -f work/* trees_report.csv

trees_report/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ work/conflict.csv and work/synthesis_tree_list.csv.
2929
* collections-1
3030
* phylesystem-1
3131
* Install peyotl
32-
* Go to the reference-taxonomy repo and say `make compile bin/jython`
33-
* Adjust SYNTH in the Makefile or put synthesis files in that location
32+
* Go to the reference-taxonomy repo and say `make compile bin/jython` (as of 2016-05-09,
33+
the `amendments` branch of the reference-taxonomy repo is required, but
34+
I expect this to get merged to master in the future)
35+
* Adjust SYNTH in the Makefile or put synthesis files in that location. It
36+
needs the files `output/labelled_supertree/labelled_supertree.tre` and
37+
`output/grafted_solution/grafted_solution.tre`
3438
* dot_peyotl is the peyotl configuration file, but it should require
3539

3640
## Known issues

trees_report/conflict.py

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
from org.opentreeoflife.taxa import Taxonomy, Nexson, Flag
55
from org.opentreeoflife.conflict import ConflictAnalysis, Disposition
66

7-
repo_dir = '../repo' # directory containing repo clones
8-
9-
default_shard = os.path.join(repo_dir, 'phylesystem-1')
10-
117
# Report generation
128

139
# Report on every tree in every study
@@ -19,6 +15,7 @@ def report_on_trees(study_ids, shard, refs, outfile):
1915
count = 0
2016
for study_id in study_ids:
2117
study = get_study(study_id, shard)
18+
if study == None: continue
2219
for tree in tree_iter_nexson_proxy(study):
2320
row = report_on_tree(tree, study, refs)
2421
writer.writerow(row)
@@ -154,7 +151,7 @@ def ingroup(self):
154151

155152
# shard is the path to the root of the repository (or shard) clone
156153

157-
def study_id_to_path(study_id, shard=default_shard):
154+
def study_id_to_path(study_id, shard):
158155
(prefix, number) = study_id.split('_', 1)
159156
if len(number) == 1:
160157
residue = '_' + number
@@ -183,45 +180,13 @@ def gobble_study(study_id, phylesystem):
183180
# should do try/catch for file-not-found
184181
if not os.path.exists(filepath):
185182
# foo, should be using try/catch
186-
print '** Not found:', self.filepath
183+
print '** Not found:', filepath
187184
return None
188185
return NexsonProxy(filepath)
189186

190187
def import_tree(tree):
191188
return Nexson.importTree(tree.nexson_tree, tree._nexson_proxy.reftax_otus, tree.tree_id)
192189

193-
# Study/tree ids in a collection
194-
195-
def collection_treespecs(path):
196-
with open(path, 'r') as infile:
197-
collection_json = json.load(infile)
198-
return map(lambda coll: (coll[u'studyID'], coll[u'treeID']),
199-
collection_json[u'decisions'])
200-
201-
synthesis_treespecs = [] # rank order
202-
trees_in_synthesis = {}
203-
204-
def read_synthesis_collections():
205-
if len(synthesis_treespecs) > 0: return
206-
for collection_name in ['fungi',
207-
'safe-microbes',
208-
'metazoa',
209-
'plants']:
210-
path = os.path.join(repo_dir, 'collections-1/collections-by-owner/opentreeoflife', collection_name + '.json')
211-
print 'reading', path
212-
for treespec in collection_treespecs(path):
213-
synthesis_treespecs.append(treespec)
214-
trees_in_synthesis[treespec] = True
215-
216-
def in_synthesis(study_id, tree_id):
217-
if len(trees_in_synthesis) == 0:
218-
read_synthesis_collections()
219-
treespec = (study_id, tree_id)
220-
if treespec in trees_in_synthesis:
221-
return trees_in_synthesis[treespec]
222-
else:
223-
return False
224-
225190
# Utilities associated with obtaining study and tree lists for reporting
226191

227192
# All study ids within a given phylesystem (shard)
@@ -231,12 +196,13 @@ def all_study_ids(shard):
231196
top = os.path.join(shard, 'study')
232197
hundreds = os.listdir(top)
233198
for dir in hundreds:
234-
dir2 = os.path.join(top, dir)
235-
if os.path.isdir(dir2):
236-
dirs = os.listdir(dir2)
237-
for study_dir in dirs:
238-
# if os.path.isdir(study_dir): ... ? ...
239-
ids.append(study_dir)
199+
if not dir.startswith('.'):
200+
dir2 = os.path.join(top, dir)
201+
if os.path.isdir(dir2):
202+
dirs = os.listdir(dir2)
203+
for study_dir in dirs:
204+
# if os.path.isdir(study_dir): ... ? ...
205+
ids.append(study_dir)
240206
print len(ids), 'studies'
241207
return ids
242208

@@ -263,6 +229,7 @@ def load_tree(path):
263229
print count, 'ids'
264230
return tree
265231

232+
repo_dir = '../..' # directory containing repo clones
266233
registry_dir = os.path.join(repo_dir, 'reference-taxonomy', 'registry')
267234

268235
# consider comparing the "^ot:focalClade" to the induced root
@@ -274,7 +241,7 @@ def load_tree(path):
274241
argparser.add_argument('--out', dest='outfile', default='-')
275242

276243
argparser.add_argument('--shard', dest='shard',
277-
default=default_shard,
244+
default=os.path.join(repo_dir, 'phylesystem-1'),
278245
help='root directory of repository (shard) containing nexsons')
279246
argparser.add_argument('--ref', dest='refs', nargs='+',
280247
default=os.path.join(registry_dir, 'draftversion4.tre'), # synthetic tree is a newick...

0 commit comments

Comments
 (0)