From: pvtroshin Date: Fri, 3 Dec 2010 16:12:13 +0000 (+0000) Subject: AAConWS further work and test cases X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=27e1fc31d6e3cc48e5abddcc939f3c73b11fcd55;p=jabaws.git AAConWS further work and test cases git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3424 e3abac25-378b-4346-85de-24260fe3988d --- diff --git a/.classpath b/.classpath index ab5b4be..0ace127 100644 --- a/.classpath +++ b/.classpath @@ -10,8 +10,7 @@ - - + diff --git a/WEB-INF/lib/aaconservation.jar b/WEB-INF/lib/aaconservation.jar deleted file mode 100644 index c41612e..0000000 Binary files a/WEB-INF/lib/aaconservation.jar and /dev/null differ diff --git a/binaries/manual.txt b/binaries/AACon_manual.txt similarity index 100% rename from binaries/manual.txt rename to binaries/AACon_manual.txt diff --git a/binaries/aaconservation.jar b/binaries/aaconservation.jar index c41612e..616bb33 100644 Binary files a/binaries/aaconservation.jar and b/binaries/aaconservation.jar differ diff --git a/datamodel/compbio/data/sequence/Method.java b/datamodel/compbio/data/sequence/Method.java new file mode 100644 index 0000000..e8764eb --- /dev/null +++ b/datamodel/compbio/data/sequence/Method.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2010 Agnieszka Golicz & Peter Troshin + * + * Amino Acid Conservation @version: 1.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 This library is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache + * License for more details. A copy of the license is in apache_license.txt. It + * is also available here: http://www.apache.org/licenses/LICENSE-2.0.txt + * Any republication or derived work distributed in source code form must + * include this copyright and license notice. + * + */ +package compbio.data.sequence; + +/** + * Enumeration listing of all the supported methods. + * + * @author Agnieszka Golicz & Peter Troshin + */ +public enum Method { + 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) { + meth = meth.trim().toLowerCase(); + if (meth.equalsIgnoreCase(KABAT.toString())) { + return KABAT; + } + if (meth.equalsIgnoreCase(JORES.toString())) { + return JORES; + } + if (meth.equalsIgnoreCase(SCHNEIDER.toString())) { + return SCHNEIDER; + } + if (meth.equalsIgnoreCase(SHENKIN.toString())) { + return SHENKIN; + } + if (meth.equalsIgnoreCase(GERSTEIN.toString())) { + return GERSTEIN; + } + if (meth.equalsIgnoreCase(TAYLOR_GAPS.toString())) { + return TAYLOR_GAPS; + } + if (meth.equalsIgnoreCase(TAYLOR_NO_GAPS.toString())) { + return TAYLOR_NO_GAPS; + } + if (meth.equalsIgnoreCase(ZVELIBIL.toString())) { + return ZVELIBIL; + } + if (meth.equalsIgnoreCase(KARLIN.toString())) { + return KARLIN; + } + if (meth.equalsIgnoreCase(ARMON.toString())) { + return ARMON; + } + if (meth.equalsIgnoreCase(THOMPSON.toString())) { + return THOMPSON; + } + if (meth.equalsIgnoreCase(NOT_LANCET.toString())) { + return NOT_LANCET; + } + if (meth.equalsIgnoreCase(MIRNY.toString())) { + return MIRNY; + } + if (meth.equalsIgnoreCase(WILLIAMSON.toString())) { + return WILLIAMSON; + } + if (meth.equalsIgnoreCase(LANDGRAF.toString())) { + return LANDGRAF; + } + if (meth.equalsIgnoreCase(SANDER.toString())) { + return SANDER; + } + if (meth.equalsIgnoreCase(VALDAR.toString())) { + return VALDAR; + } + if (meth.equalsIgnoreCase(SMERFS.toString())) { + return SMERFS; + } + return null; + } + +} diff --git a/datamodel/compbio/data/sequence/Score.java b/datamodel/compbio/data/sequence/Score.java index 8a58db3..3416e78 100644 --- a/datamodel/compbio/data/sequence/Score.java +++ b/datamodel/compbio/data/sequence/Score.java @@ -6,7 +6,6 @@ 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) diff --git a/datamodel/compbio/data/sequence/SequenceUtil.java b/datamodel/compbio/data/sequence/SequenceUtil.java index c995585..935ce74 100644 --- a/datamodel/compbio/data/sequence/SequenceUtil.java +++ b/datamodel/compbio/data/sequence/SequenceUtil.java @@ -32,8 +32,6 @@ import java.util.logging.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; -import compbio.conservation.Method; - /** * Utility class for operations on sequences * diff --git a/runner/compbio/runner/conservation/AACon.java b/runner/compbio/runner/conservation/AACon.java index ce4d293..49c87d4 100644 --- a/runner/compbio/runner/conservation/AACon.java +++ b/runner/compbio/runner/conservation/AACon.java @@ -53,12 +53,12 @@ public class AACon extends SkeletalExecutable { */ private int ncoreNumber = 0; - private final String ncorePrm = "-n="; + private final String ncorePrm = "-t="; // Cache for Limits information private static LimitsManager limits; - public static final String KEY_VALUE_SEPARATOR = Util.SPACE; + public static final String KEY_VALUE_SEPARATOR = "="; public static final String STAT_FILE = "stat.txt"; public AACon() { diff --git a/testsrc/compbio/runner/conservation/AAConTester.java b/testsrc/compbio/runner/conservation/AAConTester.java index da924f0..edf637b 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.conservation.Method; +import compbio.data.sequence.Method; import compbio.data.sequence.MultiAnnotatedSequence; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; diff --git a/testsrc/compbio/ws/client/TestAAConWS.java b/testsrc/compbio/ws/client/TestAAConWS.java index a8814c8..a76b41b 100644 --- a/testsrc/compbio/ws/client/TestAAConWS.java +++ b/testsrc/compbio/ws/client/TestAAConWS.java @@ -8,36 +8,56 @@ 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.conservation.Method; import compbio.data.msa.Annotation; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.Method; import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitExceededException; +import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; +import compbio.metadata.RunnerConfig; import compbio.metadata.UnsupportedRuntimeException; +import compbio.metadata.WrongParameterException; +import compbio.runner.conservation.AACon; import compbio.util.SysPrefs; -import compbio.ws.server.AAConWS; public class TestAAConWS { - @Test - public void test() throws FileNotFoundException, IOException { + Annotation msaws; - URL url = new URL("http://localhost:8080/jabaws/AAConWS?wsdl"); + @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); + } + + @Test + public void testAnalize() throws FileNotFoundException, IOException { + /* * MsaWS msaws = serv.getPort(new QName( * "http://msa.data.compbio/01/01/2010/", "ClustalWSPort"), @@ -46,9 +66,6 @@ public class TestAAConWS { // Annotation msaws = serv.getPort(new QName(namespace, // "ClustalWSPort"), Annotation.class); - Annotation msaws = serv.getPort(new QName(namespace, - "AAConWSPort"), Annotation.class); - // List fsl = SequenceUtil.readFasta(new FileInputStream( // AAConTester.test_alignment_input)); @@ -60,8 +77,7 @@ public class TestAAConWS { + File.separator + "TO1381.fasta.aln")); try { - System.out.println("Pres: " - + msaws.getPresets().getPresets().get(0)); + System.out.println("Pres: " + msaws.getPresets().getPresets()); String jobId = msaws.analize(fsl); System.out.println("J: " + jobId); HashSet result = msaws.getConservation(jobId); @@ -72,6 +88,78 @@ public class TestAAConWS { assertNotNull(scores); assertEquals(scores.size(), 568); + // Using presets + PresetManager presets = msaws.getPresets(); + jobId = msaws.presetAnalize(fsl, + presets.getPresetByName("Quick conservation")); + result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 13); + + jobId = msaws.presetAnalize(fsl, + presets.getPresetByName("Slow conservation")); + result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 5); + + jobId = msaws.presetAnalize(fsl, + presets.getPresetByName("Complete conservation")); + result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 18); + + } catch (UnsupportedRuntimeException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (LimitExceededException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (WrongParameterException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + + } + + @Test + public void testPresetAnalize() throws FileNotFoundException, IOException { + + String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + + File.separator; + + List fsl = SequenceUtil.readFasta(new FileInputStream( + CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + + File.separator + "TO1381.fasta.aln")); + + try { + System.out.println("Pres: " + msaws.getPresets().getPresets()); + + // Using presets + PresetManager presets = msaws.getPresets(); + String jobId = msaws.presetAnalize(fsl, + presets.getPresetByName("Quick conservation")); + HashSet result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 13); + + jobId = msaws.presetAnalize(fsl, + presets.getPresetByName("Slow conservation")); + result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 5); + + jobId = msaws.presetAnalize(fsl, + presets.getPresetByName("Complete conservation")); + result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 18); + } catch (UnsupportedRuntimeException e) { e.printStackTrace(); fail(e.getMessage()); @@ -84,7 +172,63 @@ public class TestAAConWS { } catch (ResultNotAvailableException e) { e.printStackTrace(); fail(e.getMessage()); + } catch (WrongParameterException e) { + e.printStackTrace(); + fail(e.getMessage()); } } + + @Test + public void testCustomAnalize() throws FileNotFoundException, IOException { + + String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + + File.separator; + + List fsl = SequenceUtil.readFasta(new FileInputStream( + CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + + File.separator + "TO1381.fasta.aln")); + + // Using options + RunnerConfig options = msaws.getRunnerOptions(); + // System.out.println(options.getArguments()); + + try { + options.getArgument("Calculation method").setDefaultValue("SMERFS"); + String jobId = msaws.customAnalize(fsl, options.getArguments()); + HashSet result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 1); + assertEquals( + new ArrayList(result).get(0).getScores().get(0), + 0.698f); + + options.getArgument("Calculation method").setDefaultValue("SMERFS"); + options.removeArgument("Normalize"); + System.out.println(options); + jobId = msaws.customAnalize(fsl, options.getArguments()); + result = msaws.getConservation(jobId); + assertNotNull(result); + assertEquals(result.size(), 1); + assertEquals( + new ArrayList(result).get(0).getScores().get(0), + 0.401f); + + } catch (WrongParameterException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (UnsupportedRuntimeException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (LimitExceededException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } } diff --git a/webservices/compbio/data/msa/jaxws/Align.java b/webservices/compbio/data/msa/jaxws/Align.java index 7f021d3..e380bab 100644 --- a/webservices/compbio/data/msa/jaxws/Align.java +++ b/webservices/compbio/data/msa/jaxws/Align.java @@ -7,7 +7,6 @@ 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) @@ -15,14 +14,14 @@ import compbio.data.sequence.FastaSequence; 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; } @@ -31,7 +30,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 index 7ce56ac..fc7fd26 100644 --- a/webservices/compbio/data/msa/jaxws/Analize.java +++ b/webservices/compbio/data/msa/jaxws/Analize.java @@ -7,7 +7,6 @@ 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) @@ -15,14 +14,14 @@ import compbio.data.sequence.FastaSequence; public class Analize { @XmlElement(name = "fastaSequences", namespace = "") - private List fastaSequences; + private List fastaSequences; /** * * @return * returns List */ - public List getFastaSequences() { + public List getFastaSequences() { return this.fastaSequences; } @@ -31,7 +30,7 @@ public class Analize { * @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/CustomAlign.java b/webservices/compbio/data/msa/jaxws/CustomAlign.java index 92c9bab..d258864 100644 --- a/webservices/compbio/data/msa/jaxws/CustomAlign.java +++ b/webservices/compbio/data/msa/jaxws/CustomAlign.java @@ -7,8 +7,6 @@ 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) @@ -19,16 +17,16 @@ import compbio.metadata.Option; public class CustomAlign { @XmlElement(name = "fastaSequences", namespace = "") - private List fastaSequences; + private List fastaSequences; @XmlElement(name = "options", namespace = "") - private List