Variants.py -¶
- Tags
Python
Code¶
-
class
Variants.
Variant
(pos, reference, genotype)¶ Bases:
tuple
Create new instance of Variant(pos, reference, genotype)
-
property
genotype
¶ Alias for field number 2
-
property
pos
¶ Alias for field number 0
-
property
reference
¶ Alias for field number 1
-
property
-
Variants.
ExtendedVariant
¶ alias of
Variants.Variant
-
Variants.
updateVariants
(variants, lcontig, strand, phased=True)¶ update variants such that they use same coordinate system (and strand) as the transcript
fixes 1-ness of variants
-
Variants.
mergeVariants
(variants)¶ merge overlapping variants.
Overlapping variants occur if there are two deletions at the same location:
WT ACTG Allele1 -CT- Allele2 —-
This will be encoded by samtools as (0-based coordinates):
0 * -A/ACTG 3 * -G/-G
This upsets the re-constitution algoritm.
This method separates these two variants into two non-overlapping variants making use of variable length deletions.
0 * -A/-A 1 * —G/-CTG
Another case:
WT ACTG Allele1 ACT- Allele2 —-
This will be encoded by samtools as (0-based coordinates):
0 * */-ACTG 3 * -G/*
This method separates these two as:
0 * */-ACT 3 * -G/-G
-
Variants.
indexVariants
(variants)¶ build index of variants for ranged retrieval.
-
Variants.
buildAlleles
(sequence, variants, reference_start=0, phased=True)¶ build alleles for
sequence
addingvariants
.Variants are assumed to be in 0-based coordinates on the same strand as the sequence.
reference_start
is the position of the first base ofsequence
. Set to 0, if the positions invariants
are relative tosequence
.
-
Variants.
buildOffsets
(variants, phased=True, contig=None)¶ collect coordinate offsets.
This methods takes a set of variants and computes coordinates offsets based on indels.
Conflicting variants will be removed.
Returns a list of variants, a list of removed variants and a list of offsets.