def next(self): '''Return the next record in the file.''' line = self.reader.next() row = re.split(self._separator, line) chrom = row[0] if self._prepend_chr: chrom = 'chr' + chrom pos = int(row[1]) if row[2] != '.': ID = row[2] else: ID = None ref = row[3] alt = self._map(self._parse_alt, row[4].split(',')) try: qual = int(row[5]) except ValueError: try: qual = float(row[5]) except ValueError: qual = None filt = row[6] # Record whether FILTER field was explicitly set in input VCF. if filt == '.': # VCF convention for "filters not applied" (i.e. field was not explicitly set). filterSet = False else: filterSet = True if filt == 'PASS' or filt == '.': filt = [] else: filt = filt.split(';') info = self._parse_info(row[7]) try: fmt = row[8] except IndexError: fmt = None record = _Record(chrom, pos, ID, ref, alt, qual, filt, info, fmt, self._sample_indexes) record.filterSet = filterSet if fmt is not None: samples = self._parse_samples(row[9:], fmt, record) record.samples = samples return record
def next(self, line=None): """Return the next record in the file.""" if not line: line = self.reader.next() while line.startswith('#'): line = self.reader.next() row = re.split(self._separator, line.rstrip()) chrom = row[0] if self._prepend_chr: chrom = 'chr' + chrom pos = int(row[1]) if row[2] != '.': ID = row[2] else: ID = None ref = row[3] alt = map_bad(parse_alt, row[4].split(',')) try: qual = int(row[5]) except ValueError: try: qual = float(row[5]) except ValueError: qual = None filt = row[6] if filt == '.': filt = None elif filt == 'PASS': filt = [] else: filt = filt.split(';') info = self._parse_info(row[7]) try: fmt = row[8] except IndexError: fmt = None else: if fmt == '.': fmt = None record = _Record(chrom, pos, ID, ref, alt, qual, filt, info, fmt, self._sample_indexes) if fmt is not None: samples = self._parse_samples(row[9:], fmt, record) record.samples = samples return record
def next(self): '''Return the next record in the file.''' try: line = self.reader.next() except: return True row = re.split('\t| +', line.strip()) chrom = row[0] if self._prepend_chr: chrom = 'chr' + chrom pos = int(row[1]) queryId = row[2] if row[2] != '.': ID = row[2] else: ID = None ref = row[3] queryAlt = row[4] alt = self._map(self._parse_alt, row[4].split(',')) try: qual = int(row[5]) except ValueError: try: qual = float(row[5]) except ValueError: qual = None filt = row[6].split(';') if ';' in row[6] else row[6] if filt == 'PASS': filt = None try: fmt = row[8] except IndexError: fmt = None entryDbId = self.db.createEntry( self.vcfId, chrom, pos, queryId, ref, queryAlt, qual, filt, fmt) info = self._parse_info(row[7], entryDbId) record = _Record(chrom, pos, ID, ref, alt, qual, filt, info, fmt, self._sample_indexes) if fmt is not None: samples = self._parse_samples(row[9:], fmt, record, entryDbId) record.samples = samples return False
def next(self): '''Return the next record in the file.''' line = self.reader.next() row = re.split(self._separator, line.rstrip()) chrom = row[0] if self._prepend_chr: chrom = 'chr' + chrom pos = int(row[1]) if row[2] != '.': ID = row[2] else: ID = None ref = row[3] alt = self._map(self._parse_alt, row[4].split(',')) try: qual = int(row[5]) except ValueError: try: qual = float(row[5]) except ValueError: qual = None filt = row[6] if filt == '.': filt = None elif filt == 'PASS': filt = [] else: filt = filt.split(';') info = self._parse_info(row[7]) try: fmt = row[8] except IndexError: fmt = None else: if fmt == '.': fmt = None record = _Record(chrom, pos, ID, ref, alt, qual, filt, info, fmt, self._sample_indexes) if fmt is not None: samples = self._parse_samples(row[9:], fmt, record) record.samples = samples return record
def next(self): '''Return the next record in the file.''' line = self.reader.next() row = self._row_pattern.split(line.rstrip()) chrom = row[0] if self._prepend_chr: chrom = 'chr' + chrom pos = int(row[1]) if row[2] != '.': ID = row[2] else: ID = None ref = row[3] alt = self._map(self._parse_alt, row[4].split(',')) try: qual = int(row[5]) except ValueError: try: qual = float(row[5]) except ValueError: qual = None filt = row[6] if filt == '.': filt = None elif filt == 'PASS': filt = [] else: filt = filt.split(';') info = self._parse_info(row[7]) try: fmt = row[8] except IndexError: fmt = None else: if fmt == '.': fmt = None record = _Record(chrom, pos, ID, ref, alt, qual, filt, info, fmt, self._sample_indexes) if fmt is not None: samples = self._parse_samples(row[9:], fmt, record) record.samples = samples return record
def next(self): """Return the next record in the file.""" line = self.reader.next() row = re.split(self._separator, line.rstrip()) chrom = row[0] if self._prepend_chr: chrom = "chr" + chrom pos = int(row[1]) if row[2] != ".": ID = row[2] else: ID = None ref = row[3] alt = self._map(self._parse_alt, row[4].split(",")) try: qual = int(row[5]) except ValueError: try: qual = float(row[5]) except ValueError: qual = None filt = row[6] if filt == ".": filt = None elif filt == "PASS": filt = [] else: filt = filt.split(";") info = self._parse_info(row[7]) try: fmt = row[8] except IndexError: fmt = None else: if fmt == ".": fmt = None record = _Record(chrom, pos, ID, ref, alt, qual, filt, info, fmt, self._sample_indexes) if fmt is not None: samples = self._parse_samples(row[9:], fmt, record) record.samples = samples return record