示例#1
0
def perform_sims(config, dirstub, num):
    for i in range(num):
        i += 1
        ttr = TreeToReads(configfi=config, run=0)
        diri = "{}{}".format(dirstub, i)
        if not os.path.exists(diri):
            os.makedirs(diri)
        ttr.outd = diri
        ttr.run_art()
示例#2
0
import unittest
from treetoreads import TreeToReads

#class IntegrationTestCase(unittest.TestCase):
#    """Tests that it run`."""

 #   def can_run(self):
 #       """Does it run?"""
 #       self.assertTrue(TreeToReads(configfi='tests/input/test1.cfg',run=1))

 #   def correct_snp_num(self):
 #   	"""Is the expected number of snps getting created?"""
 #   	ttr=TreeToReads(configfi='tests/input/test1.cfg',run=0)
 #   	ttr.selectMutsites() 
#        assert(len(ttr.rands))


if __name__ == '__main__':
    ttr=TreeToReads(configfi='tests/input/test1.cfg',run=0)
    ttr.run_art()
    ttr=TreeToReads(configfi='seqsim.cfg',run=0)
    ttr.run_art()
示例#3
0
def compare_trees(expected, estimated):
    #   assert(estimated.euclidean_distance(expected)<= branch lengths are hard to test. TODO figure out how.
    taxon_namespace = dendropy.TaxonSet()
    exp_tree = dendropy.Tree.get_from_path(expected,
                                           "newick",
                                           taxon_set=taxon_namespace)
    est_tree = dendropy.Tree.get_from_path(estimated,
                                           "nexus",
                                           taxon_set=taxon_namespace)
    return (est_tree.symmetric_difference(exp_tree))


if __name__ == '__main__':
    ttr = TreeToReads(
        configfi=
        '/home/ejmctavish/Documents/FDA/TreetoReads/tests/input/tree_from_fasta.cfg',
        run=0)
    print("outd is {}".format(ttr.outd))
    ttr.outd = "/home/ejmctavish/Documents/FDA/TreetoReads/tests/tree_from_fasta"
    ttr.makeOut()
    ttr.mutGenomes()
    print(ttr.getArg('genome'))
    # enter the directory like this:
    os.system("cat {}/fasta_files/*.fasta > {}/mini.aln".format(
        ttr.outd, ttr.outd))
    os.system("Garli tests/garli_mini.conf > {}/garliout".format(ttr.outd))
    assert (compare_trees('tests/input/simple_expected.tre',
                          'tests/tree_from_fasta/tff.best.tre') == 0)
    assert (compare_trees('tests/input/alt.tre',
                          'tests/tree_from_fasta/tff.best.tre') != 0)
    print('Topology is correct')
示例#4
0
import unittest
from treetoreads import TreeToReads
import subprocess
import dendropy
import subprocess
import os


def compare_trees(expected, estimated):
    #   assert(estimated.euclidean_distance(expected)<= branch lengths are hard to test. TODO figure out how.
    taxon_namespace = dendropy.TaxonSet()
    exp_tree = dendropy.Tree.get_from_path(expected, "newick", taxon_set=taxon_namespace)
    est_tree = dendropy.Tree.get_from_path(estimated, "nexus", taxon_set=taxon_namespace)
    return est_tree.symmetric_difference(exp_tree)


if __name__ == "__main__":
    ttr = TreeToReads(configfi="/home/ejmctavish/Documents/FDA/TreetoReads/tests/input/tree_from_fasta.cfg", run=0)
    print("outd is {}".format(ttr.outd))
    ttr.outd = "/home/ejmctavish/Documents/FDA/TreetoReads/tests/tree_from_fasta"
    ttr.makeOut()
    ttr.mutGenomes()
    print(ttr.getArg("genome"))
    # enter the directory like this:
    os.system("cat {}/fasta_files/*.fasta > {}/mini.aln".format(ttr.outd, ttr.outd))
    os.system("Garli tests/garli_mini.conf > {}/garliout".format(ttr.outd))
    assert compare_trees("tests/input/simple_expected.tre", "tests/tree_from_fasta/tff.best.tre") == 0
    assert compare_trees("tests/input/alt.tre", "tests/tree_from_fasta/tff.best.tre") != 0
    print("Topology is correct")
    os.system("rm -r /home/ejmctavish/Documents/FDA/TreetoReads/tests/tree_from_fasta")
示例#5
0
from dendropy.calculate import treecompare
import subprocess
import os


def compare_trees(expected, estimated):
    #   assert(estimated.euclidean_distance(expected)<= branch lengths are hard to test. TODO figure out how.
    #taxon_namespace = dendropy.TaxonSet()
    exp_tree = dendropy.Tree.get_from_path(expected, "newick")
    est_tree = dendropy.Tree.get_from_path(
        estimated, "nexus", taxon_namespace=exp_tree.taxon_namespace)
    return (treecompare.symmetric_difference(est_tree, exp_tree))


