def test_parse_header(medium_header): p = parser.Parser(stream=medium_header, path="<builtin>") header = p.parse_header() assert header.lines assert len(header.lines) == 18 EXPECTED = "HeaderLine('fileformat', 'VCFv4.3')" assert str(header.lines[0]) == EXPECTED if sys.version_info < (3, 6): EXPECTED = ( "FormatHeaderLine('FORMAT', '<ID=HQ,Number=2,Type=Integer," "Description=\"Haplotype Quality\">', OrderedDict([('ID', 'HQ'), " "('Number', 2), ('Type', 'Integer'), ('Description', " "'Haplotype Quality')]))") else: EXPECTED = ( "FormatHeaderLine('FORMAT', '<ID=HQ,Number=2,Type=Integer,Description=\"Haplotype Quality\">', " "{'ID': 'HQ', 'Number': 2, 'Type': 'Integer', 'Description': 'Haplotype Quality'})" ) assert str(header.lines[-1]) == EXPECTED assert header.samples.names == ["NA00001", "NA00002", "NA00003"]
def vcf_parser(lines): return parser.Parser(io.StringIO(MEDIUM_HEADER + lines), "<builtin>")
def vcf_header(): p = parser.Parser(io.StringIO(HEADER)) return p.parse_header()
def header_samples(): p = parser.Parser(stream=io.StringIO(MEDIUM_HEADER), path="<builtin>") p.parse_header() return (p.header, p.samples)