@@ -14,7 +14,7 @@ There main interface is the class: ``Reader``. It takes a file-like
1414object and acts as a reader::
1515
1616 >>> import vcf
17- >>> vcf_reader = vcf.Reader(open('vcf/test/example-4.0.vcf', 'rb '))
17+ >>> vcf_reader = vcf.Reader(open('vcf/test/example-4.0.vcf', 'r '))
1818 >>> for record in vcf_reader:
1919 ... print record
2020 Record(CHROM=20, POS=14370, REF=G, ALT=[A])
@@ -49,7 +49,7 @@ one-entry Python lists (see, e.g., ``Record.ALT``). Semicolon-delimited lists
4949of key=value pairs are converted to Python dictionaries, with flags being given
5050a ``True `` value. Integers and floats are handled exactly as you'd expect::
5151
52- >>> vcf_reader = vcf.Reader(open('vcf/test/example-4.0.vcf', 'rb '))
52+ >>> vcf_reader = vcf.Reader(open('vcf/test/example-4.0.vcf', 'r '))
5353 >>> record = vcf_reader.next()
5454 >>> print record.POS
5555 14370
@@ -65,10 +65,10 @@ examine properties of interest::
6565 3 1.0 0
6666 >>> print record.num_hom_ref, record.num_het, record.num_hom_alt
6767 1 1 1
68- >>> print record.nucl_diversity, record.aaf
69- 0.6 0.5
68+ >>> print record.nucl_diversity, record.aaf, record.heterozygosity
69+ 0.6 [0.5] 0.5
7070 >>> print record.get_hets()
71- [Call(sample=NA00002, GT=1|0, HQ=[51, 51], DP=8, GQ=48 )]
71+ [Call(sample=NA00002, CallData( GT=1|0, GQ=48, DP=8, HQ=[51, 51]) )]
7272 >>> print record.is_snp, record.is_indel, record.is_transition, record.is_deletion
7373 True False True False
7474 >>> print record.var_type, record.var_subtype
@@ -101,7 +101,7 @@ call data in ``data``::
101101 >>> print call.sample
102102 NA00001
103103 >>> print call.data
104- {'GT': ' 0|0', 'HQ': [58, 50], 'DP': 3, 'GQ': 49}
104+ CallData(GT= 0|0, GQ=49, DP= 3, HQ=[58, 50])
105105
106106Please note that as of release 0.4.0, attributes known to have single values (such as
107107``DP `` and ``GQ `` above) are returned as values. Other attributes are returned
@@ -134,7 +134,7 @@ For example::
134134
135135ALT records are actually classes, so that you can interrogate them::
136136
137- >>> reader = vcf.Reader(file ('vcf/test/example-4.1-bnd.vcf'))
137+ >>> reader = vcf.Reader(open ('vcf/test/example-4.1-bnd.vcf'))
138138 >>> _ = reader.next(); row = reader.next()
139139 >>> print row
140140 Record(CHROM=1, POS=2, REF=T, ALT=[T[2:3[])
@@ -146,22 +146,22 @@ Random access is supported for files with tabix indexes. Simply call fetch for
146146region you are interested in::
147147
148148 >>> vcf_reader = vcf.Reader(filename='vcf/test/tb.vcf.gz')
149- >>> for record in vcf_reader.fetch('20', 1110696, 1230237):
149+ >>> for record in vcf_reader.fetch('20', 1110696, 1230237): # doctest: +SKIP
150150 ... print record
151151 Record(CHROM=20, POS=1110696, REF=A, ALT=[G, T])
152152 Record(CHROM=20, POS=1230237, REF=T, ALT=[None])
153153
154154Or extract a single row::
155155
156- >>> print vcf_reader.fetch('20', 1110696)
156+ >>> print vcf_reader.fetch('20', 1110696) # doctest: +SKIP
157157 Record(CHROM=20, POS=1110696, REF=A, ALT=[G, T])
158158
159159
160160The ``Writer `` class provides a way of writing a VCF file. Currently, you must specify a
161161template ``Reader `` which provides the metadata::
162162
163163 >>> vcf_reader = vcf.Reader(filename='vcf/test/tb.vcf.gz')
164- >>> vcf_writer = vcf.Writer(file ('/dev/null', 'w'), vcf_reader)
164+ >>> vcf_writer = vcf.Writer(open ('/dev/null', 'w'), vcf_reader)
165165 >>> for record in vcf_reader:
166166 ... vcf_writer.write_record(record)
167167
0 commit comments