3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertFalse;
5 import static org.testng.AssertJUnit.assertNotNull;
6 import static org.testng.AssertJUnit.assertNull;
7 import static org.testng.AssertJUnit.assertTrue;
9 import jalview.datamodel.Alignment;
10 import jalview.datamodel.AlignmentI;
11 import jalview.datamodel.SequenceDummy;
12 import jalview.datamodel.SequenceI;
13 import jalview.gui.AlignFrame;
15 import java.io.IOException;
17 import org.testng.annotations.Test;
19 public class Gff3tests
22 private static String exonerateSeqs = "examples/testdata/exonerateseqs.fa",
23 exonerateOutput = "examples/testdata/exonerateoutput.gff",
24 simpleGff3file = "examples/testdata/simpleGff3.gff";
26 @Test(groups ={ "Functional" })
27 public void testExonerateImport()
29 // exonerate does not tag sequences after features, so we have a more
30 // conventional annotation import test here
32 FileLoader loader = new FileLoader(false);
34 AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs,
37 assertEquals("Unexpected number of DNA protein associations", 0,
38 af.getViewport().getAlignment().getCodonFrames().size());
40 af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null);
42 assertTrue("Expected at least one DNA protein association", af
43 .getViewport().getAlignment().getDataset().getCodonFrames()
48 @Test(groups ={ "Functional" })
49 public void simpleGff3FileIdentify()
51 assertEquals("Didn't recognise file correctly.",
52 IdentifyFile.GFF3File,
53 new IdentifyFile().Identify(simpleGff3file, FormatAdapter.FILE));
56 @Test(groups ={ "Functional" })
57 public void simpleGff3FileClass() throws IOException
59 AlignmentI dataset = new Alignment(new SequenceI[]
61 FeaturesFile ffile = new FeaturesFile(simpleGff3file,
64 boolean parseResult = ffile.parse(dataset, null, null, false, false);
65 assertTrue("return result should be true", parseResult);
66 checkDatasetfromSimpleGff3(dataset);
69 @Test(groups ={ "Functional" })
70 public void simpleGff3FileLoader() throws IOException
72 AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
73 simpleGff3file, FormatAdapter.FILE);
75 "Didn't read the alignment into an alignframe from Gff3 File",
77 checkDatasetfromSimpleGff3(af.getViewport().getAlignment().getDataset());
80 @Test(groups ={ "Functional" })
81 public void simpleGff3RelaxedIdMatching() throws IOException
83 AlignmentI dataset = new Alignment(new SequenceI[]
85 FeaturesFile ffile = new FeaturesFile(simpleGff3file,
88 boolean parseResult = ffile.parse(dataset, null, null, false, true);
89 assertTrue("return result (relaxedID matching) should be true",
91 checkDatasetfromSimpleGff3(dataset);
94 @Test(groups ={ "Functional" })
95 public void readGff3File() throws IOException
97 Gff3File gff3reader = new Gff3File(simpleGff3file, FormatAdapter.FILE);
98 Alignment dataset = new Alignment(gff3reader.getSeqsAsArray());
99 gff3reader.addProperties(dataset);
100 checkDatasetfromSimpleGff3(dataset);
104 private void checkDatasetfromSimpleGff3(AlignmentI dataset)
106 assertEquals("no sequences extracted from GFF3 file", 2,
107 dataset.getHeight());
109 SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset
114 "Failed to replace dummy seq1 with real sequence",
115 seq1 instanceof SequenceDummy
116 && ((SequenceDummy) seq1).isDummy());
118 "Failed to replace dummy seq2 with real sequence",
119 seq2 instanceof SequenceDummy
120 && ((SequenceDummy) seq2).isDummy());
121 String placeholderseq = new SequenceDummy("foo").getSequenceAsString();
122 assertFalse("dummy replacement buggy for seq1",
123 placeholderseq.equals(seq1.getSequenceAsString()));
124 assertFalse("dummy replacement buggy for seq2",
125 placeholderseq.equals(seq2.getSequenceAsString()));
126 assertNotNull("No features added to seq1",
127 seq1.getSequenceFeatures());// != null);
128 assertEquals("Wrong number of features", 3,
129 seq1.getSequenceFeatures().length);
130 assertNull(seq2.getSequenceFeatures());
132 "Wrong number of features",
135 .getSequenceFeatures() == null ? 0
136 : seq2.getSequenceFeatures().length);
138 "Expected at least one CDNA/Protein mapping for seq1",
139 dataset.getCodonFrame(seq1) != null
140 && dataset.getCodonFrame(seq1).size() > 0);
143 // @Test(groups ={ "Functional" })
144 // public final void testPrintGFFFormatSequenceIArrayMapOfStringObject()
146 // fail("Not yet implemented");
149 // @Test(groups ={ "Functional" })
150 // public final void testAlignFileBooleanStringString()
152 // fail("Not yet implemented");