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;
13 import java.io.Reader;
14 import java.util.Iterator;
16 import org.junit.Assert;
17 import org.junit.Test;
19 import MCview.PDBfile;
21 import compbio.util.FileUtil;
23 public class TestAnnotate3D
27 public void testIdVsContent() throws Exception
29 Iterator<Reader> ids = Annotate3D
30 .getRNAMLForPDBId("2GIS");
31 assertTrue("Didn't retrieve 2GIS by id.", ids != null);
32 Iterator<Reader> files = Annotate3D
33 .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
34 "examples/2GIS.pdb")));
35 assertTrue("Didn't retrieve using examples/2GIS.pdb.", files != null);
37 while (ids.hasNext() && files.hasNext())
39 BufferedReader file=new BufferedReader(files.next()), id=new BufferedReader(ids.next());
43 iline = id.readLine();
44 fline = file.readLine();
46 System.out.println(iline);
48 System.out.println(fline);
49 // next assert fails for latest RNAview - because the XMLID entries change between file and ID based RNAML generation.
50 assertTrue("Results differ for ID and file upload based retrieval (chain entry "+(++i)+")",
51 ((iline == fline && iline == null) || (iline != null
52 && fline != null && iline.equals(fline))));
54 } while (iline != null);
59 * test to demonstrate JAL-1142 - compare sequences in RNAML returned from
60 * Annotate3d vs those extracted by Jalview from the originl PDB file
65 public void testPDBfileVsRNAML() throws Exception
67 PDBfile pdbf = new PDBfile("examples/2GIS.pdb", FormatAdapter.FILE);
68 Assert.assertTrue(pdbf.isValid());
69 StringBuffer sb = new StringBuffer();
70 // Comment - should add new FileParse constructor like new FileParse(Reader
71 // ..). for direct reading
72 Iterator<Reader> readers = Annotate3D
73 .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
74 "examples/2GIS.pdb")));
76 while (readers.hasNext())
78 System.out.println("Testing RNAML input number "+(++r));
79 BufferedReader br = new BufferedReader(readers.next());
81 while ((line = br.readLine()) != null)
83 sb.append(line + "\n");
85 assertTrue("No data returned by Annotate3D", sb.length() > 0);
86 AlignmentI al = new FormatAdapter().readFile(sb.toString(),
87 FormatAdapter.PASTE, "RNAML");
89 assertTrue("No alignment returned.", al != null);
90 assertTrue("No sequences in returned alignment.", al.getHeight() > 0);
91 for (SequenceI sq : al.getSequences())
94 SequenceI struseq = null;
95 String sq_ = new String(sq.getSequence()).toLowerCase();
96 for (SequenceI _struseq : pdbf.getSeqsAsArray())
98 if (new String(_struseq.getSequence()).toLowerCase()
107 Assert.fail("Couldn't find this sequence in original input:\n"
108 + new FastaFile().print(new SequenceI[]
109 { sq }) + "\n\nOriginal input:\n"
110 + new FastaFile().print(pdbf.getSeqsAsArray()) + "\n");