From: pvtroshin Date: Thu, 2 Dec 2010 16:56:31 +0000 (+0000) Subject: AAConWS is working X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=212bbd43c19f645cccef34a608dc001fb694833c;p=jabaws.git AAConWS is working git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3416 e3abac25-378b-4346-85de-24260fe3988d --- diff --git a/.classpath b/.classpath index 7833d32..ab5b4be 100644 --- a/.classpath +++ b/.classpath @@ -10,8 +10,8 @@ - + diff --git a/IDEAS.txt b/IDEAS.txt index e2f9f7d..f9f65fd 100644 --- a/IDEAS.txt +++ b/IDEAS.txt @@ -41,4 +41,9 @@ and if it is so, then use the family) /homes/ws-dev1/servers/Test/webapps/JalviewWS/WEB-INF/classes/vamsas/pl/bin/jpred3_submit_concise /homes/ws-dev1/servers/Test/webapps/TestJWS/WEB-INF/classes/vamsas/pl/bin/jpred3_submit_concise /homes/ws-dev1/servers/Test/webapps/JalviewWS-back/WEB-INF/classes/vamsas/pl/bin/jpred3_submit_concise + + +JAXB - cannot serialize Maps and instance variables in Enums! +Best replacement for Maps is a custom object for key->value pair and a HashSet for storing the pairs. +JaxB cannot serialize instances of generic classes(?) \ No newline at end of file diff --git a/TODO.txt b/TODO.txt index b6d15ed..66b5984 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,6 +1,7 @@ TODO: -Publish jabaws-discuss contact information +Replace conservation.Method with server.ws.Method +and try building WS. If this does not work - get rid of Method Output file parsing for stat reporting cluster engine stat of www-jws2 user diff --git a/WEB-INF/lib/aaconservation.jar b/WEB-INF/lib/aaconservation.jar new file mode 100644 index 0000000..c41612e Binary files /dev/null and b/WEB-INF/lib/aaconservation.jar differ diff --git a/binaries/aaconservation.jar b/binaries/aaconservation.jar index db61ab7..c41612e 100644 Binary files a/binaries/aaconservation.jar and b/binaries/aaconservation.jar differ diff --git a/datamodel/compbio/data/sequence/Score.java b/datamodel/compbio/data/sequence/Score.java new file mode 100644 index 0000000..8a58db3 --- /dev/null +++ b/datamodel/compbio/data/sequence/Score.java @@ -0,0 +1,77 @@ +package compbio.data.sequence; + +import java.util.Arrays; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; + +import compbio.conservation.Method; +import compbio.util.annotation.Immutable; + +@XmlAccessorType(XmlAccessType.FIELD) +@Immutable +public class Score { + + private Method method; + + private List scores; + + private Score() { + // JaXB default constructor + } + + public Score(Method method, List scores) { + this.method = method; + this.scores = scores; + } + + public Method getMethod() { + return method; + } + + public List getScores() { + return scores; + } + + @Override + public String toString() { + return "Score [method=" + method + ", scores=" + scores + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((method == null) ? 0 : method.hashCode()); + result = prime * result + ((scores == null) ? 0 : scores.hashCode()); + return result; + } + + /* + * TODO test ! (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Score other = (Score) obj; + if (method != other.method) + return false; + if (scores == other.scores) { + return true; + } + if (scores == null) { + return false; + } + if (!Arrays.deepEquals(scores.toArray(), other.scores.toArray())) + return false; + return true; + } +} diff --git a/datamodel/compbio/data/sequence/SequenceUtil.java b/datamodel/compbio/data/sequence/SequenceUtil.java index 5946e78..c995585 100644 --- a/datamodel/compbio/data/sequence/SequenceUtil.java +++ b/datamodel/compbio/data/sequence/SequenceUtil.java @@ -25,6 +25,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.logging.Level; @@ -458,15 +459,14 @@ public final class SequenceUtil { * * @param results * output file of AAConservation - * @return {@link MultiAnnotatedSequence} + * @return Map with keys {@link Method} -> float[] */ - public static MultiAnnotatedSequence readResults(InputStream results) { + public static HashSet readAAConResults(InputStream results) { if (results == null) { throw new NullPointerException( "InputStream with results must be provided"); } - MultiAnnotatedSequence annotations = new MultiAnnotatedSequence( - Method.class); + HashSet annotations = new HashSet(); Scanner sc = new Scanner(results); sc.useDelimiter("#"); while (sc.hasNext()) { @@ -484,7 +484,7 @@ public final class SequenceUtil { Double value = valuesScanner.nextDouble(); values.add(value.floatValue()); } - annotations.addAnnotation(method, values); + annotations.add(new Score(method, values)); } return annotations; } diff --git a/runner/compbio/runner/conservation/AACon.java b/runner/compbio/runner/conservation/AACon.java index 5a1d752..ce4d293 100644 --- a/runner/compbio/runner/conservation/AACon.java +++ b/runner/compbio/runner/conservation/AACon.java @@ -20,12 +20,13 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; -import java.util.HashMap; +import java.util.HashSet; import java.util.List; import org.apache.log4j.Logger; -import compbio.conservation.Method; +import compbio.data.sequence.Score; +import compbio.data.sequence.SequenceUtil; import compbio.engine.client.CommandBuilder; import compbio.engine.client.Executable; import compbio.engine.client.SkeletalExecutable; @@ -66,13 +67,13 @@ public class AACon extends SkeletalExecutable { } // HashMap @Override - public HashMap getResults(String workDirectory) + public HashSet getResults(String workDirectory) throws ResultNotAvailableException { - // MultiAnnotatedSequence annotations = null; + HashSet annotations = null; try { InputStream inStream = new FileInputStream(new File(workDirectory, getOutput())); - // annotations = SequenceUtil.readResults(inStream); + annotations = SequenceUtil.readAAConResults(inStream); inStream.close(); } catch (FileNotFoundException e) { log.error(e.getMessage(), e.getCause()); @@ -84,7 +85,7 @@ public class AACon extends SkeletalExecutable { log.error(e.getMessage(), e.getCause()); throw new ResultNotAvailableException(e); } - return null; + return annotations; } private static String getLibPath() { diff --git a/testsrc/compbio/data/sequence/SequenceUtilTester.java b/testsrc/compbio/data/sequence/SequenceUtilTester.java index 742fa24..f526578 100644 --- a/testsrc/compbio/data/sequence/SequenceUtilTester.java +++ b/testsrc/compbio/data/sequence/SequenceUtilTester.java @@ -24,6 +24,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.HashSet; import java.util.List; import org.testng.annotations.Test; @@ -160,7 +161,6 @@ public class SequenceUtilTester { assertNotNull(aseqs); /* - * MultiAnnotatedSequence ma = new MultiAnnotatedSequence(); * Map> val = ma.getInstance(Trial.class); * List list = new ArrayList(); list.add(new * Float(1.2)); list.add(new Double(5.662)); val.put(Trial.one, @@ -181,9 +181,25 @@ public class SequenceUtilTester { } @Test - public void testReadResults() throws FileNotFoundException { - InputStream inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH - + "aacon_results.txt"); -// /System.out.println(SequenceUtil.readResults(inStream)); + public void testReadAAConResults() { + try { + InputStream inStream = new FileInputStream( + AllTestSuit.TEST_DATA_PATH + "aacon_results.txt"); + HashSet result = SequenceUtil.readAAConResults(inStream); + inStream.close(); + assertNotNull(result); + assertEquals(result.size(), 18); + + inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + + "aacon_result_single.out"); + result = SequenceUtil.readAAConResults(inStream); + inStream.close(); + assertNotNull(result); + assertEquals(result.size(), 1); + assertEquals(result.iterator().next().getScores().size(), 568); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } } } diff --git a/testsrc/compbio/ws/client/TestWSClient.java b/testsrc/compbio/ws/client/TestWSClient.java index 3928549..3eda42b 100644 --- a/testsrc/compbio/ws/client/TestWSClient.java +++ b/testsrc/compbio/ws/client/TestWSClient.java @@ -1,5 +1,6 @@ package compbio.ws.client; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.fail; @@ -8,6 +9,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; +import java.util.HashSet; import java.util.List; import javax.xml.namespace.QName; @@ -15,25 +17,26 @@ import javax.xml.ws.Service; import org.testng.annotations.Test; -import compbio.data.msa.MsaWS; -import compbio.data.sequence.Alignment; +import compbio.conservation.Method; +import compbio.data.msa.Annotation; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitExceededException; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.UnsupportedRuntimeException; import compbio.util.SysPrefs; -import compbio.ws.server.ClustalWS; +import compbio.ws.server.AAConWS; public class TestWSClient { @Test public void test() throws FileNotFoundException, IOException { - URL url = new URL("http://localhost:8080/jaba/ClustalWS?wsdl"); - String namespace = "http://msa.data.compbio/01/01/2010/"; - QName qname = new QName(namespace, "ClustalWS"); + URL url = new URL("http://localhost:8080/jabaws/AAConWS?wsdl"); + String namespace = "http://msa.data.compbio/01/12/2010/"; + QName qname = new QName(namespace, "AAConWS"); Service serv = Service.create(url, qname); /* * MsaWS msaws = serv.getPort(new QName( @@ -43,8 +46,8 @@ public class TestWSClient { // Annotation msaws = serv.getPort(new QName(namespace, // "ClustalWSPort"), Annotation.class); - MsaWS msaws = serv.getPort(new QName(namespace, - "ClustalWSPort"), MsaWS.class); + Annotation msaws = serv.getPort(new QName(namespace, + "AAConWSPort"), Annotation.class); // List fsl = SequenceUtil.readFasta(new FileInputStream( // AAConTester.test_alignment_input)); @@ -54,13 +57,21 @@ public class TestWSClient { List fsl = SequenceUtil.readFasta(new FileInputStream( CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" - + File.separator + "testlimit.in")); + + File.separator + "TO1381.fasta.aln")); try { - String jobId = msaws.align(fsl); - Alignment result = msaws.getResult(jobId); + System.out.println("Pres: " + + msaws.getPresets().getPresets().get(0)); + String jobId = msaws.analize(fsl); + System.out.println("J: " + jobId); + HashSet result = msaws.getConservation(jobId); assertNotNull(result); - System.out.println(result); + assertEquals(result.size(), 1); + assertEquals(result.iterator().next().getMethod(), Method.SHENKIN); + List scores = result.iterator().next().getScores(); + assertNotNull(scores); + assertEquals(scores.size(), 568); + } catch (UnsupportedRuntimeException e) { e.printStackTrace(); fail(e.getMessage()); @@ -74,6 +85,6 @@ public class TestWSClient { e.printStackTrace(); fail(e.getMessage()); } - System.out.println("Pres: " + msaws.getPresets()); + } } diff --git a/testsrc/testdata/aacon_result_single.out b/testsrc/testdata/aacon_result_single.out new file mode 100644 index 0000000..80a32a1 --- /dev/null +++ b/testsrc/testdata/aacon_result_single.out @@ -0,0 +1,2 @@ +#SHENKIN 8.653 12.481 12.481 12.481 12.481 12.481 12.481 12.481 12.481 7.862 12.481 12.481 12.481 12.481 7.862 12.481 12.481 12.481 12.481 12.481 12.481 12.481 12.481 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7.862 6 6 6 6 6 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 8.653 7.862 7.862 7.862 7.862 6 6 6 6 6 6 6 6 6 6 6 6 6 6 11.339 11.339 12.481 12.481 12.481 12.481 12.481 12.481 8.653 8.653 8.653 8.653 8.653 8.653 8.653 8.653 8.653 8.653 8.653 8.653 8.653 7.862 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 11.339 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 7.862 + diff --git a/webservices/compbio/data/msa/Annotation.java b/webservices/compbio/data/msa/Annotation.java index 45c1a68..fb8436d 100644 --- a/webservices/compbio/data/msa/Annotation.java +++ b/webservices/compbio/data/msa/Annotation.java @@ -1,12 +1,15 @@ package compbio.data.msa; import java.security.InvalidParameterException; +import java.util.HashSet; import java.util.List; +import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.Score; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitExceededException; import compbio.metadata.Option; @@ -59,6 +62,7 @@ public interface Annotation extends JManagement, Metadata { * is throw if the input sequences number or average length * exceeds what is defined by the limit */ + @WebMethod String analize( @WebParam(name = "fastaSequences") List sequences) throws UnsupportedRuntimeException, LimitExceededException, @@ -102,6 +106,7 @@ public interface Annotation extends JManagement, Metadata { * is throw if the input sequences number or average length * exceeds what is defined by the limit */ + @WebMethod String customAnalize( @WebParam(name = "fastaSequences") List sequences, @WebParam(name = "options") List> options) @@ -146,6 +151,7 @@ public interface Annotation extends JManagement, Metadata { * is throw if the input sequences number or average length * exceeds what is defined by the limit */ + @WebMethod String presetAnalize( @WebParam(name = "fastaSequences") List sequences, @WebParam(name = "preset") Preset preset) @@ -169,6 +175,8 @@ public interface Annotation extends JManagement, Metadata { * thrown if jobId is empty or cannot be recognised e.g. in * invalid format */ - String getResult(@WebParam(name = "jobId") String jobId) + @WebMethod + HashSet getConservation(@WebParam(name = "jobId") String jobId) throws ResultNotAvailableException; + } diff --git a/webservices/compbio/data/msa/jaxws/Align.java b/webservices/compbio/data/msa/jaxws/Align.java index e380bab..7f021d3 100644 --- a/webservices/compbio/data/msa/jaxws/Align.java +++ b/webservices/compbio/data/msa/jaxws/Align.java @@ -7,6 +7,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import compbio.data.sequence.FastaSequence; @XmlRootElement(name = "align", namespace = "http://msa.data.compbio/01/01/2010/") @XmlAccessorType(XmlAccessType.FIELD) @@ -14,14 +15,14 @@ import javax.xml.bind.annotation.XmlType; public class Align { @XmlElement(name = "fastaSequences", namespace = "") - private List fastaSequences; + private List fastaSequences; /** * * @return * returns List */ - public List getFastaSequences() { + public List getFastaSequences() { return this.fastaSequences; } @@ -30,7 +31,7 @@ public class Align { * @param fastaSequences * the value for the fastaSequences property */ - public void setFastaSequences(List fastaSequences) { + public void setFastaSequences(List fastaSequences) { this.fastaSequences = fastaSequences; } diff --git a/webservices/compbio/data/msa/jaxws/Analize.java b/webservices/compbio/data/msa/jaxws/Analize.java new file mode 100644 index 0000000..7ce56ac --- /dev/null +++ b/webservices/compbio/data/msa/jaxws/Analize.java @@ -0,0 +1,38 @@ + +package compbio.data.msa.jaxws; + +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import compbio.data.sequence.FastaSequence; + +@XmlRootElement(name = "analize", namespace = "http://msa.data.compbio/01/12/2010/") +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "analize", namespace = "http://msa.data.compbio/01/12/2010/") +public class Analize { + + @XmlElement(name = "fastaSequences", namespace = "") + private List fastaSequences; + + /** + * + * @return + * returns List + */ + public List getFastaSequences() { + return this.fastaSequences; + } + + /** + * + * @param fastaSequences + * the value for the fastaSequences property + */ + public void setFastaSequences(List fastaSequences) { + this.fastaSequences = fastaSequences; + } + +} diff --git a/webservices/compbio/data/msa/jaxws/GetProgressResponse.java b/webservices/compbio/data/msa/jaxws/AnalizeResponse.java similarity index 59% rename from webservices/compbio/data/msa/jaxws/GetProgressResponse.java rename to webservices/compbio/data/msa/jaxws/AnalizeResponse.java index 029a39e..f422adf 100644 --- a/webservices/compbio/data/msa/jaxws/GetProgressResponse.java +++ b/webservices/compbio/data/msa/jaxws/AnalizeResponse.java @@ -7,20 +7,20 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; -@XmlRootElement(name = "getProgressResponse", namespace = "http://msa.data.compbio/01/01/2010/") +@XmlRootElement(name = "analizeResponse", namespace = "http://msa.data.compbio/01/12/2010/") @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "getProgressResponse", namespace = "http://msa.data.compbio/01/01/2010/") -public class GetProgressResponse { +@XmlType(name = "analizeResponse", namespace = "http://msa.data.compbio/01/12/2010/") +public class AnalizeResponse { @XmlElement(name = "return", namespace = "") - private byte _return; + private String _return; /** * * @return - * returns byte + * returns String */ - public byte getReturn() { + public String getReturn() { return this._return; } @@ -29,7 +29,7 @@ public class GetProgressResponse { * @param _return * the value for the _return property */ - public void setReturn(byte _return) { + public void setReturn(String _return) { this._return = _return; } diff --git a/webservices/compbio/data/msa/jaxws/CustomAlign.java b/webservices/compbio/data/msa/jaxws/CustomAlign.java index d258864..92c9bab 100644 --- a/webservices/compbio/data/msa/jaxws/CustomAlign.java +++ b/webservices/compbio/data/msa/jaxws/CustomAlign.java @@ -7,6 +7,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import compbio.data.sequence.FastaSequence; +import compbio.metadata.Option; @XmlRootElement(name = "customAlign", namespace = "http://msa.data.compbio/01/01/2010/") @XmlAccessorType(XmlAccessType.FIELD) @@ -17,16 +19,16 @@ import javax.xml.bind.annotation.XmlType; public class CustomAlign { @XmlElement(name = "fastaSequences", namespace = "") - private List fastaSequences; + private List fastaSequences; @XmlElement(name = "options", namespace = "") - private List options; + private List