Skip to content

Order of header lines messed up #45

Closed
freeseek opened this Issue Jun 8, 2012 · 3 comments

4 participants

@freeseek
freeseek commented Jun 8, 2012

If I open a VCF file and I immediately write it back to a different file with code like this:
vcf_reader = vcf.Reader(infile)
vcf_writer = vcf.Writer(outfile,vcf_reader)
I get that the order of things in the headers is now messed up. If at first I am more like:
##fileformat=VCFv4.1
##FORMAT=...
##INFO=...
##contig=...
##reference=...
In the output file things are more like:
##contig=...
##reference=...
##contig=...
##fileformat=VCFv4.1
##contig=...
##INFO=...
##FORMAT=...
Is this even allowed by the VCF format? Is there a way to control this behavior?

@martijnvermaat
Collaborator

This is not allowed by the VCF format (the fileformat header line must be first). Looking at the code, the lines are stored as key/value pairs in a dictionary and retrieved from it in no particular order.

@lennax
lennax commented Jun 9, 2012

OrderedDict (added in 2.7 I believe)

@jamescasbon
Owner

Fixed in HEAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.