X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FGff3tests.java;h=b78a0049a6d072ec8d7306126f9037c14727f135;hb=63bb86fb2312c426063e8cd79de4685c05c4bc35;hp=8c4a40dd6883f3e9f1475e97bbcbc566c219b58d;hpb=147dc97563bc25232fdb45a2fe2c149332a4faf7;p=jalview.git diff --git a/test/jalview/io/Gff3tests.java b/test/jalview/io/Gff3tests.java index 8c4a40d..b78a004 100644 --- a/test/jalview/io/Gff3tests.java +++ b/test/jalview/io/Gff3tests.java @@ -1,5 +1,31 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.io; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertNotNull; +import static org.testng.AssertJUnit.assertNull; +import static org.testng.AssertJUnit.assertTrue; + import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceDummy; @@ -8,8 +34,7 @@ import jalview.gui.AlignFrame; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; +import org.testng.annotations.Test; public class Gff3tests { @@ -18,7 +43,7 @@ public class Gff3tests exonerateOutput = "examples/testdata/exonerateoutput.gff", simpleGff3file = "examples/testdata/simpleGff3.gff"; - @Test + @Test(groups = { "Functional" }) public void testExonerateImport() { // exonerate does not tag sequences after features, so we have a more @@ -29,83 +54,115 @@ public class Gff3tests AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs, FormatAdapter.FILE); - Assert.assertEquals("Unexpected number of DNA protein associations", 0, - af.getViewport().getAlignment().getCodonFrames().size()); + assertEquals("Unexpected number of DNA protein associations", 0, af + .getViewport().getAlignment().getCodonFrames().size()); af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null); - Assert.assertNotEquals("Expected at least one DNA protein association", - 0, af.getViewport().getAlignment().getDataset() - .getCodonFrames().size()); + assertTrue("Expected at least one DNA protein association", af + .getViewport().getAlignment().getDataset().getCodonFrames() + .size() > 0); + + } + @Test(groups = { "Functional" }) + public void simpleGff3FileIdentify() + { + assertEquals("Didn't recognise file correctly.", IdentifyFile.GFF3File, + new IdentifyFile().Identify(simpleGff3file, FormatAdapter.FILE)); } - @Test - public void simpleGff3() throws IOException + @Test(groups = { "Functional" }) + public void simpleGff3FileClass() throws IOException { - AlignmentI dataset = new Alignment(new SequenceI[] - {}); + AlignmentI dataset = new Alignment(new SequenceI[] {}); FeaturesFile ffile = new FeaturesFile(simpleGff3file, FormatAdapter.FILE); boolean parseResult = ffile.parse(dataset, null, null, false, false); - Assert.assertTrue("return result should be true", parseResult); + assertTrue("return result should be true", parseResult); checkDatasetfromSimpleGff3(dataset); } - @Test + @Test(groups = { "Functional" }) + public void simpleGff3FileLoader() throws IOException + { + AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded( + simpleGff3file, FormatAdapter.FILE); + assertTrue( + "Didn't read the alignment into an alignframe from Gff3 File", + af != null); + checkDatasetfromSimpleGff3(af.getViewport().getAlignment().getDataset()); + } + + @Test(groups = { "Functional" }) public void simpleGff3RelaxedIdMatching() throws IOException { - AlignmentI dataset = new Alignment(new SequenceI[] - {}); + AlignmentI dataset = new Alignment(new SequenceI[] {}); FeaturesFile ffile = new FeaturesFile(simpleGff3file, FormatAdapter.FILE); boolean parseResult = ffile.parse(dataset, null, null, false, true); - Assert.assertTrue("return result (relaxedID matching) should be true", + assertTrue("return result (relaxedID matching) should be true", parseResult); checkDatasetfromSimpleGff3(dataset); } + @Test(groups = { "Functional" }) + public void readGff3File() throws IOException + { + Gff3File gff3reader = new Gff3File(simpleGff3file, FormatAdapter.FILE); + Alignment dataset = new Alignment(gff3reader.getSeqsAsArray()); + gff3reader.addProperties(dataset); + checkDatasetfromSimpleGff3(dataset); + + } + private void checkDatasetfromSimpleGff3(AlignmentI dataset) { - Assert.assertEquals("no sequences extracted from GFF3 file", 2, + assertEquals("no sequences extracted from GFF3 file", 2, dataset.getHeight()); SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset .findName("seq2"); - Assert.assertNotNull(seq1); - Assert.assertNotNull(seq2); - Assert.assertFalse( + assertNotNull(seq1); + assertNotNull(seq2); + assertFalse( "Failed to replace dummy seq1 with real sequence", seq1 instanceof SequenceDummy && ((SequenceDummy) seq1).isDummy()); - Assert.assertFalse( + assertFalse( "Failed to replace dummy seq2 with real sequence", seq2 instanceof SequenceDummy && ((SequenceDummy) seq2).isDummy()); String placeholderseq = new SequenceDummy("foo").getSequenceAsString(); - Assert.assertFalse("dummy replacement buggy for seq1", + assertFalse("dummy replacement buggy for seq1", placeholderseq.equals(seq1.getSequenceAsString())); - Assert.assertNotEquals("dummy replacement buggy for seq2", + assertFalse("dummy replacement buggy for seq2", placeholderseq.equals(seq2.getSequenceAsString())); - Assert.assertNotNull("No features added to seq1", - seq1.getSequenceFeatures());// != null); - Assert.assertEquals("Wrong number of features", 3, + assertNotNull("No features added to seq1", seq1.getSequenceFeatures());// != + // null); + assertEquals("Wrong number of features", 3, seq1.getSequenceFeatures().length); - Assert.assertNull(seq2.getSequenceFeatures()); - Assert.assertEquals("Wrong number of features", 0, seq2 - .getSequenceFeatures() == null ? 0 - : seq2.getSequenceFeatures().length); + assertNull(seq2.getSequenceFeatures()); + assertEquals( + "Wrong number of features", + 0, + seq2.getSequenceFeatures() == null ? 0 : seq2 + .getSequenceFeatures().length); + assertTrue( + "Expected at least one CDNA/Protein mapping for seq1", + dataset.getCodonFrame(seq1) != null + && dataset.getCodonFrame(seq1).size() > 0); } - // @Test + // @Test(groups ={ "Functional" }) // public final void testPrintGFFFormatSequenceIArrayMapOfStringObject() // { // fail("Not yet implemented"); // } // - // @Test + // @Test(groups ={ "Functional" }) // public final void testAlignFileBooleanStringString() // { // fail("Not yet implemented");