@@ -1699,6 +1699,7 @@ def run_bam_readcount(tmp_com, outfile):
1699
1699
o = p .communicate ()
1700
1700
# if o[1] != b'Minimum mapping quality is set to 40':
1701
1701
# sys.exit("Error in running bam-readcount:\n{}".format(o[1].decode()))
1702
+ return
1702
1703
# END
1703
1704
1704
1705
@@ -1783,6 +1784,7 @@ def bamrc2af(args):
1783
1784
rcfin = args .bamrc .name
1784
1785
vcffin = args .vcf .name
1785
1786
outfin = 'bamrc_af.txt' if args .out is None else args .out .name
1787
+ minrc = args .min_rc
1786
1788
1787
1789
logger .info ('Reading VCF' )
1788
1790
posdict = dict ()
@@ -1802,7 +1804,8 @@ def bamrc2af(args):
1802
1804
with open (rcfin , 'r' ) as rc , open (outfin , 'w' ) as out :
1803
1805
for line in rc :
1804
1806
line = line .strip ().split ()
1805
- if line [3 ] == '0' : continue
1807
+ # if line[3] == '0': continue
1808
+ if int (line [3 ]) < min_rc : continue
1806
1809
try :
1807
1810
ref , alt = posdict [(line [0 ], line [1 ])]
1808
1811
except KeyError :
@@ -1811,7 +1814,7 @@ def bamrc2af(args):
1811
1814
refi = basedict [ref ]
1812
1815
alti = basedict [alt ]
1813
1816
out .write (f'{ line [0 ]} \t { line [1 ]} \t { ref } \t { alt } \t { round (int (line [refi ])/ int (line [3 ]) , 2 )} \t { round (int (line [alti ])/ int (line [3 ]), 2 )} \n ' )
1814
- logger .info ('Finishe ' )
1817
+ logger .info ('Finished ' )
1815
1818
# END
1816
1819
1817
1820
@@ -2661,6 +2664,7 @@ def main(cmd):
2661
2664
parser_bamrc2af .add_argument ("bamrc" , help = "BAM readcount file generated using bamrc" , type = argparse .FileType ('r' ))
2662
2665
parser_bamrc2af .add_argument ("vcf" , help = "VCF file" , type = argparse .FileType ('r' ))
2663
2666
parser_bamrc2af .add_argument ("out" , help = "Output file" , type = argparse .FileType ('w' ))
2667
+ parser_bamrc2af .add_argument ("--min_rc" , help = "Minimum required read count. Position with lower number of reads would be filtered out" , type = int , default = 1 )
2664
2668
2665
2669
# xls2csv
2666
2670
parser_xls2tsv .set_defaults (func = xls2csv )
0 commit comments