| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ext.paradise; |
| 22 |
|
|
| 23 |
|
import java.util.Locale; |
| 24 |
|
|
| 25 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 26 |
|
|
| 27 |
|
import jalview.datamodel.AlignmentI; |
| 28 |
|
import jalview.datamodel.SequenceI; |
| 29 |
|
import jalview.gui.JvOptionPane; |
| 30 |
|
import jalview.io.DataSourceType; |
| 31 |
|
import jalview.io.FastaFile; |
| 32 |
|
import jalview.io.FileFormat; |
| 33 |
|
import jalview.io.FormatAdapter; |
| 34 |
|
|
| 35 |
|
import java.io.BufferedReader; |
| 36 |
|
import java.io.File; |
| 37 |
|
import java.io.Reader; |
| 38 |
|
import java.util.Iterator; |
| 39 |
|
|
| 40 |
|
import org.testng.Assert; |
| 41 |
|
import org.testng.AssertJUnit; |
| 42 |
|
import org.testng.annotations.BeforeClass; |
| 43 |
|
import org.testng.annotations.Test; |
| 44 |
|
|
| 45 |
|
import compbio.util.FileUtil; |
| 46 |
|
import mc_view.PDBfile; |
| 47 |
|
|
| |
|
| 0% |
Uncovered Elements: 76 (76) |
Complexity: 17 |
Complexity Density: 0.33 |
|
| 48 |
|
public class TestAnnotate3D |
| 49 |
|
{ |
| 50 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 51 |
0 |
@BeforeClass(alwaysRun = true)... |
| 52 |
|
public void setUpJvOptionPane() |
| 53 |
|
{ |
| 54 |
0 |
JvOptionPane.setInteractiveMode(false); |
| 55 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 56 |
|
} |
| 57 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
4-
|
|
| 58 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
| 59 |
|
public void test1GIDbyId() throws Exception |
| 60 |
|
{ |
| 61 |
|
|
| 62 |
|
|
| 63 |
0 |
Iterator<Reader> ids = Annotate3D.getRNAMLForPDBId("1GID"); |
| 64 |
0 |
assertTrue("Didn't retrieve 1GID by id.", ids != null); |
| 65 |
0 |
testRNAMLcontent(ids, null); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
4-
|
|
| 68 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
| 69 |
|
public void testIdVsContent2GIS() throws Exception |
| 70 |
|
{ |
| 71 |
0 |
Iterator<Reader> ids = Annotate3D.getRNAMLForPDBId("2GIS"); |
| 72 |
0 |
assertTrue("Didn't retrieve 2GIS by id.", ids != null); |
| 73 |
0 |
Iterator<Reader> files = Annotate3D.getRNAMLForPDBFileAsString( |
| 74 |
|
FileUtil.readFileToString(new File("examples/2GIS.pdb"))); |
| 75 |
0 |
assertTrue("Didn't retrieve using examples/2GIS.pdb.", files != null); |
| 76 |
0 |
int i = 0; |
| 77 |
0 |
while (ids.hasNext() && files.hasNext()) |
| 78 |
|
{ |
| 79 |
0 |
BufferedReader file = new BufferedReader(files.next()), |
| 80 |
|
id = new BufferedReader(ids.next()); |
| 81 |
0 |
String iline, fline; |
| 82 |
0 |
do |
| 83 |
|
{ |
| 84 |
0 |
iline = id.readLine(); |
| 85 |
0 |
fline = file.readLine(); |
| 86 |
0 |
if (iline != null) |
| 87 |
|
{ |
| 88 |
0 |
System.out.println(iline); |
| 89 |
|
} |
| 90 |
0 |
if (fline != null) |
| 91 |
|
{ |
| 92 |
0 |
System.out.println(fline); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
0 |
assertTrue( |
| 97 |
|
"Results differ for ID and file upload based retrieval (chain entry " |
| 98 |
|
+ (++i) + ")", |
| 99 |
|
((iline == fline && iline == null) || (iline != null |
| 100 |
|
&& fline != null && iline.equals(fline)))); |
| 101 |
|
|
| 102 |
0 |
} while (iline != null); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
@throws |
| 111 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
4-
|
|
| 112 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
| 113 |
|
public void testPDBfileVsRNAML() throws Exception |
| 114 |
|
{ |
| 115 |
0 |
PDBfile pdbf = new PDBfile(true, false, true, "examples/2GIS.pdb", |
| 116 |
|
DataSourceType.FILE); |
| 117 |
0 |
Assert.assertTrue(pdbf.isValid()); |
| 118 |
|
|
| 119 |
|
|
| 120 |
0 |
Iterator<Reader> readers = Annotate3D.getRNAMLForPDBFileAsString( |
| 121 |
|
FileUtil.readFileToString(new File("examples/2GIS.pdb"))); |
| 122 |
0 |
testRNAMLcontent(readers, pdbf); |
| 123 |
|
} |
| 124 |
|
|
| |
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 8 |
Complexity Density: 0.31 |
|
| 125 |
0 |
private void testRNAMLcontent(Iterator<Reader> readers, PDBfile pdbf)... |
| 126 |
|
throws Exception |
| 127 |
|
{ |
| 128 |
0 |
StringBuffer sb = new StringBuffer(); |
| 129 |
0 |
int r = 0; |
| 130 |
0 |
while (readers.hasNext()) |
| 131 |
|
{ |
| 132 |
0 |
System.out.println("Testing RNAML input number " + (++r)); |
| 133 |
0 |
BufferedReader br = new BufferedReader(readers.next()); |
| 134 |
0 |
String line; |
| 135 |
0 |
while ((line = br.readLine()) != null) |
| 136 |
|
{ |
| 137 |
0 |
sb.append(line + "\n"); |
| 138 |
|
} |
| 139 |
0 |
assertTrue("No data returned by Annotate3D", sb.length() > 0); |
| 140 |
0 |
final String lines = sb.toString(); |
| 141 |
0 |
AlignmentI al = new FormatAdapter().readFile(lines, |
| 142 |
|
DataSourceType.PASTE, FileFormat.Rnaml); |
| 143 |
0 |
if (al == null || al.getHeight() == 0) |
| 144 |
|
{ |
| 145 |
0 |
System.out.println(lines); |
| 146 |
|
} |
| 147 |
0 |
assertTrue("No alignment returned.", al != null); |
| 148 |
0 |
assertTrue("No sequences in returned alignment.", al.getHeight() > 0); |
| 149 |
0 |
if (pdbf != null) |
| 150 |
|
{ |
| 151 |
0 |
for (SequenceI sq : al.getSequences()) |
| 152 |
|
{ |
| 153 |
|
{ |
| 154 |
0 |
SequenceI struseq = null; |
| 155 |
0 |
String sq_ = sq.getSequenceAsString().toLowerCase(Locale.ROOT); |
| 156 |
0 |
for (SequenceI _struseq : pdbf.getSeqsAsArray()) |
| 157 |
|
{ |
| 158 |
0 |
final String lowerCase = _struseq.getSequenceAsString() |
| 159 |
|
.toLowerCase(Locale.ROOT); |
| 160 |
0 |
if (lowerCase.equals(sq_)) |
| 161 |
|
{ |
| 162 |
0 |
struseq = _struseq; |
| 163 |
0 |
break; |
| 164 |
|
} |
| 165 |
|
} |
| 166 |
0 |
if (struseq == null) |
| 167 |
|
{ |
| 168 |
0 |
AssertJUnit.fail( |
| 169 |
|
"Couldn't find this sequence in original input:\n" |
| 170 |
|
+ new FastaFile().print(new SequenceI[] |
| 171 |
|
{ sq }, true) + "\n\nOriginal input:\n" |
| 172 |
|
+ new FastaFile().print(pdbf.getSeqsAsArray(), |
| 173 |
|
true) |
| 174 |
|
+ "\n"); |
| 175 |
|
} |
| 176 |
|
} |
| 177 |
|
} |
| 178 |
|
} |
| 179 |
|
} |
| 180 |
|
} |
| 181 |
|
} |