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.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertTrue;
27 import org.testng.Assert;
28 import org.testng.annotations.DataProvider;
29 import org.testng.annotations.Test;
31 public class IdentifyFileTest
34 @Test(groups = { "Functional" }, dataProvider = "identifyFiles")
35 public void testIdentify(String data, String expectedFileType)
37 String protocol = AppletFormatAdapter.FILE;
38 IdentifyFile ider = new IdentifyFile();
39 String actualFiletype = ider.identify(data, protocol);
40 Assert.assertEquals(actualFiletype, expectedFileType,
41 "File identification Failed!");
45 * Additional tests for Jalview features file
47 @Test(groups = "Functional")
48 public void testIdentify_featureFile()
50 IdentifyFile ider = new IdentifyFile();
53 * Jalview format with features only, no feature colours
55 String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
56 + "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
57 assertEquals(IdentifyFile.FeaturesFile,
58 ider.identify(data, AppletFormatAdapter.PASTE));
61 * Jalview feature colour followed by GFF format feature data
63 data = "METAL\tcc9900\n" + "GFF\n"
64 + "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
65 assertEquals(IdentifyFile.FeaturesFile,
66 ider.identify(data, AppletFormatAdapter.PASTE));
69 * Feature with '<' in the name (JAL-2098)
71 data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
72 assertEquals(IdentifyFile.FeaturesFile,
73 ider.identify(data, AppletFormatAdapter.PASTE));
76 @DataProvider(name = "identifyFiles")
77 public Object[][] IdentifyFileDP()
79 return new Object[][] {
80 { "examples/example.json", "JSON" },
81 { "examples/plantfdx.fa", "FASTA" },
82 { "examples/dna_interleaved.phy", "PHYLIP" },
83 { "examples/2GIS.pdb", "PDB" },
84 { "examples/rf00031_folded.stk", "STH" },
85 { "examples/testdata/test.rnaml", "RNAML" },
86 { "examples/testdata/test.aln", "CLUSTAL" },
87 { "examples/testdata/test.pfam", "PFAM" },
88 { "examples/testdata/test.msf", "MSF" },
89 { "examples/testdata/test.pir", "PIR" },
90 { "examples/testdata/test.html", "HTML" },
91 { "examples/testdata/test.pileup", "PileUp" },
92 { "examples/testdata/test.blc", "BLC" },
93 { "examples/exampleFeatures.txt", IdentifyFile.FeaturesFile },
94 { "examples/testdata/simpleGff3.gff", IdentifyFile.FeaturesFile },
95 { "examples/testdata/test.jvp", "Jalview" },
96 { "examples/testdata/test.cif", "mmCIF" },
98 "examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316",
101 // { "examples/testdata/test.amsa", "AMSA" },
102 // { "examples/test.jnet", "JnetFile" },
106 @Test(groups = "Functional")
107 public void testLooksLikeFeatureData()
109 IdentifyFile id = new IdentifyFile();
110 assertFalse(id.looksLikeFeatureData(null));
111 assertFalse(id.looksLikeFeatureData(""));
113 assertFalse(id.looksLikeFeatureData("1 \t 2 \t 3 \t 4 \t 5"));
116 .looksLikeFeatureData("Seq1\tlocal\tHelix\t2456\t2462\tss"));
118 assertTrue(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t2462\tss"));
119 // non-numeric start column:
120 assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t.\t2462\tss"));
121 // non-numeric start column:
122 assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t.\tss"));