pysam - write vcf

176 views
Skip to first unread message

Fabian Grammes

unread,
Oct 7, 2020, 7:30:30 AM10/7/20
to Pysam User group

Hey, I'm for a way to write valid .vcf files - from scratch. From the 'pysam' documentation it's not entirely clear how I would/could do that.

The `test.vcf` that I want to generate:
    ##fileformat=VCFv4.2
    ##FILTER=<ID=PASS,Description="All filters passed">
    #CHROM    POS    ID    REF    ALT    QUAL    FILTER    INFO
    chromA  100 snp1    C   G   .   PASS   .
    chromA  202 snp2    T   C   .   PASS   .

So my initial idea was:
1. generate a list of `VariantRecords`
2. extract all the relevant info fields
3. write the `.vcf`

attempt 1:
    from pysam import VariantRecord
    vr = VariantRecord()
    #TypeError: this class cannot be instantiated from Python

My second attempt using `VariantFile.add_record` failed as well. Help is appreciated!

Cheers, F






Reply all
Reply to author
Forward
0 new messages