From: Jim Procter Date: Thu, 1 May 2014 16:05:20 +0000 (+0100) Subject: JAL-1397 (probably buggy) test for recovery of background and per group alignment... X-Git-Tag: Jalview_2_9~190^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=be1777c33711ef0c9f1014ad6d47c7c2021b2526;p=jalview.git JAL-1397 (probably buggy) test for recovery of background and per group alignment annotation shading --- diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index d553629..e294616 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -2,8 +2,11 @@ package jalview.io; import static org.junit.Assert.*; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; +import jalview.schemes.AnnotationColourGradient; +import jalview.schemes.ColourSchemeI; import java.io.File; @@ -97,4 +100,70 @@ public class Jalview2xmlTests assertTrue("Didn't set T-coffee colourscheme for imported project.",af.getViewport().getGlobalColourScheme().getClass().equals(jalview.schemes.TCoffeeColourScheme.class)); System.out.println("T-Coffee score shading successfully recovered from project."); } + @Test + public void testColourByAnnotScores() throws Exception + { + String inFile = "examples/uniref50.fa",inAnnot="examples/testdata/uniref50_iupred.jva"; + String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath(); + AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE); + assertTrue("Didn't read input file "+inFile, af!=null); + af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null,null); + AlignmentAnnotation[] aa = af.getViewport().getAlignment().getSequenceAt(0).getAnnotation("IUPredWS (Short)"); + assertTrue("Didn't find any IUPred annotation to use to shade alignment.",aa!=null && aa.length>0); + AnnotationColourGradient cs = new jalview.schemes.AnnotationColourGradient(aa[0], null, AnnotationColourGradient.ABOVE_THRESHOLD); + AnnotationColourGradient gcs = new jalview.schemes.AnnotationColourGradient(aa[0], null, AnnotationColourGradient.BELOW_THRESHOLD); + cs.setSeqAssociated(true); + gcs.setSeqAssociated(true); + af.changeColour(cs); + SequenceGroup sg = new SequenceGroup(); + sg.setStartRes(57); + sg.setEndRes(92); + sg.cs = gcs; + af.getViewport().getAlignment().addGroup(sg); + sg.addSequence(af.getViewport().getAlignment().getSequenceAt(1), false); + sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true); + af.alignPanel.alignmentChanged(); + assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview")); + af.closeMenuItem_actionPerformed(true); + af=null; + af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE); + assertTrue("Failed to import new project", af!=null); + + // check for group and alignment colourschemes + + ColourSchemeI _rcs=af.getViewport().getGlobalColourScheme(); + ColourSchemeI _rgcs=af.getViewport().getAlignment().getGroups().get(0).cs; + assertTrue("Didn't recover global colourscheme",_rcs!=null); + assertTrue("Didn't recover annotation colour global scheme",_rcs instanceof AnnotationColourGradient); + AnnotationColourGradient __rcs = (AnnotationColourGradient) _rcs; + assertTrue("Annotation colourscheme wasn't sequence associated",__rcs.isSeqAssociated()); + + + boolean diffseqcols=false,diffgseqcols=false; + SequenceI[] sqs=af.getViewport().getAlignment().getSequencesArray(); + for (int p=0,pSize=af.getViewport().getAlignment().getWidth();p