From 87413bfedfbbb0dfb2a1110c37c9279bd1614ba5 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Tue, 21 Jun 2011 12:06:02 +0000 Subject: [PATCH] Get rind of NativeClusterJob interface as pretty much every jobs best to use some cluster settings, and they are simply defined in the executable conf file and passed by the SkeletalExecutable. git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4294 e3abac25-378b-4346-85de-24260fe3988d --- conf/Executable.properties | 4 ++- .../engine/client/ClusterNativeSpecExecutable.java | 26 -------------- engine/compbio/engine/client/ConfExecutable.java | 5 +++ engine/compbio/engine/client/Executable.java | 2 ++ .../compbio/engine/client/SkeletalExecutable.java | 3 +- engine/compbio/engine/cluster/drmaa/JobRunner.java | 15 ++++---- runner/compbio/runner/_SkeletalCommandBuilder.java | 6 ++++ runner/compbio/runner/_impl/NetNglyc.java | 5 +++ runner/compbio/runner/msa/Mafft.java | 38 +++++++++++++++++++- runner/compbio/runner/msa/Tcoffee.java | 11 ++---- 10 files changed, 70 insertions(+), 45 deletions(-) delete mode 100644 engine/compbio/engine/client/ClusterNativeSpecExecutable.java diff --git a/conf/Executable.properties b/conf/Executable.properties index 667875e..2c82b95 100644 --- a/conf/Executable.properties +++ b/conf/Executable.properties @@ -36,7 +36,9 @@ mafft.--aamatrix.path=binaries/matrices mafft.presets.file=conf/settings/MafftPresets.xml mafft.parameters.file=conf/settings/MafftParameters.xml mafft.limits.file=conf/settings/MafftLimits.xml -mafft.cluster.settings=-l h_cpu=24:00:00 -l h_vmem=6000M -l ram=6000M +mafft.cluster.cpunum=4 +mafft.cluster.settings=-q 64bit-pri.q -pe smp 4 -l h_cpu=24:00:00 -l h_vmem=1700M -l ram=1700M + ### Tcoffee configuration ### local.tcoffee.bin=binaries/src/tcoffee/t_coffee_source/t_coffee diff --git a/engine/compbio/engine/client/ClusterNativeSpecExecutable.java b/engine/compbio/engine/client/ClusterNativeSpecExecutable.java deleted file mode 100644 index da3939d..0000000 --- a/engine/compbio/engine/client/ClusterNativeSpecExecutable.java +++ /dev/null @@ -1,26 +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; - -public interface ClusterNativeSpecExecutable extends Executable { - - // void setNativeSpecs(String nativeSpecs); - - String getNativeSpecs(); -} diff --git a/engine/compbio/engine/client/ConfExecutable.java b/engine/compbio/engine/client/ConfExecutable.java index 9477ecf..23d0793 100644 --- a/engine/compbio/engine/client/ConfExecutable.java +++ b/engine/compbio/engine/client/ConfExecutable.java @@ -373,4 +373,9 @@ public class ConfExecutable implements ConfiguredExecutable { value += exec.toString(); return value; } + + @Override + public String getClusterJobSettings() { + return exec.getClusterJobSettings(); + } } diff --git a/engine/compbio/engine/client/Executable.java b/engine/compbio/engine/client/Executable.java index b36bc57..5eec9c8 100644 --- a/engine/compbio/engine/client/Executable.java +++ b/engine/compbio/engine/client/Executable.java @@ -65,4 +65,6 @@ public interface Executable { LimitsManager getLimits(); + String getClusterJobSettings(); + } diff --git a/engine/compbio/engine/client/SkeletalExecutable.java b/engine/compbio/engine/client/SkeletalExecutable.java index f974302..369f8e7 100644 --- a/engine/compbio/engine/client/SkeletalExecutable.java +++ b/engine/compbio/engine/client/SkeletalExecutable.java @@ -261,7 +261,8 @@ public abstract class SkeletalExecutable implements Executable { return code; } - public String getClusterSettings() { + @Override + public String getClusterJobSettings() { String settings = ph.getProperty(getType().getSimpleName() .toLowerCase() + ".cluster.settings"); return settings == null ? "" : settings; diff --git a/engine/compbio/engine/cluster/drmaa/JobRunner.java b/engine/compbio/engine/cluster/drmaa/JobRunner.java index e7ec791..a3f002a 100644 --- a/engine/compbio/engine/cluster/drmaa/JobRunner.java +++ b/engine/compbio/engine/cluster/drmaa/JobRunner.java @@ -34,7 +34,7 @@ import compbio.engine.Cleaner; import compbio.engine.ClusterJobId; import compbio.engine.Configurator; import compbio.engine.SyncExecutor; -import compbio.engine.client.ClusterNativeSpecExecutable; + import compbio.engine.client.ConfiguredExecutable; import compbio.engine.client.Executable; import compbio.engine.client.PathValidator; @@ -108,9 +108,8 @@ public class JobRunner implements SyncExecutor { * If executable require special cluster configuration parameters to * be set e.g. queue, ram, time etc */ - if (confExec.getExecutable() instanceof ClusterNativeSpecExecutable) { - setNativeSpecs(confExec.getExecutable()); - } + setNativeSpecs(confExec.getExecutable()); + log.trace("using arguments: " + jobtempl.getArgs()); this.confExecutable = confExec; @@ -161,9 +160,11 @@ public class JobRunner implements SyncExecutor { } void setNativeSpecs(Executable executable) throws DrmaaException { - jobtempl - .setNativeSpecification(((ClusterNativeSpecExecutable) executable) - .getNativeSpecs()); + String nativeSpecs = executable.getClusterJobSettings(); + if(!compbio.util.Util.isEmpty(nativeSpecs)) { + log.debug("Using cluster job settings: " + nativeSpecs); + jobtempl.setNativeSpecification(nativeSpecs); + } } void setEmail(String email) { diff --git a/runner/compbio/runner/_SkeletalCommandBuilder.java b/runner/compbio/runner/_SkeletalCommandBuilder.java index cb50504..2c3adac 100644 --- a/runner/compbio/runner/_SkeletalCommandBuilder.java +++ b/runner/compbio/runner/_SkeletalCommandBuilder.java @@ -109,5 +109,11 @@ public abstract class _SkeletalCommandBuilder implements // TODO Auto-generated method stub return null; } + + @Override + public String getClusterJobSettings() { + // TODO Auto-generated method stub + return null; + } } diff --git a/runner/compbio/runner/_impl/NetNglyc.java b/runner/compbio/runner/_impl/NetNglyc.java index 4d30683..503aa38 100644 --- a/runner/compbio/runner/_impl/NetNglyc.java +++ b/runner/compbio/runner/_impl/NetNglyc.java @@ -109,4 +109,9 @@ public class NetNglyc implements Executable { // TODO Auto-generated method stub return null; } + @Override + public String getClusterJobSettings() { + // TODO Auto-generated method stub + return null; + } } diff --git a/runner/compbio/runner/msa/Mafft.java b/runner/compbio/runner/msa/Mafft.java index 508d5f7..dbe49fe 100644 --- a/runner/compbio/runner/msa/Mafft.java +++ b/runner/compbio/runner/msa/Mafft.java @@ -27,15 +27,36 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; + import compbio.engine.client.PipedExecutable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; import compbio.runner.Util; +/** + * + * @author pvtroshin + * + */ public class Mafft extends SkeletalExecutable implements PipedExecutable { - + /* + * TODO get rid of piping: Mafft now supports --out option for output file. + * TODO enable multithreading support + */ + + /** + * Number of cores to use, not used if "mafft.cluster.cpunum" property + * is not defined and in case of local execution + */ + private int ncoreNumber = 0; + + /* + * Number of cores parameter name + */ + private final static String ncorePrm = "--thread"; + private static Logger log = Logger.getLogger(Mafft.class); private static String autoOption = "--auto"; @@ -88,6 +109,21 @@ public class Mafft extends SkeletalExecutable return this; } + + public void setNCore(int ncoreNumber) { + if (ncoreNumber < 1 || ncoreNumber > 100) { + throw new IndexOutOfBoundsException( + "Number of cores must be within 1 and 100 "); + } + this.ncoreNumber = ncoreNumber; + cbuilder.setParam(ncorePrm, Integer.toString(getNCore())); + } + + int getNCore() { + return ncoreNumber; + } + + @SuppressWarnings("unchecked") @Override public Class getType() { diff --git a/runner/compbio/runner/msa/Tcoffee.java b/runner/compbio/runner/msa/Tcoffee.java index 98b2313..d6dd3fe 100644 --- a/runner/compbio/runner/msa/Tcoffee.java +++ b/runner/compbio/runner/msa/Tcoffee.java @@ -27,7 +27,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.ClusterNativeSpecExecutable; import compbio.engine.client.CommandBuilder; import compbio.engine.client.Executable; import compbio.engine.client.PipedExecutable; @@ -38,9 +37,7 @@ import compbio.runner.Util; import compbio.util.PropertyHelper; public class Tcoffee extends SkeletalExecutable - implements - PipedExecutable, - ClusterNativeSpecExecutable { + implements PipedExecutable { private static Logger log = Logger.getLogger(Tcoffee.class); @@ -131,15 +128,11 @@ public class Tcoffee extends SkeletalExecutable int cpunum = SkeletalExecutable.getClusterCpuNum(getType()); if (cpunum != 0) { setNCore(cpunum); - } + } } return super.getParameters(provider); } - @Override - public String getNativeSpecs() { - return getClusterSettings(); - } @SuppressWarnings("unchecked") @Override -- 1.7.10.2