alphagenome.data.genome.Variant#

class alphagenome.data.genome.Variant(chromosome, position, reference_bases, alternate_bases, name='', info=<factory>)[source]#

Represents a genomic variant/mutation.

Differs from the Variant definition in a VCF file, which allows for multiple alternative bases and contains sample information. This Variant class does not include sample information or variant call quality information.

chromosome#

The chromosome name (e.g., ‘chr1’, ‘1’).

position#

The 1-based position of the variant on the chromosome.

reference_bases#

The reference base(s) at the variant position. Most frequently (not always!), these correspond to the sequence in the reference genome at positions: [position, …, position + len(reference_bases) - 1]

alternate_bases#

The alternate base(s) that replace the reference. For example, if sequence=’ACT’, position=2, reference_bases=’C’, alternate_bases=’TG’, then the actual (alternate) sequence would be ATGT.

name#

An optional name for the variant (e.g., a dbSNP ID like rs206437).

info#

An optional dictionary for additional variant information.

Attributes#

Table

end

Returns the 0-based end position of the variant.

name

reference_interval

Returns an Interval for the variant's reference sequence.

start

Returns the 0-based start position of the variant.

chromosome

position

reference_bases

alternate_bases

info

Variant.end#

Returns the 0-based end position of the variant.

Variant.name: str = ''#
Variant.reference_interval#

Returns an Interval for the variant’s reference sequence.

Variant.start#

Returns the 0-based start position of the variant.

Variant.chromosome: str#
Variant.position: int#
Variant.reference_bases: str#
Variant.alternate_bases: str#
Variant.info: dict[str, Any]#

Methods#

Table

alternate_overlaps(interval)

Checks if the variant's alternate overlaps with the interval.

as_truncated_str([max_length])

Truncates the variant str's ref and alt bases to the given max length.

copy()

Returns a deep copy of the variant.

from_dict(dictionary)

Creates a Variant from a dictionary.

from_proto(variant)

Creates a Variant from a protobuf message.

from_str(string[, variant_format])

Creates a Variant from a string representation.

reference_overlaps(interval)

Checks if the variant's reference overlaps with the interval.

split(anchor)

Splits the variant into two at the anchor point.

to_dict()

Converts the variant to a dictionary.

to_proto()

Converts the variant to a protobuf message.

Variant.alternate_overlaps(interval)[source]#

Checks if the variant’s alternate overlaps with the interval.

Return type:

bool

Variant.as_truncated_str(max_length=50)[source]#

Truncates the variant str’s ref and alt bases to the given max length.

Variant.copy()[source]#

Returns a deep copy of the variant.

Return type:

Self

classmethod Variant.from_dict(dictionary)[source]#

Creates a Variant from a dictionary.

Return type:

Self

classmethod Variant.from_proto(variant)[source]#

Creates a Variant from a protobuf message.

Return type:

Self

classmethod Variant.from_str(string, variant_format=VariantFormat.DEFAULT)[source]#

Creates a Variant from a string representation.

Parameters:
  • string (str) – The string representation.

  • variant_format (VariantFormat (default: <VariantFormat.DEFAULT: 'default'>)) – The format of the variant string. By default, this uses “chromosome:position:ref>alt” (for example, “chr1:1024:A>C”). See VariantFormat for alternate formatting options.

Return type:

Self

Returns:

A Variant object.

Variant.reference_overlaps(interval)[source]#

Checks if the variant’s reference overlaps with the interval.

Return type:

bool

Variant.split(anchor)[source]#

Splits the variant into two at the anchor point.

If the anchor point falls within the variant’s reference sequence, the variant is split into two new variants: one upstream of the anchor and one downstream. If the anchor is outside the variant’s reference sequence, the original variant is returned on the appropriate side, and None on the other.

Example

position= 3 ref: …[ A C ]… alt: …..T G T C anchor=3 | returns: (chr1:3:A>T, chr1:4:C>GTC)

Parameters:

anchor (int) – The 0-based anchor point to split the variant.

Return type:

tuple[Optional[Self], Optional[Self]]

Returns:

A tuple of the upstream and downstream variants. If the variant is only on one side of the anchorpoint, then None is returned.

Variant.to_dict()[source]#

Converts the variant to a dictionary.

Return type:

dict[str, Any]

Variant.to_proto()[source]#

Converts the variant to a protobuf message.

Return type:

Variant