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.FormatAdapter;
32 import jalview.io.StockholmFileTest;
33 import jalview.ws.jws2.AADisorderClient;
34 import jalview.ws.jws2.Jws2Discoverer;
35 import jalview.ws.jws2.jabaws2.Jws2Instance;
37 import java.util.ArrayList;
38 import java.util.List;
40 import org.testng.Assert;
41 import org.testng.annotations.AfterClass;
42 import org.testng.annotations.BeforeClass;
43 import org.testng.annotations.Test;
45 @Test(groups = { "External" })
46 public class DisorderAnnotExportImport
49 @BeforeClass(alwaysRun = true)
50 public void setUpJvOptionPane()
52 JvOptionPane.setInteractiveMode(false);
53 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
56 public static String testseqs = "examples/uniref50.fa";
58 public static Jws2Discoverer disc;
60 public static List<Jws2Instance> iupreds;
62 jalview.ws.jws2.AADisorderClient disorderClient;
64 public static jalview.gui.AlignFrame af = null;
66 @BeforeClass(inheritGroups = true)
67 public static void setUpBeforeClass() throws Exception
69 Cache.loadProperties("test/jalview/io/testProps.jvprops");
71 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
72 iupreds = new ArrayList<Jws2Instance>();
73 for (Jws2Instance svc : disc.getServices())
75 if (svc.getServiceTypeURI().toLowerCase().contains("iupredws"))
80 assertTrue("Couldn't discover any IUPred services to use to test.",
82 jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
83 af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
84 assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
87 @AfterClass(alwaysRun = true)
88 public static void tearDownAfterClass() throws Exception
99 * test for patches to JAL-1294
102 public void testDisorderAnnotExport()
104 disorderClient = new AADisorderClient(iupreds.get(0), af, null, null);
105 af.getViewport().getCalcManager().startWorker(disorderClient);
111 } catch (InterruptedException x)
115 } while (af.getViewport().getCalcManager().isWorking());
116 AlignmentI orig_alig = af.getViewport().getAlignment();
117 // NOTE: Consensus annotation row cannot be exported and reimported
118 // faithfully - so we remove them
119 List<AlignmentAnnotation> toremove = new ArrayList<AlignmentAnnotation>();
120 for (AlignmentAnnotation aa : orig_alig.getAlignmentAnnotation())
122 if (aa.autoCalculated)
127 for (AlignmentAnnotation aa : toremove)
129 orig_alig.deleteAnnotation(aa);
131 checkAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
135 static void checkAnnotationFileIO(String testname, AlignmentI al)
139 String aligfileout = new FormatAdapter().formatSequences("PFAM",
140 al.getSequencesArray());
141 String anfileout = new AnnotationFile()
142 .printAnnotationsForAlignment(al);
146 + "\nAlignment annotation file was not regenerated. Null string",
151 + "\nAlignment annotation file was not regenerated. Empty string",
152 anfileout.length() > "JALVIEW_ANNOTATION".length());
154 System.out.println("Output annotation file:\n" + anfileout
157 AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
158 FormatAdapter.PASTE, "PFAM");
162 + "\nregenerated annotation file did not annotate alignment.",
163 new AnnotationFile().readAnnotationFile(al_new, anfileout,
164 FormatAdapter.PASTE));
166 // test for consistency in io
167 StockholmFileTest.testAlignmentEquivalence(al, al_new, true);
169 } catch (Exception e)
175 + "\nCouldn't complete Annotation file roundtrip input/output/input test.");