def test_mpileup_test2(self): test = open(ospj(DATA_PATH, "mpileup_test2.tsv")).read() bpdf = sufam.__main__.get_baseparser_extended_df("test", [mpileup_parser.parse(test)], "G", "GAA") assert_equals(int(bpdf['cov'].iloc[0]), int(bpdf.G.iloc[0])) assert_equals(test.count(",") + test.count("."), int(bpdf['cov'].iloc[0])) assert_almost_equals(0.4324, float(bpdf.val_maf.iloc[0]), places=3) assert_almost_equals(0.4324, float(bpdf.most_common_indel_maf.iloc[0]), places=3) assert_equals("+", bpdf.most_common_indel_type.iloc[0])
def test_mpileup_test3(self): test = open(ospj(DATA_PATH, "mpileup_test3.tsv")).read() bpdf = sufam.__main__.get_baseparser_extended_df("test", [mpileup_parser.parse(test)], "G", "A") assert_equals(int(bpdf['cov'].iloc[0]), int(bpdf.G.iloc[0]) + int(bpdf.A.iloc[0]) + int(bpdf["T"].iloc[0])) assert_equals(1, int(bpdf["T"].iloc[0])) assert_equals("AA", bpdf.most_common_indel.iloc[0]) assert_equals("+", bpdf.most_common_indel_type.iloc[0]) assert_almost_equals(0.0139, float(bpdf.val_maf.iloc[0]), places=3) assert_almost_equals(0.0139, float(bpdf.most_common_al_maf.iloc[0]), places=3)
def test_mpileup_parser_get_mutations(self): indel_followed_by_snv = "X\t150349557\tC\t28\t.$,-12caccactggccat-12CACCACTGGCCAT.,.,,,,.-12CACCACTGGCCAT,..,,-12caccactggccaG..-12CACCACTGGCCAA,,,..,\t;FCDDDDDDD/FDCC/C/E<FBDC\n" muts = mpileup_parser.get_mutations(indel_followed_by_snv) assert_equals(len(muts), 4) assert_equals(muts.snvs["A"].count, 1) assert_equals(muts.snvs["G"].count, 1) assert_equals(muts.snvs["T"].count, 3) assert_equals(muts.deletions["CACCACTGGCCA"].count, 5) assert_almost_equals(muts.deletions["CACCACTGGCCA"].maf, 5/28.0, places=3) assert_equals("X\t150349557\tC\t28\t1\t23\t1\t3\t0\tCACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA\t", mpileup_parser.parse(indel_followed_by_snv))
def test_mpileup_test2(self): test = open(ospj(DATA_PATH, "mpileup_test2.tsv")).read() bpdf = sufam.__main__.get_baseparser_extended_df( "test", [mpileup_parser.parse(test)], "G", "GAA") assert_equals(int(bpdf['cov'].iloc[0]), int(bpdf.G.iloc[0])) assert_equals( test.count(",") + test.count("."), int(bpdf['cov'].iloc[0])) assert_almost_equals(0.4324, float(bpdf.val_maf.iloc[0]), places=3) assert_almost_equals(0.4324, float(bpdf.most_common_indel_maf.iloc[0]), places=3) assert_equals("+", bpdf.most_common_indel_type.iloc[0])
def test_mpileup_parser_get_mutations(self): indel_followed_by_snv = "X\t150349557\tC\t28\t.$,-12caccactggccat-12CACCACTGGCCAT.,.,,,,.-12CACCACTGGCCAT,..,,-12caccactggccaG..-12CACCACTGGCCAA,,,..,\t;FCDDDDDDD/FDCC/C/E<FBDC\n" muts = mpileup_parser.get_mutations(indel_followed_by_snv) assert_equals(len(muts), 4) assert_equals(muts.snvs["A"].count, 1) assert_equals(muts.snvs["G"].count, 1) assert_equals(muts.snvs["T"].count, 3) assert_equals(muts.deletions["CACCACTGGCCA"].count, 5) assert_almost_equals(muts.deletions["CACCACTGGCCA"].maf, 5 / 28.0, places=3) assert_equals( "X\t150349557\tC\t28\t1\t23\t1\t3\t0\tCACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA\t", mpileup_parser.parse(indel_followed_by_snv))
def test_mpileup_test3(self): test = open(ospj(DATA_PATH, "mpileup_test3.tsv")).read() bpdf = sufam.__main__.get_baseparser_extended_df( "test", [mpileup_parser.parse(test)], "G", "A") assert_equals( int(bpdf['cov'].iloc[0]), int(bpdf.G.iloc[0]) + int(bpdf.A.iloc[0]) + int(bpdf["T"].iloc[0])) assert_equals(1, int(bpdf["T"].iloc[0])) assert_equals("AA", bpdf.most_common_indel.iloc[0]) assert_equals("+", bpdf.most_common_indel_type.iloc[0]) assert_almost_equals(0.0139, float(bpdf.val_maf.iloc[0]), places=3) assert_almost_equals(0.0139, float(bpdf.most_common_al_maf.iloc[0]), places=3)
def test_mpileup_parser_indel_followed_by_snv(self): indel_followed_by_snv = "X\t150349557\tC\t28\t.$,-12caccactggccat-12CACCACTGGCCAT.,.,,,,.-12CACCACTGGCCAT,..,,-12caccactggccaG..-12CACCACTGGCCAA,,,..,\t;FCDDDDDDD/FDCC/C/E<FBDC\n" assert_equals( "X\t150349557\tC\t28\t1\t23\t1\t3\t0\tCACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA\t", mpileup_parser.parse(indel_followed_by_snv))
def test_mpileup_parser_two_digit_indel(self): two_digit_indel = "X\t150349557\tC\t24\t.$,-12caccactggcca.-12CACCACTGGCCA.,.,,,,.-12CACCACTGGCCA,..,,-12caccactggcca..-12CACCACTGGCCA,,,..,\t;FCDDDDDDD/FDCC/C/E<FBDC\n" assert_equals( "X\t150349557\tC\t24\t0\t24\t0\t0\t0\tCACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA\t", mpileup_parser.parse(two_digit_indel))
def test_0cov_regionwithcov(self): test = open(ospj(DATA_PATH, "mpileup_0cov_regionwithcov.tsv")).read() bpdf = sufam.__main__.get_baseparser_extended_df( "test", [mpileup_parser.parse(test)], "G", "GAA") assert_equals(None, bpdf)
def test_mpileup_parser_indel_followed_by_snv(self): indel_followed_by_snv = "X\t150349557\tC\t28\t.$,-12caccactggccat-12CACCACTGGCCAT.,.,,,,.-12CACCACTGGCCAT,..,,-12caccactggccaG..-12CACCACTGGCCAA,,,..,\t;FCDDDDDDD/FDCC/C/E<FBDC\n" assert_equals("X\t150349557\tC\t28\t1\t23\t1\t3\t0\tCACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA\t", mpileup_parser.parse(indel_followed_by_snv))
def test_mpileup_parser_two_digit_indel(self): two_digit_indel = "X\t150349557\tC\t24\t.$,-12caccactggcca.-12CACCACTGGCCA.,.,,,,.-12CACCACTGGCCA,..,,-12caccactggcca..-12CACCACTGGCCA,,,..,\t;FCDDDDDDD/FDCC/C/E<FBDC\n" assert_equals("X\t150349557\tC\t24\t0\t24\t0\t0\t0\tCACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA,CACCACTGGCCA\t", mpileup_parser.parse(two_digit_indel))
def test_0cov_regionwithcov(self): test = open(ospj(DATA_PATH, "mpileup_0cov_regionwithcov.tsv")).read() bpdf = sufam.__main__.get_baseparser_extended_df("test", [mpileup_parser.parse(test)], "G", "GAA") assert_equals(None, bpdf)