1 package jalview.ext.paradise;
3 import static org.junit.Assert.assertTrue;
5 import jalview.datamodel.AlignmentI;
6 import jalview.datamodel.SequenceI;
7 import jalview.ext.paradise.Annotate3D;
8 import jalview.io.FastaFile;
9 import jalview.io.FormatAdapter;
11 import java.io.BufferedReader;
14 import org.junit.Assert;
15 import org.junit.Test;
17 import MCview.PDBfile;
19 import compbio.util.FileUtil;
21 public class TestAnnotate3D
25 public void testIdVsContent() throws Exception
27 BufferedReader id = (BufferedReader) Annotate3D
28 .getRNAMLForPDBId("2GIS");
29 assertTrue("Didn't retrieve 2GIS by id.", id != null);
30 BufferedReader file = (BufferedReader) Annotate3D
31 .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
32 "examples/2GIS.pdb")));
33 assertTrue("Didn't retrieve using examples/2GIS.pdb.", file != null);
37 iline = id.readLine();
38 fline = file.readLine();
40 System.out.println(iline);
42 System.out.println(fline);
44 assertTrue("Results differ for ID and file upload based retrieval",
45 ((iline == fline && iline == null) || (iline != null
46 && fline != null && iline.equals(fline))));
48 } while (iline != null);
52 * test to demonstrate JAL-1142 - compare sequences in RNAML returned from
53 * Annotate3d vs those extracted by Jalview from the originl PDB file
58 public void testPDBfileVsRNAML() throws Exception
60 PDBfile pdbf = new PDBfile("examples/2GIS.pdb", FormatAdapter.FILE);
61 Assert.assertTrue(pdbf.isValid());
62 StringBuffer sb = new StringBuffer();
63 // Comment - should add new FileParse constructor like new FileParse(Reader
64 // ..). for direct reading
65 BufferedReader br = new BufferedReader(
66 Annotate3D.getRNAMLForPDBFileAsString(FileUtil
67 .readFileToString(new File("examples/2GIS.pdb"))));
69 while ((line = br.readLine()) != null)
71 sb.append(line + "\n");
73 assertTrue("No data returned by Annotate3D", sb.length() > 0);
74 AlignmentI al = new FormatAdapter().readFile(sb.toString(),
75 FormatAdapter.PASTE, "RNAML");
77 assertTrue("No alignment returned.", al != null);
78 assertTrue("No sequences in returned alignment.", al.getHeight() > 0);
79 for (SequenceI sq : al.getSequences())
82 SequenceI struseq = null;
83 String sq_ = new String(sq.getSequence()).toLowerCase();
84 for (SequenceI _struseq : pdbf.getSeqsAsArray())
86 if (new String(_struseq.getSequence()).toLowerCase().equals(sq_))
94 Assert.fail("Couldn't find this sequence in original input:\n"
95 + new FastaFile().print(new SequenceI[]
96 { sq }) + "\n\nOriginal input:\n"
97 + new FastaFile().print(pdbf.getSeqsAsArray()) + "\n");