-/**
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
+ * Copyright (C) 2015 The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
*
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.ext.jmol;
-import static org.junit.Assert.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+
+import jalview.bin.Cache;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignFrame;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.FileLoader;
import java.util.Vector;
-import jalview.datamodel.SequenceI;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-import org.junit.Test;
+import MCview.PDBfile;
/**
* @author jimp
- *
+ *
*/
public class PDBFileWithJmolTest
{
+ String[] testFile = new String[] { "./examples/1GAQ.txt",
+ "./test/jalview/ext/jmol/1QCF.pdb" }; // ,
+
+ // "./examples/DNMT1_MOUSE.pdb"
+ // };
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp()
+ {
+ Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
+ Boolean.TRUE.toString());
+ Cache.applicationProperties.setProperty("ADD_SS_ANN",
+ Boolean.TRUE.toString());
+ }
+
+ @Test(groups = { "Functional" })
+ public void testAlignmentLoader() throws Exception
+ {
+ for (String f : testFile)
+ {
+ FileLoader fl = new jalview.io.FileLoader(false);
+ AlignFrame af = fl
+ .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE);
+ validateSecStrRows(af.getViewport().getAlignment());
+ }
+ }
+
+ @Test(groups = { "Functional" })
+ public void testFileParser() throws Exception
+ {
+ for (String pdbStr : testFile)
+ {
+ PDBfile mctest = new PDBfile(false, false, false, pdbStr,
+ AppletFormatAdapter.FILE);
+ PDBFileWithJmol jtest = new PDBFileWithJmol(pdbStr,
+ jalview.io.AppletFormatAdapter.FILE);
+ Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs();
+
+ assertTrue(
+ "No sequences extracted from testfile\n"
+ + (jtest.hasWarningMessage() ? jtest.getWarningMessage()
+ : "(No warnings raised)"), seqs != null
+ && seqs.size() > 0);
+ for (SequenceI sq : seqs)
+ {
+ assertEquals("JMol didn't process " + pdbStr
+ + " to the same sequence as MCView",
+ sq.getSequenceAsString(), mcseqs.remove(0)
+ .getSequenceAsString());
+ AlignmentI al = new Alignment(new SequenceI[] { sq });
+ validateSecStrRows(al);
+ }
+ }
+ }
- @Test
- public void test() throws Exception
+ private void validateSecStrRows(AlignmentI al)
{
- PDBFileWithJmol jtest=new PDBFileWithJmol("./examples/1vsp", jalview.io.AppletFormatAdapter.FILE);
- Vector<SequenceI> seqs=jtest.getSeqs();
- assertTrue("No sequences extracted from testfile", seqs!=null && seqs.size()>0);
- assertTrue("No annotation generated.", seqs.get(0).getAnnotation()!=null && seqs.get(0).getAnnotation().length!=0);
-
+ if (!al.isNucleotide())
+ {
+ for (SequenceI asq : al.getSequences())
+ {
+ SequenceI sq = asq;
+ boolean hasDs = false;
+ while (sq.getDatasetSequence() != null
+ && sq.getAnnotation() == null)
+ {
+ sq = sq.getDatasetSequence();
+ hasDs = true;
+ }
+ checkFirstAAIsAssoc(sq);
+ if (hasDs)
+ {
+ // also verify if alignment sequence has annotation on it
+ // that is correctly mapped
+ checkFirstAAIsAssoc(asq);
+ }
+ }
+ }
}
+ private void checkFirstAAIsAssoc(SequenceI sq)
+ {
+ assertTrue("No secondary structure assigned for protein sequence.",
+ sq.getAnnotation() != null && sq.getAnnotation().length >= 1
+ && sq.getAnnotation()[0].hasIcons);
+ assertTrue(
+ "Secondary structure not associated for sequence "
+ + sq.getName(), sq.getAnnotation()[0].sequenceRef == sq);
+ }
}