This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to determine mutation type/subtype via pysam/samtools

I'm using pysam (a wrapper around samtools) to pull information from VCF records.

Is there a way to pull out the type/subtype information regarding a single mutation (line of data) contained in a VCF file? I.e. Whether the mutation is a SNP/SUB, INS, DEL, Etc.?

The following snippet pulls out the POSITION and the CHROMOSOME (respectively.)

bcf_in = VariantFile("test.bcf")
for rec in bcf_in.fetch():
    print (rec.pos)
    print (rec.chrom)

Is there a similar way to pull out the type info, or do I have to calculate it from the REF/ALT?

snp vcf samtools pysam type

1 answer

bcftools query --format '%CHROM %POS %TYPE\n' input.vcf

Log in to answer this question.