jamescasbon / PyVCF

A Variant Call Format reader for Python.
http://pyvcf.readthedocs.org/en/latest/index.html
Other
401 stars 200 forks source link

How write the information from a text file back into the VCF file? #274

Open everestial opened 7 years ago

everestial commented 7 years ago

Can some one give me a some heads up on how to approach this problem?

I read the vcf file and generated the following information (in text file). Now, I want to put back the phased information back to the vcf file.

contig  pos ref haplotype_block hap_X   hap_Y   log_odds_ratio  My_PG   Sp_PG   My_hap  Sp_hap
2   2969    C   3706    T   C   -1.902  0   1   C   T
2   3222    G   3706    G   C   -   1   0   C   G
2   3416    G   3706    A   G   -   0   1   G   A
2   5207    T   1856    T   A   2.225   0   1   T   A
2   5238    G   1856    C   G   -   1   0   C   G
2   5398    A   1856    A   G   -   0   1   A   G
2   5403    A   1856    A   G   -   0   1   A   G
2   5426    C   1856    C   A   -   0   1   C   A
2   5434    A   1856    A   G   -   0   1   A   G
2   5467    C   1856    A   C   -   1   0   A   C
2   5483    A   1856    A   C   -   0   1   A   C
2   6636    C   892 T   C   2.238   1   0   T   C
2   6740    A   892 A   G   -   0   1   A   G
2   12138   T   892 T   A   -   0   1   T   A
2   12160   G   892 G   A   -   0   1   G   A
2   12237   G   892 G   C   -   0   1   G   C
2   12298   T   892 T   G   -   0   1   T   G
2   12301   T   892 T   A   -   0   1   T   A

I want to > read the same vcf file > match the contig and position > then write the new data into the FORMAT and SAMPLE fields.

I want to create new tag in FORMAT field and insert the corresponding value in SAMPLE field:

I read through several examples and tried working this out, but I am not very clear on how to approach this problem. Any suggestions?

Thanks,

everestial commented 7 years ago

@jamescasbon @martijnvermaat @ian1roberts @arq5x: Can some of you please give me some lead on this problem?

Thanks,