+ /**
+ * 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(groups = { "Network" }, enabled = true)
+ public void testPDBfileVsRNAML() throws Exception
+ {
+ PDBfile pdbf = new PDBfile(true, false, true, "examples/2GIS.pdb",
+ FormatAdapter.FILE);
+ Assert.assertTrue(pdbf.isValid());
+ // Comment - should add new FileParse constructor like new FileParse(Reader
+ // ..). for direct reading
+ Iterator<Reader> readers = Annotate3D
+ .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
+ "examples/2GIS.pdb")));
+ testRNAMLcontent(readers, pdbf);
+ }
+
+ private void testRNAMLcontent(Iterator<Reader> readers, PDBfile pdbf)
+ throws Exception
+ {
+ StringBuffer sb = new StringBuffer();
+ int r = 0;
+ while (readers.hasNext())
+ {
+ System.out.println("Testing RNAML input number " + (++r));
+ BufferedReader br = new BufferedReader(readers.next());
+ String line;
+ while ((line = br.readLine()) != null)
+ {
+ sb.append(line + "\n");
+ }
+ assertTrue("No data returned by Annotate3D", sb.length() > 0);
+ final String lines = sb.toString();
+ AlignmentI al = new FormatAdapter().readFile(lines,
+ FormatAdapter.PASTE, "RNAML");
+ if (al == null || al.getHeight() == 0)
+ {
+ System.out.println(lines);
+ }
+ assertTrue("No alignment returned.", al != null);
+ assertTrue("No sequences in returned alignment.", al.getHeight() > 0);
+ if (pdbf != null)
+ {
+ for (SequenceI sq : al.getSequences())
+ {
+ {
+ SequenceI struseq = null;
+ String sq_ = new String(sq.getSequence()).toLowerCase();
+ for (SequenceI _struseq : pdbf.getSeqsAsArray())
+ {
+ final String lowerCase = new String(_struseq.getSequence())
+ .toLowerCase();
+ if (lowerCase.equals(sq_))
+ {
+ struseq = _struseq;
+ break;
+ }
+ }
+ if (struseq == null)
+ {
+ AssertJUnit
+ .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");
+ }
+ }
+ }
+ }
+ }
+ }