Skip to content
Merged
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
33 changes: 30 additions & 3 deletions src/MGRAST/lib/resources/metagenome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ sub instance {
$self->return_data( {"ERROR" => "id $id does not exist"}, 404 );
}
$job = $job->[0];

# check if we are changing the sequence type
if (scalar(@$rest) == 3 && $rest->[1] eq 'changesequencetype') {

# check if the user is allowed to change the data
if ($self->user && ($self->user->has_right(undef, 'edit', 'metagenome', $id) || $self->user->has_star_right('edit', 'user'))) {

# check if the passed type is valid
my $valid_types = { "Amplicon" => 1,
"MT" => 1,
"WGS" => 1,
"Unknown" => 1 };
if ($valid_types->{$rest->[2]}) {
$job->sequence_type($rest->[2]);
} else {
$self->return_data({"ERROR" => "Invalid sequence type passed (".$rest->[2].")."}, 404);
}
} else {
$self->return_data( {"ERROR" => "insufficient permissions to edit this data"}, 401 );
}
}

# job is in pipeline, just view minimal info
unless ($job->viewable) {
Expand Down Expand Up @@ -395,15 +416,21 @@ sub prepare_data {
# add metadata pointers
eval {
my $proj = $job->primary_project;
$obj->{project} = ["mgp".$proj->{id}, $url."/project/mgp".$proj->{id}];
if ($proj->{id}) {
$obj->{project} = ["mgp".$proj->{id}, $url."/project/mgp".$proj->{id}];
}
};
eval {
my $samp = $job->sample;
$obj->{sample} = ["mgs".$samp->{ID}, $url."/sample/mgs".$samp->{ID}];
if ($samp->{ID}) {
$obj->{sample} = ["mgs".$samp->{ID}, $url."/sample/mgs".$samp->{ID}];
}
};
eval {
my $lib = $job->library;
$obj->{library} = ["mgl".$lib->{ID}, $url."/library/mgl".$lib->{ID}];
if ($lib->{ID}) {
$obj->{library} = ["mgl".$lib->{ID}, $url."/library/mgl".$lib->{ID}];
}
};
# get job info
my $jstats = $job->stats();
Expand Down