Package org.biojava.nbio.aaproperties
Class Utils
java.lang.Object
org.biojava.nbio.aaproperties.Utils
This is a utility class that contains utility methods which will facilitates the coding of other methods
- Since:
- 3.0.2
- Version:
- 2011.08.22
- Author:
- kohchuanhock
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
checkSequence
(String sequence) Checks if the sequence contains invalid characters.static final String
checkSequence
(String sequence, Set<Character> cSet) Checks if the sequence contains invalid characters.static final String
cleanSequence
(String sequence, Set<Character> cSet) Returns a new sequence with all invalid characters being replaced by '-'.static final boolean
doesSequenceContainInvalidChar
(String sequence, Set<Character> cSet) Checks if given sequence contains invalid characters.static final int
getNumberOfInvalidChar
(String sequence, Set<Character> cSet, boolean ignoreCase) Return the number of invalid characters in sequence.static final double
roundToDecimals
(double d, int c) Returns a value with the desired number of decimal places.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
roundToDecimals
public static final double roundToDecimals(double d, int c) Returns a value with the desired number of decimal places.- Parameters:
d
- value to roundc
- number of decimal places desired. Must be greater or equal to zero, otherwise, the given value d would be returned without any modification.- Returns:
- a value with the given number of decimal places.
-
doesSequenceContainInvalidChar
Checks if given sequence contains invalid characters. Returns true if invalid characters are found, else return false. Note that any characters are deemed as valid only if it is found in cSet.- Parameters:
sequence
- protein sequence to be check.cSet
- the set of characters that are deemed valid.- Returns:
- true if invalid characters are found, else return false.
-
getNumberOfInvalidChar
public static final int getNumberOfInvalidChar(String sequence, Set<Character> cSet, boolean ignoreCase) Return the number of invalid characters in sequence.- Parameters:
sequence
- protein sequence to count for invalid characters.cSet
- the set of characters that are deemed valid.ignoreCase
- indicates if cases should be ignored- Returns:
- the number of invalid characters in sequence.
-
cleanSequence
Returns a new sequence with all invalid characters being replaced by '-'. Note that any character outside of the 20 standard protein amino acid codes are considered as invalid.- Parameters:
sequence
- protein sequence to be cleancSet
- user defined characters that are valid. Can be null. If null, then 20 standard protein amino acid codes will be considered as valid.- Returns:
- a new sequence with all invalid characters being replaced by '-'.
-
checkSequence
Checks if the sequence contains invalid characters. Note that any character outside of the 20 standard protein amino acid codes are considered as invalid. If yes, it will return a new sequence where invalid characters are replaced with '-'. If no, it will simply return the input sequence.- Parameters:
sequence
- protein sequence to be check for invalid characters.- Returns:
- a sequence with no invalid characters.
-
checkSequence
Checks if the sequence contains invalid characters. Note that any character outside of the 20 standard protein amino acid codes are considered as invalid. If yes, it will return a new sequence where invalid characters are replaced with '-'. If no, it will simply return the input sequence.- Parameters:
sequence
- protein sequence to be check for invalid characters.cSet
- character set which define the valid characters.- Returns:
- a sequence with no invalid characters.
-