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;
25 import org.testng.annotations.Test;
26 import org.testng.annotations.BeforeMethod;
27 import java.util.Vector;
29 import MCview.PDBfile;
31 import jalview.bin.Cache;
32 import jalview.datamodel.Alignment;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.SequenceI;
35 import jalview.gui.AlignFrame;
36 import jalview.io.AppletFormatAdapter;
37 import jalview.io.FileLoader;
43 public class PDBFileWithJmolTest
45 String[] testFile = new String[]
46 { "./examples/1GAQ.txt", "./test/jalview/ext/jmol/1QCF.pdb" }; // ,
48 // "./examples/DNMT1_MOUSE.pdb"
54 Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
55 Boolean.TRUE.toString());
56 Cache.applicationProperties.setProperty("ADD_SS_ANN",
57 Boolean.TRUE.toString());
61 public void testAlignmentLoader() throws Exception
63 for (String f : testFile)
65 FileLoader fl = new jalview.io.FileLoader(false);
67 .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE);
68 validateSecStrRows(af.getViewport().getAlignment());
73 public void testFileParser() throws Exception
75 for (String pdbStr : testFile)
77 PDBfile mctest = new PDBfile(false, false, false, pdbStr,
78 AppletFormatAdapter.FILE);
79 PDBFileWithJmol jtest = new PDBFileWithJmol(pdbStr,
80 jalview.io.AppletFormatAdapter.FILE);
81 Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs();
84 "No sequences extracted from testfile\n"
85 + (jtest.hasWarningMessage() ? jtest.getWarningMessage()
86 : "(No warnings raised)"), seqs != null
88 for (SequenceI sq : seqs)
90 assertEquals("JMol didn't process " + pdbStr
91 + " to the same sequence as MCView",
92 sq.getSequenceAsString(), mcseqs.remove(0)
93 .getSequenceAsString());
94 AlignmentI al = new Alignment(new SequenceI[]
96 validateSecStrRows(al);
102 private void validateSecStrRows(AlignmentI al)
104 if (!al.isNucleotide())
106 for (SequenceI asq : al.getSequences())
109 boolean hasDs = false;
110 while (sq.getDatasetSequence() != null
111 && sq.getAnnotation() == null)
113 sq = sq.getDatasetSequence();
116 checkFirstAAIsAssoc(sq);
119 // also verify if alignment sequence has annotation on it
120 // that is correctly mapped
121 checkFirstAAIsAssoc(asq);
127 private void checkFirstAAIsAssoc(SequenceI sq)
129 assertTrue("No secondary structure assigned for protein sequence.",
130 sq.getAnnotation() != null && sq.getAnnotation().length >= 1
131 && sq.getAnnotation()[0].hasIcons);
133 "Secondary structure not associated for sequence "
134 + sq.getName(), sq.getAnnotation()[0].sequenceRef == sq);