1 package jalview.ws.jabaws;
3 import static org.junit.Assert.*;
5 import java.util.ArrayList;
8 import jalview.datamodel.AlignmentAnnotation;
9 import jalview.datamodel.AlignmentI;
10 import jalview.io.AnnotationFile;
11 import jalview.io.FormatAdapter;
12 import jalview.io.StockholmFileTest;
13 import jalview.ws.jws2.AADisorderClient;
14 import jalview.ws.jws2.Jws2Discoverer;
15 import jalview.ws.jws2.jabaws2.Jws2Instance;
17 import org.junit.AfterClass;
18 import org.junit.BeforeClass;
19 import org.junit.Test;
21 public class DisorderAnnotExportImport
23 public static String testseqs = "examples/uniref50.fa";
25 public static Jws2Discoverer disc;
27 public static List<Jws2Instance> iupreds;
29 jalview.ws.jws2.AADisorderClient disorderClient;
31 public static jalview.gui.AlignFrame af = null;
34 public static void setUpBeforeClass() throws Exception
37 jalview.bin.Cache.initLogger();
38 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
39 iupreds = new ArrayList<Jws2Instance>();
40 for (Jws2Instance svc : disc.getServices())
42 if (svc.getServiceTypeURI().toLowerCase().contains("iupredws"))
47 assertTrue("Couldn't discover any IUPred services to use to test.",
49 jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
50 af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
51 assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
55 public static void tearDownAfterClass() throws Exception
65 * test for patches to JAL-1294
68 public void testDisorderAnnotExport()
70 disorderClient = new AADisorderClient(iupreds.get(0), af, null, null);
71 af.getViewport().getCalcManager().startWorker(disorderClient);
77 } catch (InterruptedException x)
81 } while (af.getViewport().getCalcManager().isWorking());
82 AlignmentI orig_alig = af.getViewport().getAlignment();
83 // NOTE: Consensus annotation row cannot be exported and reimported faithfully - so we remove them
84 List<AlignmentAnnotation> toremove = new ArrayList<AlignmentAnnotation>();
85 for (AlignmentAnnotation aa:orig_alig.getAlignmentAnnotation())
87 if (aa.autoCalculated)
92 for (AlignmentAnnotation aa:toremove)
94 orig_alig.deleteAnnotation(aa);
96 testAnnotationFileIO("Testing IUPred Annotation IO", orig_alig);
100 public static void testAnnotationFileIO(String testname, AlignmentI al)
104 String aligfileout = new FormatAdapter().formatSequences("PFAM",
105 al.getSequencesArray());
106 String anfileout = new AnnotationFile().printAnnotations(
107 al.getAlignmentAnnotation(), al.getGroups(),
112 + "\nAlignment annotation file was not regenerated. Null string",
117 + "\nAlignment annotation file was not regenerated. Empty string",
118 anfileout.length() > "JALVIEW_ANNOTATION".length());
120 System.out.println("Output annotation file:\n" + anfileout
123 AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
124 FormatAdapter.PASTE, "PFAM");
128 + "\nregenerated annotation file did not annotate alignment.",
129 new AnnotationFile().readAnnotationFile(al_new, anfileout,
130 FormatAdapter.PASTE));
132 // test for consistency in io
133 StockholmFileTest.testAlignmentEquivalence(al, al_new);
135 } catch (Exception e)
141 + "\nCouldn't complete Annotation file roundtrip input/output/input test.");