public static final int[] purinepyrimidineIndex;
- public static final Map<String, Integer> aa3Hash = new HashMap<String, Integer>();
+ public static final Map<String, Integer> aa3Hash = new HashMap<>();
- public static final Map<String, String> aa2Triplet = new HashMap<String, String>();
+ public static final Map<String, String> aa2Triplet = new HashMap<>();
- public static final Map<String, String> nucleotideName = new HashMap<String, String>();
+ public static final Map<String, String> nucleotideName = new HashMap<>();
// lookup from modified amino acid (e.g. MSE) to canonical form (e.g. MET)
- public static final Map<String, String> modifications = new HashMap<String, String>();
+ public static final Map<String, String> modifications = new HashMap<>();
+
+ // amino acid background Frequencies
+ public static final Map<Character, Float> aminoBackgroundFrequencies = new HashMap<>();
+
+ // nucleotide background Frequencies
+ public static final Map<Character, Float> nucleotideBackgroundFrequencies = new HashMap<>();
static
{
/**
* Nucleotide Ambiguity Codes
*/
- public static final Map<String, String[]> ambiguityCodes = new Hashtable<String, String[]>();
+ public static final Map<String, String[]> ambiguityCodes = new Hashtable<>();
/**
* Codon triplets with additional symbols for unambiguous codons that include
* ambiguity codes
*/
- public static final Hashtable<String, String> codonHash2 = new Hashtable<String, String>();
+ public static final Hashtable<String, String> codonHash2 = new Hashtable<>();
/**
* all ambiguity codes for a given base
*/
- public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<String, List<String>>();
+ public final static Hashtable<String, List<String>> _ambiguityCodes = new Hashtable<>();
static
{
List<String> codesfor = _ambiguityCodes.get(r);
if (codesfor == null)
{
- _ambiguityCodes.put(r, codesfor = new ArrayList<String>());
+ _ambiguityCodes.put(r, codesfor = new ArrayList<>());
}
if (!codesfor.contains(acode.getKey()))
{
}
// Stores residue codes/names and colours and other things
- public static Map<String, Map<String, Integer>> propHash = new Hashtable<String, Map<String, Integer>>();
+ public static Map<String, Map<String, Integer>> propHash = new Hashtable<>();
- public static Map<String, Integer> hydrophobic = new Hashtable<String, Integer>();
+ public static Map<String, Integer> hydrophobic = new Hashtable<>();
- public static Map<String, Integer> polar = new Hashtable<String, Integer>();
+ public static Map<String, Integer> polar = new Hashtable<>();
- public static Map<String, Integer> small = new Hashtable<String, Integer>();
+ public static Map<String, Integer> small = new Hashtable<>();
- public static Map<String, Integer> positive = new Hashtable<String, Integer>();
+ public static Map<String, Integer> positive = new Hashtable<>();
- public static Map<String, Integer> negative = new Hashtable<String, Integer>();
+ public static Map<String, Integer> negative = new Hashtable<>();
- public static Map<String, Integer> charged = new Hashtable<String, Integer>();
+ public static Map<String, Integer> charged = new Hashtable<>();
- public static Map<String, Integer> aromatic = new Hashtable<String, Integer>();
+ public static Map<String, Integer> aromatic = new Hashtable<>();
- public static Map<String, Integer> aliphatic = new Hashtable<String, Integer>();
+ public static Map<String, Integer> aliphatic = new Hashtable<>();
- public static Map<String, Integer> tiny = new Hashtable<String, Integer>();
+ public static Map<String, Integer> tiny = new Hashtable<>();
- public static Map<String, Integer> proline = new Hashtable<String, Integer>();
+ public static Map<String, Integer> proline = new Hashtable<>();
static
{
public static Hashtable<String, String> toDssp3State;
static
{
- toDssp3State = new Hashtable<String, String>();
+ toDssp3State = new Hashtable<>();
toDssp3State.put("H", "H");
toDssp3State.put("E", "E");
toDssp3State.put("C", " ");
}
+ static
+ {
+ aminoBackgroundFrequencies.put('A', 0.0826f);
+ aminoBackgroundFrequencies.put('Q', 0.0393f);
+ aminoBackgroundFrequencies.put('L', 0.0965f);
+ aminoBackgroundFrequencies.put('S', 0.0661f);
+ aminoBackgroundFrequencies.put('R', 0.0553f);
+ aminoBackgroundFrequencies.put('E', 0.0674f);
+ aminoBackgroundFrequencies.put('K', 0.0582f);
+ aminoBackgroundFrequencies.put('T', 0.0535f);
+ aminoBackgroundFrequencies.put('N', 0.0406f);
+ aminoBackgroundFrequencies.put('G', 0.0708f);
+ aminoBackgroundFrequencies.put('M', 0.0241f);
+ aminoBackgroundFrequencies.put('W', 0.0109f);
+ aminoBackgroundFrequencies.put('D', 0.0546f);
+ aminoBackgroundFrequencies.put('H', 0.0227f);
+ aminoBackgroundFrequencies.put('F', 0.0386f);
+ aminoBackgroundFrequencies.put('Y', 0.0292f);
+ aminoBackgroundFrequencies.put('C', 0.0137f);
+ aminoBackgroundFrequencies.put('I', 0.0593f);
+ aminoBackgroundFrequencies.put('P', 0.0472f);
+ aminoBackgroundFrequencies.put('V', 0.0686f);
+
+ }
+
+ static
+ {
+ nucleotideBackgroundFrequencies.put('A', 0.25f);
+ nucleotideBackgroundFrequencies.put('C', 0.25f);
+ nucleotideBackgroundFrequencies.put('T', 0.25f);
+ nucleotideBackgroundFrequencies.put('G', 0.25f);
+
+ }
+
public static String getCanonicalAminoAcid(String aA)
{
String canonical = modifications.get(aA);
// / cut here
public static void main(String[] args)
{
- Hashtable<String, Vector<String>> aaProps = new Hashtable<String, Vector<String>>();
+ Hashtable<String, Vector<String>> aaProps = new Hashtable<>();
System.out.println("my %aa = {");
// invert property hashes
for (String pname : propHash.keySet())
Vector<String> aprops = aaProps.get(rname);
if (aprops == null)
{
- aprops = new Vector<String>();
+ aprops = new Vector<>();
aaProps.put(rname, aprops);
}
Integer hasprop = phash.get(rname);
public static List<String> getResidues(boolean forNucleotide,
boolean includeAmbiguous)
{
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
if (forNucleotide)
{
for (String nuc : nucleotideName.keySet())
assertEquals(hmm.getSymbols(), symbols);
- assertEquals(getMatchEmission(0, 19, hmm), 3.43274);
- assertEquals(getMatchEmission(12, 12, hmm), 4.33979);
- assertEquals(getMatchEmission(23, 7, hmm), 3.65600);
- assertEquals(getMatchEmission(54, 1, hmm), 4.76187);
- assertEquals(getMatchEmission(79, 0, hmm), 2.81579);
- assertEquals(getMatchEmission(100, 0, hmm), 1.86496);
- assertEquals(getMatchEmission(112, 14, hmm), 2.77179);
- assertEquals(getMatchEmission(143, 17, hmm), 5.10478);
- assertEquals(getMatchEmission(156, 4, hmm), 4.69372);
- assertEquals(getMatchEmission(178, 3, hmm), 2.52594);
- assertEquals(getMatchEmission(210, 2, hmm), 4.23598);
- assertEquals(getMatchEmission(260, 19, hmm), 3.81122);
-
- assertEquals(getInsertEmission(2, 1, hmm), 4.42225);
- assertEquals(getInsertEmission(15, 6, hmm), 3.72501);
- assertEquals(getInsertEmission(22, 9, hmm), 2.69355);
- assertEquals(getInsertEmission(57, 2, hmm), 2.77519);
- assertEquals(getInsertEmission(62, 14, hmm), 2.89801);
- assertEquals(getInsertEmission(95, 17, hmm), 2.98532);
- assertEquals(getInsertEmission(105, 4, hmm), 3.46354);
- assertEquals(getInsertEmission(134, 1, hmm), 4.42225);
- assertEquals(getInsertEmission(143, 0, hmm), 2.68618);
- assertEquals(getInsertEmission(152, 16, hmm), 2.77519);
- assertEquals(getInsertEmission(203, 16, hmm), 2.77519);
- assertEquals(getInsertEmission(255, 12, hmm), 2.73739);
+ assertEquals(getMatchEmission(0, 19, hmm), 0.032298, 0.001d);
+ assertEquals(getMatchEmission(12, 12, hmm), 0.0130, 0.001d);
+ assertEquals(getMatchEmission(23, 7, hmm), 0.02583, 0.001d);
+ assertEquals(getMatchEmission(54, 1, hmm), 0.008549, 0.001d);
+ assertEquals(getMatchEmission(178, 3, hmm), 0.07998, 0.001d);
+ assertEquals(getMatchEmission(210, 2, hmm), 0.014465, 0.001d);
+ assertEquals(getMatchEmission(260, 19, hmm), 0.02213, 0.001d);
+
+ assertEquals(getInsertEmission(2, 1, hmm), 0.012, 0.001d);
+ assertEquals(getInsertEmission(15, 6, hmm), 0.02411, 0.001d);
+ assertEquals(getInsertEmission(22, 9, hmm), 0.06764, 0.001d);
+ assertEquals(getInsertEmission(57, 2, hmm), 0.0623, 0.001d);
+ assertEquals(getInsertEmission(203, 16, hmm), 0.0623, 0.001d);
+ assertEquals(getInsertEmission(255, 12, hmm), 0.0647, 0.001d);
assertEquals(getStateTransition(0, 6, hmm),
Double.NEGATIVE_INFINITY);
- assertEquals(getStateTransition(3, 6, hmm), 0.95510);
- assertEquals(getStateTransition(29, 3, hmm), 0.61958);
- assertEquals(getStateTransition(46, 4, hmm), 0.77255);
- assertEquals(getStateTransition(53, 1, hmm), 5.01631);
- assertEquals(getStateTransition(79, 2, hmm), 5.73865);
- assertEquals(getStateTransition(101, 2, hmm), 5.73865);
- assertEquals(getStateTransition(120, 5, hmm), 0.48576);
- assertEquals(getStateTransition(146, 5, hmm), 0.70219);
- assertEquals(getStateTransition(169, 3, hmm), 1.23224);
- assertEquals(getStateTransition(209, 0, hmm), 0.01003);
- assertEquals(getStateTransition(243, 1, hmm), 5.01631);
+ assertEquals(getStateTransition(3, 6, hmm), 0.3848, 0.001d);
+ assertEquals(getStateTransition(29, 3, hmm), 0.5382, 0.001d);
+ assertEquals(getStateTransition(169, 3, hmm), 0.2916, 0.001d);
+ assertEquals(getStateTransition(209, 0, hmm), 0.99, 0.001d);
+ assertEquals(getStateTransition(243, 1, hmm), 0.0066, 0.001d);
assertEquals(hmm.getNodeAlignmentColumn(3).intValue(), 3);
assertEquals(hmm.getReferenceAnnotation(7), '-');
Scanner scanner1 = new Scanner("1.3 2.4 5.3 3.9 9.8 4.7 4.3 2.3 6.9");
ArrayList<Double> filledArray = new ArrayList<>();
- filledArray.add(1.3);
- filledArray.add(2.4);
- filledArray.add(5.3);
- filledArray.add(3.9);
- filledArray.add(9.8);
- filledArray.add(4.7);
- filledArray.add(4.3);
- filledArray.add(2.3);
- filledArray.add(6.9);
-
- assertEquals(HMMFile.fillList(scanner1, 9), filledArray);
+ filledArray.add(0.27253);
+ filledArray.add(0.0907);
+ filledArray.add(0.00499);
+ filledArray.add(0.02024);
+ filledArray.add(0.00005);
+ filledArray.add(0.00909);
+ filledArray.add(0.01357);
+ filledArray.add(0.10026);
+ filledArray.add(0.001);
+
+ List<Double> testList = HMMFile.fillList(scanner1, 9);
+
+ for (int i = 0; i < 9; i++)
+ {
+ assertEquals(testList.get(i), filledArray.get(i), 0.001d);
+
+ }
+
filledArray.clear();
scanner1.close();
Scanner scanner2 = new Scanner(
- "1.346554 5.58756754 35.3523645 12345.3564 1.4");
- filledArray.add(1.346554);
- filledArray.add(5.58756754);
- filledArray.add(35.3523645);
- filledArray.add(12345.3564);
- filledArray.add(1.4);
-
- assertEquals(HMMFile.fillList(scanner2, 5), filledArray);
- scanner2.close();
+ "1.346 5.554 35.345 5.64 1.4");
+ filledArray.add(0.2603);
+ filledArray.add(0.00387);
+ filledArray.add(0d);
+ filledArray.add(0.00355);
+ filledArray.add(0.2466);
+
+ testList = HMMFile.fillList(scanner2, 5);
+
+ for (int i = 0; i < 5; i++)
+ {
+ assertEquals(testList.get(i), filledArray.get(i), 0.001d);
+ }
}
br.close();
fr.close();
- assertEquals(getMatchEmission(0, 2, testHMM), 1.62906);
- assertEquals(getMatchEmission(2, 1, testHMM), 2.37873);
- assertEquals(getMatchEmission(12, 2, testHMM), 2.61355);
- assertEquals(getMatchEmission(26, 0, testHMM), 1.86925);
- assertEquals(getMatchEmission(32, 3, testHMM), 2.58263);
- assertEquals(getMatchEmission(59, 3, testHMM), 2.20507);
- assertEquals(getMatchEmission(63, 0, testHMM), 0.41244);
- assertEquals(getMatchEmission(69, 1, testHMM), 3.17398);
- assertEquals(getMatchEmission(76, 2, testHMM), 2.65861);
-
- assertEquals(getInsertEmission(0, 1, testHMM), 1.38629);
- assertEquals(getInsertEmission(1, 2, testHMM), 1.38629);
- assertEquals(getInsertEmission(31, 3, testHMM), 1.28150);
- assertEquals(getInsertEmission(43, 0, testHMM), 1.32290);
- assertEquals(getInsertEmission(48, 2, testHMM), 1.52606);
- assertEquals(getInsertEmission(52, 1, testHMM), 1.62259);
- assertEquals(getInsertEmission(67, 0, testHMM), 1.38141);
- assertEquals(getInsertEmission(70, 3, testHMM), 1.38629);
- assertEquals(getInsertEmission(80, 3, testHMM), 1.38629);
-
- assertEquals(getStateTransition(2, 0, testHMM), 0.03725);
- assertEquals(getStateTransition(6, 1, testHMM), 3.89715);
- assertEquals(getStateTransition(9, 3, testHMM), 1.38021);
- assertEquals(getStateTransition(20, 4, testHMM), 0.23815);
- assertEquals(getStateTransition(34, 6, testHMM), 0.33363);
- assertEquals(getStateTransition(46, 5, testHMM), 1.05474);
- assertEquals(getStateTransition(57, 6, testHMM), 0.31164);
- assertEquals(getStateTransition(68, 2, testHMM), 3.99242);
+ assertEquals(getMatchEmission(0, 2, testHMM), 0.1961, 0.001d);
+ assertEquals(getMatchEmission(2, 1, testHMM), 0.09267, 0.001d);
+ assertEquals(getMatchEmission(12, 2, testHMM), 0.07327, 0.001d);
+ assertEquals(getMatchEmission(69, 1, testHMM), 0.04184, 0.001d);
+ assertEquals(getMatchEmission(76, 2, testHMM), 0.07, 0.001d);
+
+ assertEquals(getInsertEmission(0, 1, testHMM), 0.25, 0.001d);
+ assertEquals(getInsertEmission(1, 2, testHMM), 0.25, 0.001d);
+ assertEquals(getInsertEmission(31, 3, testHMM), 0.2776, 0.001d);
+ assertEquals(getInsertEmission(70, 3, testHMM), 0.25, 0.001d);
+ assertEquals(getInsertEmission(80, 3, testHMM), 0.25, 0.001d);
+
+ assertEquals(getStateTransition(2, 0, testHMM), 0.9634, 0.001d);
+ assertEquals(getStateTransition(6, 1, testHMM), 0.0203, 0.001d);
+ assertEquals(getStateTransition(9, 3, testHMM), 0.2515, 0.001d);
+ assertEquals(getStateTransition(20, 4, testHMM), 0.78808, 0.001d);
+ assertEquals(getStateTransition(68, 2, testHMM), 0.01845, 0.001d);
assertEquals(getStateTransition(80, 6, testHMM),
Double.NEGATIVE_INFINITY);
@Test(priority = 3)
public void testExportFile() throws IOException
{
- fn3.exportFile("test/jalview/io/test_export_hmm.txt");
- HMMFile fn3Clone = new HMMFile(
+ pKinase.exportFile("test/jalview/io/test_export_hmm.txt");
+ HMMFile pKinaseClone = new HMMFile(
new FileParse("test/jalview/io/test_export_hmm.txt",
DataSourceType.FILE));
- fn3Clone.parse();
- HiddenMarkovModel fn3HMM = new HiddenMarkovModel();
- HiddenMarkovModel fn3CloneHMM = new HiddenMarkovModel();
- fn3HMM = fn3.getHMM();
- fn3CloneHMM = fn3Clone.getHMM();
+ pKinaseClone.parse();
+ HiddenMarkovModel pKinaseHMM = new HiddenMarkovModel();
+ HiddenMarkovModel pKinaseCloneHMM = new HiddenMarkovModel();
+ pKinaseHMM = pKinase.getHMM();
+ pKinaseCloneHMM = pKinaseClone.getHMM();
- for (int i = 0; i < fn3HMM.getLength(); i++)
+ for (int i = 0; i < pKinaseHMM.getLength(); i++)
{
List<Double> list1;
List<Double> list2;
boolean result;
- list1 = fn3HMM.getNode(i).getMatchEmissions();
- list2 = fn3CloneHMM.getNode(i).getMatchEmissions();
+ list1 = pKinaseHMM.getNode(i).getMatchEmissions();
+ list2 = pKinaseCloneHMM.getNode(i).getMatchEmissions();
result = checkIfListsAreIdentical(list1, list2);
assertEquals(result, true);
- list1 = fn3HMM.getNode(i).getInsertEmissions();
- list2 = fn3CloneHMM.getNode(i).getInsertEmissions();
+ list1 = pKinaseHMM.getNode(i).getInsertEmissions();
+ list2 = pKinaseCloneHMM.getNode(i).getInsertEmissions();
result = checkIfListsAreIdentical(list1, list2);
assertEquals(result, true);
- list1 = fn3HMM.getNode(i).getStateTransitions();
- list2 = fn3CloneHMM.getNode(i).getStateTransitions();
+ list1 = pKinaseHMM.getNode(i).getStateTransitions();
+ list2 = pKinaseCloneHMM.getNode(i).getStateTransitions();
result = checkIfListsAreIdentical(list1, list2);
assertEquals(result, true);
int alignColumn1;
int alignColumn2;
- alignColumn1 = fn3HMM.getNodeAlignmentColumn(i);
- alignColumn2 = fn3CloneHMM.getNodeAlignmentColumn(i);
+ alignColumn1 = pKinaseHMM.getNodeAlignmentColumn(i);
+ alignColumn2 = pKinaseCloneHMM.getNodeAlignmentColumn(i);
assertEquals(alignColumn1, alignColumn2);
char annotation1;
char annotation2;
- annotation1 = fn3HMM.getReferenceAnnotation(i);
- annotation2 = fn3CloneHMM.getReferenceAnnotation(i);
+ annotation1 = pKinaseHMM.getReferenceAnnotation(i);
+ annotation2 = pKinaseCloneHMM.getReferenceAnnotation(i);
assertEquals(annotation1, annotation2);
- annotation1 = fn3HMM.getConsensusResidue(i);
- annotation2 = fn3CloneHMM.getConsensusResidue(i);
+ annotation1 = pKinaseHMM.getConsensusResidue(i);
+ annotation2 = pKinaseCloneHMM.getConsensusResidue(i);
assertEquals(annotation1, annotation2);
}