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.FileParse;
25 import jalview.io.FormatAdapter;
26 import jalview.io.InputStreamParser;
27 import jalview.util.MessageManager;
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 } catch (Throwable x)
102 if (x instanceof IOException)
104 throw ((IOException) x);
108 throw new IOException(
110 .getString("exception.unexpected_handling_rnaml_translation_for_pdb"),
116 public Annotate3D(String path) throws InterruptedException
118 System.out.println("Annotate3D");
122 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
123 // System.out.println("Step1");
124 // FileReader r = new FileReader(inFile);
125 // BufferedReader in = new BufferedReader(r);
126 // StringBuffer content = new StringBuffer();
127 // System.out.println("Step2");
128 // while(in.readLine()!=null){
129 // content.append(in.readLine());
130 // //System.out.println("Step3"+in.readLine());
133 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
134 // URLEncoder.encode(content.toString(), "UTF-8");
135 // for (int i=0;i<data.length();i++)
137 // System.out.print(data.charAt(i));
140 // String data = "width=50&height=100";
142 // // Send the request
143 // FileReader r = new FileReader(path);
144 // BufferedReader in = new BufferedReader(r);
145 // StringBuffer content = new StringBuffer();
146 // System.out.println("Step1");
147 // while(in.readLine()!=null){
148 // content.append(in.readLine());
151 // System.out.println("Step2");
152 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
153 // URLEncoder.encode(content.toString(), "UTF-8");
154 // System.out.println("Step2");
156 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
157 // DataInputStream is = new DataInputStream(url.openStream());
159 // while ((str = is.readLine()) != null) {
160 // System.out.println(str);
163 FileReader r = new FileReader(path);
164 BufferedReader in = new BufferedReader(r);
168 while ((str = in.readLine()) != null)
170 // System.out.println(str);
172 content = content + str;
174 System.out.println("pdbfile=" + content.toString());
175 System.out.println("capacité=" + content.length());
176 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
177 System.out.println("param=" + paramfile);
179 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
181 BufferedReader is = new BufferedReader(new InputStreamReader(
184 while ((str4 = is.readLine()) != null)
186 System.out.println(str4);
192 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
193 // connection.setRequestMethod("POST" );
194 // connection.setRequestProperty("data", path );
195 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
196 // BufferedReader input = new BufferedReader(new
197 // InputStreamReader(connection.getInputStream()));
198 // //DataInputStream input = new
199 // DataInputStream(connection.getInputStream());
201 // while((c=input.readLine())!=null){
202 // System.out.print(c);
205 // BufferedReader in1 = new BufferedReader(is);
207 // OutputStream out1 = null;
208 // System.out.println("Step3");
209 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
217 // System.out.println(data.length());
218 // System.out.println("step2");
220 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
221 // System.out.println("step3");
222 // URLConnection conn = url.openConnection();
223 // conn.setDoOutput(true);
224 // OutputStreamWriter writer = new
225 // OutputStreamWriter(conn.getOutputStream());
228 // writer.write(data);
232 // StringBuffer answer = new StringBuffer();
233 // //BufferedReader reader = new BufferedReader(new
234 // InputStreamReader(conn.getInputStream()));
236 // while ((line = reader.readLine()) != null) {
237 // answer.append(line);
238 // System.out.println(line);
243 // Output the response
245 } catch (MalformedURLException ex)
247 ex.printStackTrace();
248 } catch (IOException ex)
250 ex.printStackTrace();
254 // in = new BufferedReader(new InputStreamReader(url.openStream()));
258 // out = new FileOutputStream("temp.rnaml");
259 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
261 // while ((str = in.readLine()) != null) {
262 // System.out.println(str);
264 // System.out.println(str);
268 // } catch (MalformedURLException e) {
269 // } catch (IOException e) {
274 // public BufferedWriter getReader()
276 // System.out.println("The buffer");