Clover icon

Coverage Report

  1. Project Clover database Fri Nov 1 2024 11:46:37 GMT
  2. Package jalview.ws.jws1

File Annotate3D.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
59% of files have more coverage

Code metrics

14
42
3
1
285
109
13
0.31
14
3
4.33

Classes

Class Line # Actions
Annotate3D 41 42 13
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.ws.jws1;
22   
23    import java.io.BufferedReader;
24    import java.io.FileReader;
25    import java.io.IOException;
26    import java.io.InputStreamReader;
27    import java.io.Reader;
28    import java.net.MalformedURLException;
29    import java.net.URL;
30    import java.net.URLEncoder;
31    import java.util.Iterator;
32   
33    import jalview.datamodel.AlignmentI;
34    import jalview.io.FileFormat;
35    import jalview.io.FileParse;
36    import jalview.io.FormatAdapter;
37    import jalview.io.InputStreamParser;
38    import jalview.util.HttpUtils;
39    import jalview.util.MessageManager;
40   
 
41    public class Annotate3D
42    {
43    // protected BufferedReader in;
44    // protected BufferedWriter out;
45   
 
46  0 toggle public Annotate3D()
47    {
48  0 jalview.bin.Console.outPrintln("Annotate3D");
49    // try {
50    // Create a URL for the desired page
51    // String id = "1HR2";
52    // URL url = new
53    // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?pdbid="+id);
54    // in = new BufferedReader(new InputStreamReader(url.openStream()));
55    // String str;
56    // OutputStream out1 = null;
57    // out = new BufferedWriter(new OutputStreamWriter(out1, "temp.rnaml"));
58    // while ((str = in.readLine()) != null) {
59    // jalview.bin.Console.outPrintln(str);
60    // out.write(str);
61    // }
62    // in.close();
63    // out.close();
64    // } catch (MalformedURLException e) {
65    // } catch (IOException e) {
66    // }
67    }
68   
 
69  0 toggle public AlignmentI getRNAMLFor(final FileParse source) throws IOException
70    {
71  0 try
72    {
73  0 StringBuffer sb = new StringBuffer();
74   
75  0 Reader fpr = source.getReader();
76  0 int p = 0;
77  0 char[] cbuff = new char[2048];
78  0 while ((p = fpr.read(cbuff)) > 0)
79    {
80  0 for (int i = 0; i < p; i++)
81    {
82  0 sb.append(cbuff[i]);
83    }
84    }
85  0 Iterator<Reader> r = jalview.ext.paradise.Annotate3D
86    .getRNAMLForPDBFileAsString(sb.toString());
87  0 AlignmentI al = null;
88  0 while (r.hasNext())
89    {
90  0 FileParse fp = new InputStreamParser(r.next(),
91    source.getDataName());
92  0 AlignmentI nal = new FormatAdapter().readFromFile(fp,
93    FileFormat.Rnaml);
94  0 if (al == null)
95    {
96  0 al = nal;
97    }
98    else
99    {
100  0 al.append(nal);
101    }
102    }
103  0 return al;
104    } catch (Throwable x)
105    {
106  0 if (x instanceof IOException)
107    {
108  0 throw ((IOException) x);
109    }
110    else
111    {
112  0 throw new IOException(MessageManager.getString(
113    "exception.unexpected_handling_rnaml_translation_for_pdb"),
114    x);
115    }
116    }
117    }
118   
 
119  0 toggle public Annotate3D(String path) throws InterruptedException
120    {
121  0 jalview.bin.Console.outPrintln("Annotate3D");
122  0 try
123    {
124    // //URL url = new
125    // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+inFile);
126    // jalview.bin.Console.outPrintln("Step1");
127    // FileReader r = new FileReader(inFile);
128    // BufferedReader in = new BufferedReader(r);
129    // StringBuffer content = new StringBuffer();
130    // jalview.bin.Console.outPrintln("Step2");
131    // while(in.readLine()!=null){
132    // content.append(in.readLine());
133    // //jalview.bin.Console.outPrintln("Step3"+in.readLine());
134    // }
135    //
136    // String data = URLEncoder.encode("data", "UTF-8") + "=" +
137    // URLEncoder.encode(content.toString(), "UTF-8");
138    // for (int i=0;i<data.length();i++)
139    // {
140    // System.out.print(data.charAt(i));
141    // }
142   
143    // String data = "width=50&height=100";
144   
145    // // Send the request
146    // FileReader r = new FileReader(path);
147    // BufferedReader in = new BufferedReader(r);
148    // StringBuffer content = new StringBuffer();
149    // jalview.bin.Console.outPrintln("Step1");
150    // while(in.readLine()!=null){
151    // content.append(in.readLine());
152    //
153    // }
154    // jalview.bin.Console.outPrintln("Step2");
155    // String data = URLEncoder.encode("data", "UTF-8") + "=" +
156    // URLEncoder.encode(content.toString(), "UTF-8");
157    // jalview.bin.Console.outPrintln("Step2");
158    // URL url = new
159    // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
160    // DataInputStream is = new DataInputStream(url.openStream());
161    // String str;
162    // while ((str = is.readLine()) != null) {
163    // jalview.bin.Console.outPrintln(str);
164    // //out.write(str);
165    // }
166  0 FileReader r = new FileReader(path);
167  0 BufferedReader in = new BufferedReader(r);
168  0 String content = "";
169  0 String str;
170   
171  0 while ((str = in.readLine()) != null)
172    {
173    // jalview.bin.Console.outPrintln(str);
174   
175  0 content = content + str;
176    }
177  0 jalview.bin.Console.outPrintln("pdbfile=" + content.toString());
178  0 jalview.bin.Console.outPrintln("capacité=" + content.length());
179  0 String paramfile = URLEncoder.encode(content.toString(), "UTF-8");
180  0 jalview.bin.Console.outPrintln("param=" + paramfile);
181  0 URL url = new URL(
182    "http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="
183    + content);
184  0 BufferedReader is = new BufferedReader(
185    new InputStreamReader(HttpUtils.openStream(url)));
186  0 String str4;
187  0 while ((str4 = is.readLine()) != null)
188    {
189  0 jalview.bin.Console.outPrintln(str4);
190    // out.write(str);
191    }
192  0 in.close();
193  0 is.close();
194   
195    // HttpURLConnection connection = (HttpURLConnection)url.openConnection();
196    // connection.setRequestMethod("POST" );
197    // connection.setRequestProperty("data", path );
198    // //connection.setRequestProperty("nomDuChamp2", "valeurDuChamp2" );
199    // BufferedReader input = new BufferedReader(new
200    // InputStreamReader(connection.getInputStream()));
201    // //DataInputStream input = new
202    // DataInputStream(connection.getInputStream());
203    // String c;
204    // while((c=input.readLine())!=null){
205    // System.out.print(c);
206    // }
207    // input.close();
208    // BufferedReader in1 = new BufferedReader(is);
209   
210    // OutputStream out1 = null;
211    // jalview.bin.Console.outPrintln("Step3");
212    // BufferedWriter out = new BufferedWriter(new OutputStreamWriter(out1,
213    // "temp.rnaml"));
214    //
215    // in.close();
216    // out.close();
217   
218    // return;
219   
220    // jalview.bin.Console.outPrintln(data.length());
221    // jalview.bin.Console.outPrintln("step2");
222    // URL url = new
223    // URL("http://paradise-ibmc.u-strasbg.fr/webservices/annotate3d?data="+data);
224    // jalview.bin.Console.outPrintln("step3");
225    // URLConnection conn = url.openConnection();
226    // conn.setDoOutput(true);
227    // OutputStreamWriter writer = new
228    // OutputStreamWriter(conn.getOutputStream());
229   
230    // write parameters
231    // writer.write(data);
232    // writer.flush();
233   
234    // Get the response
235    // StringBuffer answer = new StringBuffer();
236    // //BufferedReader reader = new BufferedReader(new
237    // InputStreamReader(conn.getInputStream()));
238    // //String line;
239    // while ((line = reader.readLine()) != null) {
240    // answer.append(line);
241    // jalview.bin.Console.outPrintln(line);
242    // }
243    // writer.close();
244    // reader.close();
245   
246    // Output the response
247   
248    } catch (MalformedURLException ex)
249    {
250  0 ex.printStackTrace();
251    } catch (IOException ex)
252    {
253  0 ex.printStackTrace();
254    }
255    }
256   
257    // in = new BufferedReader(new InputStreamReader(url.openStream()));
258   
259    // String str;
260   
261    // out = new FileOutputStream("temp.rnaml");
262    // out = new BufferedWriter(new FileWriter("temp.rnaml"));
263   
264    // while ((str = in.readLine()) != null) {
265    // jalview.bin.Console.outPrintln(str);
266    // out.write(str);
267    // jalview.bin.Console.outPrintln(str);
268    // in.close();
269   
270    // out.close();
271    // } catch (MalformedURLException e) {
272    // } catch (IOException e) {
273    // }
274    //
275    // }
276   
277    // public BufferedWriter getReader()
278    // {
279    // jalview.bin.Console.outPrintln("The buffer");
280   
281    // return out;
282   
283    // }
284   
285    }