if __name__ == '__main__':
    ttr = TreeToReads(configfi='tests/input/tree_from_fasta.cfg', run=0)
    print("outd is {}".format(ttr.outd))
    ttr.make_output()
    ttr.mut_genomes_no_indels()
    print(ttr.get_arg('genome'))
    # enter the directory like this:
    os.system("cat {}/fasta_files/*.fasta > {}/mini.aln".format(
        ttr.outd, ttr.outd))
    os.system("Garli tests/garli_mini.conf > {}/garliout".format(ttr.outd))
    if dendropy.__version__.startswith("4"):
        assert (compare_trees('tests/input/simple_expected.tre',
                              'tests/tree_from_fasta/tff.best.tre') == 0)
        assert (compare_trees('tests/input/alt.tre',
                              'tests/tree_from_fasta/tff.best.tre') != 0)
        print('Topology is correct')
    else:
import unittest
from treetoreads import TreeToReads

#class IntegrationTestCase(unittest.TestCase):
#    """Tests that it run`."""

#   def can_run(self):
#       """Does it run?"""
#       self.assertTrue(TreeToReads(configfi='tests/input/test1.cfg',run=1))

#   def correct_snp_num(self):
#   	"""Is the expected number of snps getting created?"""
#   	ttr=TreeToReads(configfi='tests/input/test1.cfg',run=0)
#   	ttr.selectMutsites()
#        assert(len(ttr.rands))

if __name__ == '__main__':
    ttr = TreeToReads(configfi='tests/input/test1.cfg', run=0)
    ttr.runART()
    ttr = TreeToReads(configfi='seqsim.cfg', run=0)
    ttr.runART()
示例#7
0
import unittest
from treetoreads import TreeToReads
import subprocess

def runSNPpipe(ttr):
    print(" ".join(['../run_snppipe.sh',ttr.outd, ttr.getArg('genome')]))
    subprocess.Popen(['../run_snppipe.sh',ttr.outd, ttr.getArg('genome')])


if __name__ == '__main__':
    ttr=TreeToReads(configfi='tests/input/simple.cfg',run=0)
    ttr.runART()
    print("outd is {}".format(ttr.outd))
    print(ttr.getArg('genome'))
    runSNPpipe(ttr)

def compare_trees(expected,estimated):
 #   assert(estimated.euclidean_distance(expected)<= branch lengths are hard to test. TODO figure out how.
    #taxon_namespace = dendropy.TaxonSet()
    exp_tree = dendropy.Tree.get_from_path(
        expected,
        "newick")
    est_tree = dendropy.Tree.get_from_path(
        estimated,
        "nexus",
        taxon_namespace=exp_tree.taxon_namespace)
    return(treecompare.symmetric_difference(est_tree, exp_tree))

if __name__ == '__main__':
    ttr=TreeToReads(configfi='tests/input/tree_from_fasta.cfg',run=0)
    print("outd is {}".format(ttr.outd))
    ttr.make_output()
    ttr.mut_genomes_no_indels()
    print(ttr.get_arg('genome'))
    # enter the directory like this:
    os.system("cat {}/fasta_files/*.fasta > {}/mini.aln".format(ttr.outd, ttr.outd))
    os.system("Garli tests/garli_mini.conf > {}/garliout".format(ttr.outd))
    if dendropy.__version__.startswith("4"):
        assert(compare_trees('tests/input/simple_expected.tre','tests/tree_from_fasta/tff.best.tre')==0)
        assert(compare_trees('tests/input/alt.tre','tests/tree_from_fasta/tff.best.tre')!=0)
        print('Topology is correct')
    else:
        print('Update denropy to v4 to test topology')
    os.system("rm -r tests/tree_from_fasta")
示例#9
0
import unittest
from treetoreads import TreeToReads
import subprocess

if __name__ == '__main__':
    ttr = TreeToReads(configfi='tests/input/simple_clustering.cfg', run=1)
import unittest
from treetoreads import TreeToReads

#class IntegrationTestCase(unittest.TestCase):
#    """Tests that it run`."""

#   def can_run(self):
#       """Does it run?"""
#       self.assertTrue(TreeToReads(configfi='tests/input/test1.cfg',run=1))

#   def correct_snp_num(self):
#   	"""Is the expected number of snps getting created?"""
#   	ttr=TreeToReads(configfi='tests/input/test1.cfg',run=0)
#   	ttr.selectMutsites()
#        assert(len(ttr.rands))

if __name__ == '__main__':
    ttr = TreeToReads(configfi='tests/input/test1.cfg', run=0)
    ttr.run_art()
    ttr = TreeToReads(configfi='example.config', run=0)
    ttr.run_art()
import unittest
from treetoreads import TreeToReads

#class IntegrationTestCase(unittest.TestCase):
#    """Tests that it run`."""

 #   def can_run(self):
 #       """Does it run?"""
 #       self.assertTrue(TreeToReads(configfi='tests/input/test1.cfg',run=1))

 #   def correct_snp_num(self):
 #   	"""Is the expected number of snps getting created?"""
 #   	ttr=TreeToReads(configfi='tests/input/test1.cfg',run=0)
 #   	ttr.selectMutsites() 
#        assert(len(ttr.rands))


if __name__ == '__main__':
    ttr=TreeToReads(configfi='tests/input/test1.cfg',run=0)
    ttr.runART()
    ttr=TreeToReads(configfi='seqsim.cfg',run=0)
    ttr.runART()