| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.jabaws; |
| 22 |
|
|
| 23 |
|
import java.util.Locale; |
| 24 |
|
import static org.testng.AssertJUnit.assertNotNull; |
| 25 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 26 |
|
|
| 27 |
|
import jalview.bin.Cache; |
| 28 |
|
import jalview.bin.Console; |
| 29 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 30 |
|
import jalview.datamodel.AlignmentI; |
| 31 |
|
import jalview.gui.JvOptionPane; |
| 32 |
|
import jalview.io.AnnotationFile; |
| 33 |
|
import jalview.io.DataSourceType; |
| 34 |
|
import jalview.io.FileFormat; |
| 35 |
|
import jalview.io.FormatAdapter; |
| 36 |
|
import jalview.io.StockholmFileTest; |
| 37 |
|
import jalview.ws.api.ServiceWithParameters; |
| 38 |
|
import jalview.ws.jws2.Jws2Discoverer; |
| 39 |
|
import jalview.ws.jws2.SeqAnnotationServiceCalcWorker; |
| 40 |
|
import jalview.ws.slivkaws.SlivkaWSDiscoverer; |
| 41 |
|
|
| 42 |
|
import java.util.ArrayList; |
| 43 |
|
import java.util.List; |
| 44 |
|
|
| 45 |
|
import org.testng.Assert; |
| 46 |
|
import org.testng.annotations.AfterClass; |
| 47 |
|
import org.testng.annotations.BeforeClass; |
| 48 |
|
import org.testng.annotations.DataProvider; |
| 49 |
|
import org.testng.annotations.Test; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@Test(singleThreaded = true) |
| |
|
| 0% |
Uncovered Elements: 72 (72) |
Complexity: 14 |
Complexity Density: 0.26 |
|
| 56 |
|
public class DisorderAnnotExportImport |
| 57 |
|
{ |
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 59 |
0 |
@BeforeClass(alwaysRun = true)... |
| 60 |
|
public void setUpJvOptionPane() |
| 61 |
|
{ |
| 62 |
0 |
JvOptionPane.setInteractiveMode(false); |
| 63 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
public static String testseqs = "examples/uniref50.fa"; |
| 67 |
|
|
| 68 |
|
public static Jws2Discoverer disc; |
| 69 |
|
|
| 70 |
|
public static List<ServiceWithParameters> iupreds; |
| 71 |
|
|
| 72 |
|
jalview.ws.jws2.SeqAnnotationServiceCalcWorker disorderClient; |
| 73 |
|
|
| 74 |
|
public static jalview.gui.AlignFrame af = null; |
| 75 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 4 |
Complexity Density: 0.24 |
|
| 76 |
0 |
@BeforeClass(alwaysRun = true)... |
| 77 |
|
public static void setUpBeforeClass() throws Exception |
| 78 |
|
{ |
| 79 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
| 80 |
0 |
Console.initLogger(); |
| 81 |
0 |
disc = JalviewJabawsTestUtils.getJabawsDiscoverer(); |
| 82 |
|
|
| 83 |
0 |
while (disc.isRunning()) |
| 84 |
|
{ |
| 85 |
|
|
| 86 |
0 |
Thread.sleep(100); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
0 |
SlivkaWSDiscoverer disc2 = SlivkaWSDiscoverer.getInstance(); |
| 90 |
0 |
disc2.startDiscoverer(); |
| 91 |
0 |
while (disc2.isRunning()) |
| 92 |
|
{ |
| 93 |
0 |
Thread.sleep(100); |
| 94 |
|
} |
| 95 |
0 |
iupreds = new ArrayList<>(); |
| 96 |
0 |
for (ServiceWithParameters svc : disc2.getServices()) |
| 97 |
|
{ |
| 98 |
0 |
if (svc.getNameURI().toLowerCase().contains("iupred")) |
| 99 |
|
{ |
| 100 |
0 |
iupreds.add(svc); |
| 101 |
|
} |
| 102 |
|
} |
| 103 |
0 |
assertTrue("Couldn't discover any IUPred services to use to test.", |
| 104 |
|
iupreds.size() > 0); |
| 105 |
0 |
jalview.io.FileLoader fl = new jalview.io.FileLoader(false); |
| 106 |
0 |
af = fl.LoadFileWaitTillLoaded(testseqs, |
| 107 |
|
jalview.io.DataSourceType.FILE); |
| 108 |
0 |
assertNotNull("Couldn't load test data ('" + testseqs + "')", af); |
| 109 |
|
} |
| 110 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 111 |
0 |
@AfterClass(alwaysRun = true)... |
| 112 |
|
public static void tearDownAfterClass() throws Exception |
| 113 |
|
{ |
| 114 |
0 |
if (af != null) |
| 115 |
|
{ |
| 116 |
0 |
af.setVisible(false); |
| 117 |
0 |
af.dispose(); |
| 118 |
0 |
af = null; |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 122 |
0 |
@DataProvider(name="getIuPreds",parallel = false)... |
| 123 |
|
public static ServiceWithParameters[][] getIuPreds() |
| 124 |
|
{ |
| 125 |
0 |
ServiceWithParameters[][] services = new ServiceWithParameters[iupreds |
| 126 |
|
.size()][1]; |
| 127 |
|
|
| 128 |
0 |
int i = 0; |
| 129 |
0 |
for (ServiceWithParameters iupred : iupreds) |
| 130 |
|
{ |
| 131 |
0 |
services[i++][0] = iupred; |
| 132 |
|
} |
| 133 |
0 |
return services; |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| |
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.29 |
4-
|
|
| 139 |
0 |
@Test(groups = { "External", "Network" },dataProvider = "getIuPreds")... |
| 140 |
|
public void testDisorderAnnotExport(ServiceWithParameters iuPred) |
| 141 |
|
{ |
| 142 |
0 |
disorderClient = new SeqAnnotationServiceCalcWorker(iuPred, af, null, |
| 143 |
|
null); |
| 144 |
0 |
af.getViewport().getCalcManager().startWorker(disorderClient); |
| 145 |
0 |
do |
| 146 |
|
{ |
| 147 |
0 |
try |
| 148 |
|
{ |
| 149 |
0 |
Thread.sleep(50); |
| 150 |
|
} catch (InterruptedException x) |
| 151 |
|
{ |
| 152 |
|
} |
| 153 |
0 |
; |
| 154 |
0 |
} while (af.getViewport().getCalcManager().isWorking()); |
| 155 |
0 |
AlignmentI orig_alig = af.getViewport().getAlignment(); |
| 156 |
|
|
| 157 |
|
|
| 158 |
0 |
List<AlignmentAnnotation> toremove = new ArrayList<>(); |
| 159 |
0 |
for (AlignmentAnnotation aa : orig_alig.getAlignmentAnnotation()) |
| 160 |
|
{ |
| 161 |
0 |
if (aa.autoCalculated) |
| 162 |
|
{ |
| 163 |
0 |
toremove.add(aa); |
| 164 |
|
} |
| 165 |
|
} |
| 166 |
0 |
for (AlignmentAnnotation aa : toremove) |
| 167 |
|
{ |
| 168 |
0 |
orig_alig.deleteAnnotation(aa); |
| 169 |
|
} |
| 170 |
0 |
checkAnnotationFileIO("Testing IUPred Annotation IO", orig_alig); |
| 171 |
|
|
| 172 |
|
} |
| 173 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 174 |
0 |
static void checkAnnotationFileIO(String testname, AlignmentI al)... |
| 175 |
|
{ |
| 176 |
0 |
try |
| 177 |
|
{ |
| 178 |
0 |
String aligfileout = FileFormat.Pfam.getWriter(al) |
| 179 |
|
.print(al.getSequencesArray(), true); |
| 180 |
0 |
String anfileout = new AnnotationFile() |
| 181 |
|
.printAnnotationsForAlignment(al); |
| 182 |
0 |
assertTrue("Test " + testname |
| 183 |
|
+ "\nAlignment annotation file was not regenerated. Null string", |
| 184 |
|
anfileout != null); |
| 185 |
0 |
assertTrue("Test " + testname |
| 186 |
|
+ "\nAlignment annotation file was not regenerated. Empty string", |
| 187 |
|
anfileout.length() > "JALVIEW_ANNOTATION".length()); |
| 188 |
|
|
| 189 |
0 |
System.out.println( |
| 190 |
|
"Output annotation file:\n" + anfileout + "\n<<EOF\n"); |
| 191 |
|
|
| 192 |
0 |
AlignmentI al_new = new FormatAdapter().readFile(aligfileout, |
| 193 |
|
DataSourceType.PASTE, FileFormat.Pfam); |
| 194 |
0 |
assertTrue("Test " + testname |
| 195 |
|
+ "\nregenerated annotation file did not annotate alignment.", |
| 196 |
|
new AnnotationFile().readAnnotationFile(al_new, anfileout, |
| 197 |
|
DataSourceType.PASTE)); |
| 198 |
|
|
| 199 |
|
|
| 200 |
0 |
StockholmFileTest.testAlignmentEquivalence(al, al_new, true, false, |
| 201 |
|
false); |
| 202 |
0 |
return; |
| 203 |
|
} catch (Exception e) |
| 204 |
|
{ |
| 205 |
0 |
e.printStackTrace(); |
| 206 |
|
} |
| 207 |
0 |
Assert.fail("Test " + testname |
| 208 |
|
+ "\nCouldn't complete Annotation file roundtrip input/output/input test."); |
| 209 |
|
} |
| 210 |
|
|
| 211 |
|
} |