Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions kb_SPAdes.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module kb_SPAdes {

/* A boolean. 0 = false, anything else = true. */
typedef int bool;

/* The workspace object name of a PairedEndLibrary file, whether of the
KBaseAssembly or KBaseFile type.
*/
Expand Down Expand Up @@ -96,7 +96,7 @@ module kb_SPAdes {
(all values must be odd, less than 128 and listed in ascending order)
In the absence of these values, K values are automatically selected.
min_contig_length - integer to filter out contigs with length < min_contig_length
from the HybridSPAdes output. Default value is 0 implying no filter.
from the HybridSPAdes output. Default value is 0 implying no filter.
@optional dna_source
@optional pipeline_options
@optional kmer_sizes
Expand Down Expand Up @@ -126,7 +126,7 @@ module kb_SPAdes {
string report_name;
string report_ref;
} SPAdesOutput;

/* Run SPAdes on paired end libraries */
funcdef run_SPAdes(SPAdesParams params) returns(SPAdesOutput output)
authentication required;
Expand All @@ -139,16 +139,6 @@ module kb_SPAdes {
funcdef run_metaSPAdes(SPAdesParams params) returns(SPAdesOutput output)
authentication required;

/*
params - the params used to run metaSPAdes.
use_defaults - (optional, def 0) if 1, just return the default requirements
use_heuristic - (optional, def 1) if 1, only use a heuristic based on the reads metadata to perform estimates
*/
typedef structure {
SPAdesParams params;
int use_defaults;
} MetaSPAdesEstimatorParams;

/*
cpus - the number of CPUs required for the run
memory - the minimal amount of memory in MB required for the run
Expand All @@ -159,8 +149,8 @@ module kb_SPAdes {
int memory;
int walltime;
} MetaSPAdesEstimate;
funcdef estimate_metaSPAdes_requirements(MetaSPAdesEstimatorParams params) returns

funcdef estimate_metaSPAdes_requirements(SPAdesParams params) returns
(MetaSPAdesEstimate results) authentication required;
};

51 changes: 3 additions & 48 deletions lib/kb_SPAdes/kb_SPAdesClient.pm
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,8 @@ Run SPAdes on paired end libraries for metagenomes
=begin html

<pre>
$params is a kb_SPAdes.MetaSPAdesEstimatorParams
$params is a kb_SPAdes.SPAdesParams
$results is a kb_SPAdes.MetaSPAdesEstimate
MetaSPAdesEstimatorParams is a reference to a hash where the following keys are defined:
params has a value which is a kb_SPAdes.SPAdesParams
use_defaults has a value which is an int
SPAdesParams is a reference to a hash where the following keys are defined:
workspace_name has a value which is a string
output_contigset_name has a value which is a string
Expand All @@ -495,11 +492,8 @@ MetaSPAdesEstimate is a reference to a hash where the following keys are defined

=begin text

$params is a kb_SPAdes.MetaSPAdesEstimatorParams
$params is a kb_SPAdes.SPAdesParams
$results is a kb_SPAdes.MetaSPAdesEstimate
MetaSPAdesEstimatorParams is a reference to a hash where the following keys are defined:
params has a value which is a kb_SPAdes.SPAdesParams
use_defaults has a value which is an int
SPAdesParams is a reference to a hash where the following keys are defined:
workspace_name has a value which is a string
output_contigset_name has a value which is a string
Expand Down Expand Up @@ -924,7 +918,7 @@ kmer_sizes - (optional) K-mer sizes, Default values: 21, 33, 55, 77, 99, 127
(all values must be odd, less than 128 and listed in ascending order)
In the absence of these values, K values are automatically selected.
min_contig_length - integer to filter out contigs with length < min_contig_length
from the HybridSPAdes output. Default value is 0 implying no filter.
from the HybridSPAdes output. Default value is 0 implying no filter.
@optional dna_source
@optional pipeline_options
@optional kmer_sizes
Expand Down Expand Up @@ -1011,45 +1005,6 @@ report_ref has a value which is a string



=head2 MetaSPAdesEstimatorParams

=over 4



=item Description

params - the params used to run metaSPAdes.
use_defaults - (optional, def 0) if 1, just return the default requirements
use_heuristic - (optional, def 1) if 1, only use a heuristic based on the reads metadata to perform estimates


=item Definition

=begin html

<pre>
a reference to a hash where the following keys are defined:
params has a value which is a kb_SPAdes.SPAdesParams
use_defaults has a value which is an int

</pre>

=end html

=begin text

a reference to a hash where the following keys are defined:
params has a value which is a kb_SPAdes.SPAdesParams
use_defaults has a value which is an int


=end text

=back



=head2 MetaSPAdesEstimate

=over 4
Expand Down
15 changes: 5 additions & 10 deletions lib/kb_SPAdes/kb_SPAdesClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,10 @@ def run_metaSPAdes(self, params, context=None):

def estimate_metaSPAdes_requirements(self, params, context=None):
"""
:param params: instance of type "MetaSPAdesEstimatorParams" (params -
the params used to run metaSPAdes. use_defaults - (optional, def
0) if 1, just return the default requirements use_heuristic -
(optional, def 1) if 1, only use a heuristic based on the reads
metadata to perform estimates) -> structure: parameter "params" of
type "SPAdesParams" (Input parameters for running SPAdes.
workspace_name - the name of the workspace from which to take
input and store output. output_contigset_name - the name of the
output contigset read_libraries - a list of Illumina
:param params: instance of type "SPAdesParams" (Input parameters for
running SPAdes. workspace_name - the name of the workspace from
which to take input and store output. output_contigset_name - the
name of the output contigset read_libraries - a list of Illumina
PairedEndLibrary files in FASTQ or BAM format. dna_source -
(optional) the source of the DNA used for sequencing
'single_cell': DNA amplified from a single cell via MDA anything
Expand All @@ -195,7 +190,7 @@ def estimate_metaSPAdes_requirements(self, params, context=None):
"dna_source" of String, parameter "min_contig_length" of Long,
parameter "kmer_sizes" of list of Long, parameter
"skip_error_correction" of type "bool" (A boolean. 0 = false,
anything else = true.), parameter "use_defaults" of Long
anything else = true.)
:returns: instance of type "MetaSPAdesEstimate" (cpus - the number of
CPUs required for the run memory - the minimal amount of memory in
MB required for the run walltime - an estimate for walltime in
Expand Down
21 changes: 8 additions & 13 deletions lib/kb_SPAdes/kb_SPAdesImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class kb_SPAdes:
# state. A method could easily clobber the state set by another while
# the latter method is running.
######################################### noqa
VERSION = "1.2.3"
VERSION = "1.3.0"
GIT_URL = "https://github.com/briehl/kb_SPAdes"
GIT_COMMIT_HASH = "17687df25126cf201693f5686224b4777de36f0b"
GIT_COMMIT_HASH = "6f13deac910c9796ce8fc0d39075880f74c1ff4e"

#BEGIN_CLASS_HEADER
# Class variables and functions can be defined in this block
Expand Down Expand Up @@ -821,15 +821,10 @@ def run_metaSPAdes(self, ctx, params):

def estimate_metaSPAdes_requirements(self, ctx, params):
"""
:param params: instance of type "MetaSPAdesEstimatorParams" (params -
the params used to run metaSPAdes. use_defaults - (optional, def
0) if 1, just return the default requirements use_heuristic -
(optional, def 1) if 1, only use a heuristic based on the reads
metadata to perform estimates) -> structure: parameter "params" of
type "SPAdesParams" (Input parameters for running SPAdes.
workspace_name - the name of the workspace from which to take
input and store output. output_contigset_name - the name of the
output contigset read_libraries - a list of Illumina
:param params: instance of type "SPAdesParams" (Input parameters for
running SPAdes. workspace_name - the name of the workspace from
which to take input and store output. output_contigset_name - the
name of the output contigset read_libraries - a list of Illumina
PairedEndLibrary files in FASTQ or BAM format. dna_source -
(optional) the source of the DNA used for sequencing
'single_cell': DNA amplified from a single cell via MDA anything
Expand All @@ -849,7 +844,7 @@ def estimate_metaSPAdes_requirements(self, ctx, params):
"dna_source" of String, parameter "min_contig_length" of Long,
parameter "kmer_sizes" of list of Long, parameter
"skip_error_correction" of type "bool" (A boolean. 0 = false,
anything else = true.), parameter "use_defaults" of Long
anything else = true.)
:returns: instance of type "MetaSPAdesEstimate" (cpus - the number of
CPUs required for the run memory - the minimal amount of memory in
MB required for the run walltime - an estimate for walltime in
Expand All @@ -860,7 +855,7 @@ def estimate_metaSPAdes_requirements(self, ctx, params):
# return variables are: results
#BEGIN estimate_metaSPAdes_requirements
ws = Workspace(self.workspaceURL, token=ctx["token"])
results = estimate_metaSPAdes_reqs(params["params"], ws, use_defaults=params.get("use_defaults", 0)==1)
results = estimate_metaSPAdes_reqs(params, ws)
#END estimate_metaSPAdes_requirements

# At some point might do deeper type checking...
Expand Down
14 changes: 4 additions & 10 deletions lib/kb_SPAdes/utils/estimator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def estimate_metaSPAdes_reqs(params, ws, use_defaults=False):
def estimate_metaSPAdes_reqs(params, ws):
"""
Generates an estimate of how much computational power is needed to run metaSPAdes.
params: dict with keys (only relevant ones given):
Expand All @@ -18,19 +18,13 @@ def estimate_metaSPAdes_reqs(params, ws, use_defaults=False):
raise ValueError("workspace_name is required to estimate metaSPAdes requirements!")
if len(params.get("read_libraries", [])) == 0:
raise ValueError("At least one read library is required to estimate metaSPAdes requirements!")
if use_defaults:
return {
"cpus": 16,
"memory": 4096,
"walltime": 300
}

ws_name = params.get("workspace_name")
reads_refs = []
for lib_name in params["read_libraries"]:
reads_refs.append({"ref": lib_name if "/" in lib_name else ws_name + "/" + lib_name})
reads_infos = ws.get_object_info3({
"objects": reads_refs,
"objects": reads_refs,
"includeMetadata": 1
})

Expand All @@ -55,12 +49,12 @@ def estimate_metaSPAdes_reqs(params, ws, use_defaults=False):
# now we have an approximation of how many kmers there are. we can use
# that to guesstimate how much memory we need

predicted_mem = (total_kmers * 2.962e-08 + 16.3) * 1.1 * 1024
predicted_mem = (total_kmers * 2.962e-08 + 16.3) * 1.1 * 1024

est = {
"cpus": 16,
"memory": max(int(predicted_mem), 4096),
"walltime": max(total_kmers/100000, 300)
}

return est
return est
2 changes: 1 addition & 1 deletion lib/src/us/kbase/kbspades/HybridSPAdesParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* (all values must be odd, less than 128 and listed in ascending order)
* In the absence of these values, K values are automatically selected.
* min_contig_length - integer to filter out contigs with length < min_contig_length
* from the HybridSPAdes output. Default value is 0 implying no filter.
* from the HybridSPAdes output. Default value is 0 implying no filter.
* @optional dna_source
* @optional pipeline_options
* @optional kmer_sizes
Expand Down
4 changes: 2 additions & 2 deletions lib/src/us/kbase/kbspades/KbSPAdesClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ public SPAdesOutput runMetaSPAdes(SPAdesParams params, RpcContext... jsonRpcCont
* <p>Original spec-file function name: estimate_metaSPAdes_requirements</p>
* <pre>
* </pre>
* @param params instance of type {@link us.kbase.kbspades.MetaSPAdesEstimatorParams MetaSPAdesEstimatorParams}
* @param params instance of type {@link us.kbase.kbspades.SPAdesParams SPAdesParams}
* @return parameter "results" of type {@link us.kbase.kbspades.MetaSPAdesEstimate MetaSPAdesEstimate}
* @throws IOException if an IO exception occurs
* @throws JsonClientException if a JSON RPC exception occurs
*/
public MetaSPAdesEstimate estimateMetaSPAdesRequirements(MetaSPAdesEstimatorParams params, RpcContext... jsonRpcContext) throws IOException, JsonClientException {
public MetaSPAdesEstimate estimateMetaSPAdesRequirements(SPAdesParams params, RpcContext... jsonRpcContext) throws IOException, JsonClientException {
List<Object> args = new ArrayList<Object>();
args.add(params);
TypeReference<List<MetaSPAdesEstimate>> retType = new TypeReference<List<MetaSPAdesEstimate>>() {};
Expand Down
Loading