jacquard/utils/vcf.py
def parse_record(cls, vcf_line, sample_names):
        """Alternative constructor that parses VcfRecord from VCF string.

        Aspire to parse/represent the data such that it could be reliably
        round-tripped. (This nicety means INFO fields and FORMAT tags should be
        treated as ordered to avoid shuffling.)

        Args:
            vcf_line: the VCF variant record as a string; tab separated fields,
                trailing newlines are ignored. Must have at least 8 fixed fields
                (through INFO)
            sample_names: a list of sample name strings; these should match
                the VCF header column
        Returns:
            A mutable VcfRecord.
        """
        vcf_fields = vcf_line.rstrip("\r\n").split("\t")
        chrom, pos, rid, ref, alt, qual, rfilter, info \
                = vcf_fields[0:8]
        sample_fields = []
        sample_tag_values = {}
        if len(vcf_fields) > 9:
            rformat = vcf_fields[8]
            sample_fields = vcf_fields[9:]
            sample_tag_values = VcfRecord._sample_tag_values(sample_names,
                                                             rformat,
                                                             sample_fields)
        return VcfRecord(chrom, pos, ref, alt,
                         rid, qual, rfilter, info,
                         sample_tag_values)
def parse_record(cls, vcf_line, sample_names):
        """Alternative constructor that parses VcfRecord from VCF string.

        Aspire to parse/represent the data such that it could be reliably
        round-tripped. (This nicety means INFO fields and FORMAT tags should be
        treated as ordered to avoid shuffling.)

        Args:
            vcf_line: the VCF variant record as a string; tab separated fields,
                trailing newlines are ignored. Must have at least 8 fixed fields
                (through INFO)
            sample_names: a list of sample name strings; these should match
                the VCF header column
        Returns:
            A mutable VcfRecord.
        """
        vcf_fields = vcf_line.rstrip("\r\n").split("\t")
        chrom, pos, rid, ref, alt, qual, rfilter, info \
                = vcf_fields[0:8]
        sample_fields = []
        sample_tag_values = {}
        if len(vcf_fields) > 9:
            rformat = vcf_fields[8]
            sample_fields = vcf_fields[9:]
            sample_tag_values = VcfRecord._sample_tag_values(sample_names,
                                                             rformat,
                                                             sample_fields)
        return VcfRecord(chrom, pos, ref, alt,
                         rid, qual, rfilter, info,
                         sample_tag_values)
Alternative constructor that parses VcfRecord from VCF string.

        Aspire to parse/represent the data such that it could be reliably
        round-tripped. (This nicety means INFO fields and FORMAT tags should be
        treated as ordered to avoid shuffling.)

        Args:
            vcf_line: the VCF variant record as a string; tab separated fields,
                trailing newlines are ignored. Must have at least 8 fixed fields
                (through INFO)
            sample_names: a list of sample name strings; these should match
                the VCF header column
        Returns:
            A mutable VcfRecord.