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.ws.params.ArgumentI;
17 import java.io.IOException;
18 import java.net.MalformedURLException;
19 import java.util.ArrayList;
21 import org.testng.annotations.AfterClass;
22 import org.testng.annotations.BeforeClass;
23 import org.testng.annotations.Test;
25 public class HMMERTest {
29 @BeforeClass(alwaysRun = true)
30 public void setUpBeforeClass() throws Exception
34 { "-noquestionnaire", "-nonews", "-props",
35 "test/jalview/hmmer/testProps.jvprops", "-open",
36 "examples/uniref50.fa" });
37 // FastaFile file = null;
38 // file = new FastaFile(
39 // new FileParse("examples/uniref50.fa", DataSourceType.FILE));
40 // SequenceI[] seqs = file.getSeqsAsArray();
41 // AlignmentI al = new Alignment(seqs);
42 // frame = new AlignFrame(al, 150, 20);
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 - not the side-effect of selecting the HMM
64 * sequence that gets added to the alignment
67 HiddenMarkovModel hmm = frame.getSelectedHMM();
70 * now run hmmalign - with respect to the select HMM profile
75 public void testHMMBuild()
77 HMMBuildThread thread = new HMMBuildThread(frame,
78 new ArrayList<ArgumentI>());
79 thread.hmmbuildWaitTillComplete();
81 SequenceI seq = frame.getViewport().getAlignment().getSequenceAt(0);
82 HiddenMarkovModel hmm = seq.getHMM();
85 assertEquals(hmm.getLength().intValue(), 148);
86 assertEquals(hmm.getAlphabetType(), "amino");
87 assertEquals(hmm.getName(), "Alignment");
88 assertEquals(hmm.getProperty(HMMFile.EFF_NUMBER_OF_SEQUENCES),
90 assertEquals(hmm.getConsensusAtAlignColumn(15), 's');
93 public void testHMMAlign()
95 HMMAlignThread thread = new HMMAlignThread(frame,
96 new ArrayList<ArgumentI>());
97 thread.hmmalignWaitTillComplete();
99 AlignFrame[] alignFrames = Desktop.getAlignFrames();
100 if (alignFrames == null)
102 fail("No align frame loaded");
106 * now have the original align frame, and another for realigned sequences
108 assertEquals(alignFrames.length, 2);
109 AlignmentI original = alignFrames[0].getViewport().getAlignment();
110 assertNotNull(original);
111 AlignmentI realigned = alignFrames[1].getViewport().getAlignment();
112 assertNotNull(realigned);
113 assertNotNull(original.getHMMConsensusSequences());
114 assertNotNull(realigned.getHMMConsensusSequences());
116 SequenceI ferCapan = original.findName("FER_CAPAN");
117 assertTrue(ferCapan.getSequenceAsString().startsWith("MA------SVSAT"));
119 SequenceI ferCapanRealigned = realigned.findName("FER_CAPAN");
120 assertTrue(ferCapanRealigned.getSequenceAsString()
121 .startsWith("-------m-A----SVSAT"));