3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertNotNull;
5 import static org.testng.Assert.assertTrue;
6 import static org.testng.Assert.fail;
8 import jalview.bin.Jalview;
9 import jalview.datamodel.AlignmentI;
10 import jalview.datamodel.HiddenMarkovModel;
11 import jalview.datamodel.SequenceI;
12 import jalview.gui.AlignFrame;
13 import jalview.gui.Desktop;
14 import jalview.io.HMMFile;
15 import jalview.util.MessageManager;
16 import jalview.ws.params.ArgumentI;
17 import jalview.ws.params.simple.Option;
19 import java.io.IOException;
20 import java.net.MalformedURLException;
21 import java.util.ArrayList;
23 import org.testng.annotations.AfterClass;
24 import org.testng.annotations.BeforeClass;
25 import org.testng.annotations.Test;
27 public class HMMERTest {
31 @BeforeClass(alwaysRun = true)
32 public void setUpBeforeClass() throws Exception
35 * NB: check HMMER_PATH in testProps.jvprops is valid for
36 * the machine on which this runs
40 { "-noquestionnaire", "-nonews", "-props",
41 "test/jalview/hmmer/testProps.jvprops", "-open",
42 "examples/uniref50.fa" });
43 frame = Desktop.getAlignFrames()[0];
46 @AfterClass(alwaysRun = true)
47 public static void tearDownAfterClass() throws Exception
49 Desktop.instance.closeAll_actionPerformed(null);
53 * Test with a dependency on locally installed hmmbuild binaries
55 * @throws MalformedURLException
58 @Test(groups = "External")
59 public void testHMMBuildThenHMMAlign()
60 throws MalformedURLException, IOException
63 * run hmmbuild - note the side-effect of selecting the HMM
64 * sequence that gets added to the alignment
67 HiddenMarkovModel hmm = frame.getSelectedHMM();
71 * now run hmmalign - with respect to the select HMM profile
76 public void testHMMBuild()
79 * set up argument to run hmmbuild for the alignment
81 ArrayList<ArgumentI> params = new ArrayList<>();
82 String argName = MessageManager.getString("label.hmmbuild_for");
83 String argValue = MessageManager.getString("label.alignment");
85 new Option(argName, null, false, null, argValue, null, null));
87 HMMBuild builder = new HMMBuild(frame, params);
90 SequenceI seq = frame.getViewport().getAlignment().getSequenceAt(0);
91 HiddenMarkovModel hmm = seq.getHMM();
94 assertEquals(hmm.getLength(), 148);
95 assertEquals(hmm.getAlphabetType(), "amino");
96 assertEquals(hmm.getName(), "Alignment_HMM");
97 assertEquals(hmm.getProperty(HMMFile.EFF_NUMBER_OF_SEQUENCES),
101 public void testHMMAlign()
103 HMMAlign thread = new HMMAlign(frame,
104 new ArrayList<ArgumentI>());
107 AlignFrame[] alignFrames = Desktop.getAlignFrames();
108 if (alignFrames == null)
110 fail("No align frame loaded");
114 * now have the original align frame, and another for realigned sequences
116 assertEquals(alignFrames.length, 2);
117 AlignmentI original = alignFrames[0].getViewport().getAlignment();
118 assertNotNull(original);
119 AlignmentI realigned = alignFrames[1].getViewport().getAlignment();
120 assertNotNull(realigned);
121 assertNotNull(original.getHmmConsensus());
122 assertNotNull(realigned.getHmmConsensus());
124 SequenceI ferCapan = original.findName("FER_CAPAN");
125 assertTrue(ferCapan.getSequenceAsString().startsWith("MA------SVSAT"));
127 SequenceI ferCapanRealigned = realigned.findName("FER_CAPAN");
128 assertTrue(ferCapanRealigned.getSequenceAsString()
129 .startsWith("-------m-A----SVSAT"));