Package org.biojava.nbio.core.util
Class SequenceTools
- java.lang.Object
 - 
- org.biojava.nbio.core.util.SequenceTools
 
 
- 
public class SequenceTools extends Object
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected static StringNUCLEOTIDE_LETTERS 
- 
Constructor Summary
Constructors Constructor Description SequenceTools() 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanequalLengthSequences(ProteinSequence[] sequences)A method to check whether an array of sequences contains at least two sequences having an equal length.Sequence<?>getSequenceFromString(String sequence)Attempts to parse String as a DNA sequence first.
If this fails it tries to parse as a ProteinSequence.static booleanisNucleotideSequence(String sequence)static intpercentNucleotideSequence(String sequence)static StringpermuteCyclic(String string, int n)Cyclically permute the characters instringforward bynelements.static <T> voidpermuteCyclic(T[] array, T[] fill, int n)Cyclically permutearrayforward bynelements.static StringpermuteCyclic2(String string, int n)Improved implementation that is generally 10-100x faster, and fixes some edge-case bugs. 
 - 
 
- 
- 
Field Detail
- 
NUCLEOTIDE_LETTERS
protected static final String NUCLEOTIDE_LETTERS
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
SequenceTools
public SequenceTools()
 
 - 
 
- 
Method Detail
- 
permuteCyclic
public static String permuteCyclic(String string, int n)
Cyclically permute the characters instringforward bynelements.- Parameters:
 string- The string to permuten- The number of characters to permute by; can be positive or negative; values greater than the length of the array are acceptable
 
- 
permuteCyclic2
public static String permuteCyclic2(String string, int n)
Improved implementation that is generally 10-100x faster, and fixes some edge-case bugs.- Parameters:
 string- The string to permuten- The number of characters to permute by; can be positive or negative; values greater than the length of the array are acceptable- Returns:
 
 
- 
permuteCyclic
public static <T> void permuteCyclic(T[] array, T[] fill, int n)
Cyclically permutearrayforward bynelements.- Parameters:
 array- The original result; will not be changedfill- The permuted result will be filled into this arrayn- The number of elements to permute by; can be positive or negative; values greater than the length of the array are acceptable
 
- 
percentNucleotideSequence
public static int percentNucleotideSequence(String sequence)
 
- 
isNucleotideSequence
public static boolean isNucleotideSequence(String sequence)
 
- 
getSequenceFromString
public Sequence<?> getSequenceFromString(String sequence) throws CompoundNotFoundException
Attempts to parse String as a DNA sequence first.
If this fails it tries to parse as a ProteinSequence.
This method does not attempt to create an RNASequence.Also, a sequence such as 'ATCGTA' which is both a peptide sequence and a DNA sequence, will always be returned as a DNA sequence.
An empty string argument returns a ProteinSequence of length 0. A null argument throws a
NullPointerException- Parameters:
 sequence-- Returns:
 - Either a DNASequence or a ProteinSequence
 - Throws:
 CompoundNotFoundException
 
- 
equalLengthSequences
public static boolean equalLengthSequences(ProteinSequence[] sequences)
A method to check whether an array of sequences contains at least two sequences having an equal length.- Parameters:
 sequences- the array ofProteinSequencesequences- Returns:
 - true if any two sequences are of an equal length
 
 
 - 
 
 -