public final class Mutations<S extends Sequence<S>> extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
static Mutations<AminoAcidSequence> |
EMPTY_AMINO_ACID_MUTATIONS
Identity mutations object for amino acid sequences.
|
static Mutations<NucleotideSequence> |
EMPTY_NUCLEOTIDE_MUTATIONS
Identity mutations object for nucleotide sequences.
|
| Constructor and Description |
|---|
Mutations(Alphabet<S> alphabet,
int... mutations) |
Mutations(Alphabet<S> alphabet,
IntArrayList mutations) |
Mutations(Alphabet<S> alphabet,
String encodedMutations) |
| Modifier and Type | Method and Description |
|---|---|
Mutations<S> |
combineWith(Mutations<S> other)
Returns combined mutations array (
this applied before other). |
Mutations<S> |
concat(Mutations<S> other)
Concatenates this and other
|
int |
convertToSeq1Position(int seq2Position)
Converts position from coordinates in seq2 (after mutation) to coordinates in seq1 (before mutation) using this
alignment (mutations).
|
int |
convertToSeq2Position(int seq1Position)
Converts position from coordinates in seq1 (before mutation) to coordinates in seq2 (after mutation) using this
alignment (mutations).
|
int |
countOf(MutationType type) |
int |
countOfIndels() |
static <S extends Sequence<S>> |
decode(String string,
Alphabet<S> alphabet) |
static Mutations<AminoAcidSequence> |
decodeAA(String string) |
static Mutations<NucleotideSequence> |
decodeNuc(String string) |
static <S extends Sequence<S>> |
empty(Alphabet<S> alphabet) |
String |
encode() |
String |
encode(String separator) |
String |
encodeFixed() |
boolean |
equals(Object o) |
Mutations<S> |
extractAbsoluteMutationsForRange(int from,
int to)
Extracts mutations for a range of positions in the original sequence.
|
Mutations<S> |
extractAbsoluteMutationsForRange(Range range)
Extracts mutations for a range of positions in the original sequence.
|
Mutations<S> |
extractRelativeMutationsForRange(int from,
int to)
Extracts mutations for a range of positions in the original sequence and performs shift of corresponding
positions (moves them to
-from). |
Mutations<S> |
extractRelativeMutationsForRange(Range range)
Extracts mutations for a range of positions in the original sequence and performs shift of corresponding
positions (moves them to
-range.from). |
int |
firsMutationPosition() |
int |
firstMutationWithPosition(int position) |
int |
firstMutationWithPosition(int fromIndex,
int toIndex,
int position) |
Alphabet<S> |
getAlphabet() |
byte |
getFromAsCodeByIndex(int index) |
char |
getFromAsSymbolByIndex(int index) |
int |
getLengthDelta()
Returns the difference between the length of initial sequence and length of mutated sequence.
|
Range |
getMutatedRange() |
int |
getMutation(int index) |
int |
getPositionByIndex(int index) |
Mutations<S> |
getRange(int from,
int to)
Extracts sub mutations by
from-to mutation indices. |
int[] |
getRAWMutations() |
int |
getRawTypeByIndex(int index) |
byte |
getToAsCodeByIndex(int index) |
char |
getToAsSymbolByIndex(int index) |
MutationType |
getTypeByIndex(int index) |
int |
hashCode() |
Mutations<S> |
invert()
Inverts mutations, so that they reflect difference from seq2 to seq1.
|
boolean |
isCompatibleWith(S sequence) |
boolean |
isEmpty() |
int |
lastMutationPosition() |
Mutations<S> |
move(int offset)
Moves positions of mutations by specified offset
|
S |
mutate(S sequence) |
static int |
pabs(int position)
Converts positions returned by
convertToSeq2Position(int) and convertToSeq1Position(int) to a
positive number by applying (-1 - x) transformation for negative input values. |
Mutations<S> |
removeMutationsInRange(int from,
int to)
Removes mutations for a range of positions in the original sequence and performs shift of corresponding
positions of mutations.
|
Mutations<S> |
removeMutationsInRange(Range range)
|
Mutations<S> |
removeMutationsInRanges(Range... ranges)
|
int |
size() |
String |
toString() |
public static final Mutations<NucleotideSequence> EMPTY_NUCLEOTIDE_MUTATIONS
public static final Mutations<AminoAcidSequence> EMPTY_AMINO_ACID_MUTATIONS
public Mutations(Alphabet<S> alphabet, IntArrayList mutations)
public int size()
public int getMutation(int index)
public int[] getRAWMutations()
public boolean isEmpty()
public int getPositionByIndex(int index)
public byte getFromAsCodeByIndex(int index)
public byte getToAsCodeByIndex(int index)
public char getFromAsSymbolByIndex(int index)
public char getToAsSymbolByIndex(int index)
public int getRawTypeByIndex(int index)
public MutationType getTypeByIndex(int index)
public boolean isCompatibleWith(S sequence)
public int convertToSeq2Position(int seq1Position)
(- 1 - imagePosition), where imagePosition is a position of letter right after that place where target
nucleotide was removed according to this alignment.seq1Position - position in seq1public int convertToSeq1Position(int seq2Position)
(- 1 - imagePosition), where imagePosition is a position of letter right after that place where target
nucleotide was added according to this alignment.seq2Position - position in seq2public int getLengthDelta()
public Mutations<S> combineWith(Mutations<S> other)
this applied before other).other - second mutations objectpublic Mutations<S> move(int offset)
offset - offsetpublic Mutations<S> extractRelativeMutationsForRange(Range range)
-range.from). Insertions before range.from excluded. Insertions
after (range.to - 1) included.
Important: to extract leftmost insertions (trailing
insertions) use range.from = -1.
range - rangepublic Mutations<S> extractRelativeMutationsForRange(int from, int to)
-from).
Insertions before from excluded. Insertions after (to - 1) included.
Important: to extract leftmost insertions (trailing insertions) use from = -1. E.g.
extractRelativeMutationsForRange(mut, -1, seqLength) == mut.
from - left bound of range, inclusive. Use -1 to extract leftmost insertions.to - right bound of range, exclusivepublic Mutations<S> extractAbsoluteMutationsForRange(Range range)
Insertions before from excluded. Insertions after (to - 1) included.
Important: to extract leftmost insertions (trailing insertions) use range with from = -1.
range - target range in original sequencepublic Mutations<S> extractAbsoluteMutationsForRange(int from, int to)
Insertions before from excluded. Insertions after (to - 1) included.
Important: to extract leftmost insertions (trailing insertions) use from = -1. E.g.
extractAbsoluteMutationsForRange(mut, -1, seqLength) == mut.
from - left bound of range, inclusive. Use -1 to extract leftmost insertions.to - right bound of range, exclusivepublic Mutations<S> removeMutationsInRanges(Range... ranges)
removeMutationsInRange(int, int).
Ranges must be sorted.
ranges - ranges to removepublic Mutations<S> removeMutationsInRange(Range range)
range - range to removespublic Mutations<S> removeMutationsInRange(int from, int to)
Insertions before from will be left untouched. Insertions after (to - 1) will be removed.
Important: to remove leftmost insertions (left trailing insertions) use from = -1. E.g.
extractRelativeMutationsForRange(mut, -1, seqLength) == mut.
from - left bound of range, inclusive. Use -1 to extract leftmost insertions.to - right bound of range, exclusivepublic Mutations<S> invert()
NucleotideSequence ref = randomSequence(300);
int[] mutations = Mutations.generateMutations(ref,
MutationModels.getEmpiricalNucleotideMutationModel()
.multiply(3.0));
and the inverted mutations
int[] invMutations = ConsensusAligner.invertMutations(mutations);The following two methods are equal
Mutations.printAlignment(ref, mutations); Mutations.printAlignment(Mutations.mutate(ref, mutations), invMutations);Same stands for
Mutations.getPosition(mutations, posInSeq1)
public int countOfIndels()
public int countOf(MutationType type)
public Mutations<S> getRange(int from, int to)
from-to mutation indices.from - index in current mutations object pointing to the first mutation to be extractedto - index in current mutations object pointing to the next after last mutation to be extractedpublic int firsMutationPosition()
public int lastMutationPosition()
public Range getMutatedRange()
public String encode()
public String encodeFixed()
public static Mutations<NucleotideSequence> decodeNuc(String string)
public static Mutations<AminoAcidSequence> decodeAA(String string)
public static <S extends Sequence<S>> Mutations<S> decode(String string, Alphabet<S> alphabet)
public static int pabs(int position)
convertToSeq2Position(int) and convertToSeq1Position(int) to a
positive number by applying (-1 - x) transformation for negative input values. So, for non-existing positions
(if corresponding letter is absent in the target sequence, like in case of deletion and convertToSeq1Position(int) method) position of the first existing letter in target sequence will be returned.position - position returned by convertToSeq2Position(int) or convertToSeq1Position(int)
methodspublic int firstMutationWithPosition(int position)
public int firstMutationWithPosition(int fromIndex,
int toIndex,
int position)
Copyright © 2018. All rights reserved.