+ af = null;
+ af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
+ FormatAdapter.FILE);
+ assertTrue("Failed to import new project", af != null);
+ int newdsann = countDsAnn(af.getViewport());
+ assertTrue(
+ "Differing numbers of dataset sequence annotation\nOriginally "
+ + olddsann + " and now " + newdsann,
+ olddsann == newdsann);
+ System.out
+ .println("Read in same number of annotations as originally present ("
+ + olddsann + ")");
+ assertTrue(
+ "RNA helices colourscheme was not applied on import.",
+ af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
+ }
+
+ @Test
+ public void testTCoffeeScores() throws Exception
+ {
+ String inFile = "examples/uniref50.fa", inAnnot = "examples/uniref50.score_ascii";
+ 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);
+ assertTrue(
+ "Didn't set T-coffee colourscheme",
+ af.getViewport().getGlobalColourScheme().getClass()
+ .equals(jalview.schemes.TCoffeeColourScheme.class));
+ assertTrue(
+ "Recognise T-Coffee score from string",
+ jalview.schemes.ColourSchemeProperty.getColour(af.getViewport()
+ .getAlignment(),
+ jalview.schemes.ColourSchemeProperty.getColourName(af
+ .getViewport().getGlobalColourScheme())) != null);
+
+ 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);
+ 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 < pSize
+ && (!diffseqcols || !diffgseqcols); p++)
+ {
+ if (_rcs.findColour(sqs[0].getCharAt(p), p, sqs[0]) != _rcs
+ .findColour(sqs[5].getCharAt(p), p, sqs[5]))
+ {
+ diffseqcols = true;
+ }
+ }
+ assertTrue("Got Different sequence colours", diffseqcols);
+ System.out
+ .println("Per sequence colourscheme (Background) successfully applied and recovered.");
+
+ assertTrue("Didn't recover group colourscheme", _rgcs != null);
+ assertTrue("Didn't recover annotation colour group colourscheme",
+ _rgcs instanceof AnnotationColourGradient);
+ __rcs = (AnnotationColourGradient) _rgcs;
+ assertTrue("Group Annotation colourscheme wasn't sequence associated",
+ __rcs.isSeqAssociated());
+
+ for (int p = 0, pSize = af.getViewport().getAlignment().getWidth(); p < pSize
+ && (!diffseqcols || !diffgseqcols); p++)
+ {
+ if (_rgcs.findColour(sqs[1].getCharAt(p), p, sqs[1]) != _rgcs
+ .findColour(sqs[2].getCharAt(p), p, sqs[2]))
+ {
+ diffgseqcols = true;
+ }
+ }
+ assertTrue("Got Different group sequence colours", diffgseqcols);
+ System.out
+ .println("Per sequence (Group) colourscheme successfully applied and recovered.");
+ }
+
+ @Test
+ public void gatherViewsHere() throws Exception
+ {
+ int origCount = Desktop.getAlignFrames() == null ? 0 : Desktop
+ .getAlignFrames().length;
+ AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
+ "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+ assertTrue("Didn't read in the example file correctly.", af != null);
+ assertTrue("Didn't gather the views in the example file.",
+ Desktop.getAlignFrames().length == 1 + origCount);
+