package jalview.hmmer; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.fail; import jalview.bin.Jalview; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.HiddenMarkovModel; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.io.DataSourceType; import jalview.io.FastaFile; import jalview.io.FileParse; import jalview.ws.params.ArgumentI; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class HMMERTest { AlignFrame frame; @BeforeClass(alwaysRun = true) public static void setUpBeforeClass() throws Exception { Jalview.main( new String[] { "-noquestionnaire", "-nonews", "-props", "test/jalview/hmmer/testProps.jvprops" }); } @AfterClass(alwaysRun = true) public static void tearDownAfterClass() throws Exception { Desktop.instance.closeAll_actionPerformed(null); } @Test(priority = 0) public void testHMMBuild() throws MalformedURLException, IOException { FastaFile file = null; try { file = new FastaFile( new FileParse("examples/uniref50.fa", DataSourceType.FILE)); } catch (IOException e) { e.printStackTrace(); fail(); } SequenceI[] seqs = file.getSeqsAsArray(); AlignmentI al = new Alignment(seqs); frame = new AlignFrame(al, 150, 20); HMMBuildThread thread = new HMMBuildThread(frame, new ArrayList()); thread.hmmbuildWaitTillComplete(); SequenceI seq = frame.getViewport().getAlignment().getSequenceAt(0); HiddenMarkovModel hmm = seq.getHMM(); if (hmm == null) { fail(); } assertEquals(hmm.getLength().intValue(), 148); assertEquals(hmm.getAlphabetType(), "amino"); assertEquals(hmm.getName(), "Alignment"); assertEquals(hmm.getEffectiveNumberOfSequences(), 0.648193, 0.0001); assertEquals(hmm.getConsensusAtAlignColumn(15), 's'); } @Test(priority = 1) public void testHMMAlign() throws MalformedURLException, IOException { HMMAlignThread thread = new HMMAlignThread(frame, true, new ArrayList()); try { thread.hmmalignWaitTillComplete(); } catch (Exception e) { e.printStackTrace(); fail(); } if (Desktop.getAlignFrames() == null) { fail(); } AlignFrame fr = Desktop.getAlignFrames()[0]; AlignmentI al = fr.getViewport().getAlignment(); assertNotEquals(al, null); List hmmSeqs = al.getHMMConsensusSequences(); assertNotNull(hmmSeqs); } }