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.Alignment;
24 import jalview.datamodel.AlignmentI;
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 System.out.println("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 // System.out.println(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(), source.getDataName());
90 AlignmentI nal = new FormatAdapter().readFromFile(fp, "RNAML");
101 } catch (Throwable x)
103 if (x instanceof IOException)
105 throw ((IOException) x);
109 throw new IOException(MessageManager.getString("exception.unexpected_handling_rnaml_translation_for_pdb"),
115 public Annotate3D(String path) throws InterruptedException
117 System.out.println("Annotate3D");
121 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
122 // System.out.println("Step1");
123 // FileReader r = new FileReader(inFile);
124 // BufferedReader in = new BufferedReader(r);
125 // StringBuffer content = new StringBuffer();
126 // System.out.println("Step2");
127 // while(in.readLine()!=null){
128 // content.append(in.readLine());
129 // //System.out.println("Step3"+in.readLine());
132 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
133 // URLEncoder.encode(content.toString(), "UTF-8");
134 // for (int i=0;i<data.length();i++)
136 // System.out.print(data.charAt(i));
139 // String data = "width=50&height=100";
141 // // Send the request
142 // FileReader r = new FileReader(path);
143 // BufferedReader in = new BufferedReader(r);
144 // StringBuffer content = new StringBuffer();
145 // System.out.println("Step1");
146 // while(in.readLine()!=null){
147 // content.append(in.readLine());
150 // System.out.println("Step2");
151 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
152 // URLEncoder.encode(content.toString(), "UTF-8");
153 // System.out.println("Step2");
155 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
156 // DataInputStream is = new DataInputStream(url.openStream());
158 // while ((str = is.readLine()) != null) {
159 // System.out.println(str);
162 FileReader r = new FileReader(path);
163 BufferedReader in = new BufferedReader(r);
167 while ((str = in.readLine()) != null)
169 // System.out.println(str);
171 content = content + str;
173 System.out.println("pdbfile=" + content.toString());
174 System.out.println("capacité=" + content.length());
175 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
176 System.out.println("param=" + paramfile);
178 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
180 BufferedReader is = new BufferedReader(new InputStreamReader(
183 while ((str4 = is.readLine()) != null)
185 System.out.println(str4);
191 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
192 // connection.setRequestMethod("POST" );
193 // connection.setRequestProperty("data", path );
194 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
195 // BufferedReader input = new BufferedReader(new
196 // InputStreamReader(connection.getInputStream()));
197 // //DataInputStream input = new
198 // DataInputStream(connection.getInputStream());
200 // while((c=input.readLine())!=null){
201 // System.out.print(c);
204 // BufferedReader in1 = new BufferedReader(is);
206 // OutputStream out1 = null;
207 // System.out.println("Step3");
208 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
216 // System.out.println(data.length());
217 // System.out.println("step2");
219 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
220 // System.out.println("step3");
221 // URLConnection conn = url.openConnection();
222 // conn.setDoOutput(true);
223 // OutputStreamWriter writer = new
224 // OutputStreamWriter(conn.getOutputStream());
227 // writer.write(data);
231 // StringBuffer answer = new StringBuffer();
232 // //BufferedReader reader = new BufferedReader(new
233 // InputStreamReader(conn.getInputStream()));
235 // while ((line = reader.readLine()) != null) {
236 // answer.append(line);
237 // System.out.println(line);
242 // Output the response
244 } catch (MalformedURLException ex)
246 ex.printStackTrace();
247 } catch (IOException ex)
249 ex.printStackTrace();
253 // in = new BufferedReader(new InputStreamReader(url.openStream()));
257 // out = new FileOutputStream("temp.rnaml");
258 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
260 // while ((str = in.readLine()) != null) {
261 // System.out.println(str);
263 // System.out.println(str);
267 // } catch (MalformedURLException e) {
268 // } catch (IOException e) {
273 // public BufferedWriter getReader()
275 // System.out.println("The buffer");