Skip to content

Commit

Permalink
test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
snacktavish committed Nov 14, 2019
1 parent 25f4cae commit cc17be2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
16 changes: 10 additions & 6 deletions physcraper/opentree_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,22 @@ def generate_ATT_from_phylesystem(aln,
"your alignment `%s` ist not of type DnaCharacterMatrix" % aln
for tax in aln.taxon_namespace:
tax.label = tax.label.replace(" ", "_") # Forcing all spaces to underscore
nexson = get_nexson(study_id, phylesystem_loc)
newick = extract_tree(nexson,
tree_id,
PhyloSchema('newick',
try:
nexson = get_nexson(study_id, phylesystem_loc)
newick = extract_tree(nexson,
tree_id,
PhyloSchema('newick',
output_nexml2json='1.2.1',
content="tree",
tip_label="ot:originalLabel"))
newick = newick.replace(" ", "_") # UGH Very heavy handed, need to make sure happens on alignment side as well.
tre = Tree.get(data=newick,
newick = newick.replace(" ", "_") # UGH Very heavy handed, need to make sure happens on alignment side as well.
tre = Tree.get(data=newick,
schema="newick",
preserve_underscores=True,
taxon_namespace=aln.taxon_namespace)
except:
sys.stderr.write("failure getting tree {} from study {} from phylesystem".format(tree_id, study_id))
sys.exit()
# this gets the taxa that are in the subtree with all of their info - ott_id, original name,
otus = get_subtree_otus(nexson, tree_id=tree_id)
otu_dict = {}
Expand Down
6 changes: 0 additions & 6 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
[pytest]

# defines the root dir?
env =
HOME=~/home/blubb/Documents/gitdata

# will stop running after two test failures
addopts = --maxfail=2 -rf --durations=0 --num auto -v

# custom flags to group tests?
markers =
Expand Down
27 changes: 23 additions & 4 deletions tests/test_from_phylesystem.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import physcraper
import sys
import pytest
from pytest import mark
from dendropy import DnaCharacterMatrix

web = mark.web


@web
def test_generate_ATT_from_phylesystem():
seqaln = "tests/data/input.fas"
study_id = "pg_873"
Expand All @@ -29,4 +27,25 @@ def test_generate_ATT_from_phylesystem():
tree_id=tree_id)

data_obj == True


@pytest.mark.xfail
def test_generate_ATT_from_phylesystem_fail():
seqaln = "tests/data/input.fas"
study_id = "pg_873"
tree_id = "tree1679"
seqaln = "tests/data/minitest.fas"
mattype = "fasta"
workdir = "tests/output/opentree"
configfi = "tests/data/remotencbi.config"


sys.stdout.write("\nTesting 'generate_ATT_from_files (fromfile.py)'\n")

conf = physcraper.ConfigObj(configfi, interactive=False)
aln = DnaCharacterMatrix.get(path=seqaln, schema=mattype)
data_obj = physcraper.generate_ATT_from_phylesystem(aln=aln,
workdir=workdir,
config_obj=conf,
study_id=study_id,
tree_id=tree_id)

0 comments on commit cc17be2

Please sign in to comment.