2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static org.testng.AssertJUnit.assertFalse;
24 import static org.testng.AssertJUnit.assertSame;
25 import static org.testng.AssertJUnit.assertTrue;
27 import jalview.gui.JvOptionPane;
29 import org.testng.Assert;
30 import org.testng.annotations.BeforeClass;
31 import org.testng.annotations.DataProvider;
32 import org.testng.annotations.Test;
34 public class IdentifyFileTest
37 @BeforeClass(alwaysRun = true)
38 public void setUpJvOptionPane()
40 JvOptionPane.setInteractiveMode(false);
41 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
44 @Test(groups = { "Functional" }, dataProvider = "identifyFiles")
45 public void testIdentify(String data, FileFormatI expectedFileType)
46 throws FileFormatException
48 DataSourceType protocol = DataSourceType.FILE;
49 IdentifyFile ider = new IdentifyFile();
50 FileFormatI actualFiletype = ider.identify(data, protocol);
51 Assert.assertSame(actualFiletype, expectedFileType,
52 "File identification Failed!");
56 * Additional tests for Jalview features file
58 * @throws FileFormatException
60 @Test(groups = "Functional")
61 public void testIdentify_featureFile() throws FileFormatException
63 IdentifyFile ider = new IdentifyFile();
66 * Jalview format with features only, no feature colours
68 String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
69 + "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
70 assertSame(FileFormat.Features,
71 ider.identify(data, DataSourceType.PASTE));
74 * Jalview feature colour followed by GFF format feature data
76 data = "METAL\tcc9900\n" + "GFF\n"
77 + "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
78 assertSame(FileFormat.Features,
79 ider.identify(data, DataSourceType.PASTE));
82 * Feature with '<' in the name (JAL-2098)
84 data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
85 assertSame(FileFormat.Features,
86 ider.identify(data, DataSourceType.PASTE));
89 @DataProvider(name = "identifyFiles")
90 public Object[][] IdentifyFileDP()
92 return new Object[][] {
93 { "examples/example.json", FileFormat.Json },
94 { "examples/plantfdx.fa", FileFormat.Fasta },
95 { "examples/dna_interleaved.phy", FileFormat.Phylip },
96 { "examples/2GIS.pdb", FileFormat.PDB },
97 { "examples/rf00031_folded.stk", FileFormat.Stockholm },
98 { "examples/testdata/test.rnaml", FileFormat.Rnaml },
99 { "examples/testdata/test.aln", FileFormat.Clustal },
100 { "examples/testdata/test.pfam", FileFormat.Pfam },
101 { "examples/testdata/test.msf", FileFormat.MSF },
102 { "examples/testdata/test.pir", FileFormat.PIR },
103 { "examples/testdata/test.html", FileFormat.Html },
104 { "examples/testdata/test.pileup", FileFormat.Pileup },
105 { "examples/testdata/test.blc", FileFormat.BLC },
106 { "examples/exampleFeatures.txt", FileFormat.Features },
107 { "examples/testdata/simpleGff3.gff", FileFormat.Features },
108 { "examples/testdata/test.jvp", FileFormat.Jalview },
109 { "examples/testdata/test.cif", FileFormat.MMCif },
111 "examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316",
113 { "resources/scoreModel/pam250.scm", FileFormat.ScoreMatrix },
114 { "resources/scoreModel/blosum80.scm", FileFormat.ScoreMatrix }
115 // { "examples/testdata/test.amsa", "AMSA" },
116 // { "examples/test.jnet", "JnetFile" },
120 @Test(groups = "Functional")
121 public void testLooksLikeFeatureData()
123 IdentifyFile id = new IdentifyFile();
124 assertFalse(id.looksLikeFeatureData(null));
125 assertFalse(id.looksLikeFeatureData(""));
127 assertFalse(id.looksLikeFeatureData("1 \t 2 \t 3 \t 4 \t 5"));
130 .looksLikeFeatureData("Seq1\tlocal\tHelix\t2456\t2462\tss"));
132 assertTrue(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t2462\tss"));
133 // non-numeric start column:
134 assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t.\t2462\tss"));
135 // non-numeric start column:
136 assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t.\tss"));