2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.ws.jws1;
20 import jalview.datamodel.Alignment;
21 import jalview.datamodel.AlignmentI;
22 import jalview.io.FileParse;
23 import jalview.io.FormatAdapter;
24 import jalview.io.InputStreamParser;
26 import java.io.BufferedReader;
27 import java.io.FileReader;
28 import java.io.IOException;
29 import java.io.InputStreamReader;
30 import java.io.Reader;
31 import java.net.MalformedURLException;
33 import java.net.URLEncoder;
34 import java.util.Iterator;
36 public class Annotate3D
38 // protected BufferedReader in;
39 // protected BufferedWriter out;
43 System.out.println("Annotate3D");
45 // Create a URL for the desired page
46 // String id = "1HR2";
48 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?pdbid="+id);
49 // in = new BufferedReader(new InputStreamReader(url.openStream()));
51 // OutputStream out1 = null;
52 // out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
53 // while ((str = in.readLine()) != null) {
54 // System.out.println(str);
59 // } catch (MalformedURLException e) {
60 // } catch (IOException e) {
64 public AlignmentI getRNAMLFor(final FileParse source) throws IOException
68 StringBuffer sb = new StringBuffer();
70 Reader fpr = source.getReader();
72 char[] cbuff = new char[2048];
73 while ((p = fpr.read(cbuff)) > 0)
75 for (int i = 0; i < p; i++)
80 Iterator<Reader> r = jalview.ext.paradise.Annotate3D
81 .getRNAMLForPDBFileAsString(sb.toString());
85 FileParse fp = new InputStreamParser(r.next(), source.getDataName());
86 AlignmentI nal = new FormatAdapter().readFromFile(fp, "RNAML");
97 if (x instanceof IOException)
99 throw ((IOException) x);
103 throw new IOException(
104 "Unexpected exception when handling RNAML translation of PDB data",
110 public Annotate3D(String path) throws InterruptedException
112 System.out.println("Annotate3D");
116 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
117 // System.out.println("Step1");
118 // FileReader r = new FileReader(inFile);
119 // BufferedReader in = new BufferedReader(r);
120 // StringBuffer content = new StringBuffer();
121 // System.out.println("Step2");
122 // while(in.readLine()!=null){
123 // content.append(in.readLine());
124 // //System.out.println("Step3"+in.readLine());
127 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
128 // URLEncoder.encode(content.toString(), "UTF-8");
129 // for (int i=0;i<data.length();i++)
131 // System.out.print(data.charAt(i));
134 // String data = "width=50&height=100";
136 // // Send the request
137 // FileReader r = new FileReader(path);
138 // BufferedReader in = new BufferedReader(r);
139 // StringBuffer content = new StringBuffer();
140 // System.out.println("Step1");
141 // while(in.readLine()!=null){
142 // content.append(in.readLine());
145 // System.out.println("Step2");
146 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
147 // URLEncoder.encode(content.toString(), "UTF-8");
148 // System.out.println("Step2");
150 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
151 // DataInputStream is = new DataInputStream(url.openStream());
153 // while ((str = is.readLine()) != null) {
154 // System.out.println(str);
157 FileReader r = new FileReader(path);
158 BufferedReader in = new BufferedReader(r);
162 while ((str = in.readLine()) != null)
164 // System.out.println(str);
166 content = content + str;
168 System.out.println("pdbfile=" + content.toString());
169 System.out.println("capacité=" + content.length());
170 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
171 System.out.println("param=" + paramfile);
173 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
175 BufferedReader is = new BufferedReader(new InputStreamReader(
178 while ((str4 = is.readLine()) != null)
180 System.out.println(str4);
186 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
187 // connection.setRequestMethod("POST" );
188 // connection.setRequestProperty("data", path );
189 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
190 // BufferedReader input = new BufferedReader(new
191 // InputStreamReader(connection.getInputStream()));
192 // //DataInputStream input = new
193 // DataInputStream(connection.getInputStream());
195 // while((c=input.readLine())!=null){
196 // System.out.print(c);
199 // BufferedReader in1 = new BufferedReader(is);
201 // OutputStream out1 = null;
202 // System.out.println("Step3");
203 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
211 // System.out.println(data.length());
212 // System.out.println("step2");
214 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
215 // System.out.println("step3");
216 // URLConnection conn = url.openConnection();
217 // conn.setDoOutput(true);
218 // OutputStreamWriter writer = new
219 // OutputStreamWriter(conn.getOutputStream());
222 // writer.write(data);
226 // StringBuffer answer = new StringBuffer();
227 // //BufferedReader reader = new BufferedReader(new
228 // InputStreamReader(conn.getInputStream()));
230 // while ((line = reader.readLine()) != null) {
231 // answer.append(line);
232 // System.out.println(line);
237 // Output the response
239 } catch (MalformedURLException ex)
241 ex.printStackTrace();
242 } catch (IOException ex)
244 ex.printStackTrace();
248 // in = new BufferedReader(new InputStreamReader(url.openStream()));
252 // out = new FileOutputStream("temp.rnaml");
253 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
255 // while ((str = in.readLine()) != null) {
256 // System.out.println(str);
258 // System.out.println(str);
262 // } catch (MalformedURLException e) {
263 // } catch (IOException e) {
268 // public BufferedWriter getReader()
270 // System.out.println("The buffer");