Skip to content

Commit

Permalink
Next round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
samanvp committed Sep 18, 2018
1 parent 89d9266 commit 11bf049
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gcp_variant_transforms/beam_io/vcf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def _get_variant(self, data_line):
try:
variant_proto = self._vcf_reader.from_string(data_line)
return self._convert_to_variant(variant_proto)
except (ValueError) as e:
except ValueError as e:
logging.warning('VCF variant_proto read failed in %s for line %s: %s',
self._file_name, data_line, str(e))
return MalformedVcfRecord(self._file_name, data_line, str(e))
Expand Down
31 changes: 12 additions & 19 deletions gcp_variant_transforms/beam_io/vcfio.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,30 +212,23 @@ def read_records(self,
range_tracker # type: range_trackers.OffsetRangeTracker
):
# type: (...) -> Iterable[MalformedVcfRecord]
vcf_parser_class = None
if self._vcf_parser_type == VcfParserType.PYVCF:
record_iterator = vcf_parser.PyVcfParser(
file_name,
range_tracker,
self._pattern,
self._compression_type,
self._allow_malformed_records,
self._representative_header_lines,
buffer_size=self._buffer_size,
skip_header_lines=0)
vcf_parser_class = vcf_parser.PyVcfParser
elif self._vcf_parser_type == VcfParserType.NUCLEUS:
record_iterator = vcf_parser.NucleusParser(
file_name,
range_tracker,
self._pattern,
self._compression_type,
self._allow_malformed_records,
self._representative_header_lines,
buffer_size=self._buffer_size,
skip_header_lines=0)
vcf_parser_class = vcf_parser.NucleusParser
else:
raise ValueError(
'Unrecognized _vcf_parser_type: %s.' % str(self._vcf_parser_type))

record_iterator = vcf_parser_class(
file_name,
range_tracker,
self._pattern,
self._compression_type,
self._allow_malformed_records,
self._representative_header_lines,
buffer_size=self._buffer_size,
skip_header_lines=0)

# Convert iterator to generator to abstract behavior
for record in record_iterator:
Expand Down

0 comments on commit 11bf049

Please sign in to comment.