Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources/inbox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ sub verify_file_type {
return ($file_type, "[error] file '$fname' is of unsupported file type '$file_type'.");
}

sub file_format {
sub get_file_format {
my ($self, $tempfile, $file_type, $file_suffix) = @_;

if ($file_suffix eq 'qual') {
Expand Down
55 changes: 46 additions & 9 deletions src/MGRAST/lib/resources/job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ sub new {
};
$self->{create_param} = {
'metagenome_id' => ["string", "unique MG-RAST metagenome identifier"],
'input_id' => ["string", "shock node id of input sequence file (optional)"],
'sequence_type' => ["cv", [["WGS", "whole genome shotgun sequenceing"],
["Amplicon", "amplicon sequenceing"],
["MT", "metatranscriptome sequenceing"]] ]
'input_id' => ["string", "shock node id of input sequence file (optional)"]
};
my @input_stats = map { substr($_, 0, -4) } grep { $_ =~ /_raw$/ } @{$self->seq_stats};
map { $self->{create_param}{$_} = ['float', 'sequence statistic'] } grep { $_ !~ /drisee/ } @input_stats;
map { $self->{create_param}{$_} = ['string', 'pipeline option'] } @{$self->pipeline_opts};
$self->{create_param}{sequence_type} = [
"cv", [["WGS", "whole genome shotgun sequenceing"],
["Amplicon", "amplicon sequenceing"],
["MT", "metatranscriptome sequenceing"]]
];
return $self;
}

Expand Down Expand Up @@ -284,18 +286,53 @@ sub job_action {
my $nodeid = $post->{input_id};
eval {
my $node = $self->get_shock_node($nodeid, $self->mgrast_token);
$post = $node->{attributes}{stats_info};
# pull from stats_info and pipeline_info in attributes
foreach my $x (('stats_info', 'pipeline_info')) {
if (exists($node->{attributes}{$x}) && ref($node->{attributes}{$x})) {
foreach my $k (keys %{$node->{attributes}{$x}}) {
# only add values that are not already given
if (! exists($post->{$k})) {
$post->{$k} = $node->{attributes}{$x}{$k};
}
}
}
}
};
delete $post->{input_id};
if ($@ || (! $post)) {
$self->return_data( {"ERROR" => "unable to obtain sequence file statistics from shock node ".$nodeid}, 500 );
$self->return_data( {"ERROR" => "unable to obtain sequence file info from shock node ".$nodeid}, 500 );
}
}
# set pipeline defaults if missing
foreach my $key (@{$self->pipeline_opts}) {
if (exists($self->pipeline_defaults->{$key}) && (! exists($post->{$key}))) {
$post->{$key} = $self->pipeline_defaults->{$key};
}
}
# fix booleans
foreach my $key (keys %$post) {
if ($post->{$key} eq 'yes') {
$post->{$key} = 1;
} elsif ($post->{$key} eq 'no') {
$post->{$key} = 0;
}
}
# check params
delete $post->{metagenome_id};
foreach my $key (keys %{$self->{create_param}}) {
unless (exists $post->{$key}) {
if (($key eq 'metagenome_id') || ($key eq 'input_id')) {
next;
}
if (! exists($post->{$key})) {
$self->return_data( {"ERROR" => "Missing required parameter '$key'"}, 404 );
}
}
# calculate length trim
$post->{max_ln} = int($post->{average_length} + ($post->{filter_ln_mult} * $post->{standard_deviation_length}));
$post->{min_ln} = int($post->{average_length} - ($post->{filter_ln_mult} * $post->{standard_deviation_length}));
if ($post->{min_ln} < 1) {
$post->{min_ln} = 1;
}
# create job
$job = $master->Job->initialize($self->user, $post, $job);
$data = {
Expand All @@ -319,7 +356,7 @@ sub job_action {
log => join("\n", @log)
};
} else {
$self->return_data( {"ERROR" => "Unknown error, missing AWE job ID"}, 500 );
$self->return_data( {"ERROR" => "Unknown error, missing AWE job ID:\n".join("\n", @log)}, 500 );
}
} elsif ($action eq 'resubmit') {
my $cmd = $Conf::resubmit_to_awe." --job_id ".$job->{job_id}." --awe_id ".$post->{awe_id}." --shock_url ".$Conf::shock_url." --awe_url ".$Conf::awe_url;
Expand Down Expand Up @@ -429,7 +466,7 @@ sub job_action {
# add it
my $status = $project->add_job($job);
$data = {
project_id => $project->{id},
project_id => "mgp".$project->{id},
project_name => $project->{name},
status => $status
};
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources/metagenome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ sub prepare_data {
# add pipeline info
my $pparams = $self->pipeline_defaults;
$pparams->{assembled} = (exists($jdata->{assembled}) && $jdata->{assembled}) ? 'yes' : 'no';
$pparams->{publish_priority} = (exists($jdata->{priority}) && $jdata->{priority}) ? $jdata->{priority} : 'never';
$pparams->{priority} = (exists($jdata->{priority}) && $jdata->{priority}) ? $jdata->{priority} : 'never';
# replace value defaults
foreach my $tag (('max_ambig', 'min_qual', 'max_lqb', 'screen_indexes',
'm5nr_sims_version', 'm5rna_sims_version',
Expand Down
66 changes: 35 additions & 31 deletions src/MGRAST/lib/resources/resource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -218,51 +218,55 @@ sub hierarchy {
};
}

# hardcoded list of metagenome pipeline option keywords
# hardcoded list of metagenome pipeline option keywords for submission
sub pipeline_opts {
return [ 'assembled',
'bowtie',
'dereplicate',
'dynamic_trim',
'file_type',
'filter_ambig',
'filter_ln',
'max_ambig',
'max_ln',
'max_lqb',
'min_ln',
'min_qual',
'priority',
'screen_indexes',
'sequence_type_guess',
'sequencing_method_guess'
return [
'aa_pid',
'assembled',
'bowtie',
'dereplicate',
'dynamic_trim',
'fgs_type',
'file_type',
'filter_ambig',
'filter_ln',
'filter_ln_mult',
'max_ambig',
'max_lqb',
'min_qual',
'prefix_length',
'priority',
'rna_pid',
'screen_indexes',
'sequence_type', # not in defaults
'sequencing_method_guess' # not in defaults
];
}

# hardcoded list of metagenome pipeline paramters with defaults
sub pipeline_defaults {
return {
'aa_pid' => '90',
'assembled' => 'no',
'bowtie' => 'yes',
'dereplicate' => 'yes',
'dynamic_trim' => 'yes',
'fgs_type' => '454',
'file_type' => 'fna',
'filter_ambig' => 'yes',
'filter_ln' => 'yes',
'filter_ln_mult' => '2.0',
'filter_ambig' => 'yes',
'm5nr_annotation_version' => '1', # not in options
'm5rna_annotation_version' => '1', # not in options
'm5nr_sims_version' => '1', # not in options
'm5rna_sims_version' => '1', # not in options
'max_ambig' => '5',
'dynamic_trim' => 'yes',
'min_qual' => '15',
'max_lqb' => '5',
'dereplicate' => 'yes',
'min_qual' => '15',
'prefix_length' => '50',
'bowtie' => 'yes',
'screen_indexes' => 'h_sapiens_asm',
'fgs_type' => '454',
'priority' => 'never',
'rna_pid' => '97',
'aa_pid' => '90',
'm5nr_sims_version' => '1',
'm5rna_sims_version' => '1',
'm5nr_annotation_version' => '1',
'm5rna_annotation_version' => '1',
'assembled' => 'no',
'publish_priority' => 'never'
'screen_indexes' => 'h_sapiens'
};
}

Expand Down