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.
21 package jalview.ext.jmol;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.bin.Cache;
27 import jalview.datamodel.Alignment;
28 import jalview.datamodel.AlignmentI;
29 import jalview.datamodel.SequenceI;
30 import jalview.gui.AlignFrame;
31 import jalview.io.AppletFormatAdapter;
32 import jalview.io.FileLoader;
34 import java.util.Vector;
36 import org.testng.annotations.BeforeMethod;
37 import org.testng.annotations.Test;
39 import MCview.PDBfile;
45 public class PDBFileWithJmolTest
47 String[] testFile = new String[]
48 { "./examples/1GAQ.txt", "./test/jalview/ext/jmol/1QCF.pdb" }; // ,
50 // "./examples/DNMT1_MOUSE.pdb"
56 Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
57 Boolean.TRUE.toString());
58 Cache.applicationProperties.setProperty("ADD_SS_ANN",
59 Boolean.TRUE.toString());
62 @Test(groups ={ "Functional" })
63 public void testAlignmentLoader() throws Exception
65 for (String f : testFile)
67 FileLoader fl = new jalview.io.FileLoader(false);
69 .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE);
70 validateSecStrRows(af.getViewport().getAlignment());
74 @Test(groups ={ "Functional" })
75 public void testFileParser() throws Exception
77 for (String pdbStr : testFile)
79 PDBfile mctest = new PDBfile(false, false, false, pdbStr,
80 AppletFormatAdapter.FILE);
81 PDBFileWithJmol jtest = new PDBFileWithJmol(pdbStr,
82 jalview.io.AppletFormatAdapter.FILE);
83 Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs();
86 "No sequences extracted from testfile\n"
87 + (jtest.hasWarningMessage() ? jtest.getWarningMessage()
88 : "(No warnings raised)"), seqs != null
90 for (SequenceI sq : seqs)
92 assertEquals("JMol didn't process " + pdbStr
93 + " to the same sequence as MCView",
94 sq.getSequenceAsString(), mcseqs.remove(0)
95 .getSequenceAsString());
96 AlignmentI al = new Alignment(new SequenceI[]
98 validateSecStrRows(al);
104 private void validateSecStrRows(AlignmentI al)
106 if (!al.isNucleotide())
108 for (SequenceI asq : al.getSequences())
111 boolean hasDs = false;
112 while (sq.getDatasetSequence() != null
113 && sq.getAnnotation() == null)
115 sq = sq.getDatasetSequence();
118 checkFirstAAIsAssoc(sq);
121 // also verify if alignment sequence has annotation on it
122 // that is correctly mapped
123 checkFirstAAIsAssoc(asq);
129 private void checkFirstAAIsAssoc(SequenceI sq)
131 assertTrue("No secondary structure assigned for protein sequence.",
132 sq.getAnnotation() != null && sq.getAnnotation().length >= 1
133 && sq.getAnnotation()[0].hasIcons);
135 "Secondary structure not associated for sequence "
136 + sq.getName(), sq.getAnnotation()[0].sequenceRef == sq);