retrieving fields in vcf file

25 views
Skip to first unread message

Matthew Cserhati

unread,
Aug 25, 2021, 11:47:16 AM8/25/21
to pysam-us...@googlegroups.com
Hello all,

This isn't exactly pysam, but pyvcf-related. Does anyone know how to retrieve the genotype and the count information from a vcf file using pyvcf? What fields do I have to reference?

So, in this bit of code record.CHROM references the chromosome, POS the position, etc. How do I reference the genotype?

 vcf_reader = vcf.Reader(open(vcffile,'r'))
 for record in vcf_reader:
     s = str(record.CHROM)+" "+str(record.POS)+" "+str(record.REF)+" "+str(record.ALT[0])
     if s in snps:
         print(record)


Thanks, Matthew

IMPORTANT WARNING: This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential. You, the recipient, are obligated to maintain it in a safe, secure and confidential manner. Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer.

Reply all
Reply to author
Forward
0 new messages