+ * Asks registry to test the service on the host hostname\r
+ * \r
+ * @param hostname\r
+ * @param service\r
+ * @param writer\r
+ * @throws ConnectException\r
+ * @throws WebServiceException\r
+ */\r
+ public static void testService(String hostname, Services service,\r
+ PrintWriter writer) throws ConnectException, WebServiceException {\r
+ RegistryWS registry = connectToRegistry(hostname);\r
+ if (registry != null) {\r
+ String message = registry.testService(service);\r
+ writer.println("Service " + service + " testing results: ");\r
+ writer.println(message);\r
+ FileUtil.closeSilently(((Closeable) registry));\r
+ }\r
+ writer.flush();\r
+ }\r
+\r
+ public static Set<Services> getServices(String hostname)\r
+ throws WebServiceException, ConnectException {\r
+ RegistryWS registry = connectToRegistry(hostname);\r
+ Set<Services> services = Collections.EMPTY_SET;\r
+ if (registry != null) {\r
+ services = registry.getSupportedServices();\r
+ FileUtil.closeSilently(((Closeable) registry));\r
+ }\r
+ return services;\r
+ }\r
+\r
+ private static void listServices(String hostname)\r
+ throws WebServiceException, IOException {\r
+ Set<Services> services = Jws2Client.getServices(hostname);\r
+ if (!services.isEmpty()) {\r
+ System.out.println("Supported services are: "\r
+ + Services.toString(services));\r
+ } else {\r
+ System.out.println("Failed to connect to the registry! ");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Calculate conservation for sequences loaded from the file\r
+ * \r
+ * @param wsproxy\r
+ * a web service proxy\r
+ * @param file\r
+ * the file to read the results from\r
+ * @param preset\r
+ * Preset to use optional\r
+ * @param customOptions\r
+ * the list of options\r
+ * @return Set<Score> the conservation scores\r
+ * @throws UnknownFileFormatException\r
+ */\r
+ static <T> ScoreManager analize(List<FastaSequence> fastalist,\r
+ SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
+ List<Option<T>> customOptions) {\r
+\r
+ ScoreManager scores = null;\r
+ try {\r
+ String jobId = null;\r
+ if (customOptions != null && preset != null) {\r
+ System.out\r
+ .println("WARN: Parameters (-f) are defined together with a preset (-r) ignoring preset!");\r
+ }\r
+ if (customOptions != null) {\r
+ jobId = wsproxy.customAnalize(fastalist, customOptions);\r
+ } else if (preset != null) {\r
+ jobId = wsproxy.presetAnalize(fastalist, preset);\r
+ } else {\r
+ jobId = wsproxy.analize(fastalist);\r
+ }\r
+ System.out.println("\n\ncalling analise.........");\r
+ Thread.sleep(1000);\r
+ scores = wsproxy.getAnnotation(jobId);\r
+\r
+ } catch (JobSubmissionException e) {\r
+ System.err\r
+ .println("Exception while submitting job to a web server. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
+ } catch (ResultNotAvailableException e) {\r
+ System.err.println("Exception while waiting for results. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
+ } catch (InterruptedException e) {\r
+ // ignore and propagate an interruption\r
+ Thread.currentThread().interrupt();\r
+ System.err.println("Exception while waiting for results. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
+ } catch (WrongParameterException e) {\r
+ System.err\r
+ .println("Exception while parsing the web method input parameters. "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
+ }\r
+ return scores;\r
+\r
+ }\r
+\r
+ /**\r
+ * Calculate conservation for sequences loaded from the file\r
+ * \r
+ * @param wsproxy\r
+ * a web service proxy\r
+ * @param file\r
+ * the file to read the results from\r
+ * @param preset\r
+ * Preset to use optional\r
+ * @param customOptions\r
+ * the list of options\r
+ * @return Set<Score> the conservation scores\r
+ * @throws IOException\r
+ * @throws UnknownFileFormatException\r
+ */\r
+ static <T> ScoreManager analize(File file, SequenceAnnotation<T> wsproxy,\r
+ Preset<T> preset, List<Option<T>> customOptions) {\r
+ List<FastaSequence> fastalist = null;\r
+ try {\r
+ fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
+ assert !fastalist.isEmpty() : "Input is empty!";\r
+ } catch (IOException e) {\r
+ System.err\r
+ .println("Exception while reading the input file. "\r
+ + "Check that the input file contains a list of fasta formatted sequences! "\r
+ + "Exception details are below:");\r
+ e.printStackTrace();\r
+ } catch (UnknownFileFormatException e) {\r
+ System.err\r
+ .println("Exception while attempting to read the input file "\r
+ + "Exception details are below:");\r
+ System.out.println(e.getMessage());\r
+ e.printStackTrace();\r
+ }\r
+ return analize(fastalist, wsproxy, preset, customOptions);\r
+ }\r
+ /**\r
+ * Connects to a web service by the host and the service name web service\r
+ * type\r