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.quit();
34 public int countDsAnn(jalview.viewmodel.AlignmentViewport avp)
37 for (SequenceI sq: avp.getAlignment().getDataset().getSequences()) {
38 if (sq.getAnnotation() != null)
40 for (AlignmentAnnotation dssa : sq.getAnnotation())
42 if (dssa.isValidStruc())
52 public void testRNAStructureRecovery() throws Exception
54 String inFile = "examples/RF00031_folded.stk";
55 String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath();
56 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE);
57 assertTrue("Didn't read input file "+inFile, af!=null);
58 int olddsann=countDsAnn(af.getViewport());
59 assertTrue("Didn't find any dataset annotations",olddsann>0);
60 assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
61 af.closeMenuItem_actionPerformed(true);
63 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE);
64 assertTrue("Failed to import new project", af!=null);
65 int newdsann=countDsAnn(af.getViewport());
66 assertTrue("Differing numbers of dataset sequence annotation\nOriginally "+olddsann+" and now "+newdsann,olddsann==newdsann);
67 System.out.println("Read in same number of annotations as originally present ("+olddsann+")");
70 public void testTCoffeeScores() throws Exception
72 String inFile = "examples/uniref50.fa",inAnnot="examples/uniref50.score_ascii";
73 String tfile = File.createTempFile("JalviewTest", ".jvp").getAbsolutePath();
74 AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(inFile, FormatAdapter.FILE);
75 assertTrue("Didn't read input file "+inFile, af!=null);
76 af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null,null);
78 "Didn't set T-coffee colourscheme",
79 af.getViewport().getGlobalColourScheme().getClass()
80 .equals(jalview.schemes.TCoffeeColourScheme.class));
82 "Recognise T-Coffee score from string",
83 jalview.schemes.ColourSchemeProperty.getColour(af.getViewport()
85 jalview.schemes.ColourSchemeProperty.getColourName(af
86 .getViewport().getGlobalColourScheme())) != null);
88 assertTrue("Failed to store as a project.",af.saveAlignment(tfile, "Jalview"));
89 af.closeMenuItem_actionPerformed(true);
91 af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile, FormatAdapter.FILE);
92 assertTrue("Failed to import new project", af!=null);
93 assertTrue("Didn't set T-coffee colourscheme for imported project.",af.getViewport().getGlobalColourScheme().getClass().equals(jalview.schemes.TCoffeeColourScheme.class));
94 System.out.println("T-Coffee score shading successfully recovered from project.");