From 89b54c4138d9fcf60324227b4b64e92447793d3f Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 21 Aug 2012 11:29:58 +0100 Subject: [PATCH] JAL-1142 - test to demonstrate mismatch between rnaview and Jalview PDB parsing with 2GIS --- test/jalview/ext/paradise/TestAnnotate3D.java | 66 +++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/test/jalview/ext/paradise/TestAnnotate3D.java b/test/jalview/ext/paradise/TestAnnotate3D.java index d358c44..1ed46f4 100644 --- a/test/jalview/ext/paradise/TestAnnotate3D.java +++ b/test/jalview/ext/paradise/TestAnnotate3D.java @@ -2,13 +2,20 @@ package jalview.ext.paradise; import static org.junit.Assert.assertTrue; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.SequenceI; import jalview.ext.paradise.Annotate3D; +import jalview.io.FastaFile; +import jalview.io.FormatAdapter; import java.io.BufferedReader; import java.io.File; +import org.junit.Assert; import org.junit.Test; +import MCview.PDBfile; + import compbio.util.FileUtil; public class TestAnnotate3D @@ -17,10 +24,12 @@ public class TestAnnotate3D @Test public void testIdVsContent() throws Exception { - BufferedReader id = (BufferedReader) Annotate3D.getRNAMLForPDBId("2GIS"); + BufferedReader id = (BufferedReader) Annotate3D + .getRNAMLForPDBId("2GIS"); assertTrue("Didn't retrieve 2GIS by id.", id != null); - BufferedReader file = (BufferedReader) Annotate3D.getRNAMLForPDBFileAsString(FileUtil - .readFileToString(new File("examples/2GIS.pdb"))); + BufferedReader file = (BufferedReader) Annotate3D + .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File( + "examples/2GIS.pdb"))); assertTrue("Didn't retrieve using examples/2GIS.pdb.", file != null); String iline, fline; do @@ -39,4 +48,55 @@ public class TestAnnotate3D } while (iline != null); } + /** + * test to demonstrate JAL-1142 - compare sequences in RNAML returned from + * Annotate3d vs those extracted by Jalview from the originl PDB file + * + * @throws Exception + */ + @Test + public void testPDBfileVsRNAML() throws Exception + { + PDBfile pdbf = new PDBfile("examples/2GIS.pdb", FormatAdapter.FILE); + Assert.assertTrue(pdbf.isValid()); + StringBuffer sb = new StringBuffer(); + // Comment - should add new FileParse constructor like new FileParse(Reader + // ..). for direct reading + BufferedReader br = new BufferedReader( + Annotate3D.getRNAMLForPDBFileAsString(FileUtil + .readFileToString(new File("examples/2GIS.pdb")))); + String line; + while ((line = br.readLine()) != null) + { + sb.append(line + "\n"); + } + assertTrue("No data returned by Annotate3D", sb.length() > 0); + AlignmentI al = new FormatAdapter().readFile(sb.toString(), + FormatAdapter.PASTE, "RNAML"); + + assertTrue("No alignment returned.", al != null); + assertTrue("No sequences in returned alignment.", al.getHeight() > 0); + for (SequenceI sq : al.getSequences()) + { + { + SequenceI struseq = null; + String sq_ = new String(sq.getSequence()).toLowerCase(); + for (SequenceI _struseq : pdbf.getSeqsAsArray()) + { + if (new String(_struseq.getSequence()).toLowerCase().equals(sq_)) + { + struseq = _struseq; + break; + } + } + if (struseq == null) + { + Assert.fail("Couldn't find this sequence in original input:\n" + + new FastaFile().print(new SequenceI[] + { sq }) + "\n\nOriginal input:\n" + + new FastaFile().print(pdbf.getSeqsAsArray()) + "\n"); + } + } + } + } } -- 1.7.10.2