Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
snacktavish committed Aug 9, 2019
1 parent 459aa5e commit d3b4b4f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
19 changes: 18 additions & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,22 @@ Once you have a venv-physcraper directory, you can run:
source venv-physcraper/bin/activate
## This force reinstalling numpy first is key
pip install --force-reinstall numpy==1.14.5
pip install -r requiremenets.txt
cd physcraper
pip install -r requirements.txt
python setup.py install

Dependencies:

Currently complete phylogenetic updating requires
raxmlHPC and muscle to be installed and in the path.

Check if they are installed using

which muscle
which raxmlHPC

You can generate updated alignments to analyze using other phylogenetic software by creating a Scrape object and
running scrape.align__query_seqs()



3 changes: 1 addition & 2 deletions docs/examples/data_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@

#scraper.read_blast_wrapper()
scraper.est_full_tree()

scraper.data.write_labelled
scraper.data.write_labelled()
16 changes: 15 additions & 1 deletion physcraper/opentree_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ def bulk_tnrs_load(filename, ids_obj = None):
for source in name.get("taxonomicSources"):
taxsrc = source.split(":")
otu_dict[otu]["^{}:taxon".format(taxsrc[0])] = source.strip(taxsrc[1])
for otu in otu_dict:
otu_dict[otu]["^physcraper:status"] = "original"
otu_dict[otu]["^physcraper:last_blasted"] = None
return otu_dict


def get_tree_from_synth(ott_ids, label_format="name", citation="cites.txt",):
def get_tree_from_synth(ott_ids, label_format="name", citation="cites.txt"):
assert label_format in ['id', 'name', 'name_and_id']
resp = treemachine.get_synth_tree_pruned(ott_ids=ott_ids, label_format=label_format)
cites = ''
Expand All @@ -85,6 +88,17 @@ def get_tree_from_synth(ott_ids, label_format="name", citation="cites.txt",):
return tre


def get_tree_from_study(study_id, tree_id, label_format="name", citation="cites.txt"):
assert label_format in ['id', 'name', 'name_and_id']
api_wrapper = APIWrapper()
resp = api_wrapper.study.get(study_id, tree=tree_id, format='newick', exact=True)
query = {"ot:studyId":study_id}
new_cite = oti.find_studies(query_dict = query, verbose=True)
cites = to_string(new_cite[0]['ot:studyPublicationReference']) + new_cite[0]['ot:studyPublication']
tre = Tree.get(data=resp,
schema="newick")
return tre, cites



# ATT is a dumb acronym for Alignment Tree Taxa object
Expand Down
2 changes: 1 addition & 1 deletion physcraper/scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def run_blast_wrapper(self): # TODO Should this be happening elsewhere?
# tmpfile.write(seq.symbols_as_string())
# tmpfile.write("\n")
assert otu_id in self.data.otu_dict
last_blast = self.data.otu_dict[otu_id]['^physcraper:last_blasted']
last_blast = self.data.otu_dict[otu_id].get('^physcraper:last_blasted')
if last_blast == None:
time_passed = delay + 1
else:
Expand Down
8 changes: 6 additions & 2 deletions tests/test_treetaxon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ def test_tree_taxon():
assert filecmp.cmp(treeout, expected_tree)
os.remove(treeout)

def test_get_tree():
def test_get_synth_tree():
ott_ids = set([exp_otu_dict[otu].get("^ot:ottId") for otu in exp_otu_dict])
ott_ids = list(ott_ids)
resp = opentree_helpers.get_tree_from_synth(ott_ids=ott_ids)
print resp

test_get_tree()

def test_get_phyle_tree():
tr = opentree_helpers.get_tree_from_study(study_id='pg_1144', tree_id='tree2324', label_format="name")


0 comments on commit d3b4b4f

Please sign in to comment.