| 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 |
|
|
| |
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 6 |
Complexity Density: 0.17 |
|
| 29 |
|
public class HMMERTest { |
| 30 |
|
|
| 31 |
|
AlignFrame frame; |
| 32 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 33 |
0 |
@BeforeClass(alwaysRun = true)... |
| 34 |
|
public void setUpBeforeClass() throws Exception |
| 35 |
|
{ |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 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 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 48 |
0 |
@AfterClass(alwaysRun = true)... |
| 49 |
|
public static void tearDownAfterClass() throws Exception |
| 50 |
|
{ |
| 51 |
0 |
Desktop.getInstance().closeAll_actionPerformed(null); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
@throws |
| 58 |
|
@throws |
| 59 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
4-
|
|
| 60 |
0 |
@Test(groups = "External")... |
| 61 |
|
public void testHMMBuildThenHMMAlign() |
| 62 |
|
throws MalformedURLException, IOException |
| 63 |
|
{ |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
0 |
testHMMBuild(); |
| 68 |
0 |
List<SequenceI> hmms = frame.getViewport().getAlignment() |
| 69 |
|
.getHmmSequences(); |
| 70 |
0 |
assertFalse(hmms.isEmpty()); |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
0 |
testHMMAlign(); |
| 76 |
|
} |
| 77 |
|
|
| |
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
4-
|
|
| 78 |
0 |
public void testHMMBuild()... |
| 79 |
|
{ |
| 80 |
|
|
| 81 |
|
|
| 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 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 2 |
Complexity Density: 0.12 |
4-
|
|
| 103 |
0 |
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 |
|
|
| 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 |
|
|