MCPcopy Create free account
hub / github.com/Illumina/hap.py / writeVCFHeader

Function writeVCFHeader

src/python/Tools/__init__.py:117–159  ·  view source on GitHub ↗

write a VCF header

(filelike, extrainfo="", chrprefix="chr")

Source from the content-addressed store, hash-verified

115
116
117def writeVCFHeader(filelike, extrainfo="", chrprefix="chr"):
118 """ write a VCF header
119 """
120 header = ["CHROM",
121 "POS",
122 "ID",
123 "REF",
124 "ALT",
125 "QUAL",
126 "FILTER",
127 "INFO",
128 "FORMAT",
129 "SIMPLE"]
130
131 infos = ['##fileformat=VCFv4.1',
132 '##reference=hg19',
133 '##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">']
134
135 if extrainfo:
136 if type(extrainfo) is list:
137 infos += extrainfo
138 else:
139 infos += extrainfo.split("\n")
140
141 contigs = [["1", "249250621"], ["2", "243199373"], ["3", "198022430"], ["4", "191154276"],
142 ["5", "180915260"], ["6", "171115067"], ["7", "159138663"], ["8", "146364022"],
143 ["9", "141213431"], ["10", "135534747"], ["11", "135006516"],
144 ["12", "133851895"], ["13", "115169878"], ["14", "107349540"], ["15", "102531392"],
145 ["16", "90354753"], ["17", "81195210"], ["18", "78077248"], ["19", "59128983"],
146 ["20", "63025520"], ["21", "48129895"], ["22", "51304566"], ["X", "155270560"]]
147
148 meta = ["##fileDate=" + date.today().isoformat(),
149 "##source=HaploCompare",
150 "##source_version=%s" % version]
151
152 for i in infos:
153 filelike.write(i + "\n")
154 for c in contigs:
155 filelike.write('##contig=<ID=' + chrprefix + c[0] + ',length=' + c[1] + '>\n')
156 for i in meta:
157 filelike.write(i + "\n")
158
159 filelike.write("#" + "\t".join(header) + "\n")
160
161
162def mkdir_p(path):

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected