def setUp(self): # ensure necessary settings are made sepp.scheduler._jobPool = None sys.argv = [sys.argv[0], "-c", get_data_path("configs/test2.config")] self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.outdir = tempfile.mkdtemp() suff_bit = "-64" if sys.maxsize > 2**32 else "-32" if platform.system() == 'Darwin': suff_bit = "" for prog in ['hmmalign', 'hmmbuild', 'hmmsearch', 'pplacer']: setattr( self.x.options, prog, Namespace( path=get_data_path("../../../tools/bundled/%s/%s%s" % (platform.system(), prog, suff_bit))))
def __init__(self): ExhaustiveAlgorithm.__init__(self) self.alignment_threshold = self.options.alignment_threshold self.placer = self.options.exhaustive.placer.lower() self.push_down = True if self.options.push_down is True else False _LOG.info("Will push fragments %s from their placement edge." % ( "down" if self.push_down else "up"))
class Test(unittest.TestCase): x = None def setUp(self): self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( "data/q2-fragment-insertion/reference_alignment_tiny.fasta", "r") self.x.options.info_file = open( "data/q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info", "r") self.x.options.tree_file = open( "data/q2-fragment-insertion/reference_phylogeny_tiny.nwk", "r") self.x.options.outdir = tempfile.mkdtemp() def tearDown(self): self.x.options.alignment_file.close() self.x.options.info_file.close() self.x.options.tree_file.close() self.x.options.fragment_file.close() shutil.rmtree(self.x.options.outdir, ignore_errors=True) def test_id_collision_working(self): self.x.options.fragment_file = open( "data/q2-fragment-insertion/input_fragments.fasta", "r") self.x.run() self.assertTrue(self.x.results is not None) def test_id_collision_collision(self): self.x.options.fragment_file = open( "data/q2-fragment-insertion/input_fragments_collide.fasta", "r") with self.assertRaisesRegex( ValueError, ' whose names overlap with names in your reference'): self.x.run() self.assertTrue(self.x.results is None)
def check_and_set_sizes(self, total): assert (self.options.placement_size is None) or ( self.options.placement_size >= total), \ ("currently UPP works with only one placement subset." " Please leave placement subset size option blank.") ExhaustiveAlgorithm.check_and_set_sizes(self, total) self.options.placement_size = total
def __init__(self): ExhaustiveAlgorithm.__init__(self) self.alignment_threshold = self.options.alignment_threshold self.placer = self.options.exhaustive.placer.lower() self.push_down = True if self.options.push_down == True else False _LOG.info("Will push fragments %s from their placement edge." % ("down" if self.push_down else "up"))
def check_options(self, supply=[]): if (options().reference_pkg is not None): self.load_reference(os.path.join(options().reference.path, 'refpkg/%s.refpkg/' % options().reference_pkg)) if (options().taxonomy_file is None): supply = supply + ["taxonomy file"] if (options().taxonomy_name_mapping_file is None): supply = supply + ["taxonomy name mapping file"] ExhaustiveAlgorithm.check_options(self, supply)
def setUp(self): self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( "data/q2-fragment-insertion/reference_alignment_tiny.fasta", "r") self.x.options.info_file = open( "data/q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info", "r") self.x.options.tree_file = open( "data/q2-fragment-insertion/reference_phylogeny_tiny.nwk", "r") self.x.options.outdir = tempfile.mkdtemp()
class Test(unittest.TestCase): x = None def resetSepp(self): sepp.scheduler._jobPool = None self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.outdir = tempfile.mkdtemp() suff_bit = "-64" if sys.maxsize > 2**32 else "-32" if platform.system() == 'Darwin': suff_bit = "" for prog in ['hmmalign', 'hmmbuild', 'hmmsearch', 'pplacer']: setattr( self.x.options, prog, Namespace( path=get_data_path("../../../tools/bundled/%s/%s%s" % (platform.system(), prog, suff_bit)))) def setUp(self): # ensure necessary settings are made sys.argv = [sys.argv[0], "-c", get_data_path("configs/test2.config")] self.resetSepp() def tearDown(self): shutil.rmtree(self.x.options.outdir, ignore_errors=True) self.resetSepp() def test_diamMid(self): self.x.options.fragment_file = open( get_data_path("q2-fragment-insertion/input_fragments.fasta"), "r") self.x.options.maxDiam = 0.1 self.x.options.fragmentChunkSize = 1 self.x.options.decomp_strategy = "midpoint" self.x.run() self.assertTrue(self.x.results is not None) def test_diamCent(self): self.x.options.fragment_file = open( get_data_path("q2-fragment-insertion/input_fragments.fasta"), "r") self.x.options.maxDiam = 0.1 self.x.options.fragmentChunkSize = 1 self.x.options.decomp_strategy = "centroid" self.x.run() self.assertTrue(self.x.results is not None)
class Test(unittest.TestCase): x = None def resetSepp(self): sepp.scheduler._jobPool = None self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.outdir = tempfile.mkdtemp() suff_bit = "-64" if sys.maxsize > 2**32 else "-32" if platform.system() == 'Darwin': suff_bit = "" for prog in ['hmmalign', 'hmmbuild', 'hmmsearch', 'pplacer']: setattr(self.x.options, prog, Namespace( path=get_data_path("../../../tools/bundled/%s/%s%s" % ( platform.system(), prog, suff_bit)))) def setUp(self): # ensure necessary settings are made sys.argv = [sys.argv[0], "-c", get_data_path("configs/test2.config")] self.resetSepp() def tearDown(self): shutil.rmtree(self.x.options.outdir, ignore_errors=True) self.resetSepp() def test_diamMid(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments.fasta"), "r") self.x.options.maxDiam = 0.1 self.x.options.fragmentChunkSize = 1 self.x.options.decomp_strategy = "midpoint" self.x.run() self.assertTrue(self.x.results is not None) def test_diamCent(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments.fasta"), "r") self.x.options.maxDiam = 0.1 self.x.options.fragmentChunkSize = 1 self.x.options.decomp_strategy = "centroid" self.x.run() self.assertTrue(self.x.results is not None)
def check_options(self): self.check_outputprefix() options().info_file = "A_dummy_value" # Check to see if tree/alignment/fragment file provided, if not, # generate it from sequence file if ((not options().tree_file is None) and (not options().alignment_file is None) and (not options().sequence_file is None)): options().fragment_file = options().sequence_file elif ((options().tree_file is None) and (options().alignment_file is None) and (not options().sequence_file is None)): self.generate_backbone() else: _LOG.error( ("Either specify the backbone alignment and tree and query " "sequences or only the query sequences. Any other " "combination is invalid")) exit(-1) sequences = MutableAlignment() sequences.read_file_object(open(self.options.alignment_file.name)) backbone_size = sequences.get_num_taxa() if options().backbone_size is None: options().backbone_size = backbone_size assert options().backbone_size == backbone_size, ( ("Backbone parameter needs to match actual size of backbone; " "backbone parameter:%s backbone_size:%s") % (options().backbone_size, backbone_size)) if options().placement_size is None: options().placement_size = options().backbone_size return ExhaustiveAlgorithm.check_options(self)
def check_options(self): options().info_file = "A_dummy_value" if options().tree_file is None or options().alignment_file is None: _LOG.error("Specify the backbone alignment and tree and query sequences") exit(-1) sequences = MutableAlignment() sequences.read_file_object(open(self.options.alignment_file.name)) return ExhaustiveAlgorithm.check_options(self)
def resetSepp(self): # ensure necessary settings are made sepp.scheduler._jobPool = None sepp.scheduler._parser = None self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments.fasta"), "r") self.x.options.outdir = tempfile.mkdtemp() self.x.options.placement_size = 20
class Test(unittest.TestCase): x = None def resetSepp(self): # ensure necessary settings are made sepp.scheduler._jobPool = None sepp.scheduler._parser = None self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments.fasta"), "r") self.x.options.outdir = tempfile.mkdtemp() self.x.options.placement_size = 20 def setUp(self): sys.argv = [sys.argv[0]] self.resetSepp() self._checkpointfile = tempfile.mktemp() def tearDown(self): shutil.rmtree(self.x.options.outdir, ignore_errors=True) self.resetSepp() def test_make_checkpoints(self): self.x.options.checkpoint = set_checkpoint(self._checkpointfile) self.x.options.checkpoint_interval = 5 self.x.run() self.assertTrue(self.x.results is not None)
def check_options(self): options().info_file = "A_dummy_value" #Check to see if tree/alignment/fragment file provided, if not, generate it #from sequence file if not options().tree_file is None and not options( ).alignment_file is None and not options().sequence_file is None: options().fragment_file = options().sequence_file elif options().tree_file is None and options( ).alignment_file is None and not options().sequence_file is None: self.generate_backbone() else: _LOG.error( "Either specify the backbone alignment and tree and query sequences or only the query sequences. Any other combination is invalid" ) exit(-1) sequences = MutableAlignment() sequences.read_file_object(open(self.options.alignment_file.name)) backbone_size = sequences.get_num_taxa() if options().backbone_size is None: options().backbone_size = backbone_size assert options().backbone_size == backbone_size, ( "Backbone parameter needs to match actual size of backbone; backbone parameter:%s backbone_size:%s" % (options().backbone_size, backbone_size)) if options().placement_size is None: options().placement_size = options().backbone_size if options().alignment_size is None: _LOG.info( "Alignment subset size not given. Calculating subset size. ") alignment = MutableAlignment() alignment.read_file_object(open(self.options.alignment_file.name)) if (options().molecule == 'amino'): _LOG.warning( "Automated alignment subset selection not implemented for protein alignment. Setting to 10." ) options().alignment_size = 10 else: (averagep, maxp) = alignment.get_p_distance() align_size = 10 if (averagep > .60): while (align_size * 2 < alignment.get_num_taxa()): align_size = align_size * 2 _LOG.info( "Average p-distance of backbone is %f0.2. Alignment subset size set to %d. " % (averagep, align_size)) options().alignment_size = align_size return ExhaustiveAlgorithm.check_options(self)
def check_options(self): options().info_file = "A_dummy_value" #Check to see if tree/alignment/fragment file provided, if not, generate it #from sequence file if not options().tree_file is None and not options().alignment_file is None and not options().sequence_file is None: options().fragment_file = options().sequence_file elif options().tree_file is None and options().alignment_file is None and not options().sequence_file is None: self.generate_backbone() else: _LOG.error("Either specify the backbone alignment and tree and query sequences or only the query sequences. Any other combination is invalid") exit(-1) sequences = MutableAlignment() sequences.read_file_object(open(self.options.alignment_file.name)) backbone_size = sequences.get_num_taxa() if options().backbone_size is None: options().backbone_size = backbone_size assert options().backbone_size == backbone_size, ("Backbone parameter needs to match actual size of backbone; backbone parameter:%s backbone_size:%s" %(options().backbone_size, backbone_size)) if options().placement_size is None: options().placement_size = options().backbone_size return ExhaustiveAlgorithm.check_options(self)
def resetSepp(self): sepp.scheduler._jobPool = None self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.outdir = tempfile.mkdtemp() suff_bit = "-64" if sys.maxsize > 2**32 else "-32" if platform.system() == 'Darwin': suff_bit = "" for prog in ['hmmalign', 'hmmbuild', 'hmmsearch', 'pplacer']: setattr(self.x.options, prog, Namespace( path=get_data_path("../../../tools/bundled/%s/%s%s" % ( platform.system(), prog, suff_bit))))
def check_options(self): options().info_file = "A_dummy_value" #Check to see if tree/alignment/fragment file provided, if not, generate it #from sequence file if not options().tree_file is None and not options().alignment_file is None and not options().sequence_file is None: options().fragment_file = options().sequence_file elif options().tree_file is None and options().alignment_file is None and not options().sequence_file is None: self.generate_backbone() else: _LOG.error("Either specify the backbone alignment and tree and query sequences or only the query sequences. Any other combination is invalid") exit(-1) sequences = MutableAlignment() sequences.read_file_object(open(self.options.alignment_file.name)) backbone_size = sequences.get_num_taxa() if options().backbone_size is None: options().backbone_size = backbone_size assert options().backbone_size == backbone_size, ("Backbone parameter needs to match actual size of backbone; backbone parameter:%s backbone_size:%s" %(options().backbone_size, backbone_size)) if options().placement_size is None: options().placement_size = options().backbone_size if options().alignment_size is None: _LOG.info("Alignment subset size not given. Calculating subset size. ") alignment = MutableAlignment() alignment.read_file_object(open(self.options.alignment_file.name)) if (options().molecule == 'amino'): _LOG.warning("Automated alignment subset selection not implemented for protein alignment. Setting to 10.") options().alignment_size = 10 else: (averagep,maxp) = alignment.get_p_distance() align_size = 10 if (averagep > .60): while (align_size*2 < alignment.get_num_taxa()): align_size = align_size * 2 _LOG.info("Average p-distance of backbone is %f0.2. Alignment subset size set to %d. " % (averagep,align_size)) options().alignment_size = align_size return ExhaustiveAlgorithm.check_options(self)
def check_options(self, supply=[]): if (options().taxonomy_file is None): supply = supply + ["taxonomy file"] if (options().taxonomy_name_mapping_file is None): supply = supply + ["taxonomy name mapping file"] ExhaustiveAlgorithm.check_options(self, supply)
def __init__(self): ExhaustiveAlgorithm.__init__(self) self.pasta_only = False
def __init__(self): ExhaustiveAlgorithm.__init__(self) self.pasta_only = False self.filtered_taxa = []
class Test(unittest.TestCase): x = None def setUp(self): # ensure necessary settings are made sepp.scheduler._jobPool = None sys.argv = [sys.argv[0], "-c", get_data_path("configs/test2.config")] self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.outdir = tempfile.mkdtemp() suff_bit = "-64" if sys.maxsize > 2**32 else "-32" if platform.system() == 'Darwin': suff_bit = "" for prog in ['hmmalign', 'hmmbuild', 'hmmsearch', 'pplacer']: setattr( self.x.options, prog, Namespace( path=get_data_path("../../../tools/bundled/%s/%s%s" % (platform.system(), prog, suff_bit)))) def tearDown(self): self.x.options.alignment_file.close() self.x.options.info_file.close() self.x.options.tree_file.close() self.x.options.fragment_file.close() sepp.scheduler._jobPool = None shutil.rmtree(self.x.options.outdir, ignore_errors=True) def test_id_collision_working(self): self.x.options.fragment_file = open( get_data_path("q2-fragment-insertion/input_fragments.fasta"), "r") self.x.run() self.assertTrue(self.x.results is not None) def test_id_collision_collision(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments_collide.fasta"), "r") with self.assertRaisesRegex( ValueError, ' whose names overlap with names in your reference'): self.x.run() self.assertTrue(self.x.results is None) def test_seqnames_whitespaces(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments_spaces.fasta"), "r") with self.assertRaisesRegex(ValueError, "contain either whitespaces: "): self.x.run() self.assertTrue(self.x.results is None)
#!/usr/bin/env python # -*- coding: utf-8 -*- from sepp.exhaustive import ExhaustiveAlgorithm # #########################################################################, a# # Copyright 2012 Siavash Mirarab, Nam Nguyen, and Tandy Warnow. # This file is part of SEPP. # # SEPP is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # SEPP is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with SEPP. If not, see <http://www.gnu.org/licenses/>. # ########################################################################## # MAIN if __name__ == '__main__': ExhaustiveAlgorithm().run()
def __init__(self): ExhaustiveAlgorithm.__init__(self)
def __init__(self): ExhaustiveAlgorithm.__init__(self) self.symfrac = False self.elim = None self.filters = True
class Test(unittest.TestCase): x = None def setUp(self): # ensure necessary settings are made sepp.scheduler._jobPool = None sys.argv = [sys.argv[0], "-c", get_data_path("configs/test2.config")] self.x = ExhaustiveAlgorithm() self.x.options.alignment_file = open( get_data_path( "q2-fragment-insertion/reference_alignment_tiny.fasta"), "r") self.x.options.info_file = open( get_data_path( "q2-fragment-insertion/RAxML_info-reference-gg-raxml-bl.info"), "r") self.x.options.tree_file = open( get_data_path( "q2-fragment-insertion/reference_phylogeny_tiny.nwk"), "r") self.x.options.outdir = tempfile.mkdtemp() suff_bit = "-64" if sys.maxsize > 2**32 else "-32" if platform.system() == 'Darwin': suff_bit = "" for prog in ['hmmalign', 'hmmbuild', 'hmmsearch', 'pplacer']: setattr(self.x.options, prog, Namespace( path=get_data_path("../../../tools/bundled/%s/%s%s" % ( platform.system(), prog, suff_bit)))) def tearDown(self): self.x.options.alignment_file.close() self.x.options.info_file.close() self.x.options.tree_file.close() self.x.options.fragment_file.close() sepp.scheduler._jobPool = None shutil.rmtree(self.x.options.outdir, ignore_errors=True) def test_id_collision_working(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments.fasta"), "r") self.x.run() self.assertTrue(self.x.results is not None) def test_id_collision_collision(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments_collide.fasta"), "r") with self.assertRaisesRegex( ValueError, ' whose names overlap with names in your reference'): self.x.run() self.assertTrue(self.x.results is None) def test_seqnames_whitespaces(self): self.x.options.fragment_file = open( get_data_path( "q2-fragment-insertion/input_fragments_spaces.fasta"), "r") with self.assertRaisesRegex( ValueError, "contain either whitespaces: "): self.x.run() self.assertTrue(self.x.results is None)