Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.hmmer

File HMMERTest.java

 

Code metrics

2
36
5
1
134
92
6
0.17
7.2
5
1.2

Classes

Class Line # Actions
HMMERTest 29 36 6
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package jalview.hmmer;
2   
3    import static org.testng.Assert.assertEquals;
4    import static org.testng.Assert.assertFalse;
5    import static org.testng.Assert.assertNotNull;
6    import static org.testng.Assert.assertTrue;
7    import static org.testng.Assert.fail;
8   
9    import jalview.bin.Jalview;
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.HMMFile;
16    import jalview.util.MessageManager;
17    import jalview.ws.params.ArgumentI;
18    import jalview.ws.params.simple.Option;
19   
20    import java.io.IOException;
21    import java.net.MalformedURLException;
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.testng.annotations.AfterClass;
26    import org.testng.annotations.BeforeClass;
27    import org.testng.annotations.Test;
28   
 
29    public class HMMERTest {
30   
31    AlignFrame frame;
32   
 
33  0 toggle @BeforeClass(alwaysRun = true)
34    public void setUpBeforeClass() throws Exception
35    {
36    /*
37    * NB: check HMMER_PATH in testProps.jvprops is valid for
38    * the machine on which this runs
39    */
40  0 Jalview.main(
41    new String[]
42    { "-noquestionnaire", "-nonews", "-props",
43    "test/jalview/hmmer/testProps.jvprops", "-open",
44    "examples/uniref50.fa" });
45  0 frame = Desktop.getDesktopAlignFrames()[0];
46    }
47   
 
48  0 toggle @AfterClass(alwaysRun = true)
49    public static void tearDownAfterClass() throws Exception
50    {
51  0 Desktop.getInstance().closeAll_actionPerformed(null);
52    }
53   
54    /**
55    * Test with a dependency on locally installed hmmbuild binaries
56    *
57    * @throws MalformedURLException
58    * @throws IOException
59    */
 
60  0 toggle @Test(groups = "External")
61    public void testHMMBuildThenHMMAlign()
62    throws MalformedURLException, IOException
63    {
64    /*
65    * run hmmbuild
66    */
67  0 testHMMBuild();
68  0 List<SequenceI> hmms = frame.getViewport().getAlignment()
69    .getHmmSequences();
70  0 assertFalse(hmms.isEmpty());
71   
72    /*
73    * now run hmmalign - by default with respect to the added HMM profile
74    */
75  0 testHMMAlign();
76    }
77   
 
78  0 toggle public void testHMMBuild()
79    {
80    /*
81    * set up argument to run hmmbuild for the alignment
82    */
83  0 ArrayList<ArgumentI> params = new ArrayList<>();
84  0 String argName = MessageManager.getString("label.hmmbuild_for");
85  0 String argValue = MessageManager.getString("label.alignment");
86  0 params.add(
87    new Option(argName, null, false, null, argValue, null, null));
88   
89  0 HMMBuild builder = new HMMBuild(frame, params);
90  0 builder.run();
91   
92  0 SequenceI seq = frame.getViewport().getAlignment().getSequenceAt(0);
93  0 HiddenMarkovModel hmm = seq.getHMM();
94  0 assertNotNull(hmm);
95   
96  0 assertEquals(hmm.getLength(), 148);
97  0 assertEquals(hmm.getAlphabetType(), "amino");
98  0 assertEquals(hmm.getName(), "Alignment_HMM");
99  0 assertEquals(hmm.getProperty(HMMFile.EFF_NUMBER_OF_SEQUENCES),
100    "0.648193");
101    }
102   
 
103  0 toggle public void testHMMAlign()
104    {
105  0 HmmerCommand thread = new HMMAlign(frame,
106    new ArrayList<ArgumentI>());
107  0 thread.run();
108   
109  0 AlignFrame[] alignFrames = Desktop.getDesktopAlignFrames();
110  0 if (alignFrames == null)
111    {
112  0 fail("No align frame loaded");
113    }
114   
115    /*
116    * now have the original align frame, and another for realigned sequences
117    */
118  0 assertEquals(alignFrames.length, 2);
119  0 AlignmentI original = alignFrames[0].getViewport().getAlignment();
120  0 assertNotNull(original);
121  0 AlignmentI realigned = alignFrames[1].getViewport().getAlignment();
122  0 assertNotNull(realigned);
123  0 assertFalse(original.getHmmSequences().isEmpty());
124  0 assertFalse(realigned.getHmmSequences().isEmpty());
125   
126  0 SequenceI ferCapan = original.findName("FER_CAPAN");
127  0 assertTrue(ferCapan.getSequenceAsString().startsWith("MA------SVSAT"));
128   
129  0 SequenceI ferCapanRealigned = realigned.findName("FER_CAPAN");
130  0 assertTrue(ferCapanRealigned.getSequenceAsString()
131    .startsWith("-------m-A----SVSAT"));
132    }
133    }
134