2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.jabaws;
23 import static org.testng.AssertJUnit.assertNotNull;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.bin.Cache;
27 import jalview.datamodel.AlignmentAnnotation;
28 import jalview.datamodel.AlignmentI;
29 import jalview.gui.JvOptionPane;
30 import jalview.io.AnnotationFile;
31 import jalview.io.DataSourceType;
32 import jalview.io.FileFormat;
33 import jalview.io.FormatAdapter;
34 import jalview.io.StockholmFileTest;
35 import jalview.ws.jws2.AbstractJabaCalcWorker;
36 import jalview.ws.jws2.Jws2Discoverer;
37 import jalview.ws.jws2.jabaws2.Jws2Instance;
39 import java.util.ArrayList;
40 import java.util.List;
42 import org.testng.Assert;
43 import org.testng.annotations.AfterClass;
44 import org.testng.annotations.BeforeClass;
45 import org.testng.annotations.Test;
48 * All methods in this class are set to the Network group because setUpBeforeClass will fail
49 * if there is no network.
51 @Test(singleThreaded = true)
52 public class DisorderAnnotExportImport
55 @BeforeClass(alwaysRun = true)
56 public void setUpJvOptionPane()
58 JvOptionPane.setInteractiveMode(false);
59 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
62 public static String testseqs = "examples/uniref50.fa";
64 public static Jws2Discoverer disc;
66 public static List<Jws2Instance> iupreds;
68 jalview.ws.jws2.AbstractJabaCalcWorker disorderClient;
70 public static jalview.gui.AlignFrame af = null;
72 @BeforeClass(alwaysRun = true)
73 public static void setUpBeforeClass() throws Exception
75 Cache.loadProperties("test/jalview/io/testProps.jvprops");
77 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
79 while (disc.isRunning())
81 // don't get services until discoverer has finished
85 iupreds = new ArrayList<>();
86 for (Jws2Instance svc : disc.getServices())
88 if (svc.getNameURI().toLowerCase().contains("iupredws"))
93 assertTrue("Couldn't discover any IUPred services to use to test.",
95 jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
96 af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.DataSourceType.FILE);
97 assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
100 @AfterClass(alwaysRun = true)
101 public static void tearDownAfterClass() throws Exception
105 af.setVisible(false);
112 * test for patches to JAL-1294
114 @Test(groups = { "External", "Network" })
115 public void testDisorderAnnotExport()
117 disorderClient = new AbstractJabaCalcWorker(iupreds.get(0), af, null,
119 af.getViewport().getCalcManager().startWorker(disorderClient);
125 } catch (InterruptedException x)
129 } while (af.getViewport().getCalcManager().isWorking());
130 AlignmentI orig_alig = af.getViewport().getAlignment();
131 // NOTE: Consensus annotation row cannot be exported and reimported
132 // faithfully - so we remove them
133 List<AlignmentAnnotation> toremove = new ArrayList<>();
134 for (AlignmentAnnotation aa : orig_alig.getAlignmentAnnotation())
136 if (aa.autoCalculated)
141 for (AlignmentAnnotation aa : toremove)
143 orig_alig.deleteAnnotation(aa);
145 checkAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
149 static void checkAnnotationFileIO(String testname, AlignmentI al)
153 String aligfileout = FileFormat.Pfam.getWriter(al).print(
154 al.getSequencesArray(), true);
155 String anfileout = new AnnotationFile()
156 .printAnnotationsForAlignment(al);
160 + "\nAlignment annotation file was not regenerated. Null string",
165 + "\nAlignment annotation file was not regenerated. Empty string",
166 anfileout.length() > "JALVIEW_ANNOTATION".length());
168 System.out.println("Output annotation file:\n" + anfileout
171 AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
172 DataSourceType.PASTE, FileFormat.Pfam);
176 + "\nregenerated annotation file did not annotate alignment.",
177 new AnnotationFile().readAnnotationFile(al_new, anfileout,
178 DataSourceType.PASTE));
180 // test for consistency in io
181 StockholmFileTest.testAlignmentEquivalence(al, al_new, true, false,
184 } catch (Exception e)
190 + "\nCouldn't complete Annotation file roundtrip input/output/input test.");