jebl.evolution.sequences
public class Utils extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static State[] |
cleanSequence(java.lang.CharSequence seq,
SequenceType type)
Produce a clean sequence filtered of spaces and digits.
|
static NucleotideState[] |
complement(NucleotideState[] sequence) |
static int |
getGaplessLocation(Sequence sequence,
int gappedLocation)
Gets the site location index for this sequence excluding
any gaps.
|
static int |
getGappedLocation(Sequence sequence,
int gaplessLocation)
Gets the site location index for this sequence that corresponds
to a location given excluding all gaps.
|
static byte[] |
getStateIndices(State[] sequence) |
static SequenceType |
guessSequenceType(java.lang.CharSequence seq)
Guess type of sequence from contents.
|
static boolean |
isPredominantlyRNA(java.lang.CharSequence sequenceString,
int maximumNonGapsToLookAt)
Is the given NucleotideSequence predominantly RNA?
(i.e the more occurrences of "U" than "T")
|
static State[] |
reverse(State[] sequence) |
static NucleotideState[] |
reverseComplement(NucleotideState[] sequence) |
static java.lang.String |
reverseComplement(java.lang.String nucleotideSequence) |
static java.lang.String |
reverseComplementWithGaps(java.lang.String nucleotideSequence) |
static State[] |
stripGaps(State[] sequence) |
static java.lang.String |
toString(State[] states) |
static Sequence |
translate(Sequence sequence,
GeneticCode geneticCode)
|
static AminoAcidState[] |
translate(State[] states,
GeneticCode geneticCode)
Translates each of a given sequence of
NucleotideState s or CodonState s
to the AminoAcidState corresponding to it under the given genetic code. |
static java.lang.String |
translate(java.lang.String nucleotideSequence,
GeneticCode geneticCode)
A wrapper for
translateCharSequence(CharSequence,GeneticCode)
that takes a nucleotide sequence as a String only rather than a
CharSequence. |
static java.lang.String |
translateCharSequence(java.lang.CharSequence nucleotideSequence,
GeneticCode geneticCode)
Translates the given nucleotideSequence into an amino acid sequence
string, using the given geneticCode.
|
public static Sequence translate(Sequence sequence, GeneticCode geneticCode)
Sequence
to a corresponding Sequence
under the given genetic code.
Simply a utility function that calls AminoAcidState[] translate(final State[] states, GeneticCode geneticCode)sequence
- the Sequence.geneticCode
- public static AminoAcidState[] translate(State[] states, GeneticCode geneticCode)
NucleotideState
s or CodonState
s
to the AminoAcidState
corresponding to it under the given genetic code.
Translation doesn't stop at stop codons; these are translated to AminoAcids.STOP_STATE
.
If translating from NucleotideState
and the number
of states is not a multiple of 3, then the excess states at the end are silently dropped.states
- States to translate; must all be of the same type, either NucleotideState
or CodonState.geneticCode
- public static boolean isPredominantlyRNA(java.lang.CharSequence sequenceString, int maximumNonGapsToLookAt)
sequenceString
- the sequence string to inspect to determine if it's RNAmaximumNonGapsToLookAt
- for performance reasons, only look at a maximum of this many non-gap residues in deciding if the sequence is predominantly RNA. Can be -1 or Integer.MAX_VALUE to look at the entire sequence.public static java.lang.String reverseComplement(java.lang.String nucleotideSequence)
public static java.lang.String reverseComplementWithGaps(java.lang.String nucleotideSequence)
public static java.lang.String translateCharSequence(java.lang.CharSequence nucleotideSequence, GeneticCode geneticCode)
translate(State[],GeneticCode)
to do the
translation, hence it shares some properties with that method:
1.) Any excess nucleotides at the end will be silently discarded,
2.) Translation doesn't stop at stop codons; instead, they are
translated to "*", which is
AminoAcids.STOP_STATE
's code.nucleotideSequence
- nucleotide sequence to translategeneticCode
- genetic code to use for the translationnucleotideSequence
with
the given genetic codepublic static java.lang.String translate(java.lang.String nucleotideSequence, GeneticCode geneticCode)
translateCharSequence(CharSequence,GeneticCode)
that takes a nucleotide sequence as a String only rather than a
CharSequence. This is to preserve backwards compatibility with
existing compiled code.nucleotideSequence
- nucleotide sequence string to translategeneticCode
- genetic code to use for the translationnucleotideSequence
with
the given genetic codepublic static NucleotideState[] complement(NucleotideState[] sequence)
public static NucleotideState[] reverseComplement(NucleotideState[] sequence)
public static byte[] getStateIndices(State[] sequence)
public static int getGaplessLocation(Sequence sequence, int gappedLocation)
sequence
- the sequencegappedLocation
- the location including gapspublic static int getGappedLocation(Sequence sequence, int gaplessLocation)
sequence
- the sequencegaplessLocation
- public static SequenceType guessSequenceType(java.lang.CharSequence seq)
seq
- the sequencepublic static State[] cleanSequence(java.lang.CharSequence seq, SequenceType type)
seq
- the sequencetype
- the sequence typepublic static java.lang.String toString(State[] states)
http://code.google.com/p/jebl2/