From 6adca61e46b4daf4136621f942f313c74e44e61d Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Mon, 20 Dec 2010 13:56:37 +0000 Subject: [PATCH] Further work on AAConWS git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3534 e3abac25-378b-4346-85de-24260fe3988d --- .../{Method.java => ConservationMethod.java} | 4 +- .../compbio/data/sequence/SMERFSConstraints.java | 40 ++++++++++++++++++ datamodel/compbio/data/sequence/Score.java | 6 +-- datamodel/compbio/data/sequence/SequenceUtil.java | 4 +- .../compbio/runner/conservation/AAConTester.java | 8 ++-- testsrc/compbio/ws/client/TestAAConWS.java | 35 ++++++++-------- webservices/compbio/data/msa/Annotation.java | 43 ++++++++++++++++++++ webservices/compbio/ws/client/Services.java | 1 - webservices/compbio/ws/server/AAConWS.java | 10 +++++ 9 files changed, 120 insertions(+), 31 deletions(-) rename datamodel/compbio/data/sequence/{Method.java => ConservationMethod.java} (96%) create mode 100644 datamodel/compbio/data/sequence/SMERFSConstraints.java diff --git a/datamodel/compbio/data/sequence/Method.java b/datamodel/compbio/data/sequence/ConservationMethod.java similarity index 96% rename from datamodel/compbio/data/sequence/Method.java rename to datamodel/compbio/data/sequence/ConservationMethod.java index e8764eb..92130f1 100644 --- a/datamodel/compbio/data/sequence/Method.java +++ b/datamodel/compbio/data/sequence/ConservationMethod.java @@ -21,10 +21,10 @@ package compbio.data.sequence; * * @author Agnieszka Golicz & Peter Troshin */ -public enum Method { +public enum ConservationMethod { KABAT, JORES, SCHNEIDER, SHENKIN, GERSTEIN, TAYLOR_GAPS, TAYLOR_NO_GAPS, ZVELIBIL, KARLIN, ARMON, THOMPSON, NOT_LANCET, MIRNY, WILLIAMSON, LANDGRAF, SANDER, VALDAR, SMERFS; - public static Method getMethod(String meth) { + public static ConservationMethod getMethod(String meth) { meth = meth.trim().toLowerCase(); if (meth.equalsIgnoreCase(KABAT.toString())) { return KABAT; diff --git a/datamodel/compbio/data/sequence/SMERFSConstraints.java b/datamodel/compbio/data/sequence/SMERFSConstraints.java new file mode 100644 index 0000000..ca8496e --- /dev/null +++ b/datamodel/compbio/data/sequence/SMERFSConstraints.java @@ -0,0 +1,40 @@ +package compbio.data.sequence; + +/** + * Enumeration defining two constraints for SMERFS columns score calculation. + * MAX_SCORE gives the highest core of all the windows the column belongs to. + * MID_SCORE gives the window score to the column in the middle. + * + * @author Agnieszka Golicz & Peter Troshin + */ +public enum SMERFSConstraints { + + MAX_SCORE, MID_SCORE; + + /** + * Default column scoring schema + */ + public static final SMERFSConstraints DEFAULT_COLUMN_SCORE = SMERFSConstraints.MID_SCORE; + + /** + * Default window size value for SMERFS algorithm + */ + public static final int DEFAULT_WINDOW_SIZE = 7; + + /** + * Default gap threshold value for SMERFS algorithm + */ + public static final double DEFAULT_GAP_THRESHOLD = 0.1; + + public static SMERFSConstraints getSMERFSColumnScore(String score) { + + score = score.trim().toLowerCase(); + if (score.equalsIgnoreCase(SMERFSConstraints.MAX_SCORE.toString())) { + return SMERFSConstraints.MAX_SCORE; + } + if (score.equalsIgnoreCase(SMERFSConstraints.MID_SCORE.toString())) { + return SMERFSConstraints.MID_SCORE; + } + return null; + } +} diff --git a/datamodel/compbio/data/sequence/Score.java b/datamodel/compbio/data/sequence/Score.java index 3416e78..0e49a08 100644 --- a/datamodel/compbio/data/sequence/Score.java +++ b/datamodel/compbio/data/sequence/Score.java @@ -12,7 +12,7 @@ import compbio.util.annotation.Immutable; @Immutable public class Score { - private Method method; + private ConservationMethod method; private List scores; @@ -20,12 +20,12 @@ public class Score { // JaXB default constructor } - public Score(Method method, List scores) { + public Score(ConservationMethod method, List scores) { this.method = method; this.scores = scores; } - public Method getMethod() { + public ConservationMethod getMethod() { return method; } diff --git a/datamodel/compbio/data/sequence/SequenceUtil.java b/datamodel/compbio/data/sequence/SequenceUtil.java index ddd1222..20628a1 100644 --- a/datamodel/compbio/data/sequence/SequenceUtil.java +++ b/datamodel/compbio/data/sequence/SequenceUtil.java @@ -467,7 +467,7 @@ public final class SequenceUtil { * * @param results * output file of AAConservation - * @return Map with keys {@link Method} -> float[] + * @return Map with keys {@link ConservationMethod} -> float[] */ public static HashSet readAAConResults(InputStream results) { if (results == null) { @@ -483,7 +483,7 @@ public final class SequenceUtil { assert spacePos > 0 : "Space is expected as delimited between method " + "name and values!"; String methodLine = line.substring(0, spacePos); - Method method = Method.getMethod(methodLine); + ConservationMethod method = ConservationMethod.getMethod(methodLine); assert method != null : "Method " + methodLine + " is not recognized! "; Scanner valuesScanner = new Scanner(line.substring(spacePos)); diff --git a/testsrc/compbio/runner/conservation/AAConTester.java b/testsrc/compbio/runner/conservation/AAConTester.java index edf637b..fd3749b 100644 --- a/testsrc/compbio/runner/conservation/AAConTester.java +++ b/testsrc/compbio/runner/conservation/AAConTester.java @@ -37,7 +37,7 @@ import org.ggf.drmaa.JobInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import compbio.data.sequence.Method; +import compbio.data.sequence.ConservationMethod; import compbio.data.sequence.MultiAnnotatedSequence; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; @@ -188,7 +188,7 @@ public class AAConTester { lr.executeJob(); ConfiguredExecutable al1 = lr.waitForResult(); assertNotNull(al1.getResults()); - MultiAnnotatedSequence annotations = confAAcon.getResults(); + MultiAnnotatedSequence annotations = confAAcon.getResults(); assertNotNull(annotations); assertEquals(annotations.getAnnotations().size(), 1); assertEquals(al1.getResults(), annotations); @@ -219,7 +219,7 @@ public class AAConTester { lr.executeJob(); ConfiguredExecutable al1 = lr.waitForResult(); assertNotNull(al1.getResults()); - MultiAnnotatedSequence annotations = confAAcon.getResults(); + MultiAnnotatedSequence annotations = confAAcon.getResults(); assertNotNull(annotations); assertEquals(annotations.getAnnotations().size(), 13); assertEquals(al1.getResults(), annotations); @@ -252,7 +252,7 @@ public class AAConTester { lr.executeJob(); ConfiguredExecutable al1 = lr.waitForResult(); assertNotNull(al1.getResults()); - MultiAnnotatedSequence annotations = confAAcon.getResults(); + MultiAnnotatedSequence annotations = confAAcon.getResults(); assertNotNull(annotations); assertEquals(annotations.getAnnotations().size(), 3); assertEquals(al1.getResults(), annotations); diff --git a/testsrc/compbio/ws/client/TestAAConWS.java b/testsrc/compbio/ws/client/TestAAConWS.java index a6affb9..e0b002c 100644 --- a/testsrc/compbio/ws/client/TestAAConWS.java +++ b/testsrc/compbio/ws/client/TestAAConWS.java @@ -8,21 +8,17 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import javax.xml.namespace.QName; -import javax.xml.ws.Service; - import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import compbio.data.msa.Annotation; +import compbio.data.msa.JABAService; import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.Method; +import compbio.data.sequence.ConservationMethod; import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; import compbio.metadata.JobSubmissionException; @@ -41,18 +37,19 @@ public class TestAAConWS { @BeforeTest void initConnection() { - URL url = null; - try { - url = new URL("http://localhost:8080/jabaws/AAConWS?wsdl"); - } catch (MalformedURLException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - String namespace = "http://msa.data.compbio/01/12/2010/"; - QName qname = new QName(namespace, "AAConWS"); - Service serv = Service.create(url, qname); - msaws = serv.getPort(new QName(namespace, "AAConWSPort"), - Annotation.class); + /* + * URL url = null; try { url = new + * URL("http://localhost:8080/jabaws/AAConWS?wsdl"); } catch + * (MalformedURLException e) { e.printStackTrace(); + * fail(e.getLocalizedMessage()); } String namespace = + * "http://msa.data.compbio/01/12/2010/"; QName qname = new + * QName(namespace, "AAConWS"); Service serv = Service.create(url, + * qname); msaws = serv.getPort(new QName(namespace, "AAConWSPort"), + * Annotation.class); + */ + JABAService client = Jws2Client.connect("http://localhost:8080/jabaws", + Services.AAConWS); + msaws = (Annotation) client; } @Test @@ -83,7 +80,7 @@ public class TestAAConWS { HashSet result = msaws.getAnnotation(jobId); assertNotNull(result); assertEquals(result.size(), 1); - assertEquals(result.iterator().next().getMethod(), Method.SHENKIN); + assertEquals(result.iterator().next().getMethod(), ConservationMethod.SHENKIN); List scores = result.iterator().next().getScores(); assertNotNull(scores); assertEquals(scores.size(), 568); diff --git a/webservices/compbio/data/msa/Annotation.java b/webservices/compbio/data/msa/Annotation.java index 27a1d55..1de9f30 100644 --- a/webservices/compbio/data/msa/Annotation.java +++ b/webservices/compbio/data/msa/Annotation.java @@ -9,6 +9,7 @@ import javax.jws.WebParam; import javax.jws.WebService; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.SMERFSConstraints; import compbio.data.sequence.Score; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitExceededException; @@ -163,6 +164,48 @@ public interface Annotation extends JABAService, JManagement, Metadata { JobSubmissionException, WrongParameterException; /** + * + * Analyse the sequences. The actual analysis algorithm is defined by the + * type T. + * + * Any dataset containing a greater number of sequences or the average + * length of the sequences are greater then defined in the default Limit + * will not be accepted for an alignment operation and + * JobSubmissionException will be thrown. + * + * @param sequences + * List of FastaSequence objects. The programme does not perform + * any sequence validity checks. Nor does it checks whether the + * sequences names are unique. It is responsibility of the caller + * to validate this information + * @return jobId - unique identifier for the job + * @throws JobSubmissionException + * is thrown when the job could not be submitted due to the + * following reasons: 1) The number of sequences in the + * submission or their average length is greater then defined by + * the default Limit. 2) Any problems on the server side e.g. it + * is misconfigured or malfunction, is reported via this + * exception. In the first case the information on the limit + * could be obtained from an exception. + * @throws InvalidParameterException + * thrown if input list of fasta sequence is null or empty + * @throws UnsupportedRuntimeException + * thrown if server OS does not support native executables for a + * given web service, e.g. JABAWS is deployed on Windows and + * Mafft service is called + * @throws LimitExceededException + * is throw if the input sequences number or average length + * exceeds what is defined by the limit + */ + @WebMethod + String customSMERFS( + @WebParam(name = "fastaSequences") List sequences, + int windowWidth, SMERFSConstraints scoringMethod, + float gapTreshold, boolean normalize) + throws UnsupportedRuntimeException, LimitExceededException, + JobSubmissionException; + + /** * Return the result of the job. * * @param jobId diff --git a/webservices/compbio/ws/client/Services.java b/webservices/compbio/ws/client/Services.java index 95a0a89..6734a36 100644 --- a/webservices/compbio/ws/client/Services.java +++ b/webservices/compbio/ws/client/Services.java @@ -70,7 +70,6 @@ public enum Services { switch (this) { case AAConWS : - return service.getPort(portName, Annotation.class); // deliberate leaking diff --git a/webservices/compbio/ws/server/AAConWS.java b/webservices/compbio/ws/server/AAConWS.java index a32533f..f9d8ce6 100644 --- a/webservices/compbio/ws/server/AAConWS.java +++ b/webservices/compbio/ws/server/AAConWS.java @@ -13,6 +13,7 @@ import org.apache.log4j.Logger; import compbio.data.msa.Annotation; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.SMERFSConstraints; import compbio.data.sequence.Score; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; @@ -174,4 +175,13 @@ public class AAConWS implements Annotation { return WSUtil.align(sequences, confAAcon, null, "presetAnalize", limit); } + @Override + public String customSMERFS(List sequences, int windowWidth, + SMERFSConstraints scoringMethod, float gapTreshold, + boolean normalize) throws UnsupportedRuntimeException, + LimitExceededException, JobSubmissionException { + // TODO Auto-generated method stub + return null; + } + } -- 1.7.10.2