3 import jalview.datamodel.Alignment;
4 import jalview.datamodel.AlignmentI;
5 import jalview.datamodel.SequenceDummy;
6 import jalview.datamodel.SequenceI;
7 import jalview.gui.AlignFrame;
9 import java.io.IOException;
11 import org.junit.Assert;
12 import org.junit.Test;
14 public class Gff3tests
17 private static String exonerateSeqs = "examples/testdata/exonerateseqs.fa",
18 exonerateOutput = "examples/testdata/exonerateoutput.gff",
19 simpleGff3file = "examples/testdata/simpleGff3.gff";
22 public void testExonerateImport()
24 // exonerate does not tag sequences after features, so we have a more
25 // conventional annotation import test here
27 FileLoader loader = new FileLoader(false);
29 AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs,
32 Assert.assertEquals("Unexpected number of DNA protein associations", 0,
33 af.getViewport().getAlignment().getCodonFrames().size());
35 af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null);
37 Assert.assertNotEquals("Expected at least one DNA protein association",
38 0, af.getViewport().getAlignment().getDataset()
39 .getCodonFrames().size());
44 public void simpleGff3FileIdentify()
46 Assert.assertEquals("Didn't recognise file correctly.",
47 IdentifyFile.GFF3File,
48 new IdentifyFile().Identify(simpleGff3file, FormatAdapter.FILE));
52 public void simpleGff3FileClass() throws IOException
54 AlignmentI dataset = new Alignment(new SequenceI[]
56 FeaturesFile ffile = new FeaturesFile(simpleGff3file,
59 boolean parseResult = ffile.parse(dataset, null, null, false, false);
60 Assert.assertTrue("return result should be true", parseResult);
61 checkDatasetfromSimpleGff3(dataset);
65 public void simpleGff3FileLoader() throws IOException
67 AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
68 simpleGff3file, null);
70 "Didn't read the alignment into an alignframe from Gff3 File",
72 checkDatasetfromSimpleGff3(af.getViewport().getAlignment().getDataset());
76 public void simpleGff3RelaxedIdMatching() throws IOException
78 AlignmentI dataset = new Alignment(new SequenceI[]
80 FeaturesFile ffile = new FeaturesFile(simpleGff3file,
83 boolean parseResult = ffile.parse(dataset, null, null, false, true);
84 Assert.assertTrue("return result (relaxedID matching) should be true",
86 checkDatasetfromSimpleGff3(dataset);
90 public void readGff3File() throws IOException
92 Gff3File gff3reader = new Gff3File(simpleGff3file, FormatAdapter.FILE);
93 Alignment dataset = new Alignment(gff3reader.getSeqsAsArray());
94 gff3reader.addProperties(dataset);
95 checkDatasetfromSimpleGff3(dataset);
99 private void checkDatasetfromSimpleGff3(AlignmentI dataset)
101 Assert.assertEquals("no sequences extracted from GFF3 file", 2,
102 dataset.getHeight());
104 SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset
106 Assert.assertNotNull(seq1);
107 Assert.assertNotNull(seq2);
109 "Failed to replace dummy seq1 with real sequence",
110 seq1 instanceof SequenceDummy
111 && ((SequenceDummy) seq1).isDummy());
113 "Failed to replace dummy seq2 with real sequence",
114 seq2 instanceof SequenceDummy
115 && ((SequenceDummy) seq2).isDummy());
116 String placeholderseq = new SequenceDummy("foo").getSequenceAsString();
117 Assert.assertFalse("dummy replacement buggy for seq1",
118 placeholderseq.equals(seq1.getSequenceAsString()));
119 Assert.assertNotEquals("dummy replacement buggy for seq2",
120 placeholderseq.equals(seq2.getSequenceAsString()));
121 Assert.assertNotNull("No features added to seq1",
122 seq1.getSequenceFeatures());// != null);
123 Assert.assertEquals("Wrong number of features", 3,
124 seq1.getSequenceFeatures().length);
125 Assert.assertNull(seq2.getSequenceFeatures());
126 Assert.assertEquals("Wrong number of features", 0, seq2
127 .getSequenceFeatures() == null ? 0
128 : seq2.getSequenceFeatures().length);
130 "Expected at least one CDNA/Protein mapping for seq1",
131 dataset.getCodonFrame(seq1) != null
132 && dataset.getCodonFrame(seq1).size() > 0);
136 // public final void testPrintGFFFormatSequenceIArrayMapOfStringObject()
138 // fail("Not yet implemented");
142 // public final void testAlignFileBooleanStringString()
144 // fail("Not yet implemented");