From 0965a336a3bc311c2527d7aacfa733e38fcfc4be Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Thu, 24 Oct 2013 15:12:35 +0100 Subject: [PATCH] Delete JABAWS testing codes --- testsrc/compbio/data/msa/CategoryTester.java | 70 ---- .../data/sequence/ClustalAlignmentUtilTester.java | 102 ----- .../data/sequence/FastaGeneratorManager.java | 61 --- .../compbio/data/sequence/FastaReaderTester.java | 77 ---- .../data/sequence/FastaSequenceGenerator.java | 151 ------- .../sequence/FastaSequenceGeneratorTester.java | 44 -- .../compbio/data/sequence/FastaSequenceTester.java | 41 -- .../compbio/data/sequence/SequenceUtilTester.java | 426 -------------------- .../compbio/engine/EngineConfiguratorTester.java | 58 --- testsrc/compbio/engine/FilePullerTester.java | 203 ---------- testsrc/compbio/engine/LoadBalancerTester.java | 68 ---- testsrc/compbio/engine/PulledFileCacheTester.java | 97 ----- .../engine/client/CommandBuilderTester.java | 106 ----- .../compbio/engine/client/PathValidatorTester.java | 79 ---- .../engine/cluster/drmaa/ClusterSessionTester.java | 96 ----- .../drmaa/DrmaaAsyncClusterEngineTester.java | 184 --------- .../cluster/drmaa/DrmaaClusterEngineTester.java | 188 --------- .../compbio/engine/cluster/drmaa/UtilTester.java | 56 --- .../engine/conf/DirectoryManagerTester.java | 66 --- .../engine/conf/PropertyHelperManagerTester.java | 116 ------ .../engine/conf/RunnerConfigMarshallerTester.java | 263 ------------ .../engine/local/AsyncLocalRunnerTester.java | 392 ------------------ .../engine/local/EngineResourcesLeakTester.java | 181 --------- .../compbio/engine/local/LocalRunnerTester.java | 153 ------- testsrc/compbio/metadata/AllTestSuit.java | 53 --- .../compbio/metadata/OptionCombinatorTester.java | 102 ----- .../compbio/metadata/OptionMarshallerTester.java | 190 --------- testsrc/compbio/metadata/PresetTester.java | 194 --------- testsrc/compbio/metadata/RunnerConfigTester.java | 269 ------------ .../collector/ExecutionStatCollectorTester.java | 120 ------ testsrc/compbio/stat/collector/StatDBTester.java | 143 ------- .../compbio/stat/collector/TestInputFilter.java | 40 -- .../stat/servlet/util/StatCollectionTester.java | 30 -- .../compbio/ws/client/AAConWSClientExample.java | 123 ------ testsrc/compbio/ws/client/TestAAConWS.java | 257 ------------ testsrc/compbio/ws/client/TestIUPredWS.java | 104 ----- testsrc/compbio/ws/client/TestRNAalifoldWS.java | 106 ----- testsrc/compbio/ws/client/WSTesterTester.java | 61 --- testsrc/compbio/ws/server/RegistryWSTester.java | 222 ---------- 39 files changed, 5292 deletions(-) delete mode 100644 testsrc/compbio/data/msa/CategoryTester.java delete mode 100644 testsrc/compbio/data/sequence/ClustalAlignmentUtilTester.java delete mode 100644 testsrc/compbio/data/sequence/FastaGeneratorManager.java delete mode 100644 testsrc/compbio/data/sequence/FastaReaderTester.java delete mode 100644 testsrc/compbio/data/sequence/FastaSequenceGenerator.java delete mode 100644 testsrc/compbio/data/sequence/FastaSequenceGeneratorTester.java delete mode 100644 testsrc/compbio/data/sequence/FastaSequenceTester.java delete mode 100644 testsrc/compbio/data/sequence/SequenceUtilTester.java delete mode 100644 testsrc/compbio/engine/EngineConfiguratorTester.java delete mode 100644 testsrc/compbio/engine/FilePullerTester.java delete mode 100644 testsrc/compbio/engine/LoadBalancerTester.java delete mode 100644 testsrc/compbio/engine/PulledFileCacheTester.java delete mode 100644 testsrc/compbio/engine/client/CommandBuilderTester.java delete mode 100644 testsrc/compbio/engine/client/PathValidatorTester.java delete mode 100644 testsrc/compbio/engine/cluster/drmaa/ClusterSessionTester.java delete mode 100644 testsrc/compbio/engine/cluster/drmaa/DrmaaAsyncClusterEngineTester.java delete mode 100644 testsrc/compbio/engine/cluster/drmaa/DrmaaClusterEngineTester.java delete mode 100644 testsrc/compbio/engine/cluster/drmaa/UtilTester.java delete mode 100644 testsrc/compbio/engine/conf/DirectoryManagerTester.java delete mode 100644 testsrc/compbio/engine/conf/PropertyHelperManagerTester.java delete mode 100644 testsrc/compbio/engine/conf/RunnerConfigMarshallerTester.java delete mode 100644 testsrc/compbio/engine/local/AsyncLocalRunnerTester.java delete mode 100644 testsrc/compbio/engine/local/EngineResourcesLeakTester.java delete mode 100644 testsrc/compbio/engine/local/LocalRunnerTester.java delete mode 100644 testsrc/compbio/metadata/AllTestSuit.java delete mode 100644 testsrc/compbio/metadata/OptionCombinatorTester.java delete mode 100644 testsrc/compbio/metadata/OptionMarshallerTester.java delete mode 100644 testsrc/compbio/metadata/PresetTester.java delete mode 100644 testsrc/compbio/metadata/RunnerConfigTester.java delete mode 100644 testsrc/compbio/stat/collector/ExecutionStatCollectorTester.java delete mode 100644 testsrc/compbio/stat/collector/StatDBTester.java delete mode 100644 testsrc/compbio/stat/collector/TestInputFilter.java delete mode 100644 testsrc/compbio/stat/servlet/util/StatCollectionTester.java delete mode 100644 testsrc/compbio/ws/client/AAConWSClientExample.java delete mode 100644 testsrc/compbio/ws/client/TestAAConWS.java delete mode 100644 testsrc/compbio/ws/client/TestIUPredWS.java delete mode 100644 testsrc/compbio/ws/client/TestRNAalifoldWS.java delete mode 100644 testsrc/compbio/ws/client/WSTesterTester.java delete mode 100644 testsrc/compbio/ws/server/RegistryWSTester.java diff --git a/testsrc/compbio/data/msa/CategoryTester.java b/testsrc/compbio/data/msa/CategoryTester.java deleted file mode 100644 index 00a93f4..0000000 --- a/testsrc/compbio/data/msa/CategoryTester.java +++ /dev/null @@ -1,70 +0,0 @@ -package compbio.data.msa; - -import java.net.ConnectException; -import java.util.Set; - -import javax.xml.ws.WebServiceException; - -import org.testng.Assert; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; -import compbio.ws.client.Jws2Client; -import compbio.ws.client.Services; -import compbio.ws.client.WSTesterTester; - -public class CategoryTester { - - // test category membership from string constants - RegistryWS registry = null; - - @BeforeTest(groups = AllTestSuit.test_group_webservices) - public void setupTest() { - try { - /* - * registry = Jws2Client .connectToRegistry( - * "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jaba"); - */ - registry = Jws2Client.connectToRegistry(WSTesterTester.SERVER); - - } catch (ConnectException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - - } - - /* - * This test will FAIL unless a connection to a running JABAWS web server is - * made! - */ - @Test(groups = AllTestSuit.test_group_webservices) - public void categoryTest() { - Set servicecategories = registry.getServiceCategories(); - - boolean found = false; - for (Category svccategory : servicecategories) { - - Set catservices; - - for (String category : new String[]{Category.CATEGORY_ALIGNMENT, - Category.CATEGORY_CONSERVATION, Category.CATEGORY_DISORDER}) { - if (category.equals(svccategory.name)) { - found = true; - catservices = svccategory.getServices(); - System.out.println("Found " + catservices.size() - + " services in category " + category - + "(service category string " + svccategory + ")"); - } - } - } - if (!found) { - Assert.fail("Could not match any category to one of the given category constants"); - } - } - -} diff --git a/testsrc/compbio/data/sequence/ClustalAlignmentUtilTester.java b/testsrc/compbio/data/sequence/ClustalAlignmentUtilTester.java deleted file mode 100644 index 812cd6f..0000000 --- a/testsrc/compbio/data/sequence/ClustalAlignmentUtilTester.java +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; - -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; - -public class ClustalAlignmentUtilTester { - - @Test() - public void testReadClustalFile() { - try { - readWriteClustal("TO1381.aln"); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - static void readWriteClustal(String fname) throws IOException, - UnknownFileFormatException { - FileInputStream fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH - + fname); - Alignment seqAl = ClustalAlignmentUtil.readClustalFile(fio); - assertTrue(seqAl != null); - assertTrue(seqAl.getSize() == 3); - assertNotNull(seqAl.getSequences()); - assertEquals(3, seqAl.getSequences().size()); - - // Now try to write the alignment read - Writer os = new FileWriter(AllTestSuit.TEST_DATA_PATH + fname - + ".written"); - ClustalAlignmentUtil.writeClustalAlignment(os, seqAl); - fio.close(); - os.close(); - - fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + fname - + ".written"); - Alignment readseqs = ClustalAlignmentUtil.readClustalFile(fio); - assertTrue(readseqs != null); - assertTrue(readseqs.getSize() == 3); - fio.close(); - } - - @Test() - public void testReadClustalFileShortNames() { - try { - readWriteClustal("TO1381s.aln"); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test() - public void testReadClustalFileLongNames() { - try { - readWriteClustal("TO1381L.aln"); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - -} diff --git a/testsrc/compbio/data/sequence/FastaGeneratorManager.java b/testsrc/compbio/data/sequence/FastaGeneratorManager.java deleted file mode 100644 index 9305d8b..0000000 --- a/testsrc/compbio/data/sequence/FastaGeneratorManager.java +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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; - -import java.io.IOException; -import java.util.List; - -import compbio.util.FileUtil; - -public class FastaGeneratorManager { - - public static void main(String[] args) throws IOException { - FastaSequenceGenerator fgen = new FastaSequenceGenerator( - FastaSequenceGenerator.SeqType.PROTEIN, 50); - - List fslist = fgen.generateFasta(400); - writeToFile(fslist, "SmallProtein.fasta"); - - fgen = new FastaSequenceGenerator( - FastaSequenceGenerator.SeqType.PROTEIN, 200); - - fslist = fgen.generateFasta(500); - writeToFile(fslist, "200x500Protein.fasta"); - - fgen = new FastaSequenceGenerator(FastaSequenceGenerator.SeqType.DNA, - 1000); - fslist = fgen.generateFasta(3000); - writeToFile(fslist, "1000x3000Dna.fasta"); - - fgen = new FastaSequenceGenerator(FastaSequenceGenerator.SeqType.DNA, - 50000); - fslist = fgen.generateFasta(300); - writeToFile(fslist, "50000x300Dna.fasta"); - System.out.println("Done"); - } - - static void writeToFile(List fastalist, String filepath) - throws IOException { - StringBuilder sb = new StringBuilder(); - for (FastaSequence fs : fastalist) { - sb.append(fs.getOnelineFasta() + "\n"); - } - FileUtil.writeToFile(sb.toString(), filepath); - } -} diff --git a/testsrc/compbio/data/sequence/FastaReaderTester.java b/testsrc/compbio/data/sequence/FastaReaderTester.java deleted file mode 100644 index 3a3b747..0000000 --- a/testsrc/compbio/data/sequence/FastaReaderTester.java +++ /dev/null @@ -1,77 +0,0 @@ -package compbio.data.sequence; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; - -public class FastaReaderTester { - - static FastaSequence s0 = new FastaSequence( - "zedpshvyzg", - "GCQDKNNIAELNEIMGTTRSPSDWQHMKGASPRAEIGLTGKKDSWWRHCCSKEFNKTPPPIHPDMKRWGWMWNRENFEKFLIDNFLNPPCPRLMLTKGTWWRHEDLCHEIFWSTLRWLCLGNQSFSAMIWGHLCECHRMIWWESNEHMFWLKFRRALKKMNSNGPCMGPDNREWMITNRMGKEFCGPAFAGDCQSCWRKCHKTNKICFNEKKGTPTKIDHEQKDIMDILKDIDNHRNWKQCQLWLLTSKSTDQESTTMLTWSTWRDFFIIIKQPFDHKCRGALDANGDFQIAAELKWPAPMIILRQNQKTMHDKSCHHFFTNRCPLMHTTRANDKQCSWHTRKQFICQQDFTTWQHRPDTHRILPSWCMSTRRKNHIKNTPALAFSTCEMGDLPNGWAPGTIILQRQFTQAIKLPQETTGWPRCDPKFDHWNMSKWLRQLLGRDDEMIPPQCD"); - - static FastaSequence s1 = new FastaSequence( - "xovkactesa", - "CPLSKWWNRRAFLSHTANHWMILMTWEGPHDGESKMRIAMMKWSPCKPTMSHFRCGLDAWAEPIRQIACESTFRM" - + "FCTTPRPIHKLTEMWGHMNGWTGAFCRQLECEWMMPPRHPHPCTSTFNNNKKRLIGQIPNEGKQLFINFQKPQHG" - + "FSESDIWIWKDNPTAWHEGLTIAGIGDGQHCWNWMPMPWSGAPTSNALIEFWTWLGMIGTRCKTQGMWWDAMNHH" - + "DQFELSANAHIAAHHMEKKMILKPDDRNLGDDTWMPPGKIWMRMFAKNTNACWPEGCRDDNEEDDCGTHNLHRMC"); - static FastaSequence s2 = new FastaSequence( - "ntazzewyvv", - "CGCKIF D D NMKDNNRHG TDIKKHGFMH IRHPE KRDDC FDNHCIMPKHRRWGLWD" - + "EASINM AQQWRSLPPSRIMKLNG HGCDCMHSHMEAD DTKQSGIKGTFWNG HDAQWLCRWG" - + "EFITEA WWGRWGAITFFHAH ENKNEIQECSDQNLKE SRTTCEIID TCHLFTRHLDGW" - + " RCEKCQANATHMTW ACTKSCAEQW FCAKELMMN " - + "W KQMGWRCKIFRKLFRDNCWID FELPWWPICFCCKGLSTKSHSAHDGDQCRRW WPDCARDWLGPGIRGEF " - + "FCTHICQQLQRNFWCGCFRWNIEKRMFEIFDDNMAAHWKKCMHFKFLIRIHRHGPITMKMTWCRSGCCFGKTRRLPDSSFISAFLDPKHHRDGSGMMMWSSEMRSCAIPDPQQAWNQGKWIGQIKDWNICFAWPIRENQQCWATPHEMPSGFHFILEKWDALAHPHMHIRQKKCWAWAFLSLMSSTHSDMATFQWAIPGHNIWSNWDNIICGWPRI"); - static FastaSequence s3 = new FastaSequence(" 12 d t y wi k jbke ", - " KLSHHDCD" + " N" + " H" + " HSKCTEPHCGNSHQML\n\rHRDP" - + " CCDQCQSWEAENWCASMRKAILF"); - static FastaSequence s4 = new FastaSequence(" 12 d t>y wi->foo k jbke ", - " KLSHHDCD" + " N" + " H" + " HSKCTEPHCGNSHQML\n\rHRDP" - + " CCDQCQSWEAENWCASMRKAILF"); - @Test() - public void test() { - - List old_seqs = null; - final List list = new ArrayList(); - try { - old_seqs = SequenceUtil.readFasta(new FileInputStream( - AllTestSuit.TEST_DATA_PATH + "complicated.fasta")); - final FastaReader fr = new FastaReader(AllTestSuit.TEST_DATA_PATH - + "complicated.fasta"); - - while (fr.hasNext()) { - final FastaSequence fs = fr.next(); - list.add(fs); - } - } catch (final FileNotFoundException e) { - e.printStackTrace(); - Assert.fail(e.getLocalizedMessage()); - } catch (final IOException e) { - e.printStackTrace(); - Assert.fail(e.getLocalizedMessage()); - } - System.out.println("OLD: " + old_seqs); - System.out.println("NEW: " + list); - Assert.assertEquals(old_seqs.size(), list.size()); - Assert.assertEquals(old_seqs.get(0), list.get(0)); - Assert.assertEquals(old_seqs.get(1), list.get(1)); - // Assert.assertEquals(old_seqs.get(2), list.get(2)); - // Assert.assertEquals(seqs.get(3), list.get(3)); - - Assert.assertEquals(FastaReaderTester.s0, list.get(0)); - Assert.assertEquals(FastaReaderTester.s1, list.get(1)); - Assert.assertEquals(FastaReaderTester.s2, list.get(2)); - Assert.assertEquals(FastaReaderTester.s3, list.get(3)); - Assert.assertEquals(FastaReaderTester.s4, list.get(4)); - - } -} diff --git a/testsrc/compbio/data/sequence/FastaSequenceGenerator.java b/testsrc/compbio/data/sequence/FastaSequenceGenerator.java deleted file mode 100644 index c1aeb4e..0000000 --- a/testsrc/compbio/data/sequence/FastaSequenceGenerator.java +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class FastaSequenceGenerator { - - enum SeqType { - DNA, PROTEIN - } - - enum ProteinAlphabet { - A, R, N, D, C, E, Q, G, H, I, L, K, M, F, P, S, T, W, V - }; - - enum DNAAlphabet { - C, T, G, A, U - }; - - enum Letters { - q, w, e, r, t, y, u, i, o, p, a, s, d, f, g, h, j, k, l, z, x, c, v, b, n, m - }; - - final SeqType seqtype; - final int seqNumber; - final Random rand; - - /** - * - * @param type - * of the sequence to be generated one of DNA or PROTEIN - * @param seqNumber - * number of sequences to be generated - */ - public FastaSequenceGenerator(SeqType type, int seqNumber) { - this.seqtype = type; - this.seqNumber = seqNumber; - this.rand = new Random(); - } - - /** - * Generate a list of Fasta formatted sequences with sequence length between - * 0.5 to 1 of maxLenght. Name of the sequence as well as the sequence is - * generated randomly - * - * @param maxSeqLength - * maximum length of generated sequence - * @return - */ - public List generateFasta(int maxSeqLength) { - List fastal = new ArrayList(); - FastaSequence seq = null; - for (int i = 0; i < seqNumber; i++) { - switch (this.seqtype) { - case DNA: - seq = new FastaSequence(generateName(), generateDna( - maxSeqLength, getRandomNumber(0.5, 0.99))); - break; - case PROTEIN: - seq = new FastaSequence(generateName(), generateProtein( - maxSeqLength, getRandomNumber(0.5, 0.99))); - break; - default: - throw new AssertionError("Cannot recognise a type!"); - } - fastal.add(seq); - } - return fastal; - } - - private String generateName() { - Letters[] letters = Letters.values(); - int max = letters.length - 1; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 10; i++) { - sb.append(letters[getRandomNumber(0, max)]); - } - return sb.toString(); - } - - private String generateProtein(int length, double variability) { - ProteinAlphabet[] proteinA = ProteinAlphabet.values(); - int max = proteinA.length - 1; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length * variability; i++) { - sb.append(proteinA[getRandomNumber(max)]); - } - return sb.toString(); - } - - private String generateDna(int length, double variability) { - if (variability == 0) { - variability = 1; - } - DNAAlphabet[] dnaA = DNAAlphabet.values(); - int max = dnaA.length - 1; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length * variability; i++) { - sb.append(dnaA[getRandomNumber(max)]); - } - return sb.toString(); - } - - /* - * Returns random integers in range from 0 to max - * - * @param max - * - * @return - */ - private int getRandomNumber(int max) { - return rand.nextInt(max); - } - - /* - * Returns random integers with value in range from min to max - * - * @param min - * - * @param max - * - * @return - */ - private int getRandomNumber(int min, int max) { - return new Long(Math.round((max - min) * rand.nextDouble() + min)) - .intValue(); - } - - private double getRandomNumber(double min, double max) { - return (max - min) * rand.nextDouble() + min; - } -} diff --git a/testsrc/compbio/data/sequence/FastaSequenceGeneratorTester.java b/testsrc/compbio/data/sequence/FastaSequenceGeneratorTester.java deleted file mode 100644 index 374a052..0000000 --- a/testsrc/compbio/data/sequence/FastaSequenceGeneratorTester.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertTrue; - -import java.util.List; - -import org.testng.annotations.Test; - -public class FastaSequenceGeneratorTester { - - @Test() - public void testProteinSequenceGeneration() { - FastaSequenceGenerator fs = new FastaSequenceGenerator( - FastaSequenceGenerator.SeqType.PROTEIN, 100); - assertEquals(100, fs.generateFasta(100).size()); - - fs = new FastaSequenceGenerator(FastaSequenceGenerator.SeqType.DNA, 50); - List flist = fs.generateFasta(100); - assertEquals(50, flist.size()); - for (FastaSequence s : flist) { - assertTrue(s.getLength() >= 50); - } - - } -} diff --git a/testsrc/compbio/data/sequence/FastaSequenceTester.java b/testsrc/compbio/data/sequence/FastaSequenceTester.java deleted file mode 100644 index eaeac43..0000000 --- a/testsrc/compbio/data/sequence/FastaSequenceTester.java +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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; - -import static org.testng.AssertJUnit.assertEquals; - -import org.testng.annotations.Test; - -public class FastaSequenceTester { - - @Test() - public void testGetFormattedFasta() { - FastaSequence fs = new FastaSequence( - "test", - "kjashf asjkdfhjkahsdfkadf fewyweyrfhjajfasdjkfkjhasdjkfaskhdfjhasdjkf " - + "hdflhdghuetirwhglhasdghfjkhdfs gdsfkjghsdjfgjhdsfglkhskdjfgjhjsdkfgkhsdjkfghsdkjfgh " - + "sdfjglkjhsdflkjg sdfgklhsdkfgdfkjghjkshgdflsdfgjkshdfghksdjfgkjhsdfgjkh"); - assertEquals(219, fs.getSequence().length()); - assertEquals(11, fs.getFormatedSequence(20).split("\n").length); - assertEquals(3, fs.getFormatedSequence(80).split("\n").length); - fs = new FastaSequence("test", "kjashf f "); - assertEquals(1, fs.getFormatedSequence(80).split("\n").length); - assertEquals(7, fs.getFormatedSequence(1).split("\n").length); - } -} diff --git a/testsrc/compbio/data/sequence/SequenceUtilTester.java b/testsrc/compbio/data/sequence/SequenceUtilTester.java deleted file mode 100644 index 9468cda..0000000 --- a/testsrc/compbio/data/sequence/SequenceUtilTester.java +++ /dev/null @@ -1,426 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * Copyright (c) 2013 Alexander Sherstnev - * - * JAva Bioinformatics Analysis Web Services (JABAWS) - * @version: 2.5 - * - * 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: - * - * @see: 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; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; - -public class SequenceUtilTester { - - @Test() - public void isNonAmbNucleotideSequence() { - String dnaseq = "atgatTGACGCTGCTGatgtcgtgagtgga"; - assertTrue(SequenceUtil.isNonAmbNucleotideSequence(dnaseq)); - String dirtyDnaseq = "atgAGTggt\taGGTgc\ncgcACTgc gACtcgcGAt cgA "; - assertTrue(SequenceUtil.isNonAmbNucleotideSequence(dirtyDnaseq)); - String nonDna = "atgfctgatgcatgcatgatgctga"; - assertFalse(SequenceUtil.isNonAmbNucleotideSequence(nonDna)); - - nonDna = "atgc1tgatgcatgcatgatgctga"; - assertFalse(SequenceUtil.isNonAmbNucleotideSequence(nonDna)); - - nonDna = "ARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQL"; - assertFalse(SequenceUtil.isNonAmbNucleotideSequence(nonDna)); - // String ambDna = "AGTCRYMKSWHBVDN"; // see IUPAC Nucleotide Code - assertFalse(SequenceUtil.isNonAmbNucleotideSequence(nonDna)); - } - - @Test() - public void CleanSequence() { - String dirtySeq = "atgAGTggt\taGGTgc\ncgcAC\rTgc gACtcgcGAt cgA "; - assertEquals("atgAGTggtaGGTgccgcACTgcgACtcgcGAtcgA".toUpperCase(),SequenceUtil.cleanSequence(dirtySeq)); - } - - @Test() - public void DeepCleanSequence() { - String dirtySeq = "a!t?g.A;GTggt\ta12GGTgc\ncgc23AC\rTgc gAC<>.,?!|\\|/t@cg-c¬GA=_+(0){]}[:£$&^*\"t cgA "; - assertEquals("atgAGTggtaGGTgccgcACTgcgACtcgcGAtcgA".toUpperCase(),SequenceUtil.deepCleanSequence(dirtySeq)); - } - - @Test() - public void isProteinSequence() { - String dirtySeq = "atgAGTggt\taGGTgc\ncgcAC\rTgc gACtcgcGAt cgA "; - assertFalse(SequenceUtil.isProteinSequence(dirtySeq)); - String notaSeq = "atgc1tgatgcatgcatgatgctga"; - assertFalse(SequenceUtil.isProteinSequence(notaSeq)); - String AAseq = "ARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQL"; - assertTrue(SequenceUtil.isProteinSequence(AAseq)); - AAseq += "XU"; - assertFalse(SequenceUtil.isProteinSequence(AAseq)); - - } - - @Test() - public void CleanProteinSequence() { - String dirtySeq = "atgAGTggt\taGGTgc\ncgcAC\rTgc gACtcgcGAt cgA "; - assertFalse(SequenceUtil.isProteinSequence(dirtySeq)); - // This will still be NON protein sequence despite having only correct - // letters because the letters match perfectly the nucleotide sequence! - assertFalse(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(dirtySeq))); - - String notaSeq = "atgc1tgatgcatgcatgatgmctga"; - assertFalse(SequenceUtil.isProteinSequence(notaSeq)); - assertTrue(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(notaSeq))); - - String AAseq = "ARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQL"; - assertTrue(SequenceUtil.isProteinSequence(AAseq)); - assertTrue(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(AAseq))); - AAseq += "XU"; - - assertFalse(SequenceUtil.isProteinSequence(AAseq)); - assertTrue(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(AAseq))); - } - - @Test() - public void ReadWriteFasta() { - try { - FileInputStream fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "TO1381.fasta"); - assertNotNull(fio); - List fseqs = SequenceUtil.readFasta(fio); - assertNotNull(fseqs); - assertEquals(3, fseqs.size()); - assertEquals(3, fseqs.size()); - fio.close(); - FileOutputStream fou = new FileOutputStream(AllTestSuit.TEST_DATA_PATH + "TO1381.fasta.written"); - SequenceUtil.writeFasta(fou, fseqs); - fou.close(); - FileOutputStream fou20 = new FileOutputStream(AllTestSuit.TEST_DATA_PATH + "TO1381.fasta20.written"); - SequenceUtil.writeFasta(fou20, fseqs, 21); - fou20.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - // Potential Bug :- Sequence names are shortened to 2-3 letters - @Test - public void testReadFastaWriteClustal() { - - try { - FileInputStream fio = new FileInputStream( - AllTestSuit.TEST_DATA_PATH + "TO1381.fasta"); - assertNotNull(fio); - List fseqs = SequenceUtil.readFasta(fio); - assertNotNull(fseqs); - fio.close(); - - char gapChar = '-'; - FileOutputStream fou = new FileOutputStream( - AllTestSuit.TEST_DATA_PATH + "TO1381.aln.written"); - SequenceUtil.writeClustal(fou, fseqs, gapChar); - fou.close(); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - /** - * This test tests the loading of horizontally formatted Jronn output file - */ - @Test - public void LoadJronnFile() { - - FileInputStream fio; - try { - fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "jronn.out"); - Map aseqs = SequenceUtil.readJRonn(fio); - assertNotNull(aseqs); - assertEquals(aseqs.size(), 3); - Score aseq = aseqs.get("Foobar"); - assertNotNull(aseq); - assertNotNull(aseq.getScores()); - assertEquals(aseq.getScores().size(), aseq.getScores().size()); - fio.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (UnknownFileFormatException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - enum Trial { - one, two, three - }; - - /** - * This test tests the loading of horizontally formatted Jronn output file - * - * First seq - * - * M 0.86010 0.88512 0.37094 - * - * T 0.79983 0.85864 0.44331 - * - */ - @SuppressWarnings("unchecked") - @Test - public void ReadDisemblResults() { - Map>> _ranges=new HashMap>>(); - Map> ranges=new HashMap>(); - Map> _values=new HashMap>(); - Map values = new HashMap(); - Set rset; - rset = new HashSet(); - for (String[] se:new String[][] { { "34","41"},{"50","58"},{"83","91"},{"118","127"},{" 160","169"},{" 191","220"},{" 243","252"},{" 287","343"},{" 350","391"},{" 429","485"},{" 497","506"},{"539","547"}}) { - rset.add(new Range(se)); - } - ranges.put(DisemblResult.COILS.toString(), rset); - values.put(DisemblResult.COILS.toString(), Float.valueOf(0.86010f)); - rset = new HashSet(); - for (String[] se:new String[][] { { "355","368"}}) { - rset.add(new Range(se)); - } - ranges.put(DisemblResult.REM465.toString(), rset); - values.put(DisemblResult.REM465.toString(), Float.valueOf(0.88512f)); - rset = new HashSet(); - for (String[] se:new String[][] { { "190","204"}}) { - rset.add(new Range(se)); - } - ranges.put(DisemblResult.HOTLOOPS.toString(), rset); - values.put(DisemblResult.HOTLOOPS.toString(), Float.valueOf(0.37094f)); - _ranges.put("Foobar_dundeefriends", ranges); - _values.put("Foobar_dundeefriends", values); - FileInputStream fio; - try { - fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "disembl.out"); - Map> aseqs = SequenceUtil.readDisembl(fio); - assertNotNull(aseqs); - assertEquals(aseqs.size(), 3); - ScoreManager sman = ScoreManager.newInstance(aseqs); - - for (String fs : aseqs.keySet()) { - assertTrue(" Foobar_dundeefriends Foobar dundeefriends ".contains(fs)); - Set scores = aseqs.get(fs); - assertEquals(scores.size(), 3); - for (Score sc:scores) { - if (_ranges.containsKey(fs)) { - assertEquals("Checking range for Method "+sc.getMethod(),_ranges.get(fs).get(sc.getMethod()), sc.getRanges()); - assertEquals("Checking first value for Method "+sc.getMethod(), _values.get(fs).get(sc.getMethod()), sc.getScores().get(0)); - } - } - } - fio.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (UnknownFileFormatException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - /** - * This method tests the loading of horizontally formatted Jronn output file - * - * First sequence: - * - * >Foobar_dundeefriends - * - * # GlobDoms 2-358, 373-568 - * - * # Disorder 1-5, 206-218, 243-250, 288-300, 313-324, 359-372, 475-481 - * - * # RESIDUE DYDX RAW SMOOTHED - * - * M 0.0044 -0.2259 -0.2259 - * - * T -0.1308 -0.2170 -0.2170 - * - * ............ - * - * > Second sequence - */ - @SuppressWarnings("unchecked") - @Test - public void ReadGlobPlotResults() { - - FileInputStream fio; - try { - fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "globplot.out"); - HashMap> aseqs = SequenceUtil.readGlobPlot(fio); - assertNotNull(aseqs); - assertEquals(aseqs.size(), 3); - - String fsdf = null; - Set scores = null; - for (String fs : aseqs.keySet()) { - if ("Foobar_dundeefriends".contains(fs)) { - fsdf = fs; - scores = aseqs.get(fs); - } - assertEquals(scores.size(), 5); - } - - ScoreManager sm = ScoreManager.newInstanceSingleSequence(scores); - sm.writeOut(new PrintWriter(System.out, true)); - - for (Score score : scores) { - if (score.getMethod().equals(GlobProtResult.Disorder.toString())) { - assertEquals(score.getRanges().size(), 7); - assertTrue(score.getScores().isEmpty()); - } - if (GlobProtResult.valueOf(score.getMethod()) == GlobProtResult.Dydx) { - assertFalse(score.getScores().isEmpty()); - assertTrue(score.getRanges().isEmpty()); - } - } - fio.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (UnknownFileFormatException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void ReadIUPredForShortAndLongDisorder() { - try { - Map scores = SequenceUtil.readIUPred(new File(AllTestSuit.TEST_DATA_PATH, "out.long")); - ScoreManager man = ScoreManager.newInstanceSingleScore(scores); - assertNotNull(scores); - assertEquals(3, scores.size()); - - Score score = scores.get("Foobar_dundeefriends"); - assertNotNull(score); - assertEquals(0, score.getRanges().size()); - assertEquals(568, score.getScores().size()); - assertEquals("Long", score.getMethod()); - - score = scores.get("Foobar"); - assertNotNull(score); - assertEquals(0, score.getRanges().size()); - assertEquals(481, score.getScores().size()); - assertEquals("Long", score.getMethod()); - - score = scores.get("dundeefriends"); - assertNotNull(score); - assertEquals(0, score.getRanges().size()); - assertEquals(513, score.getScores().size()); - assertEquals("Long", score.getMethod()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (UnknownFileFormatException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void ReadIUPredForGlobDomain() { - try { - Map scores = SequenceUtil.readIUPred(new File(AllTestSuit.TEST_DATA_PATH, "output.glob")); - assertNotNull(scores); - assertEquals(2, scores.size()); - ScoreManager man = ScoreManager.newInstanceSingleScore(scores); - assertEquals(2, man.getNumberOfSeq()); - Score score = scores.get("P53_HUMA"); - assertNotNull(score); - assertEquals(2, score.getRanges().size()); - assertEquals(0, score.getScores().size()); - assertEquals("Glob", score.getMethod()); - score = scores.get("Foobar_dundeefriends"); - assertEquals(0, score.getRanges().size()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (UnknownFileFormatException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void ReadAAConResults() { - 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()); - } - } - @Test - public void ReadJpredResults() { - try { - InputStream inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "Jpred.test1.out"); - List result = SequenceUtil.readJpredFile(inStream); - inStream.close(); - assertNotNull(result); - assertEquals(result.size(), 19); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} - diff --git a/testsrc/compbio/engine/EngineConfiguratorTester.java b/testsrc/compbio/engine/EngineConfiguratorTester.java deleted file mode 100644 index 6a0d27d..0000000 --- a/testsrc/compbio/engine/EngineConfiguratorTester.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine; - -import static org.testng.Assert.fail; - -import org.testng.annotations.Test; - -import compbio.engine.client.ConfiguredExecutable; -import compbio.metadata.JobSubmissionException; -import compbio.runner.msa.ClustalW; - -public class EngineConfiguratorTester { - - @Test - public void testGetAsyncEngine() { - - ClustalW clustal = new ClustalW(); - - try { - SyncExecutor sEngine = Configurator.getSyncEngine(Configurator - .configureExecutable(clustal)); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void testGetSyncEngine() { - ClustalW clustal = new ClustalW(); - try { - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal); - AsyncExecutor aEngine = Configurator.getAsyncEngine(confClust); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - -} diff --git a/testsrc/compbio/engine/FilePullerTester.java b/testsrc/compbio/engine/FilePullerTester.java deleted file mode 100644 index 2ffb4c8..0000000 --- a/testsrc/compbio/engine/FilePullerTester.java +++ /dev/null @@ -1,203 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.util.concurrent.TimeUnit; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.local.AsyncLocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; -import compbio.runner.msa.Muscle; - -public class FilePullerTester { - - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381.fasta"; - - String jobId; - String jobId2; - String jobId3; - - @BeforeTest(alwaysRun = true) - public void init() { - ClustalW clustal = new ClustalW(); - clustal.setInput(test_input); - Muscle ms = new Muscle().setInput(test_input); - Muscle ms2 = new Muscle().setInput(test_input); - - try { - // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); - ConfiguredExecutable confms = Configurator - .configureExecutable(ms, Executable.ExecProvider.Local); - - ConfiguredExecutable confms2 = Configurator - .configureExecutable(ms2, Executable.ExecProvider.Local); - - AsyncLocalRunner as = new AsyncLocalRunner(); - jobId = as.submitJob(confClustal); - jobId2 = as.submitJob(confms); - jobId3 = as.submitJob(confms2); - - ConfiguredExecutable al = as.getResults(jobId); - ConfiguredExecutable al2 = as.getResults(jobId2); - ConfiguredExecutable al3 = as.getResults(jobId3); - assertNotNull(al); - assertNotNull(al2); - assertNotNull(al3); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_engine }) - public void testPull() { - assertNotNull(jobId, "init() method failed!"); - String workDir = Configurator.getWorkDirectory(jobId); - String statFile = workDir + File.separator + ClustalW.getStatFile(); - - ChunkHolder ch = ProgressGetter.pull(statFile, 0); - while (ch == null) { - ch = ProgressGetter.pull(statFile, 0); - } - String chunk = ""; - long pos = 0; - do { - chunk = ch.getChunk(); - assertNotNull(chunk); - pos = ch.getNextPosition(); - ch = ProgressGetter.pull(statFile, pos); - } while (chunk.length() > 0); - - // All consequent pulls just return empty chunk and same position = - // file.length - ch = ProgressGetter.pull(statFile, pos); - assertNotNull(ch); - assertEquals(ch.getChunk().length(), 0); - // Output file size depends on the operation system fs! - // assertEquals(ch.getNextPosition(), 668); - - ch = ProgressGetter.pull(statFile, pos); - assertNotNull(ch); - assertEquals(ch.getChunk().length(), 0); - // Output file size depends on the operation system and fs! - // assertEquals(ch.getNextPosition(), 668); - - } - - @Test(groups = { AllTestSuit.test_group_engine }) - public void testGetDelay() { - FilePuller fp = FilePuller.newFilePuller(Configurator - .getWorkDirectory(jobId) - + File.separator + "stat.log", 256); - // default delay is 5 minutes - assertEquals(fp.getDelayValue(TimeUnit.SECONDS), 5 * 60); - long d = 1000 * 1000 * 1000L * 60; // 1m in nanoseconds - fp.setDelay(d, TimeUnit.NANOSECONDS); - assertEquals(fp.getDelayValue(TimeUnit.NANOSECONDS), d); - assertEquals(fp.getDelayValue(TimeUnit.SECONDS), 60); - assertEquals(fp.getDelayValue(TimeUnit.MINUTES), 1); - } - - @Test(groups = { AllTestSuit.test_group_engine }, dependsOnMethods = { "testPull" }) - public void testCache() { - assertNotNull(jobId, "init() method failed!"); - assertNotNull(jobId2, "init() method failed!"); - assertEquals(PulledFileCache.getSize(), 1); // One is from previous test - - String statFile = Configurator.getWorkDirectory(jobId) + File.separator - + ClustalW.getStatFile(); - String statFile2 = Configurator.getWorkDirectory(jobId2) - + File.separator + Muscle.getStatFile(); - String statFile3 = Configurator.getWorkDirectory(jobId3) - + File.separator + Muscle.getStatFile(); - - ChunkHolder ch = ProgressGetter.pull(statFile, 0); - assertEquals(PulledFileCache.getSize(), 1); // Still one as job has been - // retrieved from cache - ChunkHolder ch2 = ProgressGetter - .pull(statFile2, 0, 5, TimeUnit.SECONDS); // 5 - // second delay - assertEquals(PulledFileCache.getSize(), 2); // One is from previous test - - // Pull the first job completely - while (ch == null) { - ch = ProgressGetter.pull(statFile, 0); - } - String chunk = ""; - long pos = 0; - do { - chunk = ch.getChunk(); - assertNotNull(chunk); - pos = ch.getNextPosition(); - ch = ProgressGetter.pull(statFile, pos); - } while (chunk.length() > 0); - - try { - Thread.sleep(1000 * 6); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - // Elements are removed on put operation only - assertEquals(PulledFileCache.getSize(), 2); // One is from previous test - ChunkHolder ch3 = ProgressGetter.pull(statFile3, 0); - // Now old element was removed, but new added, thus size remains - // constant - assertEquals(PulledFileCache.getSize(), 2); // One is from previous test - - } - - @Test - public void testGet() { - - FilePuller pp = FilePuller - .newProgressPuller(AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "percentProgress.txt"); - try { - assertEquals(pp.getProgress(), 12); - pp.disconnect(); - } catch (NumberFormatException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/engine/LoadBalancerTester.java b/testsrc/compbio/engine/LoadBalancerTester.java deleted file mode 100644 index f345720..0000000 --- a/testsrc/compbio/engine/LoadBalancerTester.java +++ /dev/null @@ -1,68 +0,0 @@ -package compbio.engine; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.List; - -import org.testng.annotations.Test; - -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.SequenceUtil; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Limit; -import compbio.metadata.PresetManager; -import compbio.runner.msa.ClustalW; - -public class LoadBalancerTester { - - @Test - public void testLoadBalance() { - /** - * This is 5 sequence x per 20000 length - */ - String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "testlimit.fasta"; - try { - FileInputStream fio = new FileInputStream(test_input); - List data = SequenceUtil.readFasta(fio); - fio.close(); - assertNotNull(data); - assertTrue(data.size() > 0); - - ClustalW clustal = new ClustalW(); - /** - * ClustalW local limit is 2 sequences per 500 letters - */ - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal); - ExecProvider aEngine = LoadBalancer.getEngine(confClust, data); - Limit locExec = new Limit(2, 500, PresetManager.LOCAL_ENGINE_LIMIT_PRESET); - // For testing of production configuration uncomment - //Limit locExec = confClust - // .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); - assertTrue(locExec.getSeqNumber() <= data.size() - || locExec.getAvgSeqLength() * locExec.getSeqNumber() <= Limit - .getAvgSequenceLength(data)); - // Engine will be local because LoadBalancer accessed the presets & limits - // directly - // For testing of production configuration uncomment - // assertEquals(aEngine, ExecProvider.Cluster); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - - } -} diff --git a/testsrc/compbio/engine/PulledFileCacheTester.java b/testsrc/compbio/engine/PulledFileCacheTester.java deleted file mode 100644 index 9201e73..0000000 --- a/testsrc/compbio/engine/PulledFileCacheTester.java +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.util.concurrent.TimeUnit; - -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; - -public class PulledFileCacheTester { - - @Test - public void test() { - try { - FilePuller fp1 = FilePuller.newFilePuller( - AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "1", 256); - fp1.setDelay(2, TimeUnit.SECONDS); - - FilePuller fp2 = FilePuller.newFilePuller( - AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "2", 256); - fp2.setDelay(1, TimeUnit.SECONDS); - - FilePuller fp3 = FilePuller.newFilePuller( - AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "3", 256); - fp3.setDelay(1, TimeUnit.SECONDS); - - FilePuller fp4 = FilePuller.newFilePuller( - AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "4", 256); - fp4.setDelay(5, TimeUnit.SECONDS); - - // This only hold if tested in isolation thus clear is essential - PulledFileCache.clear(); - assertEquals(PulledFileCache.getSize(), 0); - PulledFileCache.put(fp1); - PulledFileCache.put(fp2); - PulledFileCache.put(fp3); - PulledFileCache.put(fp4); - assertEquals(PulledFileCache.getSize(), 4); - Thread.sleep(1000); - // sweep was not called yet - assertEquals(PulledFileCache.getSize(), 4); - // now sweep is called - PulledFileCache.put(fp1); - // fp1 and fp1 and fp4 only remains - copies are allowed this is - // responsibility of the caller to ensure they are not there - assertEquals(PulledFileCache.getSize(), 3); - assertNotNull(PulledFileCache - .get(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "1")); - assertNotNull(PulledFileCache - .get(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "4")); - - for (int i = 0; i < 4; i++) { - Thread.sleep(1000); - FilePuller fp = PulledFileCache - .get(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "4"); - // This will update access time - fp.isFileCreated(); - } - // still fp1 and fp4 only remains - - assertEquals(PulledFileCache.getSize(), 3); - PulledFileCache.put(FilePuller.newFilePuller( - AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "5", 256)); - // at this point only fp4 and 5 will remain - assertEquals(PulledFileCache.getSize(), 2); - assertNotNull(PulledFileCache - .get(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "4")); - assertNotNull(PulledFileCache - .get(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "5")); - - } catch (InterruptedException e) { - fail(e.getMessage()); - } - } - -} diff --git a/testsrc/compbio/engine/client/CommandBuilderTester.java b/testsrc/compbio/engine/client/CommandBuilderTester.java deleted file mode 100644 index 41b8354..0000000 --- a/testsrc/compbio/engine/client/CommandBuilderTester.java +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.client; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import org.testng.annotations.Test; - -import compbio.metadata.RunnerConfig; -import compbio.runner.msa.ClustalW; -import compbio.runner.msa.Mafft; -import compbio.runner.msa.Muscle; - -public class CommandBuilderTester { - - @Test() - public void testCommandBuilding() { - CommandBuilder builder = new CommandBuilder("="); - builder.setParam("-MATRIX", "blosum65"); - assertTrue(builder.getCommands().size() == 1); - String p = builder.getParamValue("-MATRIX"); - builder.setParam("-clustalw"); - builder.setParam("-in", "\\gile\\path\\abs.txt"); - System.out.println(builder.getCommands()); - assertTrue(builder.getCommands().size() == 3); - builder.setParam("-stat=/test.log"); - assertTrue(builder.getCommands().size() == 4); - System.out.println("CP:" + builder.getCommands()); - assertTrue(builder.setParam("-stat=/newtest.log")); - - List clist = Arrays.asList("-prop", "-tree=treefile.txt", - "-clustalw"); - builder.addParams(clist); - assertTrue(builder.size() == 6); - builder.setParams(clist); - assertTrue(builder.size() == 3); - System.out.println("CP:" + builder.getCommands()); - String option = "-log=error.txt"; - builder.setFirst(option); - assertEquals(builder.getCommands().get(0), option); - builder.setParam("-newParam2"); - assertEquals(builder.getCommands().get(0), option); - builder.setLast(option); - assertNotSame(builder.getCommands().get(0), option); - assertEquals(builder.getCommands().get(builder.size() - 1), option); - builder.setParam("-newParam3"); - assertEquals(builder.getCommands().get(builder.size() - 1), option); - builder.setParam("-prm5", "prm5Value"); - assertTrue(builder.hasParam("-prm5")); - } - - @Test - public void testSpaceDelimiterExecutable() { - CommandBuilder cbuilder = new CommandBuilder(" "); - cbuilder.addParams(Arrays.asList("-clwstrict", "-quiet", "-verbose", - "-log", "EXEC_STAT_FILE")); - } - - @Test - public void testOptionsToCommand() { - try { - RunnerConfig rconf = ConfExecutable - .getRunnerOptions(Mafft.class); - CommandBuilder cbuilder = CommandBuilder.newCommandBuilder( - rconf.getArguments(), Mafft.KEY_VALUE_SEPARATOR); - String comm = ""; - for (String val : cbuilder.getCommands()) { - assertFalse(val.contains(cbuilder.nameValueSeparator)); - comm += val + cbuilder.nameValueSeparator; - } - assertEquals(cbuilder.getCommandString(), comm); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } -} diff --git a/testsrc/compbio/engine/client/PathValidatorTester.java b/testsrc/compbio/engine/client/PathValidatorTester.java deleted file mode 100644 index f6867f7..0000000 --- a/testsrc/compbio/engine/client/PathValidatorTester.java +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.client; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; - -import org.testng.annotations.Test; - -import compbio.engine.client.PathValidator; -import compbio.runner.msa.ClustalW; -import compbio.util.SysPrefs; - -public class PathValidatorTester { - - @Test - public void testIsAbsolutePath() { - - if (SysPrefs.isWindows) { - /* - * slash(\) has to be prefixed with another slash to produce a - * single slash - */ - assertTrue(PathValidator.isAbsolutePath("d:\\temp")); - assertFalse(PathValidator.isAbsolutePath("/home")); - } else { - assertFalse(PathValidator.isAbsolutePath("d:\\temp")); - assertTrue(PathValidator.isAbsolutePath("/home")); - } - assertFalse(PathValidator.isAbsolutePath("home")); - } - - @Test - public void testGetClassPath() { - String clname = ClustalW.class.getSimpleName(); - System.out.println("%" + clname); - URL url = ClustalW.class.getResource(clname + ".class"); - URL url2 = ClassLoader.getSystemResource("Engine.local.properties"); - - try { - File f = new File(url.toURI()); - System.out.println("&" + f.getAbsolutePath()); - System.out.println("&" + f.getCanonicalPath()); - System.out.println("&" + f.getParent()); - } catch (URISyntaxException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - System.out.println("!!" + url2); - System.out.println("!" + url.getFile()); - System.out.println("!" + System.getProperty("java.class.path", null)); - - } -} diff --git a/testsrc/compbio/engine/cluster/drmaa/ClusterSessionTester.java b/testsrc/compbio/engine/cluster/drmaa/ClusterSessionTester.java deleted file mode 100644 index d72337b..0000000 --- a/testsrc/compbio/engine/cluster/drmaa/ClusterSessionTester.java +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.cluster.drmaa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import org.testng.annotations.Test; - -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.Job; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; -import compbio.util.Util; - -public class ClusterSessionTester { - - @Test(sequential = true, groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_engine }) - public void testTaskList() { - ClustalW cl = new ClustalW(); - - try { - ConfiguredExecutable clw = Configurator - .configureExecutable(cl, Executable.ExecProvider.Cluster); - ClusterRunner jr = ClusterRunner.getInstance(clw); - String jobId = jr.submitJob(); - ClusterSession cs = ClusterSession.getInstance(); - // this only holds for sequential execution - //assertEquals(cs.jobs.size(), 1); - assertTrue(Job.getByTaskId(jobId, cs.jobs) != null); - assertEquals(Job.getByTaskId(jobId, cs.jobs).getConfExecutable(), - clw); - jr.cancelJob(jobId); - // this only holds for sequential execution - assertEquals(cs.jobs.size(), 0); - - clw = Configurator.configureExecutable(cl, - Executable.ExecProvider.Cluster); - assertFalse(Util.isEmpty(clw.getWorkDirectory())); - AsyncExecutor aengine = Configurator.getAsyncEngine(clw); - jobId = aengine.submitJob(clw); - assertEquals(cs.jobs.size(), 1); - assertTrue(Job.getByTaskId(jobId, cs.jobs) != null); - assertEquals(Job.getByTaskId(jobId, cs.jobs).getConfExecutable(), - clw); - assertFalse(Util.isEmpty(compbio.engine.Configurator - .getWorkDirectory(jobId))); - String workDir = clw.getWorkDirectory(); - assertEquals(workDir, compbio.engine.Configurator - .getWorkDirectory(jobId)); - - aengine.getResults(jobId); - assertEquals(cs.jobs.size(), 0); - assertFalse(Util.isEmpty(clw.getWorkDirectory())); - // after job has been removed from the list (e.g when completed) - // reference to a work directory can still be obtained by other - // means - assertFalse(Util.isEmpty(compbio.engine.Configurator - .getWorkDirectory(jobId))); - assertEquals(compbio.engine.Configurator.getWorkDirectory(jobId), - workDir); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - -} diff --git a/testsrc/compbio/engine/cluster/drmaa/DrmaaAsyncClusterEngineTester.java b/testsrc/compbio/engine/cluster/drmaa/DrmaaAsyncClusterEngineTester.java deleted file mode 100644 index 922aa90..0000000 --- a/testsrc/compbio/engine/cluster/drmaa/DrmaaAsyncClusterEngineTester.java +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.cluster.drmaa; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import org.testng.annotations.Test; - -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; -import compbio.util.SysPrefs; - -public class DrmaaAsyncClusterEngineTester { - - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381.fasta"; - public static String large_test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "1000x3000Dna.fasta"; - public static String cluster_test_outfile = "TO1381.clustal.cluster.out"; - - /** - * This test uses ClustalW executable as runnable to testing, thus depends - * on its correct functioning - */ - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_engine }) - public void testSubmit() { - ClustalW clustal = new ClustalW(); - assertFalse("Cluster execution can only be in unix environment", - SysPrefs.isWindows); - clustal.setInput(test_input).setOutput(cluster_test_outfile); - try { - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); - AsyncExecutor runner = new AsyncClusterRunner(); - assertNotNull("Runner is NULL", runner); - String jobId = runner.submitJob(confClustal); - assertEquals("Input was not set!", test_input, clustal.getInput()); - assertNotNull("JobId is null", jobId); - JobStatus status = runner.getJobStatus(jobId); - assertTrue("Status of the process is wrong!", - status == JobStatus.PENDING || status == JobStatus.RUNNING); - JobStatus info = runner.getJobStatus(jobId); - assertNotNull("JobInfo is null", info); - Executable result = runner.getResults(jobId); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(expectedExceptions = ResultNotAvailableException.class, groups = { - AllTestSuit.test_group_cluster, AllTestSuit.test_group_engine }) - // expectedExceptions = ResultNotAvailableException.class, - public void testCancel() throws ResultNotAvailableException { - ClustalW clustal = new ClustalW(); - assertFalse("Cluster execution can only be in unix environment", - SysPrefs.isWindows); - clustal.setInput(large_test_input).setOutput(cluster_test_outfile); - - try { - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); - AsyncClusterRunner runner = new AsyncClusterRunner(); - String jobId = runner.submitJob(confClustal); - assertNotNull("Runner is NULL", runner); - // assertNotNull("JobId is null", jobId1); - Thread.sleep(200); - JobStatus status = runner.getJobStatus(jobId); - assertTrue("Status of the process is wrong!", - status == JobStatus.PENDING || status == JobStatus.RUNNING); - assertFalse("Status of the process is wrong!", - status == JobStatus.FINISHED); - runner.cancelJob(jobId); - // This is never NULL as long as the job has started! - ConfiguredExecutable exec = runner.getResults(jobId); - assertNull(exec.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail("Interupted exception caught:" + e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_engine }) - public void testGetJobStatus() { - ClustalW clustal = new ClustalW(); - assertFalse("Cluster execution can only be in unix environment", - SysPrefs.isWindows); - clustal.setInput(test_input).setOutput(cluster_test_outfile); - - try { - AsyncClusterRunner runner = new AsyncClusterRunner(); - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); - String jobId = runner.submitJob(confClustal); - assertNotNull("Runner is NULL", runner); - AsyncClusterRunner runner2 = new AsyncClusterRunner(); - - boolean hasRun = false; - boolean hasPended = false; - Thread.sleep(500); - JobStatus status = runner2.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - if (status == JobStatus.CANCELLED) { - fail("Job is not cancelled!"); - } - if (status == JobStatus.FAILED) { - fail("Job should not fail!"); - } - if (status == JobStatus.RUNNING) { - hasRun = true; - } - if (status == JobStatus.PENDING) { - hasPended = true; - } - if (status == JobStatus.UNDEFINED) { - System.out.println("Wrong status (UNDEFINED) reported by cluster engine!"); - break; - } - status = runner2.getJobStatus(jobId); - } - assertTrue(hasRun); - assertTrue(hasPended); - assertTrue(hasRun); - // Bear in mind that if the task were not put in the queue - // immediately - // the status could be UNDEFINED! - // assertFalse(hasUndefined); - AsyncClusterRunner runner3 = new AsyncClusterRunner(); - Executable exec = runner3.getResults(jobId); - assertNotNull(exec); - // Now try collecting result for the second time - exec=null; - Thread.sleep(1000); - exec = runner3.getResults(jobId); - assertNotNull(exec); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/engine/cluster/drmaa/DrmaaClusterEngineTester.java b/testsrc/compbio/engine/cluster/drmaa/DrmaaClusterEngineTester.java deleted file mode 100644 index eb5ead2..0000000 --- a/testsrc/compbio/engine/cluster/drmaa/DrmaaClusterEngineTester.java +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.cluster.drmaa; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.text.ParseException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.Test; - -import compbio.data.sequence.Alignment; -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.EngineUtil; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; -import compbio.util.SysPrefs; - -public class DrmaaClusterEngineTester { - - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381.fasta"; - public static String cluster_test_outfile = "TO1381.clustal.cluster.out"; - - /** - * This test uses ClustalW executable as runnable to testing, thus depends - * on its correct functioning - */ - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_engine }) - public void testSubmit() { - ClustalW clustal = new ClustalW(); - assertFalse("Cluster execution can only be in unix environment", - SysPrefs.isWindows); - clustal.setInput(test_input).setOutput(cluster_test_outfile); - - try { - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal, - Executable.ExecProvider.Cluster); - assertNotNull(confClust.getWorkDirectory()); - - ClusterRunner runner = ClusterRunner.getInstance(confClust); - assertEquals("Input was not set!", test_input, clustal.getInput()); - assertNotNull("Runner is NULL", runner); - runner.executeJob(); - // assertNotNull("JobId is null", jobId1); - JobStatus status = runner.getJobStatus(); - assertTrue("Status of the process is wrong!", - status == JobStatus.PENDING || status == JobStatus.RUNNING); - JobInfo info = runner.getJobInfo(); - - assertFalse(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.CANCELLED)); - assertFalse(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.STARTED)); - assertFalse(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.COLLECTED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.FINISHED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.SUBMITTED)); - - ConfiguredExecutable confExec = runner.waitForResult(); - // At this point results are marked as collected - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.COLLECTED)); - - assertNotNull("JobInfo is null", info); - StatisticManager sm = new StatisticManager(info); - assertNotNull("Statistics manager is null", sm); - - try { - - String exits = sm.getExitStatus(); - assertNotNull("Exit status is null", exits); - // cut 4 trailing zeros from the number - int exitsInt = ClusterEngineUtil.CLUSTER_STAT_IN_SEC.parse(exits) - .intValue(); - assertEquals("Exit status is not 0", 0, exitsInt); - System.out.println(sm.getAllStats()); - - } catch (ParseException e) { - e.printStackTrace(); - fail("Parse Exception: " + e.getMessage()); - } - assertTrue("Process exited:", sm.hasExited()); - assertFalse("Process aborted:", sm.wasAborted()); - assertFalse("Process hasdump:", sm.hasDump()); - assertFalse("Process signaled:", sm.hasSignaled()); - - Alignment al = confExec.getResults(); - assertNotNull(al); - assertFalse("Could not remove some files whilst cleaning up ", - runner.cleanup()); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (ResultNotAvailableException e) { - fail("DrmaaException caught:" + e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_engine }) - public void testCancel() { - ClustalW clustal = new ClustalW(); - assertFalse("Cluster execution can only be in unix environment", - SysPrefs.isWindows); - clustal.setInput(test_input).setOutput(cluster_test_outfile); - - try { - - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal, - Executable.ExecProvider.Cluster); - assertNotNull(confClust.getWorkDirectory()); - - ClusterRunner runner = ClusterRunner.getInstance(confClust); - assertNotNull("Runner is NULL", runner); - - runner.executeJob(); - // assertNotNull("JobId is null", jobId1); - Thread.sleep(500); - JobStatus status = runner.getJobStatus(); - assertTrue("Status of the process is wrong!", - status == JobStatus.PENDING || status == JobStatus.RUNNING); - runner.cancelJob(); - Thread.sleep(200); // give fs time to write a file - JobInfo info = runner.getJobInfo(); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.CANCELLED)); - assertFalse(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.STARTED)); - assertFalse(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.COLLECTED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.FINISHED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.SUBMITTED)); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail("Interupted exception caught:" + e.getMessage()); - } - } - -} diff --git a/testsrc/compbio/engine/cluster/drmaa/UtilTester.java b/testsrc/compbio/engine/cluster/drmaa/UtilTester.java deleted file mode 100644 index d8bf470..0000000 --- a/testsrc/compbio/engine/cluster/drmaa/UtilTester.java +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.cluster.drmaa; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.fail; - -import java.text.ParseException; - -import org.testng.annotations.Test; - -import compbio.engine.cluster.drmaa.ClusterEngineUtil; - -public class UtilTester { - - @Test - public void testParser() { - try { - Number n = ClusterEngineUtil.CLUSTER_STAT_IN_SEC.parse("11.0000"); - assertNotNull(n); - int t = n.intValue(); - assertEquals(11, t); - n = ClusterEngineUtil.CLUSTER_STAT_IN_SEC.parse("11.2300"); - assertNotNull(n); - t = n.intValue(); - assertEquals(11, t); - float f = n.floatValue(); - assertEquals(11.23f, f); - n = ClusterEngineUtil.CLUSTER_STAT_IN_SEC.parse("0.0310"); - assertNotNull(n); - f = n.floatValue(); - assertEquals(0.031f, f); - } catch (ParseException e) { - e.printStackTrace(); - fail("Parsing failed: " + e.getMessage()); - } - - } -} diff --git a/testsrc/compbio/engine/conf/DirectoryManagerTester.java b/testsrc/compbio/engine/conf/DirectoryManagerTester.java deleted file mode 100644 index acde559..0000000 --- a/testsrc/compbio/engine/conf/DirectoryManagerTester.java +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.conf; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.util.HashSet; -import java.util.Set; - -import org.testng.annotations.Test; - -import compbio.runner.msa.ClustalW; -import compbio.util.SysPrefs; - -public class DirectoryManagerTester { - - @Test(invocationCount = 4, threadPoolSize = 4, sequential = false) - public void testGetDirectory() { - Set set = new HashSet(); - for (int i = 0; i < 20000; i++) { - long number = DirectoryManager.getNonRepeatableNumber(); - assertTrue(set.add(number)); - // Cannot rely on the length is the returned long, as precision is - // implementation dependent - // see testNanoTime method below - // assertEquals(Long.toString(number).length(), 17); - } - String name = DirectoryManager.getTaskDirectory(ClustalW.class); - assertTrue(name.startsWith(ClustalW.class.getSimpleName())); - } - - /* - * In fact the precision of System.nanoTime() varies depending on the JVM - * Sun 1.6.0_17 JVM gives the same precision on linux x64 as on windows x32 - * but openjdk 1.6.x gives more digits on linux than sun JVM It looks like - * the precision is desided at runtime, so the number of digits returned is - * unknown - */ - @Test(enabled = false) - public void testNanoTime() { - if (SysPrefs.isWindows) { - assertEquals(Long.toString(System.nanoTime()).length(), 16); - } else { - // This is not always true for Linux - assertEquals(Long.toString(System.nanoTime()).length(), 14); - } - } - -} diff --git a/testsrc/compbio/engine/conf/PropertyHelperManagerTester.java b/testsrc/compbio/engine/conf/PropertyHelperManagerTester.java deleted file mode 100644 index ab3aa42..0000000 --- a/testsrc/compbio/engine/conf/PropertyHelperManagerTester.java +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.conf; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.io.File; - -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; -import compbio.util.PropertyHelper; - -public class PropertyHelperManagerTester { - - PropertyHelper ph; - - @BeforeClass(alwaysRun=true) - public void testLoadResources() { - ph = PropertyHelperManager.getPropertyHelper(); - assertNotNull(ph); - } - - @Test(groups = AllTestSuit.test_group_cluster) - public void testClusterEngineConf() { - // Below are the properties on cluster engine required for its - // functioning - validateDirProp("cluster.tmp.directory"); - } - - void validateDirProp(String propName) { - assertNotNull(ph); - assertNotNull(ph.getProperty(propName)); - File tmp = new File(ph.getProperty(propName).trim()); - assertTrue(tmp.exists()); - assertTrue(tmp.isDirectory()); - assertTrue(tmp.canRead()); - assertTrue(tmp.canWrite()); - } - - void validateExecFileProp(String propName) { - validateFileProp(propName); - File tmp = new File(ph.getProperty(propName)); - assertTrue(tmp.canExecute()); - } - - void validateFileProp(String propName) { - assertNotNull(ph.getProperty(propName)); - File tmp = new File(ph.getProperty(propName)); - assertTrue(tmp.exists()); - assertTrue(tmp.isFile()); - assertTrue(tmp.canRead()); - } - - @Test - public void validateClustalConfiguration() { - // Below are the properties on Clustal executable required for its - // functioning - // Executables could not be verified as full path is constructed only at - // runtime - assertNotNull("local.clustalw.bin.windows"); - assertNotNull("local.clustalw.bin"); - assertNotNull("cluster.clustalw.bin"); - validateFileProp("clustalw.presets.file"); - validateFileProp("clustalw.parameters.file"); - //validateFileProp("clustalw.limits.file"); - } - - @Test - public void validateMuscleConfiguration() { - assertNotNull("local.muscle.bin.windows"); - assertNotNull("local.muscle.bin"); - assertNotNull("cluster.muscle.bin"); - validateFileProp("muscle.presets.file"); - validateFileProp("muscle.parameters.file"); - //validateFileProp("muscle.limits.file"); - } - - @Test - public void validateTcoffeeConfiguration() { - assertNotNull("local.tcoffee.bin.windows"); - assertNotNull("local.tcoffee.bin"); - assertNotNull("cluster.tcoffee.bin"); - validateFileProp("tcoffee.presets.file"); - validateFileProp("tcoffee.parameters.file"); - //validateFileProp("tcoffee.limits.file"); - } - - @Test - public void validateMafftConfiguration() { - assertNotNull("local.mafft.bin.windows"); - assertNotNull("local.mafft.bin"); - assertNotNull("cluster.mafft.bin"); - validateFileProp("mafft.presets.file"); - validateFileProp("mafft.parameters.file"); - //validateFileProp("mafft.limits.file"); - } -} diff --git a/testsrc/compbio/engine/conf/RunnerConfigMarshallerTester.java b/testsrc/compbio/engine/conf/RunnerConfigMarshallerTester.java deleted file mode 100644 index db2ac48..0000000 --- a/testsrc/compbio/engine/conf/RunnerConfigMarshallerTester.java +++ /dev/null @@ -1,263 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.conf; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.JAXBException; -import javax.xml.validation.Schema; -import javax.xml.validation.Validator; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import compbio.metadata.AllTestSuit; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.RunnerConfig; -import compbio.metadata.ValueConstrain; -import compbio.metadata.WrongParameterException; -import compbio.runner.msa.Mafft; - -public class RunnerConfigMarshallerTester { - - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "MafftParameters.xml"; - public static String test_schema_output = "RunnerConfigSchema.xml"; - public static String test_output = AllTestSuit.OUTPUT_DIR_ABSOLUTE + "MafftParameters.out.xml"; - - public static String invalidDoc = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "InvalidMafftParameters.xml"; - - RunnerConfig rconfig = null; - Parameter matrixParam = null; - RunnerConfigMarshaller pmarshaller = null; - - @BeforeMethod - public void setup() { - // write some parameters programmatically - try { - rconfig = new RunnerConfig(); - rconfig.setRunnerClassName(Mafft.class.getName()); - List> prms = new ArrayList>(); - - Parameter p1 = new Parameter("Type", "Type of the sequence (PROTEIN or DNA)"); - // TODO publish help on a compbio web site - - p1.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - p1.addPossibleValues("PROTEIN", "DNA"); - p1.setOptionName("-TYPE"); - p1.setRequired(false); - - /* - * -MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or - * filename - */ - Option p2 = new Option("MATRIX", "Protein weight matrix"); - // TODO publish help on a compbio web site - - p2.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p2.addOptionNames("-jtree"); // "-retree" - p2.setRequired(false); - - Parameter p3 = new Parameter("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID"); - // This attribute is required by strict schema - p3.setOptionName("--AAMATRIX"); - p3.setRequired(true); - p3.setDefaultValue("pam"); - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - vc.setMin("-10.12"); - vc.setMax("0"); - p3.setValidValue(vc); - - prms.add(p1); - prms.add(p2); - prms.add(p3); - matrixParam = p3; - rconfig.setOptions(prms); - - pmarshaller = new RunnerConfigMarshaller(RunnerConfig.class, Parameter.class, Option.class, ValueConstrain.class); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test() - public void testMarshalling() { - - File outfile = new File(this.test_output); - try { - pmarshaller.write(rconfig, new FileOutputStream(outfile)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - assertTrue("Output file expected, but nothing found!", outfile.exists()); - outfile.delete(); - } - - @Test() - public void testUnMarshalling() { - - File outfile = new File(this.test_output); - try { - pmarshaller.write(rconfig, new FileOutputStream(outfile)); - - RunnerConfig rconfig = pmarshaller.read(new FileInputStream(outfile), RunnerConfig.class, Parameter.class, Option.class, - ValueConstrain.class); - assertNotNull(rconfig); - assertEquals(rconfig.getParameters().size(), this.rconfig.getParameters().size()); - assertEquals(rconfig.getRunnerClassName(), this.rconfig.getRunnerClassName()); - assertTrue(matrixParam.equals(rconfig.getArgument("MATRIX1"))); - assertFalse(matrixParam.equals(rconfig.getArgument("Type"))); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - // outfile.delete(); - } - - @Test() - public void testValidation() { - try { - System.out.println("CCCC " + rconfig); - // write schema - pmarshaller.generateSchema(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output); - - File schemafile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output); - assertTrue(schemafile.exists()); - // document is NOT valid even against a loose schema as elements in - // java are annotated as required - Validator looseValidator = RunnerConfigMarshaller.getValidator(schemafile.getAbsolutePath()); - - // write output xml file - File outfile = new File(this.test_output); - pmarshaller.write(rconfig, new FileOutputStream(outfile)); - - assertTrue("Invalid output is NOT expected", RunnerConfigMarshaller.validate(looseValidator, test_output)); - - Schema strictSchema = RunnerConfigMarshaller.getSchema(AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator - + "RunnerConfigSchema.xsd"); - - Validator strictVal = RunnerConfigMarshaller.getValidator(strictSchema); - - // document is invalid against strict schema - assertFalse("Invalid output is expected", RunnerConfigMarshaller.validate(strictVal, invalidDoc)); - - // schemafile.delete(); - // outfile.delete(); - - } catch (MalformedURLException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (SAXException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - - } - - @Test(expectedExceptions = JAXBException.class) - public void testValidationOnMarshalling() throws SAXException, JAXBException, MalformedURLException { - // This is not valid parameter - Parameter p = new Parameter("MATRIXXX", "Protein weight matrix"); - // This attribute is required by strict schema - // p.setOptionName("-M"); - p.setRequired(true); - rconfig.addParameter(p); - try { - - // strict schema invalidate this document and throw an exception - // just discard the output - pmarshaller.writeAndValidate(rconfig, AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator + "RunnerConfigSchema.xsd", - new ByteArrayOutputStream()); - - fail("Exception has been thrown before this place in unreachable"); - - } catch (MalformedURLException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test() - public void testSchemaFromCodeGeneration() { - try { - - pmarshaller.generateSchema(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - File schemafile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_schema_output); - assertTrue("Schema file expected but not found", schemafile.exists()); - assertTrue("Schema file seems to be empty", schemafile.length() > 50); - // schemafile.delete(); - } - -} diff --git a/testsrc/compbio/engine/local/AsyncLocalRunnerTester.java b/testsrc/compbio/engine/local/AsyncLocalRunnerTester.java deleted file mode 100644 index 271d0e9..0000000 --- a/testsrc/compbio/engine/local/AsyncLocalRunnerTester.java +++ /dev/null @@ -1,392 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.local; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.util.concurrent.CancellationException; - -import org.testng.annotations.Test; - -import compbio.data.sequence.Alignment; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.EngineUtil; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; -import compbio.runner.msa.Muscle; -import compbio.util.SysPrefs; - -public class AsyncLocalRunnerTester { - - // Input path must be absolute to avoid coping input in working directory - public static String unix_test_input = AllTestSuit.CURRENT_DIRECTORY - + File.separator + AllTestSuit.TEST_DATA_PATH + "TO1381.fasta"; - - public static String unix_test_AVG_input = AllTestSuit.CURRENT_DIRECTORY - + File.separator + AllTestSuit.TEST_DATA_PATH - + "50x500Protein.fasta"; - - public static String unix_test_LARGE_input = AllTestSuit.CURRENT_DIRECTORY - + File.separator + AllTestSuit.TEST_DATA_PATH - + "200x500Protein.fasta"; - - // Output file will be located in the task working directory, thus only name - // is required - public static String unix_test_outfile = "TO1381.alignment.out"; - public static String cluster_test_outfile = "TO1381.alignment.cluster.out"; - - // Input path must be absolute to avoid coping input in working directory - public static String win_test_input = AllTestSuit.CURRENT_DIRECTORY - + File.separator + AllTestSuit.TEST_DATA_PATH + "TO1381.fasta"; - - public static String win_test_LARGE_input = AllTestSuit.CURRENT_DIRECTORY - + File.separator + AllTestSuit.TEST_DATA_PATH - + "200x500Protein.fasta"; - - public static String win_test_AVG_input = AllTestSuit.CURRENT_DIRECTORY - + File.separator + AllTestSuit.TEST_DATA_PATH - + "50x500Protein.fasta"; - - // Output file will be located in the task working directory, thus only name - // is required - public static String win_test_outfile = "TO1381.alignment.out"; - - @Test(expectedExceptions = { CancellationException.class, - ResultNotAvailableException.class }, groups = { AllTestSuit.test_group_engine }) - public void testCancelLocally() throws ResultNotAvailableException { - System.out.println("Running testCancelLocally"); - ClustalW clustal = new ClustalW(); - - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - clustal.setInput(win_test_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - clustal.setInput(unix_test_input).setOutput(unix_test_outfile); - } - AsyncExecutor lr = new AsyncLocalRunner(); - try { - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal); - String jobId = lr.submitJob(confClust); - // Thread.sleep(10); //wait for 100ms - assertNotSame(lr.getJobStatus(jobId), JobStatus.FINISHED, - "Job has finished already. Too late to test cancel!"); - lr.cancelJob(jobId); - // This call causes CancellationException to be thrown - Executable clustalr = lr.getResults(jobId); - // @see AsyncLocalRunner.cleanup documents - // assertTrue(lr.cleanup(jobId)); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(invocationCount = 5, threadPoolSize = 4, groups = { AllTestSuit.test_group_engine }) - public void testSubmitLocally() { - System.out.println("Running testSubmitLocally()"); - Muscle muscle = new Muscle(); - - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - muscle.setInput(win_test_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - muscle.setInput(unix_test_input).setOutput(unix_test_outfile); - } - AsyncExecutor lr = new AsyncLocalRunner(); - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle); - String jobId = lr.submitJob(confMuscle); - // Thread.sleep(10); //wait for 100ms - // assertNotSame("Job has finished already. Too late to test cancel!", - // JobStatus.FINISHED, lr.getJobStatus(jobId)); - // This call causes CancellationException to be thrown - Executable muscler = lr.getResults(jobId); - Alignment al = confMuscle.getResults(); - assertNotNull(al); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(invocationCount = 5, threadPoolSize = 4, groups = { AllTestSuit.test_group_engine }) - public void testGetStatus() { - System.out.println("Running testGetStatus"); - Muscle muscle = new Muscle(); - - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - muscle.setInput(win_test_AVG_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - muscle.setInput(unix_test_AVG_input).setOutput(unix_test_outfile); - } - AsyncExecutor lr = new AsyncLocalRunner(); - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle); - String jobId = lr.submitJob(confMuscle); - // Thread.sleep(10); //wait for 100ms - JobStatus status = lr.getJobStatus(jobId); - while (status == JobStatus.UNDEFINED) { - assertTrue(status == JobStatus.UNDEFINED); - Thread.sleep(100); - status = lr.getJobStatus(jobId); - } - while (status != JobStatus.FINISHED) { - Thread.sleep(500); - assertTrue(status == JobStatus.RUNNING); - status = lr.getJobStatus(jobId); - } - // assert that we get here, means that the job reached FINISHED - // status - // This call causes CancellationException to be thrown - Executable muscler = lr.getResults(jobId); - /* - * After results were obtained the task were removed for the queue, - * and it status could not be determined - */ - // Make sure list has been updated - Thread.sleep(200); - status = lr.getJobStatus(jobId); - assertTrue(status == JobStatus.FINISHED); - - Alignment al = confMuscle.getResults(); - - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(expectedExceptions = CancellationException.class, groups = { AllTestSuit.test_group_engine }) - public void testMultipleCancelLocally() { - System.out.println("Running testMultipleCancelLocally()"); - ClustalW clustal = new ClustalW(); - ClustalW clustal2 = new ClustalW(); - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - clustal.setInput(win_test_input).setOutput(win_test_outfile); - clustal2.setInput(win_test_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - clustal.setInput(unix_test_input).setOutput(unix_test_outfile); - clustal2.setInput(unix_test_input).setOutput(unix_test_outfile); - } - try { - ConfiguredExecutable confClustal1 = Configurator - .configureExecutable(clustal); - ConfiguredExecutable confClustal2 = Configurator - .configureExecutable(clustal2); - AsyncLocalRunner lr = new AsyncLocalRunner(); - AsyncLocalRunner lr2 = new AsyncLocalRunner(); - - String jobId1 = lr.submitJob(confClustal1); - String jobId2 = lr2.submitJob(confClustal2); - - // Thread.sleep(10); //wait for 100ms - assertNotSame(lr.getJobStatus(jobId1), JobStatus.FINISHED, - "Job has finished already. Too late to test cancel!"); - lr.cancelJob(jobId1); - // Thread.sleep(10); - assertNotSame(lr2.getJobStatus(jobId2), JobStatus.FINISHED, - "Job has finished already. Too late to test cancel!"); - lr2.cancelJob(jobId2); - // This call causes CancellationException to be thrown - Executable clustalr = lr.getResults(jobId1); - Executable clustalr2 = lr2.getResults(jobId2); - - assertTrue(lr.cleanup(jobId1)); - assertTrue(lr2.cleanup(jobId2)); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_engine }) - public void testCancelCompletedTaskLocally() { - System.out.println("Running testCancelCompletedTaskLocally"); - ClustalW clustal = new ClustalW(); - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - clustal.setInput(win_test_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - clustal.setInput(unix_test_input).setOutput(unix_test_outfile); - } - try { - ConfiguredExecutable confClustal1 = Configurator - .configureExecutable(clustal); - AsyncLocalRunner lr = new AsyncLocalRunner(); - String jobId = lr.submitJob(confClustal1); - Thread.currentThread(); - Thread.sleep(3000); // wait for 100ms - assertEquals(lr.getJobStatus(jobId), JobStatus.FINISHED, - "Job has not finished!"); - lr.cancelJob(jobId); - // This call causes CancellationException to be thrown - Executable clustalr = lr.getResults(jobId); - assertNotNull(clustalr); - - assertTrue(EngineUtil.isMarked(confClustal1.getWorkDirectory(), - JobStatus.CANCELLED)); - assertTrue(EngineUtil.isMarked(confClustal1.getWorkDirectory(), - JobStatus.STARTED)); - assertTrue(EngineUtil.isMarked(confClustal1.getWorkDirectory(), - JobStatus.COLLECTED)); - assertTrue(EngineUtil.isMarked(confClustal1.getWorkDirectory(), - JobStatus.FINISHED)); - assertFalse(EngineUtil.isMarked(confClustal1.getWorkDirectory(), - JobStatus.SUBMITTED)); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_engine }) - public void testAsyncRetrievOperation() { - System.out.println("Running testAsyncOperation()"); - Muscle muscle = new Muscle(); - - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - muscle.setInput(win_test_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - muscle.setInput(unix_test_input).setOutput(unix_test_outfile); - } - - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle); - AsyncExecutor lr = new AsyncLocalRunner(); - String jobId = lr.submitJob(confMuscle); - AsyncLocalRunner as = new AsyncLocalRunner(); - ConfiguredExecutable muscler = (ConfiguredExecutable) as - .getResults(jobId); - assertNotNull(muscler); - Alignment al1 = muscler.getResults(); - - assertTrue(EngineUtil.isMarked(muscler.getWorkDirectory(), - JobStatus.STARTED)); - assertTrue(EngineUtil.isMarked(muscler.getWorkDirectory(), - JobStatus.COLLECTED)); - assertTrue(EngineUtil.isMarked(muscler.getWorkDirectory(), - JobStatus.FINISHED)); - assertFalse(EngineUtil.isMarked(muscler.getWorkDirectory(), - JobStatus.CANCELLED)); - assertFalse(EngineUtil.isMarked(muscler.getWorkDirectory(), - JobStatus.SUBMITTED)); - Alignment al2 = confMuscle.getResults(); - assertNotNull(al1); - assertNotNull(al2); - assertTrue(al1.equals(al2)); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_engine }) - public void testAsyncCancelOperation() { - System.out.println("Running testAsyncOperation()"); - Muscle muscle = new Muscle(); - - if (SysPrefs.isWindows) { - System.out.println("Working in WINDOWS environment"); - muscle.setInput(win_test_input).setOutput(win_test_outfile); - } else { - System.out.println("Working in UNIX environment"); - muscle.setInput(unix_test_input).setOutput(unix_test_outfile); - } - - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle); - AsyncExecutor lr = new AsyncLocalRunner(); - String jobId = lr.submitJob(confMuscle); - // This call causes CancellationException to be thrown - AsyncLocalRunner as = new AsyncLocalRunner(); - assertTrue(as.getJobStatus(jobId) != JobStatus.FINISHED); - as.cancelJob(jobId); - assertTrue(as.getJobStatus(jobId) == JobStatus.CANCELLED); - - assertTrue(EngineUtil.isMarked(confMuscle.getWorkDirectory(), - JobStatus.CANCELLED)); - // could be both - // assertFalse(Util.isMarked(confMuscle.getWorkDirectory(), - // Util.StatFileType.STARTED)); - assertFalse(EngineUtil.isMarked(confMuscle.getWorkDirectory(), - JobStatus.COLLECTED)); - assertFalse(EngineUtil.isMarked(confMuscle.getWorkDirectory(), - JobStatus.FINISHED)); - assertFalse(EngineUtil.isMarked(confMuscle.getWorkDirectory(), - JobStatus.SUBMITTED)); - // Executable muscler = as.getResult(jobId); - // assertNotNull(muscler); - // Alignment al = muscle.getResults(); - // assertNotNull(al); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} diff --git a/testsrc/compbio/engine/local/EngineResourcesLeakTester.java b/testsrc/compbio/engine/local/EngineResourcesLeakTester.java deleted file mode 100644 index 08e194c..0000000 --- a/testsrc/compbio/engine/local/EngineResourcesLeakTester.java +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.local; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.testng.annotations.Test; - -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.SubmissionManager; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; -import compbio.runner.msa.Muscle; - -public class EngineResourcesLeakTester { - - static int numberOfExecutions = 50; - - @Test(groups = { AllTestSuit.test_group_long }) - public void loadEngineRetrieveResultsManyTimes() { - - List idlist = new ArrayList(); - ClustalW clu = new ClustalW(); - clu.setInput(AllTestSuit.test_input_real); - try { - for (int i = 0; i < numberOfExecutions; i++) { - ConfiguredExecutable cclustal = Configurator - .configureExecutable(clu, Executable.ExecProvider.Local); - AsyncExecutor engine = Configurator.getAsyncEngine(cclustal); - String jobId = engine.submitJob(cclustal); - assertNotNull(jobId); - Thread.sleep(50); - assertNotNull(SubmissionManager.getTask(jobId)); - assertTrue(idlist.add(jobId)); - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - assertEquals(idlist.size(), numberOfExecutions); - // assertEquals(SubmissionManager.submittedTasks.size(), - // numberOfExecutions * 2); - - try { - while (true) { - int doneCounter = 0; - for (String taskId : idlist) { - AsyncExecutor engine = Configurator.getAsyncEngine(taskId); - JobStatus status = engine.getJobStatus(taskId); - System.out.println("Status for job: " + taskId + " " - + status); - - if (status == JobStatus.FINISHED) { - assertNotNull(taskId); - System.out.println(taskId); - // System.out.println(SubmissionManager.submittedTasks); - // assertNotNull(SubmissionManager.getTask(taskId)); - Thread.sleep(200); // let buffers to be written - ConfiguredExecutable confclust = (ConfiguredExecutable) engine - .getResults(taskId); - assertNotNull(confclust); - assertNotNull(confclust.getResults()); - doneCounter++; - } - } - if (doneCounter == numberOfExecutions) { - break; - } - } - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_long }) - public void loadEngineRetrieveResultsOnce() { - - Map idlist = new HashMap(); - Muscle muscle = new Muscle(); - muscle.setInput(AllTestSuit.test_input_real); - muscle.setOutput("muscle.out"); - try { - for (int i = 0; i < numberOfExecutions; i++) { - ConfiguredExecutable cmuscle = Configurator - .configureExecutable(muscle, - Executable.ExecProvider.Local); - AsyncExecutor engine = Configurator.getAsyncEngine(cmuscle); - String jobId = engine.submitJob(cmuscle); - assertNotNull(jobId); - Thread.sleep(50); - assertNotNull(SubmissionManager.getTask(jobId)); - assertTrue(idlist.put(jobId, false) == null); - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - assertEquals(idlist.size(), numberOfExecutions); - // assertEquals(SubmissionManager.submittedTasks.size(), 20); - - try { - int doneCounter = 0; - while (true) { - if (doneCounter == numberOfExecutions) { - break; - } - for (String taskId : idlist.keySet()) { - Thread.sleep(50); // slow checking down - AsyncExecutor engine = Configurator.getAsyncEngine(taskId); - JobStatus status = engine.getJobStatus(taskId); - System.out.println("Status for job: " + taskId + " " - + status); - - if (status == JobStatus.FINISHED) { - assertNotNull(taskId); - if (idlist.get(taskId)) { - continue; - } - System.out.println(taskId); - // System.out.println(SubmissionManager.submittedTasks); - // assertNotNull(SubmissionManager.getTask(taskId)); - Thread.sleep(100);// let the buffers to write things - ConfiguredExecutable confclust = (ConfiguredExecutable) engine - .getResults(taskId); - assertNotNull(confclust); - assertNotNull(confclust.getResults()); - idlist.put(taskId, true); - doneCounter++; - } - } - } - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/engine/local/LocalRunnerTester.java b/testsrc/compbio/engine/local/LocalRunnerTester.java deleted file mode 100644 index 13dfed0..0000000 --- a/testsrc/compbio/engine/local/LocalRunnerTester.java +++ /dev/null @@ -1,153 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.engine.local; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.AssertJUnit.assertNotSame; -import static org.testng.AssertJUnit.assertNull; -import static org.testng.AssertJUnit.fail; - -import java.util.concurrent.CancellationException; - -import org.testng.annotations.Test; - -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.EngineUtil; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.runner.msa.ClustalW; - -public class LocalRunnerTester { - - public static String cluster_test_outfile = "TO1381.clustal.cluster.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out - // go up 2 directories from workspace: workspace/clustengine - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381.fasta"; - public static String test_outfile = "TO1381.clustal.out"; - - @Test(expectedExceptions = CancellationException.class, groups = { AllTestSuit.test_group_engine }) - public void testCancelLocally() { - ClustalW clustal = new ClustalW(); - clustal.setInput(test_input).setOutput(test_outfile); - - try { - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal); - LocalRunner lr = new LocalRunner(confClust); - - lr.executeJob(); - // Thread.sleep(10); //wait for 100ms - assertNotSame("Job has finished already. Too late to test cancel!", - JobStatus.FINISHED, lr.getJobStatus()); - lr.cancelJob(); - // This call causes CancellationException to be thrown - Executable clustalr = lr.waitForResult(); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.CANCELLED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.STARTED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.COLLECTED)); - assertTrue(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.FINISHED)); - assertFalse(EngineUtil.isMarked(confClust.getWorkDirectory(), - JobStatus.SUBMITTED)); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(expectedExceptions = { CancellationException.class, - JobExecutionException.class }, groups = { AllTestSuit.test_group_engine }) - public void testMultipleCancelLocally() throws JobExecutionException { - ClustalW clustal = new ClustalW(); - ClustalW clustal2 = new ClustalW(); - clustal.setInput(test_input).setOutput(test_outfile); - clustal2.setInput(test_input).setOutput(test_outfile); - try { - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal); - ConfiguredExecutable confClust2 = Configurator - .configureExecutable(clustal2); - - LocalRunner lr = new LocalRunner(confClust); - LocalRunner lr2 = new LocalRunner(confClust2); - - lr.executeJob(); - lr2.executeJob(); - - // Thread.sleep(10); //wait for 100ms - assertNotSame("Job has finished already. Too late to test cancel!", - JobStatus.FINISHED, lr.getJobStatus()); - lr.cancelJob(); - // Thread.sleep(10); - assertNotSame("Job has finished already. Too late to test cancel!", - JobStatus.FINISHED, lr2.getJobStatus()); - lr2.cancelJob(); - // This call causes CancellationException to be thrown - Executable clustalr = lr.waitForResult(); - Executable clustalr2 = lr2.waitForResult(); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(expectedExceptions = { CancellationException.class }, groups = { AllTestSuit.test_group_engine }) - public void testCancelCompletedTaskLocally() throws JobExecutionException { - ClustalW clustal = new ClustalW(); - clustal.setInput(test_input).setOutput(test_outfile); - - try { - ConfiguredExecutable confClust = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); - LocalRunner lr = new LocalRunner(confClust); - lr.executeJob(); - Thread.currentThread(); - Thread.sleep(30); // wait for 100ms - assertNotSame("Job has not finished!", JobStatus.FINISHED, lr - .getJobStatus()); - lr.cancelJob(); - // This call causes ResultNotAvailableException to be thrown - ConfiguredExecutable clustalr = lr.waitForResult(); - assertNull(clustalr.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/metadata/AllTestSuit.java b/testsrc/compbio/metadata/AllTestSuit.java deleted file mode 100644 index 8e9d9aa..0000000 --- a/testsrc/compbio/metadata/AllTestSuit.java +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * Copyright (c) 2013 Alexander Sherstnev - * - * JAva Bioinformatics Analysis Web Services (JABAWS) - * @version: 2.5 - * - * 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: - * @see: 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.metadata; - -import java.io.File; -import compbio.util.SysPrefs; - -public class AllTestSuit { - public final static String test_group_cluster = "cluster"; - public final static String test_group_runner = "runner"; - public final static String test_group_non_windows = "non_windows"; - public final static String test_group_windows_only = "windows_only"; - public final static String test_group_engine = "engine"; - public final static String test_group_long = "performance"; - public final static String test_group_webservices = "webservices"; - - // For this to work execution must start from the project directory! - public static final String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + File.separator; - public static final String TEST_DATA_PATH = "testsrc" + File.separator + "testdata" + File.separator; - public static final String TEST_DATA_PATH_ABSOLUTE = AllTestSuit.CURRENT_DIRECTORY + TEST_DATA_PATH; - - // For cluster execution paths MUST BE ABSOLUTE as cluster hosts will not be - // able to access the task otherwise - public static final String OUTPUT_DIR_ABSOLUTE = AllTestSuit.CURRENT_DIRECTORY + "local_jobsout" + File.separator; - public static final String RUNNER_TEST_LOGGER = "RunnerLogger"; - - public static final String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "TO1381.fasta"; - public static final String test_alignment_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "TO1381.fasta.aln"; - public static final String test_input_real = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "50x500Protein.fasta"; - public static final String test_input_dna = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "3dnaseqs.fasta"; - public static final String test_input_large = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "1000x3000Dna.fasta"; - - public static final String test_input_aln = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "unfolded_RF00031.aln"; - -} diff --git a/testsrc/compbio/metadata/OptionCombinatorTester.java b/testsrc/compbio/metadata/OptionCombinatorTester.java deleted file mode 100644 index 6a85aeb..0000000 --- a/testsrc/compbio/metadata/OptionCombinatorTester.java +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.metadata; - -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import javax.xml.bind.JAXBException; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.msa.ClustalW; -import compbio.runner.msa.Mafft; -import compbio.runner.msa.Muscle; - -public class OptionCombinatorTester { - - static final String mafftConfigFile = AllTestSuit.TEST_DATA_PATH - + "MafftParameters.xml"; - - static final String muscleConfigFile = AllTestSuit.TEST_DATA_PATH - + "MuscleParameters.xml"; - - static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH - + "ClustalParameters.xml"; - - RunnerConfig mafftConfig = null; - RunnerConfig muscleConfig = null; - RunnerConfig clustalConfig = null; - - @BeforeMethod - @SuppressWarnings("unchecked") - void setup() { - try { - RunnerConfigMarshaller mf = new RunnerConfigMarshaller( - RunnerConfig.class); - mafftConfig = mf.read( - new FileInputStream(new File(mafftConfigFile)), - RunnerConfig.class); - RunnerConfigMarshaller musclemarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - muscleConfig = musclemarsh.read(new FileInputStream(new File( - muscleConfigFile)), RunnerConfig.class); - - RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - clustalConfig = clustalmarsh.read(new FileInputStream(new File( - clustalConfigFile)), RunnerConfig.class); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void testgetAllOptions() { - OptionCombinator opc = new OptionCombinator(mafftConfig); - System.out.println(opc.getOptionsAtRandom()); - OptionCombinator muscleOpc = new OptionCombinator(muscleConfig); - System.out.println("Mucle " + muscleOpc.getOptionsAtRandom()); - OptionCombinator clustalOpc = new OptionCombinator(clustalConfig); - System.out.println("Clustal " + clustalOpc.getOptionsAtRandom()); - - } - - @Test - public void testgetAllParameters() { - OptionCombinator opc = new OptionCombinator(mafftConfig); - System.out.println(opc.getAllParameters()); - OptionCombinator muscleOpc = new OptionCombinator(muscleConfig); - System.out.println("Muscle : " + muscleOpc.getAllParameters()); - OptionCombinator clustalOpc = new OptionCombinator(clustalConfig); - System.out.println("Clustal : " + clustalOpc.getAllParameters()); - } -} diff --git a/testsrc/compbio/metadata/OptionMarshallerTester.java b/testsrc/compbio/metadata/OptionMarshallerTester.java deleted file mode 100644 index b681729..0000000 --- a/testsrc/compbio/metadata/OptionMarshallerTester.java +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.metadata; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertNotNull; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.stream.StreamSource; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.runner.msa.Mafft; - -public class OptionMarshallerTester { - - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "MafftParameters.xml"; - public static String test_schema_output = "NextGenMafftOptionsSchema.xml"; - public static String test_output = "MafftOptions.xml.out"; - public static String reWrittenInput = AllTestSuit.OUTPUT_DIR_ABSOLUTE + "rewrittenMafftParams.xml"; - - RunnerConfig rconfig = null; - Option matrixParam = null; - - @BeforeMethod() - public void setup() { - // write some parameters programmatically - try { - rconfig = new RunnerConfig(); - rconfig.setRunnerClassName(Mafft.class.getName()); - List> prms = new ArrayList>(); - - Parameter p1 = new Parameter("Type", "Type of the sequence (PROTEIN or DNA)"); - // TODO publish help on a compbio web site - - p1.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - p1.addPossibleValues("PROTEIN", "DNA"); - p1.setOptionName("-TYPE"); - p1.setRequired(false); - - /* - * -MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or - * filename - */ - Option p2 = new Option("MATRIX", "Protein weight matrix"); - // TODO publish help on a compbio web site - - p2.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p2.addOptionNames("-jtree"); - p2.addOptionNames("-jfasta"); - p2.setRequired(false); - - Parameter p3 = new Parameter("MATRIX2", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID"); - // This attribute is required by strict schema - p3.setOptionName("-MATRIX"); - p3.setRequired(true); - p3.setDefaultValue("id"); - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - vc.setMin("-10.12"); - vc.setMax("0"); - p3.setValidValue(vc); - - prms.add(p1); - prms.add(p2); - prms.add(p3); - matrixParam = p2; - rconfig.setOptions(prms); - - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(expectedExceptions = { javax.xml.bind.MarshalException.class }) - public void testMarshalling() throws JAXBException { - - File outfile = new File(AllTestSuit.OUTPUT_DIR_ABSOLUTE, test_output); - try { - RunnerConfigMarshaller rmarsh = new RunnerConfigMarshaller(RunnerConfig.class); - - // This throws an exception - // I am not sure why - rmarsh.writeAndValidate(rconfig, AllTestSuit.TEST_DATA_PATH_ABSOLUTE + File.separator + "RunnerConfigSchema.xsd", - new FileOutputStream(outfile)); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (SAXException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - assertTrue("Output file expected, but nothing found!", outfile.exists()); - // outfile.delete(); - } - - @Test() - public void testUnMarshalling() { - try { - File input = new File(this.test_input); - assertTrue(input.exists()); - JAXBContext ctx = JAXBContext.newInstance(RunnerConfig.class); - Unmarshaller um = ctx.createUnmarshaller(); - JAXBElement rconfig = um.unmarshal(new StreamSource(input), RunnerConfig.class); - RunnerConfig runner = rconfig.getValue(); - assertNotNull(runner); - System.out.println(runner); - assertFalse(runner.options.isEmpty()); - assertFalse(runner.parameters.isEmpty()); - assertEquals(7, runner.options.size()); - assertEquals(8, runner.parameters.size()); - Option stypeOption = runner.getArgument("Sequence type"); - System.out.println(stypeOption); - assertNotNull(stypeOption); - assertFalse(stypeOption.isRequired); - assertEquals("--auto", stypeOption.defaultValue); - assertEquals(2, stypeOption.optionNames.size()); - - assertEquals(" ", runner.getPrmSeparator()); - Option guidetrOption = runner.getArgument("Guide tree rebuild"); - Parameter guidetr = (Parameter) guidetrOption; - ValueConstrain constraint = guidetr.getValidValue(); - assertEquals("Integer", constraint.type.toString()); - assertEquals(1, constraint.getMin()); - assertEquals(100, constraint.getMax()); - - RunnerConfigMarshaller rmarsh = new RunnerConfigMarshaller(RunnerConfig.class); - // Now see if we can write a valid document back discard the actual - // output only validation is important here - rmarsh.write(rconfig, new FileOutputStream(new File(reWrittenInput))); - RunnerConfig rc = rmarsh.readAndValidate(new FileInputStream(new File(reWrittenInput)), RunnerConfig.class); - assertEquals(runner, rc); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (SAXException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} diff --git a/testsrc/compbio/metadata/PresetTester.java b/testsrc/compbio/metadata/PresetTester.java deleted file mode 100644 index 0b5a0a3..0000000 --- a/testsrc/compbio/metadata/PresetTester.java +++ /dev/null @@ -1,194 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.metadata; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.transform.stream.StreamSource; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.runner.msa.Mafft; - -public class PresetTester { - - public static final String input = AllTestSuit.TEST_DATA_PATH - + "MafftPresets.xml"; - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "MafftParameters.xml"; - - PresetManager presets = null; - RunnerConfig rconfParams = null; - - @BeforeTest(enabled = true) - public void loadPresets() { - try { - // Load Preset definitions - RunnerConfigMarshaller rconfigPresets = new RunnerConfigMarshaller( - PresetManager.class); - File infile = new File(input); - assertTrue(infile.exists()); - presets = rconfigPresets.read(new FileInputStream(infile), - PresetManager.class); - assertNotNull(presets); - assertFalse(presets.preset.isEmpty()); - - // Load Parameters definitions - File input = new File(this.test_input); - assertTrue(input.exists()); - JAXBContext ctx = JAXBContext.newInstance(RunnerConfig.class); - Unmarshaller um = ctx.createUnmarshaller(); - JAXBElement rconfigParams = um.unmarshal( - new StreamSource(input), RunnerConfig.class); - rconfParams = rconfigParams.getValue(); - assertNotNull(rconfParams); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void marshallPreset() { - try { - RunnerConfigMarshaller rconfig = new RunnerConfigMarshaller( - PresetManager.class); - PresetManager pman = getPresets(); - assertNotNull(pman); - rconfig.readAndValidate(new FileInputStream(new File(input)), - PresetManager.class); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (SAXException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void validatePresets() { - assertNotNull(presets); - assertEquals(presets.getPresets().size(), 6); - try { - for (Preset pr : presets.getPresets()) { - List> options; - options = pr.getArguments(rconfParams); - assertFalse(options.isEmpty()); - if (pr.name.equals("L-INS-i (Accuracy-oriented)")) { - assertEquals(options.size(), 2); - Option o = options.get(0); - if (o.name.equals("Pairwise alignment computation method")) { - List onames = o.getOptionNames(); - boolean match = false; - for (String oname : onames) { - if (oname.equals("--localpair")) { - match = true; - break; - } - } - assertTrue(match); - } - } - if (pr.name.equals("NW-NS-PartTree-1 (Speed oriented)")) { - assertEquals(options.size(), 4); - } - } - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void testPresetWithMuptiOptions() { - assertNotNull(presets); - assertEquals(presets.getPresets().size(), 6); - try { - for (Preset pr : presets.getPresets()) { - List> options; - options = pr.getArguments(rconfParams); - assertFalse(options.isEmpty()); - if (pr.name.equals("E-INS-i (Accuracy-oriented)")) { - assertEquals(options.size(), 3); - Option o = options.get(0); - if (o.name.equals("Pairwise alignment computation method")) { - List onames = o.getOptionNames(); - boolean match = false; - for (String oname : onames) { - if (oname.equals("--genafpair")) { - match = true; - break; - } - } - assertTrue(match); - } - } - if (pr.name.equals("NW-NS-PartTree-1 (Speed oriented)")) { - assertEquals(options.size(), 4); - } - } - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - private static PresetManager getPresets() { - Preset preset1 = new Preset(); - preset1.name = "L-INS-i (Accuracy-oriented)"; - preset1.description = "dsfjkg fdjksghkjsgdfh jksdfg sdfgkjhsdfgk kjsdfg "; - - List optionNames = new ArrayList(); - optionNames.add("--localpair"); - optionNames.add("--maxiterate 1000"); - preset1.option = optionNames; - PresetManager prman = new PresetManager(); - prman.preset = Collections.singletonList(preset1); - prman.runnerClassName = Mafft.class.getCanonicalName(); - - return prman; - } -} diff --git a/testsrc/compbio/metadata/RunnerConfigTester.java b/testsrc/compbio/metadata/RunnerConfigTester.java deleted file mode 100644 index 99549e1..0000000 --- a/testsrc/compbio/metadata/RunnerConfigTester.java +++ /dev/null @@ -1,269 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @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: - * @see: 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.metadata; - -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; -import static org.testng.AssertJUnit.fail; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.runner.msa.Mafft; - -public class RunnerConfigTester { - - public static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE + "MafftParameters.xml"; - - RunnerConfig rconfig = null; - - @BeforeMethod - public void setup() { - try { - rconfig = new RunnerConfig(); - rconfig.setRunnerClassName(Mafft.class.getName()); - List> prms = new ArrayList>(); - - RunnerConfigMarshaller pmarshaller = new RunnerConfigMarshaller(RunnerConfig.class, Parameter.class, - Option.class, ValueConstrain.class); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void testValidate() { - try { - rconfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(expectedExceptions = WrongParameterException.class) - public void testCreateParameter() throws WrongParameterException { - Parameter p3 = new Parameter("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID"); - // This attribute is required by strict schema - p3.setOptionName("--AAMATRIX"); - p3.setRequired(true); - // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED - // IN WITHIN POSSIBLE VALUES - p3.setDefaultValue("pam22"); - String com = p3.toCommand(" "); - System.out.println("AAAAAAAAAAAAAA!" + com); - } - - @Test() - public void testParameterToCommand() throws WrongParameterException { - Parameter p3 = new Parameter("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.addPossibleValues("BLOSUM", "PAM", "GONNET", "ID"); - // This attribute is required by strict schema - p3.setOptionName("--AAMATRIX"); - p3.setRequired(true); - // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED - // IN WITHIN POSSIBLE VALUES - p3.setDefaultValue("PAM"); - String com = p3.toCommand("="); - assertTrue(com.startsWith("--AAMATRIX")); - assertTrue(com.endsWith("PAM")); - assertTrue(com.contains("=")); - p3.setDefaultValue("ID"); - com = p3.toCommand("="); - assertFalse(com.endsWith("PAM")); - assertFalse(com.contains("PAM")); - } - - @Test(expectedExceptions = ValidationException.class) - public void testOptionNoDefaultValidate() throws ValidationException { - Option p3 = new Option("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX", "--ABMAT", "--BBBB"))); - p3.setRequired(true); - // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED - // IN WITHIN POSSIBLE VALUES - p3.validate(); - } - - @Test(expectedExceptions = WrongParameterException.class) - public void testOptionSetInvalidValue() throws WrongParameterException { - - Option p3 = new Option("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX", "--ABMAT", "--BBBB"))); - p3.setRequired(true); - // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED - // IN WITHIN POSSIBLE VALUES - p3.setDefaultValue("AAA"); - } - - @Test() - public void testOptionToCommand() { - try { - Option p3 = new Option("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - - p3.setOptionNames(new HashSet(Arrays.asList("--AAMATRIX", "--ABMAT", "--BBBB"))); - p3.setRequired(true); - // THIS LINE IS CAUSING EXCEPTION AS DEFAULT VALUE MUST BE DEFINED - // IN WITHIN POSSIBLE VALUES - p3.setDefaultValue("--BBBB"); - p3.validate(); - String com = p3.toCommand("="); - assertEquals("--BBBB", com); - p3.setDefaultValue("--ABMAT"); - com = p3.toCommand("="); - assertEquals("--ABMAT", com); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(expectedExceptions = IllegalStateException.class) - public void testCreateNumParameterWithoutValidValue() throws MalformedURLException { - try { - Parameter p4 = new Parameter("Matrix", "DNA weight matrix"); - // This is causing exception is ValidValue constrain is not defined - // for - // numeric value - p4.setDefaultValue("5"); - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test() - public void testCreateParameterWithValidValueConstrain() throws MalformedURLException { - Parameter p4 = new Parameter("Matrix", "DNA weight matrix"); - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - vc.setMin("0"); - vc.setMax("10"); - p4.setValidValue(vc); - try { - p4.setDefaultValue("5"); - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(expectedExceptions = WrongParameterException.class) - public void testValidateLowerBoundaryConstrainCheck() throws WrongParameterException { - Parameter p3 = new Parameter("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - // This attribute is required by strict schema - p3.setOptionName("--AAMATRIX"); - p3.setRequired(true); - - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - vc.setMin("-10.12"); - vc.setMax("0"); - p3.setValidValue(vc); - // THIS IS CAUSING EXCEPTION - p3.setDefaultValue("-11.0"); - } - - @Test(expectedExceptions = WrongParameterException.class) - public void testValidateUpperBoundaryConstrainCheck() throws WrongParameterException { - Parameter p3 = new Parameter("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - // This attribute is required by strict schema - p3.setOptionName("--AAMATRIX"); - p3.setRequired(true); - - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - vc.setMin("-10.12"); - vc.setMax("0"); - p3.setValidValue(vc); - // THIS IS CAUSING EXCEPTION - p3.setDefaultValue("1"); - } - - @Test() - public void testValidateBoundaryConstrainCheck() { - try { - Parameter p3 = new Parameter("Matrix1", "Protein weight matrix"); - // TODO publish help on a compbio web site - p3.setFurtherDetails("http://www.compbio.dundee.ac.uk/users/pvtroshin/ws/Index.html"); - // This attribute is required by strict schema - p3.setOptionName("--AAMATRIX"); - p3.setRequired(true); - - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - vc.setMin("-10.12"); - p3.setValidValue(vc); - // Max value boundary is not defined so 1 is valid - p3.setDefaultValue("1"); - p3.validate(); - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(expectedExceptions = ValidationException.class) - public void testValidateValueConstrain() throws ValidationException { - ValueConstrain vc = new ValueConstrain(); - vc.setType(ValueConstrain.Type.Float); - // NO BOUNDARIES DEFINED - vc.validate(); - } -} diff --git a/testsrc/compbio/stat/collector/ExecutionStatCollectorTester.java b/testsrc/compbio/stat/collector/ExecutionStatCollectorTester.java deleted file mode 100644 index b99b36c..0000000 --- a/testsrc/compbio/stat/collector/ExecutionStatCollectorTester.java +++ /dev/null @@ -1,120 +0,0 @@ -package compbio.stat.collector; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.io.File; -import java.util.Date; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; -import compbio.stat.collector.JobDirectory; - -public class ExecutionStatCollectorTester { - - final static String LOCAL_JOBS = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "ljobs"; - final static String CLUSTER_JOBS = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "jobs"; - @Test - public void testCollectStat() { - ExecutionStatCollector local_jobs = new ExecutionStatCollector( - LOCAL_JOBS, 1); - ExecutionStatCollector cl_jobs = new ExecutionStatCollector( - CLUSTER_JOBS, 24); - - // Collect statistics prior to call getStats()! - local_jobs.collectStatistics(); - cl_jobs.collectStatistics(); - - StatProcessor local_stats = local_jobs.getStats(); - StatProcessor cl_stats = cl_jobs.getStats(); - - assertEquals(local_stats.getJobNumber(), 12); - // ClustalW#1015343425414965 - empty - assertEquals(local_stats.getIncompleteJobs().size(), 1); - assertEquals(local_stats.getFailedJobs().size(), 0); - assertEquals(local_stats.getAbandonedJobs().size(), 1); - - } - - @Test - public void testUpdateStatTester() { - - ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - ScheduledFuture sf = executor.scheduleAtFixedRate( - new ExecutionStatCollector(LOCAL_JOBS, 1), 1, 10, - TimeUnit.SECONDS); - - try { - Thread.sleep(1000 * 35); - executor.shutdown(); - executor.awaitTermination(300, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } - - /** - * This test will fail in time as it relies on last access time for file in - * the filesystem! This OK as it has been tested by then. - * - */ - @Test (enabled = false) - public void testHasTimedOut() { - ExecutionStatCollector ecol = new ExecutionStatCollector(LOCAL_JOBS, 1); - File f = new File(LOCAL_JOBS + File.separator - + "ClustalW#1015373448154965"); - File timedOut = new File(LOCAL_JOBS + File.separator - + "Mafft#7868649707286965"); - - JobDirectory jd = new JobDirectory(f); - JobDirectory timedOutDir = new JobDirectory(timedOut); - System.out.println("! " + new Date(f.lastModified())); - - assertTrue((System.currentTimeMillis() - f.lastModified()) - / (1000 * 60 * 60) < 1); - assertFalse((System.currentTimeMillis() - timedOut.lastModified()) - / (1000 * 60 * 60) < 1); - assertFalse(ecol.hasTimedOut(jd)); - assertTrue(ecol.hasTimedOut(timedOutDir)); - } - - @Test - public void testHasCompleted() { - ExecutionStatCollector ecol_no_timeout = new ExecutionStatCollector( - LOCAL_JOBS, 10000000); - ExecutionStatCollector ecol = new ExecutionStatCollector(LOCAL_JOBS, 1); - - File normal = new File(LOCAL_JOBS + File.separator - + "ClustalW#100368900075204"); - File finished = new File(LOCAL_JOBS + File.separator - + "ClustalW#1015373448154965"); - File cancelled = new File(LOCAL_JOBS + File.separator - + "Mafft#7918237850044965"); - File noresult = new File(LOCAL_JOBS + File.separator - + "ClustalW#1015343425414965"); - - JobDirectory dnormal = new JobDirectory(normal); - JobDirectory dfinished = new JobDirectory(finished); - JobDirectory dcancelled = new JobDirectory(cancelled); - - JobDirectory dnoresult = new JobDirectory(noresult); - - assertTrue(ecol.hasCompleted(dnormal)); - assertTrue(ecol.hasCompleted(dfinished)); - assertTrue(ecol.hasCompleted(dcancelled)); - - assertTrue(ecol.hasCompleted(dnoresult)); - assertFalse(ecol_no_timeout.hasCompleted(dnoresult)); - - } -} diff --git a/testsrc/compbio/stat/collector/StatDBTester.java b/testsrc/compbio/stat/collector/StatDBTester.java deleted file mode 100644 index 85bc81d..0000000 --- a/testsrc/compbio/stat/collector/StatDBTester.java +++ /dev/null @@ -1,143 +0,0 @@ -package compbio.stat.collector; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import compbio.stat.servlet.util.StatCollection; -import compbio.stat.servlet.util.Totals; -import compbio.ws.client.Services; - -public class StatDBTester { - StatDB statdb; - Timestamp from; - Timestamp to; - - @BeforeClass(alwaysRun=true ) - public void init() { - try { - statdb = new StatDB(true); - Calendar fromCal = Calendar.getInstance(); - fromCal.set(2011, 4, 1); - - Calendar toCal = Calendar.getInstance(); - toCal.set(2011, 5, 1); - from = new Timestamp(fromCal.getTimeInMillis()); - to = new Timestamp(toCal.getTimeInMillis()); - - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getLocalizedMessage()); - } - } - - /* - * This test fails if run with other tests. This is likely due to the fact that StatDB - * is initialised with connection to other then the test database from StatCollector class. - * TODO look at this - */ - @Test(enabled = false) - public void testReadYearData() { - Calendar cal = Calendar.getInstance(); - cal.set(2010, 4, 1); - try { - List jobs = statdb.readData( - new Timestamp(cal.getTimeInMillis()), to, Services.MuscleWS, false); - assertNotNull(jobs); - assertEquals(jobs.size(), 1294); - // statdb.shutdownDBServer(); - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - - } - - /* - * This test fails if run with other tests. This is likely due to the fact that StatDB - * is initialised with connection to other then the test database from StatCollector class. - * TODO look at this - */ - @Test(enabled =false) - public void testReadOneMonthData() { - try { - List jobs = statdb.readData(from, to, Services.TcoffeeWS, false); - assertNotNull(jobs); - assertEquals(jobs.size(), 36); - - jobs = statdb.readData(from,to, Services.ClustalWS,false); - - assertNotNull(jobs); - assertEquals(jobs.size(), 137); - - jobs = statdb.readData(from, to, Services.MafftWS,false); - assertNotNull(jobs); - assertEquals(jobs.size(), 136); - - jobs = statdb.readData(from,to, Services.ProbconsWS,false); - assertNotNull(jobs); - assertEquals(jobs.size(), 9); - - jobs = statdb.readData(from,to, Services.MuscleWS,false); - assertNotNull(jobs); - assertEquals(jobs.size(), 63); - - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } - - /* - * This test fails if run with other tests. This is likely due to the fact that StatDB - * is initialised with connection to other then the test database from StatCollector class. - * TODO look at this - */ - @Test(enabled=false) - public void testGetEarliestRecord() { - try { - Date earliestRec = statdb.getEarliestRecord(); - - assertEquals(1278543600000L, earliestRec.getTime()); - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getLocalizedMessage()); - } - - } - - @Test(sequential=true) - public void testVerifyJobsCount() { - - try { - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.MONTH, -5); - Timestamp from = new Timestamp(cal.getTimeInMillis()); - cal.add(Calendar.MONTH, 1); - Timestamp to = new Timestamp(cal.getTimeInMillis()); - StatCollection sc = StatCollection.newStatCollecton(from, to); - Totals t = Totals.sumStats(sc.getAllStat()); - - //System.out.println(sc.getAllStat()); - - assertEquals(t.getTotal(), statdb.getTotalJobsCount(from, to)); - assertEquals(t.getAbandoned(), statdb.getAbandonedCount(from, to)); - assertEquals(t.getCancelled(), statdb.getCancelledCount(from, to)); - assertEquals(t.getIncomplete(), statdb.getIncompleteCount(from, to)); - - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getLocalizedMessage()); - } - - } -} diff --git a/testsrc/compbio/stat/collector/TestInputFilter.java b/testsrc/compbio/stat/collector/TestInputFilter.java deleted file mode 100644 index 23203e1..0000000 --- a/testsrc/compbio/stat/collector/TestInputFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -package compbio.stat.collector; - -import java.io.File; -import java.io.IOException; - -import org.testng.Assert; -import org.testng.annotations.Test; - -import compbio.metadata.AllTestSuit; - -public class TestInputFilter { - - final static String FASTA_INPUT = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381.fasta"; - final static String ALN_INPUT = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381L.aln"; - final static String TEST_FASTA_INPUT = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "test_input.fasta"; - final static String TEST_ALIGNMENT_INPUT = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "test_input.aln"; - @Test - public void TestInputFilter() { - InputFilter ifilter = new InputFilter(); - try { - // Makes sure real files are accepted - Assert.assertTrue(ifilter.accept(new File(FASTA_INPUT))); - Assert.assertTrue(ifilter.accept(new File(ALN_INPUT))); - - // .. and test files are not - Assert.assertFalse(ifilter.accept(new File(TEST_ALIGNMENT_INPUT))); - Assert.assertFalse(ifilter.accept(new File(TEST_FASTA_INPUT))); - // does not matter if the file is empty, it is still not a test - // file! - Assert.assertTrue(ifilter.accept(File.createTempFile("aaa", "bbb"))); - } catch (IOException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/stat/servlet/util/StatCollectionTester.java b/testsrc/compbio/stat/servlet/util/StatCollectionTester.java deleted file mode 100644 index 830ce05..0000000 --- a/testsrc/compbio/stat/servlet/util/StatCollectionTester.java +++ /dev/null @@ -1,30 +0,0 @@ -package compbio.stat.servlet.util; - -import java.sql.SQLException; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Map; - -import org.testng.Assert; -import org.testng.annotations.Test; - -public class StatCollectionTester { - - @Test - public void testGetStats() { - Map stats; - Calendar cal = GregorianCalendar.getInstance(); - cal.add(Calendar.MONTH, -3); - - try { - stats = StatCollection.getStats(cal.getTime()); - - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - - } - -} diff --git a/testsrc/compbio/ws/client/AAConWSClientExample.java b/testsrc/compbio/ws/client/AAConWSClientExample.java deleted file mode 100644 index 23eaf36..0000000 --- a/testsrc/compbio/ws/client/AAConWSClientExample.java +++ /dev/null @@ -1,123 +0,0 @@ -package compbio.ws.client; - -import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.Writer; -import java.util.List; - -import compbio.data.msa.SequenceAnnotation; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.ScoreManager; -import compbio.data.sequence.SequenceUtil; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.UnsupportedRuntimeException; -import compbio.metadata.WrongParameterException; -import compbio.runner.conservation.AACon; - -/** - * AAConWS client example - */ -public class AAConWSClientExample { - - /* - * Input sequences. For the simplicity keep them in the class - */ - static final String input = ">Foo \r\n" - + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV\r\n" - + "ARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQL\r\n" - + "LPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLAC\r\n" - + "ARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQM\r\n" - + "HLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEV\r\n" - + "FALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSR\r\n" - + "VVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADA\r\n" - + "RLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVL\r\n" - + "TTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRES\r\n" - + "GVFEMDGFADDFGALLQALARRHGWLGI\r\n" - + "\r\n" - + ">Bar \r\n" - + "-----------------------------------MGDTTAGEMAVQRGLALH-------\r\n" - + "---------QQRHAEAAVLLQQASDAAPEHPGIALWL-HALEDAGQAEAAAA-YTRAHQL\r\n" - + "LPEEPYITAQLLN--------------------AVAQGVGAVEPFAFLSEDASAAE----\r\n" - + "----------SVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQM\r\n" - + "HLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEV\r\n" - + "FALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSR\r\n" - + "VVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADA\r\n" - + "RLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVL\r\n" - + "TTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRES\r\n" - + "GVFEMDGFADDFGALLQALARRHGWLGI\r\n" - + "\r\n" - + ">Noname \r\n" - + "-MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV\r\n" - + "ARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALED--------------HQL\r\n" - + "LPEEPYITAQLDVLSAQVR-------------AAVAQGVGAVEPFAFLSEDASAAEQLAC\r\n" - + "ARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQM\r\n" - + "HLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEV\r\n" - + "FALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSR\r\n" - + "VVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADA\r\n" - + "RLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVL\r\n" - + "TTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRES\r\n" - + "I---------------------------"; - - public static void main(String[] args) throws UnsupportedRuntimeException, - JobSubmissionException, WrongParameterException, - FileNotFoundException, IOException, ResultNotAvailableException, - InterruptedException { - - /* - * Annotation interface for AAConWS web service instance - */ - SequenceAnnotation client = (SequenceAnnotation) Jws2Client - .connect("http://www.compbio.dundee.ac.uk/aacon", - Services.AAConWS); - - /* Get the list of available presets */ - PresetManager presetman = client.getPresets(); - - /* Get the Preset object by preset name */ - Preset preset = presetman.getPresetByName("Complete conservation"); - - /* - * Load sequences in FASTA format from the file You can use something - * like new FileInputStream() to load sequence from the file - */ - List fastalist = SequenceUtil - .readFasta(new ByteArrayInputStream(input.getBytes())); - - /* - * Submit loaded sequences for an alignment using preset. The job - * identifier is returned by this method, you can retrieve the results - * with it sometime later. - */ - String jobId = client.presetAnalize(fastalist, preset); - - /* This method will block for the duration of the calculation */ - ScoreManager result = client.getAnnotation(jobId); - - /* - * This is a better way of obtaining results, it does not involve - * holding the connection open for the duration of the calculation, - * Besides, as the University of Dundee public server will reset the - * connection after 10 minutes of idling, this is the only way to obtain - * the results of long running task from our public server. - */ - // while (client.getJobStatus(jobId) != JobStatus.FINISHED) { - // Thread.sleep(1000); // wait a second, then recheck the status - // } - - /* Output the alignment to standard out */ - Writer writer = new PrintWriter(System.out, true); - IOHelper.writeOut(writer, result); - writer.close(); - // Score.write(result, System.out); - - /* Alternatively, you can record retrieved alignment into the file */ - // FileOutputStream out = new FileOutputStream("result.txt"); - // Score.write(result, out); - // out.close(); - } -} diff --git a/testsrc/compbio/ws/client/TestAAConWS.java b/testsrc/compbio/ws/client/TestAAConWS.java deleted file mode 100644 index d54e67f..0000000 --- a/testsrc/compbio/ws/client/TestAAConWS.java +++ /dev/null @@ -1,257 +0,0 @@ -package compbio.ws.client; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; -import static org.testng.Assert.assertTrue; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.ConnectException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.ws.WebServiceException; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import compbio.data.msa.JABAService; -import compbio.data.msa.SequenceAnnotation; -import compbio.data.sequence.ConservationMethod; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.ScoreManager; -import compbio.data.sequence.SequenceUtil; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitExceededException; -import compbio.metadata.Option; -import compbio.metadata.Preset; -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; - -public class TestAAConWS { - - SequenceAnnotation msaws; - - @BeforeTest(groups = {AllTestSuit.test_group_webservices}) - 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); - */try { - JABAService client = Jws2Client.connect( - "http://localhost:8080/jabaws", Services.AAConWS); - msaws = (SequenceAnnotation) client; - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testAnalize() throws FileNotFoundException, IOException { - - /* - * MsaWS msaws = serv.getPort(new QName( - * "http://msa.data.compbio/01/01/2010/", "ClustalWSPort"), - * MsaWS.class); - */ - // Annotation msaws = serv.getPort(new QName(namespace, - // "ClustalWSPort"), Annotation.class); - - // List fsl = SequenceUtil.readFasta(new FileInputStream( - // AAConTester.test_alignment_input)); - - 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()); - String jobId = msaws.analize(fsl); - System.out.println("J: " + jobId); - ScoreManager result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 1); - - assertEquals(result.asSet().iterator().next().getMethod(), - ConservationMethod.SHENKIN.toString()); - List scores = result.asSet().iterator().next().getScores(); - assertNotNull(scores); - assertEquals(scores.size(), 568); - - // Using presets - PresetManager presets = msaws.getPresets(); - jobId = msaws.presetAnalize(fsl, - presets.getPresetByName("Quick conservation")); - result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 13); - - jobId = msaws.presetAnalize(fsl, - presets.getPresetByName("Slow conservation")); - result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 5); - - jobId = msaws.presetAnalize(fsl, - presets.getPresetByName("Complete conservation")); - result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().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(groups = {AllTestSuit.test_group_webservices}) - public void testRecoverArgsForPreset() throws Exception { - PresetManager presets = msaws.getPresets(); - for (Preset preset:presets.getPresets()) - { - List> args = preset.getArguments(msaws.getRunnerOptions()); - List opts = preset.getOptions(); - assertTrue(args.size()>=opts.size(),"Couldn't recover all Option items for preset "+preset.getName()); - } - } - @Test(groups = {AllTestSuit.test_group_webservices}) - 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")); - ScoreManager result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 13); - - jobId = msaws.presetAnalize(fsl, - presets.getPresetByName("Slow conservation")); - result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 5); - - jobId = msaws.presetAnalize(fsl, - presets.getPresetByName("Complete conservation")); - result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().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(groups = {AllTestSuit.test_group_webservices}) - 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 { - List> args = new ArrayList>(); - Option arg,normarg; - args.add(arg=options.getArgument("SMERFS")); - args.add(normarg=options.getArgument("Normalize")); - arg.setValue(arg.getPossibleValues().get(0)); - // options.getArgument("SMERFS Column Scoring Method") - // .setDefaultValue("MAX_SCORE"); - // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1"); - String jobId = msaws.customAnalize(fsl, args); - ScoreManager result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 1); - assertEquals(result.asSet().iterator().next().getScores().get(0), - 0.698f); - args.remove(normarg); // remove normalization argument - // System.out.println(options); - jobId = msaws.customAnalize(fsl, args); - result = msaws.getAnnotation(jobId); - assertNotNull(result); - assertEquals(result.asSet().size(), 1); - assertEquals(result.asSet().iterator().next().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/testsrc/compbio/ws/client/TestIUPredWS.java b/testsrc/compbio/ws/client/TestIUPredWS.java deleted file mode 100644 index 158b9ae..0000000 --- a/testsrc/compbio/ws/client/TestIUPredWS.java +++ /dev/null @@ -1,104 +0,0 @@ -package compbio.ws.client; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.ConnectException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.ws.WebServiceException; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import compbio.data.msa.JABAService; -import compbio.data.msa.SequenceAnnotation; -import compbio.data.sequence.ConservationMethod; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.ScoreManager; -import compbio.data.sequence.SequenceUtil; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitExceededException; -import compbio.metadata.Option; -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.IUPredWS; - -public class TestIUPredWS { - - SequenceAnnotation msaws; - - @BeforeTest(groups = {AllTestSuit.test_group_webservices}) - 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); - */try { - JABAService client = Jws2Client.connect( - "http://localhost:8080/jabaws", Services.IUPredWS); - msaws = (SequenceAnnotation) client; - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_webservices}) - 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")); - - try { - List> opts=new ArrayList>(); - opts.add(msaws.getRunnerOptions().getArgumentByOptionName("Long")); - String jobId = msaws.customAnalize(fsl,opts); - System.out.println("J: " + jobId); - ScoreManager result = msaws.getAnnotation(jobId); - assertNotNull(result); -// assertEquals(result.asSet().size(), 1); - - } 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()); - } - - } -} diff --git a/testsrc/compbio/ws/client/TestRNAalifoldWS.java b/testsrc/compbio/ws/client/TestRNAalifoldWS.java deleted file mode 100644 index cafe9cb..0000000 --- a/testsrc/compbio/ws/client/TestRNAalifoldWS.java +++ /dev/null @@ -1,106 +0,0 @@ - package compbio.ws.client; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.net.ConnectException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.ws.WebServiceException; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import compbio.data.msa.JABAService; -import compbio.data.msa.SequenceAnnotation; -import compbio.data.sequence.Alignment; -import compbio.data.sequence.ClustalAlignmentUtil; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.RNAStructScoreManager; -import compbio.data.sequence.UnknownFileFormatException; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitExceededException; -import compbio.metadata.Option; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.UnsupportedRuntimeException; -import compbio.metadata.WrongParameterException; -import compbio.ws.server.RNAalifoldWS; - - -public class TestRNAalifoldWS { - - SequenceAnnotation foldws; -// RNAalifoldWS foldws; - - @BeforeTest(groups = {AllTestSuit.test_group_webservices}) - void initConnection() { - - try { - JABAService client = Jws2Client.connect( - "http://localhost:8080/jabaws", Services.RNAalifoldWS); -// foldws = (RNAalifoldWS) client; - foldws = (SequenceAnnotation) client; - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testFold() throws FileNotFoundException, IOException, - UnknownFileFormatException { - - Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream( - AllTestSuit.test_input_aln)); - - List fsl = aln.getSequences(); - - try { - List> options = new ArrayList>(); - options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis")); - options.add(foldws.getRunnerOptions().getArgumentByOptionName("-p")); - options.add(foldws.getRunnerOptions().getArgumentByOptionName("--MEA")); - - System.out.println("TestRNAalifoldWS: print options: " + options.toString()); - - String jobId = foldws.customAnalize(fsl, options); - System.out.println("J: " + jobId); - RNAStructScoreManager result = (RNAStructScoreManager)foldws.getAnnotation(jobId); - - Writer writer = new OutputStreamWriter(System.out); - result.writeOut(writer); - - assertNotNull(result); - - } 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()); - } - } -} - - - diff --git a/testsrc/compbio/ws/client/WSTesterTester.java b/testsrc/compbio/ws/client/WSTesterTester.java deleted file mode 100644 index 3671e1b..0000000 --- a/testsrc/compbio/ws/client/WSTesterTester.java +++ /dev/null @@ -1,61 +0,0 @@ -package compbio.ws.client; - -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.PrintWriter; -import java.net.ConnectException; -import javax.xml.ws.WebServiceException; -import org.testng.annotations.Test; -import compbio.metadata.AllTestSuit; - -public class WSTesterTester { - - public static final String SERVER = "http://localhost:8080/jabaws"; - // public static final String SERVER = "http://192.168.202.130/jabaws"; - - // public static final String SERVER = - // "http://nanna.cluster.lifesci.dundee.ac.uk:8080/jaba"; - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testAllWindowsWS() { - WSTester tester = new WSTester(SERVER, - new PrintWriter(System.out, true)); - try { - assertTrue(tester.checkService(Services.AAConWS)); - assertTrue(tester.checkService(Services.JronnWS)); - assertTrue(tester.checkService(Services.ClustalWS)); - assertTrue(tester.checkService(Services.MuscleWS)); - assertTrue(tester.checkService(Services.ClustalOWS)); - assertTrue(tester.checkService(Services.IUPredWS)); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - - // Will throw UnsupportedRuntimeException on windows - // ws = Jws2Client.connect(SERVER, Services.MafftWS); - // assertTrue(tester.checkService(ws)); - - } - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testAllWS() { - WSTester tester = new WSTester(SERVER, new PrintWriter(System.out)); - try { - for (Services service : Services.values()) { - assertTrue(tester.checkService(service)); - } - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - -} diff --git a/testsrc/compbio/ws/server/RegistryWSTester.java b/testsrc/compbio/ws/server/RegistryWSTester.java deleted file mode 100644 index 34f7b6c..0000000 --- a/testsrc/compbio/ws/server/RegistryWSTester.java +++ /dev/null @@ -1,222 +0,0 @@ -package compbio.ws.server; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.ConnectException; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -import javax.xml.ws.WebServiceException; - -import org.testng.annotations.Test; - -import compbio.data.msa.MsaWS; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.SequenceUtil; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.ResultNotAvailableException; -import compbio.ws.client.Jws2Client; -import compbio.ws.client.Services; -import compbio.ws.client.WSTesterTester; - -public class RegistryWSTester { - - @Test(groups = {AllTestSuit.test_group_webservices, - AllTestSuit.test_group_windows_only}) - public void testGetSupportedServices() { - try { - compbio.data.msa.RegistryWS reg = Jws2Client - .connectToRegistry(WSTesterTester.SERVER); - System.out.println(reg.getSupportedServices()); - Set supserv = reg.getSupportedServices(); - assertTrue(supserv.containsAll(Arrays.asList(new Services[]{ - Services.AAConWS, Services.ClustalOWS, Services.IUPredWS, - Services.MuscleWS, Services.ClustalWS, Services.JronnWS}))); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testTestService() { - compbio.data.msa.RegistryWS reg = null; - try { - reg = Jws2Client.connectToRegistry(WSTesterTester.SERVER); - assertNotNull(reg.testService(Services.AAConWS)); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(dependsOnMethods = {"testTestService"}, groups = {AllTestSuit.test_group_webservices}) - public void testIsOperating() { - try { - compbio.data.msa.RegistryWS reg = Jws2Client - .connectToRegistry(WSTesterTester.SERVER); - assertTrue(reg.isOperating(Services.AAConWS)); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(dependsOnMethods = {"testTestService"}, groups = {AllTestSuit.test_group_webservices}) - public void testGetLastTestedOn() { - try { - compbio.data.msa.RegistryWS reg = Jws2Client - .connectToRegistry(WSTesterTester.SERVER); - assertNotNull(reg.getLastTestedOn(Services.AAConWS)); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(dependsOnMethods = {"testTestService"}, groups = {AllTestSuit.test_group_webservices}) - public void testGetLastTested() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - try { - compbio.data.msa.RegistryWS reg = Jws2Client - .connectToRegistry(WSTesterTester.SERVER); - System.out.println(reg.getLastTested(Services.AAConWS)); - assertTrue(reg.getLastTested(Services.AAConWS) > 0); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testTestAllServices() { - try { - compbio.data.msa.RegistryWS reg = Jws2Client - .connectToRegistry(WSTesterTester.SERVER); - System.out.println(reg.testAllServices()); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testProgressReporting() { - MsaWS service = null; - try { - service = (MsaWS) Jws2Client.connect( - "http://www.compbio.dundee.ac.uk/jabaws", - // "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jabaws", - Services.ProbconsWS); - File input = new File(AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "200x500Protein.fasta"); - assertTrue(input.exists()); - List fs = SequenceUtil - .readFasta(new FileInputStream(input)); - String jobId = service.align(fs); - Thread.sleep(5000); - ChunkHolder pos = null; - while (service.getJobStatus(jobId) == JobStatus.RUNNING) { - if (pos == null) { - pos = service.pullExecStatistics(jobId, 0); - } else { - pos = service.pullExecStatistics(jobId, - pos.getNextPosition()); - } - Thread.sleep(10); - System.out.print(pos.getChunk()); - } - System.out.println(); - System.out.println(service.getResult(jobId)); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testPullRunningJob() { - MsaWS service = null; - try { - service = (MsaWS) Jws2Client.connect( - "http://webserv1.cluster.lifesci.dundee.ac.uk:8089/jabaws", - Services.ProbconsWS); - String jobId = "@Probcons#158079030012566"; - ChunkHolder pos = null; - while (service.getJobStatus(jobId) == JobStatus.RUNNING) { - if (pos == null) { - pos = service.pullExecStatistics(jobId, 0); - } else { - pos = service.pullExecStatistics(jobId, - pos.getNextPosition()); - } - Thread.sleep(10); - System.out.print(pos.getChunk()); - } - System.out.println(); - System.out.println(service.getResult(jobId)); - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} -- 1.7.10.2