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) {
62 public Annotate3D(String path) throws InterruptedException
64 System.out.println("Annotate3D");
68 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
69 // System.out.println("Step1");
70 // FileReader r = new FileReader(inFile);
71 // BufferedReader in = new BufferedReader(r);
72 // StringBuffer content = new StringBuffer();
73 // System.out.println("Step2");
74 // while(in.readLine()!=null){
75 // content.append(in.readLine());
76 // //System.out.println("Step3"+in.readLine());
79 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
80 // URLEncoder.encode(content.toString(), "UTF-8");
81 // for (int i=0;i<data.length();i++)
83 // System.out.print(data.charAt(i));
86 // String data = "width=50&height=100";
88 // // Send the request
89 // FileReader r = new FileReader(path);
90 // BufferedReader in = new BufferedReader(r);
91 // StringBuffer content = new StringBuffer();
92 // System.out.println("Step1");
93 // while(in.readLine()!=null){
94 // content.append(in.readLine());
97 // System.out.println("Step2");
98 // String data = URLEncoder.encode("data", "UTF-8") + "=" +
99 // URLEncoder.encode(content.toString(), "UTF-8");
100 // System.out.println("Step2");
102 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
103 // DataInputStream is = new DataInputStream(url.openStream());
105 // while ((str = is.readLine()) != null) {
106 // System.out.println(str);
109 FileReader r = new FileReader(path);
110 BufferedReader in = new BufferedReader(r);
114 while ((str = in.readLine()) != null)
116 // System.out.println(str);
118 content = content + str;
120 System.out.println("pdbfile=" + content.toString());
121 System.out.println("capacité=" + content.length());
122 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
123 System.out.println("param=" + paramfile);
125 "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
127 BufferedReader is = new BufferedReader(new InputStreamReader(
130 while ((str4 = is.readLine()) != null)
132 System.out.println(str4);
138 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
139 // connection.setRequestMethod("POST" );
140 // connection.setRequestProperty("data", path );
141 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
142 // BufferedReader input = new BufferedReader(new
143 // InputStreamReader(connection.getInputStream()));
144 // //DataInputStream input = new
145 // DataInputStream(connection.getInputStream());
147 // while((c=input.readLine())!=null){
148 // System.out.print(c);
151 // BufferedReader in1 = new BufferedReader(is);
153 // OutputStream out1 = null;
154 // System.out.println("Step3");
155 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
163 // System.out.println(data.length());
164 // System.out.println("step2");
166 // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
167 // System.out.println("step3");
168 // URLConnection conn = url.openConnection();
169 // conn.setDoOutput(true);
170 // OutputStreamWriter writer = new
171 // OutputStreamWriter(conn.getOutputStream());
174 // writer.write(data);
178 // StringBuffer answer = new StringBuffer();
179 // //BufferedReader reader = new BufferedReader(new
180 // InputStreamReader(conn.getInputStream()));
182 // while ((line = reader.readLine()) != null) {
183 // answer.append(line);
184 // System.out.println(line);
189 // Output the response
191 } catch (MalformedURLException ex)
193 ex.printStackTrace();
194 } catch (IOException ex)
196 ex.printStackTrace();
200 // in = new BufferedReader(new InputStreamReader(url.openStream()));
204 // out = new FileOutputStream("temp.rnaml");
205 // out = new BufferedWriter(new FileWriter("temp.rnaml"));
207 // while ((str = in.readLine()) != null) {
208 // System.out.println(str);
210 // System.out.println(str);
214 // } catch (MalformedURLException e) {
215 // } catch (IOException e) {
220 // public BufferedWriter getReader()
222 // System.out.println("The buffer");