Skip to content

Commit

Permalink
parse meta when initing the reader, rather than at iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
James Casbon committed Jan 17, 2012
1 parent 9ae8aff commit 2d68a32
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ def __init__(self, fsock, aggressive=False):
self._mapper = self._none_map
else:
self._mapper = self._pass_map
self._parse_metainfo()



def __iter__(self):
return self
Expand Down Expand Up @@ -428,8 +431,6 @@ def _parse_samples(self, samples, samp_fmt):

def next(self):
'''Return the next record in the file.'''
if self._samples is None:
self._parse_metainfo()
row = self.reader.next().split()
chrom = row[0]
pos = int(row[1])
Expand Down Expand Up @@ -467,9 +468,6 @@ class Writer(object):
def __init__(self, stream, template):
self.writer = csv.writer(stream, delimiter="\t")
self.template = template
# TODO: shouldnt have to poke the parser to get the meta
if template._samples is None:
template._parse_metainfo()
for line in template._header_lines:
stream.write(line)
self.write_header()
Expand Down

0 comments on commit 2d68a32

Please sign in to comment.