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.datamodel.AlignmentAnnotation;
27 import jalview.datamodel.AlignmentI;
28 import jalview.io.AnnotationFile;
29 import jalview.io.FormatAdapter;
30 import jalview.io.StockholmFileTest;
31 import jalview.ws.jws2.AADisorderClient;
32 import jalview.ws.jws2.Jws2Discoverer;
33 import jalview.ws.jws2.jabaws2.Jws2Instance;
35 import java.util.ArrayList;
36 import java.util.List;
38 import org.testng.Assert;
39 import org.testng.annotations.AfterClass;
40 import org.testng.annotations.BeforeClass;
41 import org.testng.annotations.Test;
43 public class DisorderAnnotExportImport
45 public static String testseqs = "examples/uniref50.fa";
47 public static Jws2Discoverer disc;
49 public static List<Jws2Instance> iupreds;
51 jalview.ws.jws2.AADisorderClient disorderClient;
53 public static jalview.gui.AlignFrame af = null;
55 @BeforeClass(alwaysRun = true)
56 public static void setUpBeforeClass() throws Exception
59 jalview.bin.Cache.initLogger();
60 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
61 iupreds = new ArrayList<Jws2Instance>();
62 for (Jws2Instance svc : disc.getServices())
64 if (svc.getServiceTypeURI().toLowerCase().contains("iupredws"))
69 assertTrue("Couldn't discover any IUPred services to use to test.",
71 jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
72 af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
73 assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
77 public static void tearDownAfterClass() throws Exception
87 * test for patches to JAL-1294
89 @Test(groups ={ "Functional" })
90 public void testDisorderAnnotExport()
92 disorderClient = new AADisorderClient(iupreds.get(0), af, null, null);
93 af.getViewport().getCalcManager().startWorker(disorderClient);
99 } catch (InterruptedException x)
103 } while (af.getViewport().getCalcManager().isWorking());
104 AlignmentI orig_alig = af.getViewport().getAlignment();
105 // NOTE: Consensus annotation row cannot be exported and reimported
106 // faithfully - so we remove them
107 List<AlignmentAnnotation> toremove = new ArrayList<AlignmentAnnotation>();
108 for (AlignmentAnnotation aa : orig_alig.getAlignmentAnnotation())
110 if (aa.autoCalculated)
115 for (AlignmentAnnotation aa : toremove)
117 orig_alig.deleteAnnotation(aa);
119 testAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
123 public static void testAnnotationFileIO(String testname, AlignmentI al)
127 String aligfileout = new FormatAdapter().formatSequences("PFAM",
128 al.getSequencesArray());
129 String anfileout = new AnnotationFile()
130 .printAnnotationsForAlignment(al);
134 + "\nAlignment annotation file was not regenerated. Null string",
139 + "\nAlignment annotation file was not regenerated. Empty string",
140 anfileout.length() > "JALVIEW_ANNOTATION".length());
142 System.out.println("Output annotation file:\n" + anfileout
145 AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
146 FormatAdapter.PASTE, "PFAM");
150 + "\nregenerated annotation file did not annotate alignment.",
151 new AnnotationFile().readAnnotationFile(al_new, anfileout,
152 FormatAdapter.PASTE));
154 // test for consistency in io
155 StockholmFileTest.testAlignmentEquivalence(al, al_new, true);
157 } catch (Exception e)
163 + "\nCouldn't complete Annotation file roundtrip input/output/input test.");