Skip to content

Variant method to get all alleles as a string #2181

@jeromekelleher

Description

@jeromekelleher

There are often times when we'd like to get the genotypes for a given site as the actual alleles rather than the indexes into the alleles list. (This is what #2168 was about, I assume.)

We can add this as a method to the Variant class easily enough. We can just raise an error if there are any non-1 length alleles in there.

What do we call it?

This is the replacement also for the old as_bytes option, which basically did the same thing.

It might look something like

def genotypes_as_alleles(self): -> str
     """
     Returns a string s in which s[j] is the value of ``var.alleles[var.genotypes[j]]``. Raises an error if 
     all alleles are not of length 1.
     """

Metadata

Metadata

Assignees

No one assigned

    Labels

    Python APIIssue is about the Python API

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions