X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fclient%2FAAConClient.java;h=f7f26038eb03001fe9da7605d7fb9e4964b229df;hb=1e1c3681ba25ee1797a46f871b8c80f259afe2ca;hp=34fc751a2f915414bb68da74f09bc772d62774fa;hpb=e98ca8829b7c42c00f2f2588e1168d3f31eb248f;p=jabaws.git diff --git a/webservices/compbio/ws/client/AAConClient.java b/webservices/compbio/ws/client/AAConClient.java index 34fc751..f7f2603 100644 --- a/webservices/compbio/ws/client/AAConClient.java +++ b/webservices/compbio/ws/client/AAConClient.java @@ -1,6 +1,6 @@ -/* Copyright (c) 2010 Peter Troshin +/* Copyright (c) 2011 Peter Troshin * - * Amino Acid Conservation Web Service client @version: 1.0 + * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -30,11 +30,11 @@ import static compbio.ws.client.Constraints.pseparator; import java.io.Closeable; import java.io.File; import java.io.IOException; -import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.Writer; import java.net.MalformedURLException; import java.net.URL; import java.util.List; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -42,9 +42,9 @@ import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.WebServiceException; -import compbio.data.msa.Annotation; +import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.Score; +import compbio.data.sequence.ScoreManager; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; import compbio.metadata.JobSubmissionException; @@ -102,7 +102,7 @@ public class AAConClient { File parametersFile = IOHelper.getFile(cmd, paramFile, true); String presetName = CmdHelper.getPresetName(cmd); - Annotation msaws = connect(); + SequenceAnnotation msaws = connect(); Preset preset = null; if (presetName != null) { preset = MetadataHelper.getPreset(msaws, presetName); @@ -113,17 +113,17 @@ public class AAConClient { customOptions = MetadataHelper.processParameters(prms, msaws.getRunnerOptions()); } - Set result = null; + ScoreManager result = null; if (inputFile != null) { System.out.println("Calculating conservation..."); result = analize(inputFile, msaws, preset, customOptions); - OutputStream outStream = null; + Writer outStream = null; if (outFile != null) { - outStream = IOHelper.getOutStream(outFile); + outStream = IOHelper.getWriter(outFile); } else { // this stream is going to be closed later which is fine as // std.out will not be - outStream = System.out; + outStream = new PrintWriter(System.out, true); } writeOut(outStream, result); // stream is closed in the method no need to close it here @@ -153,17 +153,17 @@ public class AAConClient { * @param result * the AACon scores to output */ - static void writeOut(OutputStream outStream, Set result) { + static void writeOut(Writer writer, ScoreManager result) { try { - Score.write(result, outStream); + result.writeOut(writer); } catch (IOException e) { System.err .println("Problems writing output file! Stack trace is below: "); e.printStackTrace(); } finally { - if (outStream != null) { + if (writer != null) { try { - outStream.close(); + writer.close(); } catch (IOException ignored) { // e.printStackTrace(); } @@ -175,11 +175,12 @@ public class AAConClient { * Connects to a AACon web service by the host and the service name * * - * @return {@link Annotation} + * @return {@link AlignmentAnnotation} * @throws WebServiceException * if cannot connect to a web service */ - public static Annotation connect() throws WebServiceException { + public static SequenceAnnotation connect() + throws WebServiceException { URL url = null; log.log(Level.FINE, "Attempting to connect..."); try { @@ -193,8 +194,8 @@ public class AAConClient { QName portName = new QName(QUALIFIED_SERVICE_NAME, "AAConWS" + "Port"); @SuppressWarnings("unchecked") - Annotation serviceIF = serv - .getPort(portName, Annotation.class); + SequenceAnnotation serviceIF = serv.getPort(portName, + SequenceAnnotation.class); log.log(Level.FINE, "Connected successfully!"); return serviceIF; @@ -214,11 +215,11 @@ public class AAConClient { * @return Set the conservation scores * @throws UnknownFileFormatException */ - static Set analize(File file, Annotation wsproxy, + static ScoreManager analize(File file, SequenceAnnotation wsproxy, Preset preset, List> customOptions) { List fastalist = null; - Set scores = null; + ScoreManager scores = null; try { fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());