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
Returns the 0-based end position of the variant. |
|
Returns an |
|
Returns the 0-based start position of the variant. |
|
- Variant.end#
Returns the 0-based end position of the variant.
- Variant.reference_interval#
Returns an
Interval
for the variant’s reference sequence.
- Variant.start#
Returns the 0-based start position of the variant.
Methods#
Table
|
Checks if the variant's alternate overlaps with the interval. |
|
Truncates the variant str's ref and alt bases to the given max length. |
|
Returns a deep copy of the variant. |
|
Creates a |
|
Creates a |
|
Creates a |
|
Checks if the variant's reference overlaps with the interval. |
|
Splits the variant into two at the anchor point. |
|
Converts the variant to a dictionary. |
|
Converts the variant to a protobuf message. |
- Variant.alternate_overlaps(interval)[source]#
Checks if the variant’s alternate overlaps with the interval.
- Return type:
- Variant.as_truncated_str(max_length=50)[source]#
Truncates the variant str’s ref and alt bases to the given max length.
- 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:
- 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)