mandawilson/PyVCF — Issue #1: INFO fields not read/written correctly
Author: mandawilson
Created: 2012-03-02 19:32:34+00:00
State: open
Labels: bug, enhancement

(1) Info values that are string are being truncated to the first letter (since they are sequences like lists).

E.g. When STR=Test, what is stored is STR=T.

(2) When INFO.Number > 1 or INFO.Number == "." or INFO.Number == "A" or INFO.Number == "G" the value should be a list according to the vcf 4.1 format described below. (Note: Not sure if it should be a list when the length is 1 or 0, also not sure if we should always make sure lists for "A" an "G" are correct length with Nones or not.)

(3) Also when INFO.Type == "Flag" the output was "KEY=True;" instead of just "KEY;".

(4) It would be nice if the KEY/VALUE pairs were output in the order in which they are read so that it is easier for users to see significant changes when doing a diff between an input vcf file and one that is output after filtering/modification. This applies to everything, not just INFO fields so I will create a separate issue for ordering.

According to VCF format 4.1:

##INFO=

Possible Types for INFO fields are: Integer, Float, Flag, Character, and String.

The Number entry is an Integer that describes the number of values that can be included with the INFO field. For example, if the INFO field contains a single number, then this value should be 1; if the INFO field describes a pair of numbers, then this value should be 2 and so on. If the field has one value per alternate allele then this value should be 'A'; if the field has one value for each possible genotype (more relevant to the FORMAT tags) then this value should be 'G'. If the number of possible values varies, is unknown, or is unbounded, then this value should be '.'. The 'Flag' type indicates that the INFO field does not contain a Value entry, and hence the Number should be 0 in this case. The Description value must be surrounded by double-quotes. Double-quote character can be escaped with backslash (\") and backslash as \\.