3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertNotEquals;
5 import static org.testng.Assert.assertNotNull;
6 import static org.testng.Assert.fail;
8 import jalview.bin.Jalview;
9 import jalview.datamodel.Alignment;
10 import jalview.datamodel.AlignmentI;
11 import jalview.datamodel.HiddenMarkovModel;
12 import jalview.datamodel.SequenceI;
13 import jalview.gui.AlignFrame;
14 import jalview.gui.Desktop;
15 import jalview.io.DataSourceType;
16 import jalview.io.FastaFile;
17 import jalview.io.FileParse;
18 import jalview.ws.params.ArgumentI;
20 import java.io.IOException;
21 import java.net.MalformedURLException;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.testng.annotations.AfterClass;
26 import org.testng.annotations.BeforeClass;
27 import org.testng.annotations.Test;
30 public class HMMERTest {
34 @BeforeClass(alwaysRun = true)
35 public static void setUpBeforeClass() throws Exception
39 { "-noquestionnaire", "-nonews", "-props",
40 "test/jalview/hmmer/testProps.jvprops" });
43 @AfterClass(alwaysRun = true)
44 public static void tearDownAfterClass() throws Exception
46 Desktop.instance.closeAll_actionPerformed(null);
50 public void testHMMBuild() throws MalformedURLException, IOException
52 FastaFile file = null;
56 new FileParse("examples/uniref50.fa", DataSourceType.FILE));
57 } catch (IOException e)
62 SequenceI[] seqs = file.getSeqsAsArray();
63 AlignmentI al = new Alignment(seqs);
64 frame = new AlignFrame(al, 150, 20);
66 HMMBuildThread thread = new HMMBuildThread(frame,
67 new ArrayList<ArgumentI>());
68 thread.hmmbuildWaitTillComplete();
70 SequenceI seq = frame.getViewport().getAlignment().getSequenceAt(0);
71 HiddenMarkovModel hmm = seq.getHMM();
77 assertEquals(hmm.getLength().intValue(), 148);
78 assertEquals(hmm.getAlphabetType(), "amino");
79 assertEquals(hmm.getName(), "Alignment");
80 assertEquals(hmm.getEffectiveNumberOfSequences(), 0.648193, 0.0001);
81 assertEquals(hmm.getConsensusAtAlignColumn(15), 's');
85 public void testHMMAlign() throws MalformedURLException, IOException
87 HMMAlignThread thread = new HMMAlignThread(frame, true,
88 new ArrayList<ArgumentI>());
91 thread.hmmalignWaitTillComplete();
98 if (Desktop.getAlignFrames() == null)
103 AlignFrame fr = Desktop.getAlignFrames()[0];
104 AlignmentI al = fr.getViewport().getAlignment();
105 assertNotEquals(al, null);
106 List<SequenceI> hmmSeqs = al.getHMMConsensusSequences();
107 assertNotNull(hmmSeqs);