def parse_intervals(genotype): records = {} for line in genotype.header: match = _VCF_DICT.match(line) if not match: continue key, values = match.groups() if key == "contig": values = dict(pair.split("=", 1) for pair in values.split(",")) record = BEDRecord() record.contig = values["ID"] record.start = 0 record.end = int(values["length"]) record.name = record.contig record.strand = "+" records[record.contig] = [record] if not records: sys.stderr.write("ERROR: List of contigs not found in VCF header; " "specifying --intervals is required!\n") return None return records
def parse_intervals(genotype): records = {} for line in genotype.header: match = _VCF_DICT.match(line) if not match: continue key, values = match.groups() if key == "contig": values = dict(pair.split("=", 1) for pair in values.split(",")) record = BEDRecord() record.contig = values["ID"] record.start = 0 record.end = int(values["length"]) record.name = record.contig record.strand = "+" records[record.contig] = [record] if not records: sys.stderr.write("ERROR: List of contigs not found in VCF header; " "specifying --intervals is required!\n") return None return records
def test_bedrecord__setters__type_errors(): record = BEDRecord("my_contig\t12\t345\tname\t0\t+") with pytest.raises(ValueError): record.contig = 17 with pytest.raises(ValueError): record.start = "foo" with pytest.raises(ValueError): record.end = "foo" with pytest.raises(ValueError): record.name = 17.3 with pytest.raises(ValueError): record.score = "foo" with pytest.raises(ValueError): record.strand = "foo"