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 java.io.BufferedInputStream;
21 import java.io.BufferedReader;
22 import java.io.BufferedWriter;
23 import java.io.DataInputStream;
25 import java.io.FileOutputStream;
26 import java.io.FileReader;
27 import java.io.FileWriter;
28 import java.io.IOException;
29 import java.io.InputStream;
30 import java.io.InputStreamReader;
31 import java.io.OutputStream;
32 import java.io.OutputStreamWriter;
33 import java.io.Reader;
34 import java.io.StringWriter;
35 import java.net.HttpURLConnection;
36 import java.net.MalformedURLException;
38 import java.net.URLConnection;
40 import java.net.URLEncoder;
44 public class Annotate3D {
45 //protected BufferedReader in;
46 //protected BufferedWriter out;
50 System.out.println("Annotate3D");
52 // Create a URL for the desired page
54 //URL url = new URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?pdbid="+id);
55 //in = new BufferedReader(new InputStreamReader(url.openStream()));
57 //OutputStream out1 = null;
58 //out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
59 //while ((str = in.readLine()) != null) {
60 //System.out.println(str);
65 //} catch (MalformedURLException e) {
66 //} catch (IOException e) {
70 public Annotate3D(String path) throws InterruptedException{
71 System.out.println("Annotate3D");
73 // //URL url = new URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
74 // System.out.println("Step1");
75 // FileReader r = new FileReader(inFile);
76 // BufferedReader in = new BufferedReader(r);
77 // StringBuffer content = new StringBuffer();
78 // System.out.println("Step2");
79 // while(in.readLine()!=null){
80 // content.append(in.readLine());
81 // //System.out.println("Step3"+in.readLine());
84 // String data = URLEncoder.encode("data", "UTF-8") + "=" + URLEncoder.encode(content.toString(), "UTF-8");
85 // for (int i=0;i<data.length();i++)
87 // System.out.print(data.charAt(i));
90 //String data = "width=50&height=100";
93 // // Send the request
94 // FileReader r = new FileReader(path);
95 // BufferedReader in = new BufferedReader(r);
96 // StringBuffer content = new StringBuffer();
97 // System.out.println("Step1");
98 // while(in.readLine()!=null){
99 // content.append(in.readLine());
102 // System.out.println("Step2");
103 // String data = URLEncoder.encode("data", "UTF-8") + "=" + URLEncoder.encode(content.toString(), "UTF-8");
104 // System.out.println("Step2");
105 // URL url = new URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
106 // DataInputStream is = new DataInputStream(url.openStream());
108 // while ((str = is.readLine()) != null) {
109 // System.out.println(str);
112 FileReader r = new FileReader(path);
113 BufferedReader in = new BufferedReader(r);
117 while((str=in.readLine())!=null){
118 //System.out.println(str);
122 System.out.println("pdbfile="+content.toString());
123 System.out.println("capacité="+content.length());
124 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
125 System.out.println("param="+paramfile);
126 URL url = new URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+content);
127 BufferedReader is = new BufferedReader(new InputStreamReader(url.openStream()));
129 while ((str4 = is.readLine()) != null) {
130 System.out.println(str4);
136 // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
137 // connection.setRequestMethod("POST" );
138 // connection.setRequestProperty("data", path );
139 // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
140 // BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
141 // //DataInputStream input = new DataInputStream(connection.getInputStream());
143 // while((c=input.readLine())!=null){
144 // System.out.print(c);
147 //BufferedReader in1 = new BufferedReader(is);
149 // OutputStream out1 = null;
150 // System.out.println("Step3");
151 // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
159 //System.out.println(data.length());
160 //System.out.println("step2");
161 //URL url = new URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
162 //System.out.println("step3");
163 //URLConnection conn = url.openConnection();
164 //conn.setDoOutput(true);
165 //OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
168 //writer.write(data);
172 // StringBuffer answer = new StringBuffer();
173 // //BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
175 // while ((line = reader.readLine()) != null) {
176 // answer.append(line);
177 // System.out.println(line);
182 //Output the response
185 } catch (MalformedURLException ex) {
186 ex.printStackTrace();
187 } catch (IOException ex) {
188 ex.printStackTrace();
192 //in = new BufferedReader(new InputStreamReader(url.openStream()));
197 //out = new FileOutputStream("temp.rnaml");
198 //out = new BufferedWriter(new FileWriter("temp.rnaml"));
200 //while ((str = in.readLine()) != null) {
201 //System.out.println(str);
203 //System.out.println(str);
208 // } catch (MalformedURLException e) {
209 // } catch (IOException e) {
214 //public BufferedWriter getReader()
216 //System.out.println("The buffer");