def __init__(self, args): self.indels = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_all_indel) self.snvs = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_all_snv) self.info = [] self.fmt = [] self.flt = [] self.contigs = [] self.other = [] self.chrom_order = []
def __init__(self, args): self.germline = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_all_germline) self.loh = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_all_loh) self.somatic = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_all_somatic) self.info = [] self.flt = [] self.contigs = load_contigs(args) self.other = [] self.chrom_order = [] self.tumor_name = args.tumor_name self.normal_name = args.normal_name
def run(args): '''Main wrapper function for filtering SomaticSniper VCF files''' # Print the filters to the log logger.info( '<FILTER>LowDPN="Normal DP < {0.min_normal_depth}"'.format(args)) logger.info('<FILTER>LowDPT="Tumor DP < {0.min_tumor_depth}"'.format(args)) logger.info('<FILTER>LowMQT="Tumor MQ < {0.min_mapq_tumor}"'.format(args)) logger.info( '<FILTER>LowMQN="Normal MQ < {0.min_mapq_normal}"'.format(args)) logger.info('<FILTER>LowGQT="Tumor GQ < {0.min_gq_tumor}"'.format(args)) logger.info('<FILTER>LowGQN="Normal GQ < {0.min_gq_normal}"'.format(args)) logger.info( '<FILTER>LowScore="Somatic score < {0.min_somatic_score}"'.format( args)) # New info and filter lines info = [ '##INFO=<ID=NTYPE,Number=1,Type=String,Description="Normal type, can be REF,GERM,SOMATIC,LOH,UK">', '##INFO=<ID=TTYPE,Number=1,Type=String,Description="Tumor type REF,GERM,SOMATIC,LOH,UK">' ] filters = [ '##FILTER=<ID=PASS,Description="Accept as a confident somatic mutation">', '##FILTER=<ID=LowDPN,Description="Normal DP < {0.min_normal_depth}">'. format(args), '##FILTER=<ID=LowDPT,Description="Tumor DP < {0.min_tumor_depth}">'. format(args), '##FILTER=<ID=LowMQT,Description="Tumor MQ < {0.min_mapq_tumor}">'. format(args), '##FILTER=<ID=LowMQN,Description="Normal MQ < {0.min_mapq_normal}">'. format(args), '##FILTER=<ID=LowGQT,Description="Tumor GQ < {0.min_gq_tumor}">'. format(args), '##FILTER=<ID=LowGQN,Description="Normal GQ < {0.min_gq_normal}">'. format(args), '##FILTER=<ID=LowScore,Description="Somatic score < {0.min_somatic_score}">' .format(args), '##FILTER=<ID=UK,Description="Unknown variant type">' ] # Load the contigs contigs = load_contigs(args) # Process the file with open(args.output_vcf, 'wb') as o: sniper_reader = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_vcf) sniper_reader.Open() sniper_reader.get_header() sniper_reader.write_new_header(o, filters=filters, info=info, contigs=contigs) sniper_reader.apply_filters(o, args, SniperRecord) sniper_reader.Close() logger.info('Filtered and formatted VCF file: {0}'.format( os.path.abspath(args.output_vcf)))
def run(args): '''Main wrapper function for filtering MuTect VCF files''' logger.info( '<FILTER>LowDPN=Normal depth < {0.min_normal_depth}'.format(args)) logger.info( '<FILTER>LowDPT=Tumor depth < {0.min_tumor_depth}'.format(args)) logger.info( '<FILTER>TAF=(SAMPLE == TUMOR) && (TYPE==SOM) && AF < {0.min_alt_freq_tumor:.2f}' .format(args)) logger.info( '<FILTER>NAF=(SAMPLE == NORMAL) && (TYPE==SOM) && AF >= {0.max_alt_freq_normal:.2f}' .format(args)) logger.info('<FILTER>LowBQ=BQ < {0.min_base_quality}'.format(args)) # New filter and info lines to add to the output vcf filters = [ '##FILTER=<ID=LowDPN,Description="Normal depth < {0.min_normal_depth}">' .format(args), '##FILTER=<ID=LowDPT,Description="Tumor depth < {0.min_tumor_depth}">'. format(args), '##FILTER=<ID=TAF,Description="Tumor: (TYPE == SOM) && AF < {0.min_alt_freq_tumor:.2f}">' .format(args), '##FILTER=<ID=NAF,Description="Normal: (TYPE == SOM) && AF >= {0.max_alt_freq_normal:.2f}">' .format(args), '##FILTER=<ID=LowBQ,Description="BQ < {0.min_base_quality}">'.format( args), '##FILTER=<ID=UK,Description="SS==5">' ] info = [ '##INFO=<ID=NTYPE,Number=1,Type=String,Description="Normal type, can be WT, GERM, SOMATIC, LOH, PTM, UK">', '##INFO=<ID=TTYPE,Number=1,Type=String,Description="Tumor type, can be WT, GERM, SOMATIC, LOH, PTM, UK">' ] # Process the file with open(args.output_vcf, 'wb') as o: mutect_reader = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_vcf) mutect_reader.Open() mutect_reader.get_header() mutect_reader.write_new_header(o, filters=filters, info=info) mutect_reader.apply_filters(o, args, MutectRecord) mutect_reader.Close()
def run(args): '''Main wrapper function for filtering Shimmer VCF files''' # Print the filters to the log logger.info('<FILTER>LowDPN=Normal DP < {0.min_normal_depth}'.format(args)) logger.info('<FILTER>LowDPT=Tumor DP < {0.min_tumor_depth}'.format(args)) logger.info('<FILTER>TAF=Tumor AF < {0.min_alt_freq_tumor:.3f}>'.format(args)) logger.info('<FILTER>NAF=Normal AF >= {0.max_alt_freq_normal:.3f}>'.format(args)) logger.info('<FILTER>LowQual=QUAL < {0.min_qual}>'.format(args)) # New filter and format lines formats = ['##FORMAT=<ID=AF,Number=1,Type=Float,Description="Ratio of reads with alternate base">'] filters = [ '##FILTER=<ID=PASS,Description="Accept as a confident somatic mutation">', '##FILTER=<ID=LowDPN,Description="Normal DP < {0.min_normal_depth}">'.format(args), '##FILTER=<ID=LowDPT,Description="Tumor DP < {0.min_tumor_depth}">'.format(args), '##FILTER=<ID=TAF,Description="Tumor AF < {0.min_alt_freq_tumor:.3f}">'.format(args), '##FILTER=<ID=NAF,Description="Normal AF >= {0.max_alt_freq_normal:.3f}">'.format(args), '##FILTER=<ID=LowQual,Description="QUAL < {0.min_qual}">'.format(args) ] # Load the VarSifter dictionary varsifter = load_varsifter(args) # Load the contigs reffile = '##reference=file://' + os.path.abspath(args.reference) contigs = load_contigs(args) # Process the file with open(args.output_vcf, 'wb') as o: shimmer_reader = VcfReader(args.choice, args.tumor_name, args.normal_name, args.input_vcf) shimmer_reader.Open() shimmer_reader.get_header() shimmer_reader.write_new_header(o, filters=filters, formats=formats, refpath=reffile, contigs=contigs) shimmer_reader.apply_filters(o, args, ShimmerRecord, vsdict=varsifter) shimmer_reader.Close()