import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.HiddenMarkovModel;
+import jalview.datamodel.Profile;
import jalview.datamodel.ProfileI;
+import jalview.datamodel.Profiles;
import jalview.datamodel.ProfilesI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
+import jalview.io.FileParse;
+import jalview.io.HMMFile;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AAFrequencyTest
{
+ HiddenMarkovModel hmm;
+
@BeforeClass(alwaysRun = true)
public void setUpJvOptionPane()
{
assertEquals("T", ann.displayCharacter);
}
- /*
- @Test(groups = { "Functional" })
- public void testGetHMMProfileFor()
+
+ @Test(groups = { "Functional" }, priority = 1)
+ public void testExtractHMMProfile()
throws MalformedURLException, IOException
{
HMMFile hmmFile = new HMMFile(new FileParse(
"test/jalview/io/test_MADE1_hmm.txt", DataSourceType.FILE));
- hmmFile.parse();
- HiddenMarkovModel hmm = hmmFile.getHMM();
+ hmm = hmmFile.getHMM();
int[] expected = { 0, 4, 100, 'T', 71, 'C', 12, 'G', 9, 'A', 9 };
- int[] actual = AAFrequency.getHMMProfileFor(hmm, 17, false);
+ int[] actual = AAFrequency.extractHMMProfile(hmm, 17, false);
for (int i = 0; i < actual.length; i++)
{
if (i == 2)
{
- assertEquals(actual[i], expected[i], 5);
+ assertEquals(actual[i], expected[i]);
}
else
{
- assertEquals(actual[i], expected[i], 1);
+ assertEquals(actual[i], expected[i]);
}
}
- int[] expected2 = { 0, 4, 85, 'A', 85, 'C', 0, 'G', 0, 'T', 0 };
- int[] actual2 = AAFrequency.getHMMProfileFor(hmm, 2, true);
- for (int i = 0; i < actual.length; i++)
+ int[] expected2 = { 0, 4, 100, 'A', 85, 'C', 0, 'G', 0, 'T', 0 };
+ int[] actual2 = AAFrequency.extractHMMProfile(hmm, 2, true);
+ for (int i = 0; i < actual2.length; i++)
{
if (i == 2)
{
- assertEquals(actual[i], expected[i], 5);
+ assertEquals(actual[i], expected[i]);
}
else
{
- assertEquals(actual[i], expected[i], 1);
+ assertEquals(actual[i], expected[i]);
}
}
+
+ assertNull(AAFrequency.extractHMMProfile(null, 98978867, true));
+ }
+
+ @Test(groups = { "Functional" }, priority = 2)
+ public void testGetAnalogueCount()
+ {
+ int count;
+ count = AAFrequency.getAnalogueCount(hmm, 0, 'T', false);
+ assertEquals(7859, count);
+ count = AAFrequency.getAnalogueCount(hmm, 20, 'G', false);
+ assertEquals(7546, count);
+ count = AAFrequency.getAnalogueCount(hmm, 1077, 'G', true);
+ assertEquals(0, count);
}
- */
+
+ @Test(groups = { "Functional" }, priority = 3)
+ public void testCompleteInformation()
+ {
+ ProfileI prof1 = new Profile(1, 0, 100, "A");
+ ProfileI prof2 = new Profile(1, 0, 100, "-");
+
+ ProfilesI profs = new Profiles(new ProfileI[] { prof1, prof2 });
+ Annotation ann1 = new Annotation(6.5f);
+ Annotation ann2 = new Annotation(0f);
+ Annotation[] annots = new Annotation[] { ann1, ann2 };
+ SequenceI seq = new Sequence("", "AA", 0, 0);
+ seq.setHMM(hmm);
+ AlignmentAnnotation annot = new AlignmentAnnotation("", "", annots);
+ annot.setSequenceRef(seq);
+ AAFrequency.completeInformation(annot, profs, 0, 1, false, true, 1);
+ float ic = annot.annotations[0].value;
+ assertEquals(0.91532f, ic, 0.0001f);
+ ic = annot.annotations[1].value;
+ assertEquals(0f, ic, 0.0001f);
+ int i = 0;
+ }
+
}