def filter_vcf(pileup, outfile=None, chr_col=0, ref_col=3, alt_col=4, sep='\t'): """ Removes lines where ALT==REF and chromosomes other than 1 - 22, X, Y and MT""" fh = open(pileup, "r") if outfile is None: outfile=pileup+'.filt' fu.delete(outfile) fh_out = open(outfile, "w") for line in fh: line = line.strip() if line.startswith('#'): fh_out.write(str(line)+'\n') else: fields=line.split(sep) if(len(fields)>=8): chr=str(fields[chr_col]) ref=str(fields[ref_col]) alt=str(fields[alt_col]) if (alt != ref) and (fu.find_first_index(ACCEPTED_CHR, chr.strip()) > -1): fh_out.write(str(line)+'\n')
def filter_pileup(pileup, outfile=None, chr_col=0, ref_col=2, alt_col=3, sep='\t'): fh = open(pileup, "r") if outfile is None: outfile = pileup + '.vcf' fu.delete(outfile) fh_out = open(outfile, "w") fh_out.write(vcfheader(pileup) + '\n') for line in fh: line = line.strip() fields = line.split(sep) chr = str(fields[chr_col]) ref = str(fields[ref_col]) alt = str(fields[alt_col]) if (alt != ref) and (fu.find_first_index(ACCEPTED_CHR, chr.strip()) > -1): fh_out.write(varpileup_line2vcf_line(fields[0:9]) + '\n')
def filter_vcf(pileup, outfile=None, chr_col=0, ref_col=3, alt_col=4, sep='\t'): """ Removes lines where ALT==REF and chromosomes other than 1 - 22, X, Y and MT""" fh = open(pileup, "r") if outfile is None: outfile = pileup + '.filt' fu.delete(outfile) fh_out = open(outfile, "w") for line in fh: line = line.strip() if line.startswith('#'): fh_out.write(str(line) + '\n') else: fields = line.split(sep) if (len(fields) >= 8): chr = str(fields[chr_col]) ref = str(fields[ref_col]) alt = str(fields[alt_col]) if (alt != ref) and (fu.find_first_index( ACCEPTED_CHR, chr.strip()) > -1): fh_out.write(str(line) + '\n')
def filter_vcf(pileup, outfile=None, chr_col=0, ref_col=3, alt_col=4, sep='\t'): fh = open(pileup, "r") if (outfile is None): outfile = pileup + '.filt' fu.delete(outfile) fh_out = open(outfile, "w") for line in fh: line = line.strip() if line.startswith('#'): fh_out.write(str(line) + '\n') else: fields = line.split(sep) if (len(fields) >= 8): chr = str(fields[chr_col]) ref = str(fields[ref_col]) alt = str(fields[alt_col]) if ((alt != ref) and \ (fu.find_first_index(ACCEPTED_CHR, chr.strip()) > -1)): fh_out.write(str(line) + '\n') ### EOF
def filter_pileup(pileup, outfile=None, chr_col=0, ref_col=2, alt_col=3, sep='\t'): fh = open(pileup, "r") if outfile is None: outfile=pileup+'.vcf' fu.delete(outfile) fh_out = open(outfile, "w") fh_out.write(vcfheader(pileup)+'\n') for line in fh: line = line.strip() fields=line.split(sep) chr=str(fields[chr_col]) ref=str(fields[ref_col]) alt=str(fields[alt_col]) if (alt != ref) and (fu.find_first_index(ACCEPTED_CHR, chr.strip()) > -1): fh_out.write(varpileup_line2vcf_line(fields[0:9]) +'\n' )