X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fparadise%2FAnnotate3D.java;h=3b7044bb18fa5a1c8d14af9fadc60d04f119f925;hb=b3d9eaf8829a3aeb2bbc522315207a7940b0844e;hp=114de42ee4afa4b35a8fe864a956e91ac352fdcb;hpb=9d75efeeb9a6e51bd328f56e376dca4e007b635c;p=jalview.git
diff --git a/src/jalview/ext/paradise/Annotate3D.java b/src/jalview/ext/paradise/Annotate3D.java
index 114de42..3b7044b 100644
--- a/src/jalview/ext/paradise/Annotate3D.java
+++ b/src/jalview/ext/paradise/Annotate3D.java
@@ -1,22 +1,42 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ext.paradise;
+import jalview.util.JSONUtils;
+import jalview.util.MessageManager;
import jalview.ws.HttpClientUtils;
+import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONStreamAware;
import org.json.simple.parser.ContentHandler;
import org.json.simple.parser.ParseException;
@@ -25,29 +45,38 @@ import org.json.simple.parser.ParseException;
*
* @author jimp
*
- * History: v1.0 revised from original due to refactoring of
- * paradise-ubmc.u-strasbg.fr/webservices/annotate3d to
- * http://arn-ibmc.in2p3.fr/api/compute/2d?tool=rnaview
+ * @version v1.0 revised from original due to refactoring of
+ * paradise-ubmc.u-strasbg.fr/webservices/annotate3d to
+ * http://arn-ibmc.in2p3.fr/api/compute/2d?tool=rnaview
+ * See also testing URL from fjossinet:
+ * http://charn2-ibmc.u-strasbg.fr:8080/api/compute/2d
+ * If in doubt, check against the REST client at:
+ * https://github.com/fjossinet/RNA-Science
+ * -Toolbox/blob/master/pyrna/restclient.py
*/
public class Annotate3D
{
- private static String twoDtoolsURL = "http://arn-ibmc.in2p3.fr/api/compute/2d";
+ // also test with
+ // "http://charn2-ibmc.u-strasbg.fr:8080/api/compute/2d";
+ private static String twoDtoolsURL = "http://arn-ibmc.in2p3.fr/api/compute/2d?tool=rnaview";
+
private static ContentHandler createContentHandler()
{
- ContentHandler ch = new ContentHandler() {
+ ContentHandler ch = new ContentHandler()
+ {
@Override
public void startJSON() throws ParseException, IOException
{
// TODO Auto-generated method stub
-
+
}
@Override
public void endJSON() throws ParseException, IOException
{
// TODO Auto-generated method stub
-
+
}
@Override
@@ -65,8 +94,8 @@ public class Annotate3D
}
@Override
- public boolean startObjectEntry(String key) throws ParseException,
- IOException
+ public boolean startObjectEntry(String key)
+ throws ParseException, IOException
{
// TODO Auto-generated method stub
return false;
@@ -94,16 +123,17 @@ public class Annotate3D
}
@Override
- public boolean primitive(Object value) throws ParseException,
- IOException
+ public boolean primitive(Object value)
+ throws ParseException, IOException
{
// TODO Auto-generated method stub
return false;
}
-
+
};
return ch;
}
+
public static Iterator getRNAMLForPDBFileAsString(String pdbfile)
throws Exception
{
@@ -111,77 +141,118 @@ public class Annotate3D
vals.add(new BasicNameValuePair("tool", "rnaview"));
vals.add(new BasicNameValuePair("data", pdbfile));
vals.add(new BasicNameValuePair("output", "rnaml"));
- return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals));
+ // return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL,
+ // vals));
+ ArrayList readers = new ArrayList();
+ final BufferedReader postResponse = HttpClientUtils
+ .doHttpUrlPost(twoDtoolsURL, vals, 0, 0);
+ readers.add(postResponse);
+ return readers.iterator();
+
}
- public static Iterator processJsonResponseFor(Reader respons) throws Exception
+
+ /**
+ * @param respons
+ * @return
+ * @throws Exception
+ */
+ public static Iterator processJsonResponseFor(Reader respons)
+ throws Exception
{
- org.json.simple.parser.JSONParser jp = new org.json.simple.parser.JSONParser();
- try {
- final JSONArray responses = (JSONArray) jp.parse(respons);
- final Iterator rvals = responses.iterator();
- return new Iterator()
+ // BH 2019 never called?
+ try
+ {
+ @SuppressWarnings("unchecked")
+ final Iterator