Esempio n. 1
0
    def test_conversion_and_reverse(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-r", "teste", "-c"],
                        unittest=True)

        triseq_arg_check(args)
Esempio n. 2
0
    def test_reverse_concatenate(self):

        args = get_args(["-in", concatenated_small_phy[0],
                         "-r", concatenated_small_par[0],
                         "-of", "fasta",
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        exp = []
        data = []

        for fl in sorted([x for x in os.listdir(".")
                          if x.startswith("BaseConc")]):
            with open(fl) as fh:
                data.append(sorted([x.rstrip().lower()
                                    for x in fh.readlines()]))
            os.remove(fl)

        for fl in dna_data_fas:
            with open(fl) as fh:
                exp.append(sorted([x.rstrip().lower()
                                   for x in fh.readlines()]))

        self.assertEqual(exp, data)
Esempio n. 3
0
    def teste_consensus_single_file(self):

        args = get_args(["-in", "teste"] +
                        ["--consensus-single-file", "-c", "-quiet"],
                        unittest=True)

        triseq_arg_check(args)
Esempio n. 4
0
    def teste_consensus_single_file(self):

        args = get_args(["-in", "teste"] +
                        ["--consensus-single-file", "-c", "-quiet"],
                        unittest=True)

        triseq_arg_check(args)
Esempio n. 5
0
    def test_reverse_concatenate(self):

        args = get_args([
            "-in", concatenated_small_phy[0], "-r", concatenated_small_par[0],
            "-of", "fasta", "-quiet"
        ],
                        unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        exp = []
        data = []

        for fl in sorted(
            [x for x in os.listdir(".") if x.startswith("BaseConc")]):
            with open(fl) as fh:
                data.append(
                    sorted([x.rstrip().lower() for x in fh.readlines()]))
            os.remove(fl)

        for fl in dna_data_fas:
            with open(fl) as fh:
                exp.append(sorted([x.rstrip().lower()
                                   for x in fh.readlines()]))

        self.assertEqual(exp, data)
Esempio n. 6
0
    def test_gap_coding_warning(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-of", "fasta", "nexus", "-c", "-quiet",
                         "--code-gaps"],
                        unittest=True)

        triseq_arg_check(args)
Esempio n. 7
0
    def test_gap_coding_warning(self):

        args = get_args(
            ["-in"] + dna_data_fas +
            ["-of", "fasta", "nexus", "-c", "-quiet", "--code-gaps"],
            unittest=True)

        triseq_arg_check(args)
Esempio n. 8
0
    def test_code_gaps(self):

        args = get_args(["-in"] + dna_data_fas + [
            "--code-gaps", "-o",
            join(output_dir, "teste"), "-of", "nexus", "-quiet"
        ],
                        unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)
Esempio n. 9
0
    def teste_no_output_concatenation(self):

        args = get_args(["-in"] + dna_data_fas + ["-p", "teste", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 10
0
    def test_code_gaps(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--code-gaps",
                         "-o", join(output_dir, "teste"),
                         "-of", "nexus",
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)
Esempio n. 11
0
    def teste_consensus_outformats(self):

        args = get_args(["-in", "teste"] + ["--consensus", "IUPAC", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 12
0
    def teste_no_ima2_params(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-o", "teste", "-of", "ima2", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 13
0
    def teste_consensus_outformats(self):

        args = get_args(["-in", "teste"] +
                        ["--consensus", "IUPAC", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 14
0
    def teste_single_concatenation_with_zorro(self):

        args = get_args(["-in", "teste"] +
                        ["-o", "teste", "-z", "teste", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 15
0
    def teste_single_concatenation_with_zorro(self):

        args = get_args(["-in", "teste"] +
                        ["-o", "teste", "-z", "teste", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 16
0
    def teste_no_output_concatenation(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-p", "teste", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 17
0
    def test_gap_coding_outformat(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-of", "fasta", "-c", "-quiet", "--code-gaps"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 18
0
    def teste_no_ima2_params(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-o", "teste", "-of", "ima2", "-quiet"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 19
0
    def test_get_taxa(self):

        args = get_args(["-in"] + dna_data_fas + ["--get-taxa", "-quiet"],
                        unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)

        self.assertTrue(os.path.exists("Taxa_list.csv"))
        os.remove("Taxa_list.csv")
Esempio n. 20
0
    def test_informative_filter(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--informative-filter", "1", "2",
                         "-o", join(output_dir, "teste"),
                         "-of", "fasta",
                         "-quiet"])

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.fas")))
Esempio n. 21
0
    def test_get_taxa(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--get-taxa",
                         "-quiet"], unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)

        self.assertTrue(os.path.exists("Taxa_list.csv"))
        os.remove("Taxa_list.csv")
Esempio n. 22
0
    def test_interleave(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--interleave",
                         "-o", join(output_dir, "teste"),
                         "-of", "fasta",
                         "-quiet"], unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.fas")))
Esempio n. 23
0
    def test_gap_coding_outformat(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-of", "fasta", "-c", "-quiet",
                         "--code-gaps"],
                        unittest=True)

        with self.assertRaises(SystemExit) as cm:
            triseq_arg_check(args)

        self.assertEqual(cm.exception.code, 1)
Esempio n. 24
0
    def test_missing_filter_prop_val(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--missing-filter", "0.1", "0.5",
                         "-o", join(output_dir, "teste"),
                         "-of", "fasta",
                         "-quiet"], unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.fas")))
Esempio n. 25
0
    def test_convert_raxml2nex(self):

        args = get_args(["-p", concatenated_small_parNex[0],
                         "-o", join(output_dir, "test"),
                         "-quiet"])
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(concatenated_small_par[0]) as fh1, \
                open(join(output_dir, "test.part.File")) as fh2:
            self.assertEqual(fh1.read(), fh2.read().replace("LG", "DNA"))
Esempio n. 26
0
    def test_convert_raxml2nex(self):

        args = get_args(["-p", concatenated_small_parNex[0],
                         "-o", join(output_dir, "test"),
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(concatenated_small_par[0]) as fh1, \
                open(join(output_dir, "test.part.File")) as fh2:
            self.assertEqual(fh1.read(), fh2.read().replace("LG", "DNA"))
Esempio n. 27
0
    def test_exclude_taxa(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--exclude-taxa", "spa",
                         "-o", join(output_dir, "teste"),
                         "-of", "fasta",
                         "-quiet"])

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.fas")))
Esempio n. 28
0
    def test_ima2_output(self):

        args = get_args(["-in"] + dna_data_fas + [
            "--ima2-params", ima2_pop_file, "(1,2):3)4:5", "IS", "1", "-o",
            join(output_dir, "teste"), "-of", "ima2", "-quiet"
        ],
                        unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.txt")))
Esempio n. 29
0
    def test_missing_filter_prop_val(self):

        args = get_args(["-in"] + dna_data_fas + [
            "--missing-filter", "0.1", "0.5", "-o",
            join(output_dir, "teste"), "-of", "fasta", "-quiet"
        ],
                        unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.fas")))
Esempio n. 30
0
    def test_interleave(self):

        args = get_args(["-in"] + dna_data_fas + [
            "--interleave", "-o",
            join(output_dir, "teste"), "-of", "fasta", "-quiet"
        ],
                        unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.fas")))
Esempio n. 31
0
    def test_grep_taxa(self):

        args = get_args(["-in"] + dna_data_fas + [
            "-grep", "spa", "-o",
            join(output_dir, "teste"), "-of", "fasta", "-quiet"
        ],
                        unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        with open(join(output_dir, "teste.fas")) as fh:
            self.assertEqual(fh.read().count("spa"), 1)
Esempio n. 32
0
    def test_ima2_output(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--ima2-params", ima2_pop_file, "(1,2):3)4:5", "IS",
                         "1",
                         "-o", join(output_dir, "teste"),
                         "-of", "ima2",
                         "-quiet"], unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        self.assertTrue(os.path.exists(join(output_dir, "teste.txt")))
Esempio n. 33
0
    def test_simple_concatenation(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-of", "fasta",
                         "-o", join(output_dir, "teste"),
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(join(data_path, "BaseConcatenation.fas")) as fh1, \
                open(join(output_dir, "teste.fas")) as fh2:
            self.assertEqual(sorted(fh1.readlines()), sorted(fh2.readlines()))
Esempio n. 34
0
    def test_grep_taxa(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-grep", "spa",
                         "-o", join(output_dir, "teste"),
                         "-of", "fasta",
                         "-quiet"], unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)
        with open(join(output_dir, "teste.fas")) as fh:
            self.assertEqual(fh.read().count("spa"), 1)
Esempio n. 35
0
    def test_select_alignments(self):

        args = get_args(["-in"] + dna_data_fas + ["-s", "spa", "-quiet"],
                        unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        fls = sorted(os.listdir("Taxa_selection"))

        shutil.rmtree("Taxa_selection")

        self.assertEqual(fls, ["BaseConc1.fas", "BaseConc7.fas"])
Esempio n. 36
0
    def test_simple_concatenation(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-of", "fasta",
                         "-o", join(output_dir, "teste"),
                         "-quiet"])
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(join(data_path, "BaseConcatenation.fas")) as fh1, \
                open(join(output_dir, "teste.fas")) as fh2:
            self.assertEqual(fh1.read(), fh2.read())
Esempio n. 37
0
    def test_consensus_singlefile(self):

        args = get_args(["-in"] + dna_data_fas + [
            "--consensus", "Soft mask", "--consensus-single-file", "-of",
            "fasta", "-c", "-quiet"
        ],
                        unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)

        self.assertTrue(os.path.exists(join("consensus", "consensus.fas")))
        shutil.rmtree("consensus")
Esempio n. 38
0
    def test_collapse(self):

        args = get_args(["-in"] + dna_data_fas + [
            "--collapse", "-o",
            join(output_dir, "teste"), "-of", "fasta", "-quiet"
        ],
                        unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        fls = sorted(os.listdir(output_dir))

        self.assertEqual(fls, ['teste.fas', 'teste.haplotypes'])
Esempio n. 39
0
    def test_collapse(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--collapse",
                         "-o", join(output_dir, "teste"),
                         "-of", "fasta",
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        fls = sorted(os.listdir(output_dir))

        self.assertEqual(fls, ['teste.fas', 'teste.haplotypes'])
Esempio n. 40
0
    def test_select_alignments(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["-s", "spa",
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        fls = sorted(os.listdir("Taxa_selection"))

        shutil.rmtree("Taxa_selection")

        self.assertEqual(fls, ["BaseConc1.fas", "BaseConc7.fas"])
Esempio n. 41
0
    def test_convert_par2raxml(self):

        args = get_args([
            "-p", concatenated_small_par[0], "-o",
            join(output_dir, "test"), "-quiet"
        ],
                        unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(concatenated_small_parNex[0]) as fh1, \
                open(join(output_dir, "test.charset")) as fh2:
            self.assertEqual(fh1.read(), fh2.read())
Esempio n. 42
0
    def test_consensus(self):

        args = get_args(["-in", dna_data_fas[0],
                        "--consensus", "Soft mask",
                         "-of", "fasta",
                         "-c",
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open("BaseConc1.fas") as fh:
            self.assertTrue(fh.read().startswith(">consensus"))

        os.remove("BaseConc1.fas")
Esempio n. 43
0
    def test_simple_conversion(self):

        args = get_args(
            ["-in", dna_data_fas[0], "-of", "fasta", "-c", "-quiet"],
            unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(join(data_path, "BaseConc1.fas")) as fh1, \
                open("BaseConc1.fas") as fh2:
            self.assertEqual(fh1.read().rstrip().lower(),
                             fh2.read().rstrip().lower())

        os.remove("BaseConc1.fas")
Esempio n. 44
0
    def test_consensus_singlefile(self):

        args = get_args(["-in"] + dna_data_fas +
                        ["--consensus", "Soft mask",
                         "--consensus-single-file",
                         "-of", "fasta",
                         "-c",
                         "-quiet"], unittest=True)

        triseq_arg_check(args)
        main_parser(args, args.infile)

        self.assertTrue(os.path.exists(join("consensus","consensus.fas")))
        shutil.rmtree("consensus")
Esempio n. 45
0
    def test_consensus(self):

        args = get_args([
            "-in", dna_data_fas[0], "--consensus", "Soft mask", "-of", "fasta",
            "-c", "-quiet"
        ],
                        unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open("BaseConc1.fas") as fh:
            self.assertTrue(fh.read().startswith(">consensus"))

        os.remove("BaseConc1.fas")
Esempio n. 46
0
    def test_simple_conversion(self):

        args = get_args(["-in", dna_data_fas[0],
                         "-of", "fasta",
                         "-c",
                         "-quiet"], unittest=True)
        triseq_arg_check(args)
        main_parser(args, args.infile)

        with open(join(data_path, "BaseConc1.fas")) as fh1, \
                open("BaseConc1.fas") as fh2:
            self.assertEqual(fh1.read().rstrip().lower(),
                             fh2.read().rstrip().lower())

        os.remove("BaseConc1.fas")
Esempio n. 47
0
    def test_conversion_and_reverse(self):

        args = get_args(["-in"] + dna_data_fas + ["-r", "teste", "-c"],
                        unittest=True)

        triseq_arg_check(args)