Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo 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")
Ejemplo 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")))
Ejemplo 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")
Ejemplo 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")))
Ejemplo 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)
Ejemplo 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")))
Ejemplo 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"))
Ejemplo 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"))
Ejemplo 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")))
Ejemplo 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")))
Ejemplo 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")))
Ejemplo 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")))
Ejemplo 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)
Ejemplo 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")))
Ejemplo 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()))
Ejemplo 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)
Ejemplo 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"])
Ejemplo 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())
Ejemplo 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")
Ejemplo 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'])
Ejemplo 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'])
Ejemplo 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"])
Ejemplo 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())
Ejemplo 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")
Ejemplo 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")
Ejemplo 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")
Ejemplo 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")
Ejemplo 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")
Ejemplo 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)