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.assertTrue;
26 import org.testng.Assert;
27 import org.testng.annotations.DataProvider;
28 import org.testng.annotations.Test;
30 public class IdentifyFileTest
33 @Test(groups = { "Functional" }, dataProvider = "identifyFiles")
34 public void Identify(String data, String expectedFileType)
36 String protocol = AppletFormatAdapter.FILE;
37 IdentifyFile ider = new IdentifyFile();
38 String actualFiletype = ider.identify(data, protocol);
39 Assert.assertEquals(actualFiletype, expectedFileType,
40 "File identification Failed!");
43 @DataProvider(name = "identifyFiles")
44 public Object[][] IdentifyFileDP()
46 return new Object[][] {
47 { "examples/example.json", "JSON" },
48 { "examples/plantfdx.fa", "FASTA" },
49 { "examples/dna_interleaved.phy", "PHYLIP" },
50 { "examples/2GIS.pdb", "PDB" },
51 { "examples/rf00031_folded.stk", "STH" },
52 { "examples/testdata/test.rnaml", "RNAML" },
53 { "examples/testdata/test.aln", "CLUSTAL" },
54 { "examples/testdata/test.pfam", "PFAM" },
55 { "examples/testdata/test.msf", "MSF" },
56 { "examples/testdata/test.pir", "PIR" },
57 { "examples/testdata/test.html", "HTML" },
58 { "examples/testdata/test.pileup", "PileUp" },
59 { "examples/testdata/test.blc", "BLC" },
60 { "examples/exampleFeatures.txt", IdentifyFile.FeaturesFile },
61 { "examples/testdata/simplegff3.gff", IdentifyFile.FeaturesFile },
62 { "examples/testdata/exampleFeaturesMixed.gff",
63 IdentifyFile.FeaturesFile },
64 { "examples/testdata/test.jvp", "Jalview" },
66 "examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316",
69 // { "examples/testdata/test.amsa", "AMSA" },
70 // { "examples/test.jnet", "JnetFile" },
74 @Test(groups = "Functional")
75 public void testLooksLikeFeatureData()
77 IdentifyFile id = new IdentifyFile();
78 assertFalse(id.looksLikeFeatureData(null));
79 assertFalse(id.looksLikeFeatureData(""));
81 assertFalse(id.looksLikeFeatureData("1 \t 2 \t 3 \t 4 \t 5"));
84 .looksLikeFeatureData("Seq1\tlocal\tHelix\t2456\t2462\tss"));
86 assertTrue(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t2462\tss"));
87 // non-numeric start column:
88 assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t.\t2462\tss"));
89 // non-numeric start column:
90 assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t.\tss"));