Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not write variants below --allele_freq_thres to .vcf file #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions bin/type_vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def parse_args(args=None):

return parser.parse_args(args)

def ivar_variants_to_vcf_string(FileIn,RefIn):
def ivar_variants_to_vcf_string(FileIn,RefIn,minAF):
'''
Credit to nf-core: https://github.com/nf-core/viralrecon

Expand Down Expand Up @@ -77,6 +77,7 @@ def ivar_variants_to_vcf_string(FileIn,RefIn):
ID='.'
REF=line[2]
ALT=line[3]
ALT_FREQ=line[10]
var_type = 'SNP'
if ALT[0] == '+':
ALT = REF + ALT[1:]
Expand All @@ -98,6 +99,8 @@ def ivar_variants_to_vcf_string(FileIn,RefIn):
writeLine = True
if (CHROM,POS,REF,ALT) in varList:
writeLine = False
if float(ALT_FREQ) < minAF:
writeLine = False
if re.match('^.*N+$', REF):
writeLine = False
else:
Expand Down Expand Up @@ -348,7 +351,7 @@ def main(args=None):
args = parse_args(args)

if args.TSV_IN:
vcfString = ivar_variants_to_vcf_string(args.TSV_IN,args.REF_IN)
vcfString = ivar_variants_to_vcf_string(args.TSV_IN,args.REF_IN,args.ALLELE_FREQ_THRESH)

elif args.VCF_IN:
vcfString = read_vcf_to_vcf_string(args.VCF_IN)
Expand Down