3 import static org.junit.Assert.*;
4 import jalview.datamodel.AlignmentAnnotation;
5 import jalview.datamodel.SequenceI;
6 import jalview.gui.AlignFrame;
10 import org.junit.AfterClass;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
14 public class Jalview2xmlTests
18 * @throws java.lang.Exception
21 public static void setUpBeforeClass() throws Exception
23 jalview.bin.Jalview.main(new String[] {"-props","test/src/jalview/io/testProps.jvprops"});
27 * @throws java.lang.Exception
30 public static void tearDownAfterClass() throws Exception
32 jalview.gui.Desktop.instance.closeAll_actionPerformed(null);
35 public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
38 for (SequenceI sq: avp.getAlignment().getDataset().getSequences()) {
39 if (sq.getAnnotation() != null)
41 for (AlignmentAnnotation dssa : sq.getAnnotation())
43 if (dssa.isValidStruc())
53 public void testRNAStructureRecovery() throws Exception
55 String inFile = "examples/RF00031_folded.stk";
56 String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath();
57 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE);
58 assertTrue("Didn't read input file "+inFile, af!=null);
59 int olddsann=countDsAnn(af.getViewport());
60 assertTrue("Didn't find any dataset annotations",olddsann>0);
61 af.rnahelicesColour_actionPerformed(null);
62 assertTrue("Couldn't apply RNA helices colourscheme",af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
63 assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
64 af.closeMenuItem_actionPerformed(true);
66 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE);
67 assertTrue("Failed to import new project", af!=null);
68 int newdsann=countDsAnn(af.getViewport());
69 assertTrue("Differing numbers of dataset sequence annotation\nOriginally "+olddsann+" and now "+newdsann,olddsann==newdsann);
70 System.out.println("Read in same number of annotations as originally present ("+olddsann+")");
71 assertTrue("RNA helices colourscheme was not applied on import.",af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
74 public void testTCoffeeScores() throws Exception
76 String inFile = "examples/uniref50.fa",inAnnot="examples/uniref50.score_ascii";
77 String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath();
78 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE);
79 assertTrue("Didn't read input file "+inFile, af!=null);
80 af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null,null);
82 "Didn't set T-coffee colourscheme",
83 af.getViewport().getGlobalColourScheme().getClass()
84 .equals(jalview.schemes.TCoffeeColourScheme.class));
86 "Recognise T-Coffee score from string",
87 jalview.schemes.ColourSchemeProperty.getColour(af.getViewport()
89 jalview.schemes.ColourSchemeProperty.getColourName(af
90 .getViewport().getGlobalColourScheme())) != null);
92 assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
93 af.closeMenuItem_actionPerformed(true);
95 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE);
96 assertTrue("Failed to import new project", af!=null);
97 assertTrue("Didn't set T-coffee colourscheme for imported project.",af.getViewport().getGlobalColourScheme().getClass().equals(jalview.schemes.TCoffeeColourScheme.class));
98 System.out.println("T-Coffee score shading successfully recovered from project.");