X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FIdentifyFileTest.java;h=c00cf069e9e1015d29ba7b556d2a6e12128ceacc;hb=37de9310bec3501cbc6381e0c3dcb282fcaad812;hp=85410d13af886332fa060ea07bfcc207f9011dca;hpb=52288466dd1e71946a06fd1e6ea15fa8e652c693;p=jalview.git diff --git a/test/jalview/io/IdentifyFileTest.java b/test/jalview/io/IdentifyFileTest.java index 85410d1..c00cf06 100644 --- a/test/jalview/io/IdentifyFileTest.java +++ b/test/jalview/io/IdentifyFileTest.java @@ -1,5 +1,29 @@ +/* + * 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.assertTrue; + import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -8,15 +32,47 @@ public class IdentifyFileTest { @Test(groups = { "Functional" }, dataProvider = "identifyFiles") - public void Identify(String data, String expectedFileType) + public void testIdentify(String data, String expectedFileType) { String protocol = AppletFormatAdapter.FILE; IdentifyFile ider = new IdentifyFile(); - String actualFiletype = ider.Identify(data, protocol); + String actualFiletype = ider.identify(data, protocol); Assert.assertEquals(actualFiletype, expectedFileType, "File identification Failed!"); } + /** + * Additional tests for Jalview features file + */ + @Test(groups = "Functional") + public void testIdentify_featureFile() + { + IdentifyFile ider = new IdentifyFile(); + + /* + * Jalview format with features only, no feature colours + */ + String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n" + + "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n"; + assertEquals(IdentifyFile.FeaturesFile, + ider.identify(data, AppletFormatAdapter.PASTE)); + + /* + * Jalview feature colour followed by GFF format feature data + */ + data = "METAL\tcc9900\n" + "GFF\n" + + "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n"; + assertEquals(IdentifyFile.FeaturesFile, + ider.identify(data, AppletFormatAdapter.PASTE)); + + /* + * Feature with '<' in the name (JAL-2098) + */ + data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n"; + assertEquals(IdentifyFile.FeaturesFile, + ider.identify(data, AppletFormatAdapter.PASTE)); + } + @DataProvider(name = "identifyFiles") public Object[][] IdentifyFileDP() { @@ -34,8 +90,10 @@ public class IdentifyFileTest { "examples/testdata/test.html", "HTML" }, { "examples/testdata/test.pileup", "PileUp" }, { "examples/testdata/test.blc", "BLC" }, - { "examples/testdata/simplegff3.gff", "GFF v2 or v3" }, + { "examples/exampleFeatures.txt", IdentifyFile.FeaturesFile }, + { "examples/testdata/simpleGff3.gff", IdentifyFile.FeaturesFile }, { "examples/testdata/test.jvp", "Jalview" }, + { "examples/testdata/test.cif", "mmCIF" }, { "examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316", "FASTA" }, @@ -45,4 +103,22 @@ public class IdentifyFileTest }; } + @Test(groups = "Functional") + public void testLooksLikeFeatureData() + { + IdentifyFile id = new IdentifyFile(); + assertFalse(id.looksLikeFeatureData(null)); + assertFalse(id.looksLikeFeatureData("")); + // too few columns: + assertFalse(id.looksLikeFeatureData("1 \t 2 \t 3 \t 4 \t 5")); + // GFF format: + assertTrue(id + .looksLikeFeatureData("Seq1\tlocal\tHelix\t2456\t2462\tss")); + // Jalview format: + assertTrue(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t2462\tss")); + // non-numeric start column: + assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t.\t2462\tss")); + // non-numeric start column: + assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t.\tss")); + } }