Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
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)
Esempio n. 6
0
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)