def test_conversion_and_reverse(self): args = get_args(["-in"] + dna_data_fas + ["-r", "teste", "-c"], unittest=True) triseq_arg_check(args)
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)
def teste_consensus_single_file(self): args = get_args(["-in", "teste"] + ["--consensus-single-file", "-c", "-quiet"], unittest=True) triseq_arg_check(args)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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")
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")))
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")))
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")))
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"))
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"))
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")))
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")))
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")))
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")))
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)
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")))
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()))
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)
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"])
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())
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")
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'])
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'])
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())
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")
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")
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")
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")
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")