2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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.AlignmentI;
24 import jalview.io.FileFormat;
25 import jalview.io.FileParse;
26 import jalview.io.FormatAdapter;
27 import jalview.io.InputStreamParser;
28 import jalview.util.MessageManager;
30 import java.io.BufferedReader;
31 import java.io.FileReader;
32 import java.io.IOException;
33 import java.io.InputStreamReader;
34 import java.io.Reader;
35 import java.net.MalformedURLException;
37 import java.net.URLEncoder;
38 import java.util.Iterator;
40 public class Annotate3D
42 // protected BufferedReader in;
43 // protected BufferedWriter out;
47 jalview.bin.Console.outPrintln("Annotate3D");
49 // Create a URL for the desired page
50 // String id = "1HR2";
52 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?pdbid="+id);
53 // in = new BufferedReader(new InputStreamReader(url.openStream()));
55 // OutputStream out1 = null;
56 // out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
57 // while ((str = in.readLine()) != null) {
58 // jalview.bin.Console.outPrintln(str);
63 // } catch (MalformedURLException e) {
64 // } catch (IOException e) {
68 public AlignmentI getRNAMLFor(final FileParse source) throws IOException
72 StringBuffer sb = new StringBuffer();
74 Reader fpr = source.getReader();
76 char[] cbuff = new char[2048];
77 while ((p = fpr.read(cbuff)) > 0)
79 for (int i = 0; i < p; i++)
84 Iterator<Reader> r = jalview.ext.paradise.Annotate3D
85 .getRNAMLForPDBFileAsString(sb.toString());
89 FileParse fp = new InputStreamParser(r.next(),
90 source.getDataName());
91 AlignmentI nal = new FormatAdapter().readFromFile(fp,
103 } catch (Throwable x)
105 if (x instanceof IOException)
107 throw ((IOException) x);
111 throw new IOException(MessageManager.getString(
112 "exception.unexpected_handling_rnaml_translation_for_pdb"),
118 public Annotate3D(String path) throws InterruptedException
120 jalview.bin.Console.outPrintln("Annotate3D");
124 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
125 // jalview.bin.Console.outPrintln("Step1");
126 // FileReader r = new FileReader(inFile);
127 // BufferedReader in = new BufferedReader(r);
128 // StringBuffer content = new StringBuffer();
129 // jalview.bin.Console.outPrintln("Step2");
130 // while(in.readLine()!=null){
131 // content.append(in.readLine());
132 // //jalview.bin.Console.outPrintln("Step3"+in.readLine());
135 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
136 // URLEncoder.encode(content.toString(), "UTF-8");
137 // for (int i=0;i<data.length();i++)
139 // System.out.print(data.charAt(i));
142 // String data = "width=50&height=100";
144 // // Send the request
145 // FileReader r = new FileReader(path);
146 // BufferedReader in = new BufferedReader(r);
147 // StringBuffer content = new StringBuffer();
148 // jalview.bin.Console.outPrintln("Step1");
149 // while(in.readLine()!=null){
150 // content.append(in.readLine());
153 // jalview.bin.Console.outPrintln("Step2");
154 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
155 // URLEncoder.encode(content.toString(), "UTF-8");
156 // jalview.bin.Console.outPrintln("Step2");
158 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
159 // DataInputStream is = new DataInputStream(url.openStream());
161 // while ((str = is.readLine()) != null) {
162 // jalview.bin.Console.outPrintln(str);
165 FileReader r = new FileReader(path);
166 BufferedReader in = new BufferedReader(r);
170 while ((str = in.readLine()) != null)
172 // jalview.bin.Console.outPrintln(str);
174 content = content + str;
176 jalview.bin.Console.outPrintln("pdbfile=" + content.toString());
177 jalview.bin.Console.outPrintln("capacité=" + content.length());
178 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
179 jalview.bin.Console.outPrintln("param=" + paramfile);
181 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
183 BufferedReader is = new BufferedReader(
184 new InputStreamReader(url.openStream()));
186 while ((str4 = is.readLine()) != null)
188 jalview.bin.Console.outPrintln(str4);
194 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
195 // connection.setRequestMethod("POST" );
196 // connection.setRequestProperty("data", path );
197 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
198 // BufferedReader input = new BufferedReader(new
199 // InputStreamReader(connection.getInputStream()));
200 // //DataInputStream input = new
201 // DataInputStream(connection.getInputStream());
203 // while((c=input.readLine())!=null){
204 // System.out.print(c);
207 // BufferedReader in1 = new BufferedReader(is);
209 // OutputStream out1 = null;
210 // jalview.bin.Console.outPrintln("Step3");
211 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
219 // jalview.bin.Console.outPrintln(data.length());
220 // jalview.bin.Console.outPrintln("step2");
222 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
223 // jalview.bin.Console.outPrintln("step3");
224 // URLConnection conn = url.openConnection();
225 // conn.setDoOutput(true);
226 // OutputStreamWriter writer = new
227 // OutputStreamWriter(conn.getOutputStream());
230 // writer.write(data);
234 // StringBuffer answer = new StringBuffer();
235 // //BufferedReader reader = new BufferedReader(new
236 // InputStreamReader(conn.getInputStream()));
238 // while ((line = reader.readLine()) != null) {
239 // answer.append(line);
240 // jalview.bin.Console.outPrintln(line);
245 // Output the response
247 } catch (MalformedURLException ex)
249 ex.printStackTrace();
250 } catch (IOException ex)
252 ex.printStackTrace();
256 // in = new BufferedReader(new InputStreamReader(url.openStream()));
260 // out = new FileOutputStream("temp.rnaml");
261 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
263 // while ((str = in.readLine()) != null) {
264 // jalview.bin.Console.outPrintln(str);
266 // jalview.bin.Console.outPrintln(str);
270 // } catch (MalformedURLException e) {
271 // } catch (IOException e) {
276 // public BufferedWriter getReader()
278 // jalview.bin.Console.outPrintln("The buffer");