+ boolean headless = false;
+
+ protected Vector<String> services = null;
+
+ private static RestClient getInstance()
+ {
+ return (RestClient) ApplicationSingletonProvider.getInstance(RestClient.class);
+ }
+
+ public static RestClient makeShmmrRestClient()
+ {
+ String action = "Analysis",
+ description = "Sequence Harmony and Multi-Relief (Brandt et al. 2010)",
+ name = MessageManager.getString("label.multiharmony");
+ Hashtable<String, InputType> iparams = new Hashtable<>();
+ // jalview.ws.rest.params.JobConstant toolp;
+ // toolp = new jalview.ws.rest.JobConstant("tool","jalview");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new jalview.ws.rest.params.JobConstant("mbjob[method]","shmr");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new
+ // jalview.ws.rest.params.JobConstant("mbjob[description]","step 1");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new jalview.ws.rest.params.JobConstant("start_search","1");
+ // iparams.put(toolp.token, toolp);
+ // toolp = new jalview.ws.rest.params.JobConstant("blast","0");
+ // iparams.put(toolp.token, toolp);
+
+ jalview.ws.rest.params.Alignment aliinput = new jalview.ws.rest.params.Alignment();
+ // SHMR server has a 65K limit for content pasted into the 'ali' parameter,
+ // so we always upload our files.
+ aliinput.token = "ali_file";
+ aliinput.writeAsFile = true;
+ iparams.put(aliinput.token, aliinput);
+ jalview.ws.rest.params.SeqGroupIndexVector sgroups = new jalview.ws.rest.params.SeqGroupIndexVector();
+ sgroups.setMinsize(2);
+ sgroups.min = 2;// need at least two group defined to make a partition
+ iparams.put("groups", sgroups);
+ sgroups.token = "groups";
+ sgroups.sep = " ";
+ RestServiceDescription shmrService = new RestServiceDescription(action,
+ description, name,
+ "http://zeus.few.vu.nl/programs/shmrwww/index.php?tool=jalview", // ?tool=jalview&mbjob[method]=shmr&mbjob[description]=step1",
+ "?tool=jalview", iparams, true, false, '-');
+ // a priori knowledge of the data returned from the service
+ shmrService.addResultDatatype(JvDataType.ANNOTATION);
+ return new RestClient(shmrService);
+ }
+
+ public static RestClient[] getRestClients()
+ {
+ RestClient c = getInstance();
+
+ if (c.services == null)
+ {
+ c.services = new Vector<>();
+ try
+ {
+ for (RestServiceDescription descr : RestServiceDescription
+ .parseDescriptions(
+ jalview.bin.Cache.getDefault(RSBS_SERVICES,
+ makeShmmrRestClient().service.toString())))
+ {
+ c.services.add(descr.toString());
+ }
+ } catch (Exception ex)
+ {
+ System.err.println(
+ "Serious - RSBS descriptions in user preferences are corrupt!");
+ ex.printStackTrace();
+ }
+
+ }
+ RestClient[] lst = new RestClient[c.services.size()];
+ int i = 0;
+ for (String svc : c.services)
+ {
+ lst[i++] = new RestClient(new RestServiceDescription(svc));
+ }
+ return lst;
+ }
+
+ public static Vector<String> getRsbsDescriptions()
+ {
+ Vector<String> rsbsDescrs = new Vector<>();
+ for (RestClient rsbs : getRestClients())
+ {
+ rsbsDescrs.add(rsbs.getRestDescription().toString());
+ }
+ return rsbsDescrs;
+ }
+
+ public static void setRsbsServices(Vector<String> rsbsUrls)
+ {
+ if (rsbsUrls != null)
+ {
+ // TODO: consider validating services ?
+ RestClient c = getInstance();
+ c.services = new Vector<>(rsbsUrls);
+ StringBuffer sprop = new StringBuffer();
+ for (String s : c.services)
+ {
+ sprop.append(s);
+ }
+ Cache.setProperty(RSBS_SERVICES, sprop.toString());
+ }
+ else
+ {
+ Cache.removeProperty(RSBS_SERVICES);
+ }
+ }
+