X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=test%2Fjalview%2Fext%2Fjmol%2FPDBFileWithJmolTest.java;h=7bcf9023b046f95e1020ab81ccaa029717682c4d;hb=44546988ddf22f69b12b0793bcdbcb7b0452d47c;hp=ef142870fd635e818885ac21766aedd036578e26;hpb=fc56d1454866629d66e5d37070c4bd76a968ccce;p=jalview.git diff --git a/test/jalview/ext/jmol/PDBFileWithJmolTest.java b/test/jalview/ext/jmol/PDBFileWithJmolTest.java index ef14287..7bcf902 100644 --- a/test/jalview/ext/jmol/PDBFileWithJmolTest.java +++ b/test/jalview/ext/jmol/PDBFileWithJmolTest.java @@ -20,10 +20,8 @@ */ package jalview.ext.jmol; -import static org.junit.Assert.*; - -import java.util.Vector; - +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; @@ -31,8 +29,12 @@ import jalview.gui.AlignFrame; import jalview.io.AppletFormatAdapter; import jalview.io.FileLoader; +import java.util.Vector; + import org.junit.Test; +import MCview.PDBfile; + /** * @author jimp * @@ -40,25 +42,33 @@ import org.junit.Test; public class PDBFileWithJmolTest { String[] testFile = new String[] - { "./examples/1GAQ.txt" }; // , "./examples/DNMT1_MOUSE.pdb" }; + { "./examples/1GAQ.txt", "./test/jalview/ext/jmol/1QCF.pdb" }; // , + + // "./examples/DNMT1_MOUSE.pdb" + // }; @Test - public void testAlignmentLoader() throws Exception - { - for (String f:testFile) { + public void testAlignmentLoader() throws Exception + { + for (String f : testFile) + { FileLoader fl = new jalview.io.FileLoader(false); - AlignFrame af = fl.LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE); + AlignFrame af = fl + .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE); validateSecStrRows(af.getViewport().getAlignment()); } - } + } + @Test 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 seqs = jtest.getSeqs(); + Vector seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs(); assertTrue( "No sequences extracted from testfile\n" @@ -67,6 +77,10 @@ public class PDBFileWithJmolTest && 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); @@ -74,28 +88,39 @@ public class PDBFileWithJmolTest } } + private void validateSecStrRows(AlignmentI al) { - if (!al.isNucleotide()) { for (SequenceI asq : al.getSequences()) { SequenceI sq = asq; - while (sq.getDatasetSequence()!=null && sq.getAnnotation()==null) + boolean hasDs = false; + while (sq.getDatasetSequence() != null + && sq.getAnnotation() == null) { - sq = asq.getDatasetSequence(); + sq = sq.getDatasetSequence(); + hasDs = true; + } + checkFirstAAIsAssoc(sq); + if (hasDs) + { + // also verify if alignment sequence has annotation on it + // that is correctly mapped + checkFirstAAIsAssoc(asq); } - 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); } } } + + 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); + } }