2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ext.paradise;
23 import static org.junit.Assert.assertTrue;
24 import jalview.datamodel.AlignmentI;
25 import jalview.datamodel.SequenceI;
26 import jalview.io.FastaFile;
27 import jalview.io.FormatAdapter;
29 import java.io.BufferedReader;
31 import java.io.Reader;
32 import java.util.Iterator;
34 import org.junit.Assert;
35 import org.junit.Test;
37 import MCview.PDBfile;
39 import compbio.util.FileUtil;
41 public class TestAnnotate3D
45 public void test1GIDbyId() throws Exception
47 // use same ID as standard tests given at
48 // https://bitbucket.org/fjossinet/pyrna-rest-clients
49 Iterator<Reader> ids = Annotate3D.getRNAMLForPDBId("1GID");
50 assertTrue("Didn't retrieve 1GID by id.", ids != null);
51 testRNAMLcontent(ids, null);
55 public void testIdVsContent2GIS() throws Exception
57 Iterator<Reader> ids = Annotate3D.getRNAMLForPDBId("2GIS");
58 assertTrue("Didn't retrieve 2GIS by id.", ids != null);
59 Iterator<Reader> files = Annotate3D.getRNAMLForPDBFileAsString(FileUtil
60 .readFileToString(new File("examples/2GIS.pdb")));
61 assertTrue("Didn't retrieve using examples/2GIS.pdb.", files != null);
63 while (ids.hasNext() && files.hasNext())
65 BufferedReader file = new BufferedReader(files.next()), id = new BufferedReader(
70 iline = id.readLine();
71 fline = file.readLine();
74 System.out.println(iline);
78 System.out.println(fline);
80 // next assert fails for latest RNAview - because the XMLID entries
81 // change between file and ID based RNAML generation.
83 "Results differ for ID and file upload based retrieval (chain entry "
85 ((iline == fline && iline == null) || (iline != null
86 && fline != null && iline.equals(fline))));
88 } while (iline != null);
93 * test to demonstrate JAL-1142 - compare sequences in RNAML returned from
94 * Annotate3d vs those extracted by Jalview from the originl PDB file
99 public void testPDBfileVsRNAML() throws Exception
101 PDBfile pdbf = new PDBfile(true, false, true, "examples/2GIS.pdb",
103 Assert.assertTrue(pdbf.isValid());
104 // Comment - should add new FileParse constructor like new FileParse(Reader
105 // ..). for direct reading
106 Iterator<Reader> readers = Annotate3D
107 .getRNAMLForPDBFileAsString(FileUtil.readFileToString(new File(
108 "examples/2GIS.pdb")));
109 testRNAMLcontent(readers, pdbf);
112 private void testRNAMLcontent(Iterator<Reader> readers, PDBfile pdbf)
115 StringBuffer sb = new StringBuffer();
117 while (readers.hasNext())
119 System.out.println("Testing RNAML input number " + (++r));
120 BufferedReader br = new BufferedReader(readers.next());
122 while ((line = br.readLine()) != null)
124 sb.append(line + "\n");
126 assertTrue("No data returned by Annotate3D", sb.length() > 0);
127 AlignmentI al = new FormatAdapter().readFile(sb.toString(),
128 FormatAdapter.PASTE, "RNAML");
129 if (al == null || al.getHeight() == 0)
131 System.out.println(sb.toString());
133 assertTrue("No alignment returned.", al != null);
134 assertTrue("No sequences in returned alignment.", al.getHeight() > 0);
137 for (SequenceI sq : al.getSequences())
140 SequenceI struseq = null;
141 String sq_ = new String(sq.getSequence()).toLowerCase();
142 for (SequenceI _struseq : pdbf.getSeqsAsArray())
144 if (new String(_struseq.getSequence()).toLowerCase().equals(
153 Assert.fail("Couldn't find this sequence in original input:\n"
154 + new FastaFile().print(new SequenceI[]
156 + "\n\nOriginal input:\n"
157 + new FastaFile().print(pdbf.getSeqsAsArray()) + "\n");