X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FJalview2xmlTests.java;h=6dfa7291ae7756865c9d7c64d9b98ba960b625bf;hb=7ab5d6b0ba5fec1ea4a4239e79c476d841622485;hp=dc192344d467b59af43910b00c885d97ff59dad8;hpb=1889827c44c51f6353fe8619e5d44b421158af23;p=jalview.git diff --git a/test/jalview/io/Jalview2xmlTests.java b/test/jalview/io/Jalview2xmlTests.java index dc19234..6dfa729 100644 --- a/test/jalview/io/Jalview2xmlTests.java +++ b/test/jalview/io/Jalview2xmlTests.java @@ -44,7 +44,8 @@ public class Jalview2xmlTests @BeforeClass public static void setUpBeforeClass() throws Exception { - jalview.bin.Jalview.main(new String[] {"-props","test/src/jalview/io/testProps.jvprops"}); + jalview.bin.Jalview.main(new String[] + { "-props", "test/src/jalview/io/testProps.jvprops" }); } /** @@ -54,12 +55,14 @@ public class Jalview2xmlTests public static void tearDownAfterClass() throws Exception { jalview.gui.Desktop.instance.closeAll_actionPerformed(null); - + } + public int countDsAnn(jalview.viewmodel.AlignmentViewport avp) { - int numdsann=0; - for (SequenceI sq: avp.getAlignment().getDataset().getSequences()) { + int numdsann = 0; + for (SequenceI sq : avp.getAlignment().getDataset().getSequences()) + { if (sq.getAnnotation() != null) { for (AlignmentAnnotation dssa : sq.getAnnotation()) @@ -73,35 +76,52 @@ public class Jalview2xmlTests } return numdsann; } + @Test public void testRNAStructureRecovery() throws Exception { String inFile = "examples/RF00031_folded.stk"; - 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); - int olddsann=countDsAnn(af.getViewport()); - assertTrue("Didn't find any dataset annotations",olddsann>0); + 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); + int olddsann = countDsAnn(af.getViewport()); + assertTrue("Didn't find any dataset annotations", olddsann > 0); af.rnahelicesColour_actionPerformed(null); - assertTrue("Couldn't apply RNA helices colourscheme",af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour); - assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview")); + assertTrue( + "Couldn't apply RNA helices colourscheme", + af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour); + 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); - 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); + 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); + 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() @@ -113,26 +133,40 @@ public class Jalview2xmlTests jalview.schemes.ColourSchemeProperty.getColourName(af .getViewport().getGlobalColourScheme())) != null); - assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview")); + 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."); + 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); + 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); @@ -144,56 +178,71 @@ public class Jalview2xmlTests 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")); + 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); - + 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); + + 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()); + 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