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.ws.jws1;
23 import jalview.datamodel.Alignment;
24 import jalview.datamodel.AlignmentI;
25 import jalview.io.FileParse;
26 import jalview.io.FormatAdapter;
27 import jalview.io.InputStreamParser;
29 import java.io.BufferedReader;
30 import java.io.FileReader;
31 import java.io.IOException;
32 import java.io.InputStreamReader;
33 import java.io.Reader;
34 import java.net.MalformedURLException;
36 import java.net.URLEncoder;
37 import java.util.Iterator;
39 public class Annotate3D
41 // protected BufferedReader in;
42 // protected BufferedWriter out;
46 System.out.println("Annotate3D");
48 // Create a URL for the desired page
49 // String id = "1HR2";
51 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?pdbid="+id);
52 // in = new BufferedReader(new InputStreamReader(url.openStream()));
54 // OutputStream out1 = null;
55 // out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
56 // while ((str = in.readLine()) != null) {
57 // System.out.println(str);
62 // } catch (MalformedURLException e) {
63 // } catch (IOException e) {
67 public AlignmentI getRNAMLFor(final FileParse source) throws IOException
71 StringBuffer sb = new StringBuffer();
73 Reader fpr = source.getReader();
75 char[] cbuff = new char[2048];
76 while ((p = fpr.read(cbuff)) > 0)
78 for (int i = 0; i < p; i++)
83 Iterator<Reader> r = jalview.ext.paradise.Annotate3D
84 .getRNAMLForPDBFileAsString(sb.toString());
88 FileParse fp = new InputStreamParser(r.next(), source.getDataName());
89 AlignmentI nal = new FormatAdapter().readFromFile(fp, "RNAML");
100 if (x instanceof IOException)
102 throw ((IOException) x);
106 throw new IOException(
107 "Unexpected exception when handling RNAML translation of PDB data",
113 public Annotate3D(String path) throws InterruptedException
115 System.out.println("Annotate3D");
119 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
120 // System.out.println("Step1");
121 // FileReader r = new FileReader(inFile);
122 // BufferedReader in = new BufferedReader(r);
123 // StringBuffer content = new StringBuffer();
124 // System.out.println("Step2");
125 // while(in.readLine()!=null){
126 // content.append(in.readLine());
127 // //System.out.println("Step3"+in.readLine());
130 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
131 // URLEncoder.encode(content.toString(), "UTF-8");
132 // for (int i=0;i<data.length();i++)
134 // System.out.print(data.charAt(i));
137 // String data = "width=50&height=100";
139 // // Send the request
140 // FileReader r = new FileReader(path);
141 // BufferedReader in = new BufferedReader(r);
142 // StringBuffer content = new StringBuffer();
143 // System.out.println("Step1");
144 // while(in.readLine()!=null){
145 // content.append(in.readLine());
148 // System.out.println("Step2");
149 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
150 // URLEncoder.encode(content.toString(), "UTF-8");
151 // System.out.println("Step2");
153 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
154 // DataInputStream is = new DataInputStream(url.openStream());
156 // while ((str = is.readLine()) != null) {
157 // System.out.println(str);
160 FileReader r = new FileReader(path);
161 BufferedReader in = new BufferedReader(r);
165 while ((str = in.readLine()) != null)
167 // System.out.println(str);
169 content = content + str;
171 System.out.println("pdbfile=" + content.toString());
172 System.out.println("capacité=" + content.length());
173 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
174 System.out.println("param=" + paramfile);
176 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
178 BufferedReader is = new BufferedReader(new InputStreamReader(
181 while ((str4 = is.readLine()) != null)
183 System.out.println(str4);
189 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
190 // connection.setRequestMethod("POST" );
191 // connection.setRequestProperty("data", path );
192 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
193 // BufferedReader input = new BufferedReader(new
194 // InputStreamReader(connection.getInputStream()));
195 // //DataInputStream input = new
196 // DataInputStream(connection.getInputStream());
198 // while((c=input.readLine())!=null){
199 // System.out.print(c);
202 // BufferedReader in1 = new BufferedReader(is);
204 // OutputStream out1 = null;
205 // System.out.println("Step3");
206 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
214 // System.out.println(data.length());
215 // System.out.println("step2");
217 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
218 // System.out.println("step3");
219 // URLConnection conn = url.openConnection();
220 // conn.setDoOutput(true);
221 // OutputStreamWriter writer = new
222 // OutputStreamWriter(conn.getOutputStream());
225 // writer.write(data);
229 // StringBuffer answer = new StringBuffer();
230 // //BufferedReader reader = new BufferedReader(new
231 // InputStreamReader(conn.getInputStream()));
233 // while ((line = reader.readLine()) != null) {
234 // answer.append(line);
235 // System.out.println(line);
240 // Output the response
242 } catch (MalformedURLException ex)
244 ex.printStackTrace();
245 } catch (IOException ex)
247 ex.printStackTrace();
251 // in = new BufferedReader(new InputStreamReader(url.openStream()));
255 // out = new FileOutputStream("temp.rnaml");
256 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
258 // while ((str = in.readLine()) != null) {
259 // System.out.println(str);
261 // System.out.println(str);
265 // } catch (MalformedURLException e) {
266 // } catch (IOException e) {
271 // public BufferedWriter getReader()
273 // System.out.println("The buffer");