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;
35 public class Annotate3D
37 // protected BufferedReader in;
38 // protected BufferedWriter out;
42 System.out.println("Annotate3D");
44 // Create a URL for the desired page
45 // String id = "1HR2";
47 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?pdbid="+id);
48 // in = new BufferedReader(new InputStreamReader(url.openStream()));
50 // OutputStream out1 = null;
51 // out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
52 // while ((str = in.readLine()) != null) {
53 // System.out.println(str);
58 // } catch (MalformedURLException e) {
59 // } catch (IOException e) {
63 public AlignmentI getRNAMLFor(final FileParse source) throws IOException
67 StringBuffer sb = new StringBuffer();
69 Reader fpr = source.getReader();
71 char[] cbuff = new char[2048];
72 while ((p = fpr.read(cbuff)) > 0)
74 for (int i = 0; i < p; i++)
80 FileParse fp = new InputStreamParser(
81 jalview.ext.paradise.Annotate3D.getRNAMLForPDBFileAsString(sb
82 .toString()), source.getDataName());
83 AlignmentI nal = new FormatAdapter().readFromFile(fp, "RNAML");
87 if (x instanceof IOException)
89 throw ((IOException) x);
93 throw new IOException(
94 "Unexpected exception when handling RNAML translation of PDB data",
100 public Annotate3D(String path) throws InterruptedException
102 System.out.println("Annotate3D");
106 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
107 // System.out.println("Step1");
108 // FileReader r = new FileReader(inFile);
109 // BufferedReader in = new BufferedReader(r);
110 // StringBuffer content = new StringBuffer();
111 // System.out.println("Step2");
112 // while(in.readLine()!=null){
113 // content.append(in.readLine());
114 // //System.out.println("Step3"+in.readLine());
117 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
118 // URLEncoder.encode(content.toString(), "UTF-8");
119 // for (int i=0;i<data.length();i++)
121 // System.out.print(data.charAt(i));
124 // String data = "width=50&height=100";
126 // // Send the request
127 // FileReader r = new FileReader(path);
128 // BufferedReader in = new BufferedReader(r);
129 // StringBuffer content = new StringBuffer();
130 // System.out.println("Step1");
131 // while(in.readLine()!=null){
132 // content.append(in.readLine());
135 // System.out.println("Step2");
136 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
137 // URLEncoder.encode(content.toString(), "UTF-8");
138 // System.out.println("Step2");
140 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
141 // DataInputStream is = new DataInputStream(url.openStream());
143 // while ((str = is.readLine()) != null) {
144 // System.out.println(str);
147 FileReader r = new FileReader(path);
148 BufferedReader in = new BufferedReader(r);
152 while ((str = in.readLine()) != null)
154 // System.out.println(str);
156 content = content + str;
158 System.out.println("pdbfile=" + content.toString());
159 System.out.println("capacité=" + content.length());
160 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
161 System.out.println("param=" + paramfile);
163 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
165 BufferedReader is = new BufferedReader(new InputStreamReader(
168 while ((str4 = is.readLine()) != null)
170 System.out.println(str4);
176 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
177 // connection.setRequestMethod("POST" );
178 // connection.setRequestProperty("data", path );
179 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
180 // BufferedReader input = new BufferedReader(new
181 // InputStreamReader(connection.getInputStream()));
182 // //DataInputStream input = new
183 // DataInputStream(connection.getInputStream());
185 // while((c=input.readLine())!=null){
186 // System.out.print(c);
189 // BufferedReader in1 = new BufferedReader(is);
191 // OutputStream out1 = null;
192 // System.out.println("Step3");
193 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
201 // System.out.println(data.length());
202 // System.out.println("step2");
204 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
205 // System.out.println("step3");
206 // URLConnection conn = url.openConnection();
207 // conn.setDoOutput(true);
208 // OutputStreamWriter writer = new
209 // OutputStreamWriter(conn.getOutputStream());
212 // writer.write(data);
216 // StringBuffer answer = new StringBuffer();
217 // //BufferedReader reader = new BufferedReader(new
218 // InputStreamReader(conn.getInputStream()));
220 // while ((line = reader.readLine()) != null) {
221 // answer.append(line);
222 // System.out.println(line);
227 // Output the response
229 } catch (MalformedURLException ex)
231 ex.printStackTrace();
232 } catch (IOException ex)
234 ex.printStackTrace();
238 // in = new BufferedReader(new InputStreamReader(url.openStream()));
242 // out = new FileOutputStream("temp.rnaml");
243 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
245 // while ((str = in.readLine()) != null) {
246 // System.out.println(str);
248 // System.out.println(str);
252 // } catch (MalformedURLException e) {
253 // } catch (IOException e) {
258 // public BufferedWriter getReader()
260 // System.out.println("The buffer");