Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes / updates to api2 #123

Merged
merged 3 commits into from Oct 4, 2012
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources2/library.pm
Expand Up @@ -248,7 +248,7 @@ sub check_pagination {
next if ($param eq 'offset');
$additional_params .= $param."=".$cgi->param($param)."&";
}
if (length($additional_params) {
if (length($additional_params)) {
chop $additional_params;
}
my $prev_offset = $offset - $limit;
Expand Down
39 changes: 13 additions & 26 deletions src/MGRAST/lib/resources2/metagenome.pm
Expand Up @@ -108,10 +108,9 @@ sub attributes {
return { "id" => [ 'string', 'unique object identifier' ],
"name" => [ 'string', 'human readable identifier' ],
"sequence_type" => [ 'string', 'sequencing type' ],
"file_size" => [ 'integer', 'sequence file size in bytes' ],
"library" => [ 'reference library', 'reference to the related library object' ],
"sample" => [ 'reference sample', 'reference to the related sample object' ],
"primary_project" => [ 'reference project', 'reference to the primary project object' ],
"project" => [ 'reference project', 'reference to the project object' ],
"metadata" => [ 'hash', 'key value pairs describing metadata' ],
"created" => [ 'date', 'time the object was first created' ],
"version" => [ 'integer', 'version of the object' ],
Expand Down Expand Up @@ -194,37 +193,25 @@ sub prepare_data {
my $objects = [];
foreach my $job (@$data) {
my $obj = {};
$obj->{id} = "mgm".$job->{metagenome_id};
$obj->{name} = $job->{name};
$obj->{url} = $cgi->url.'/metagenome/'.$obj->{id};
$obj->{created} = $job->{created_on};
$obj->{id} = "mgm".$job->{metagenome_id};
$obj->{name} = $job->{name};
$obj->{url} = $cgi->url.'/metagenome/'.$obj->{id};
$obj->{created} = $job->{created_on};

if ($cgi->param('verbosity')) {
if ($cgi->param('verbosity') eq 'full') {
$obj->{metadata} = $jobdata->{$job->{metagenome_id}};
$obj->{metadata} = $jobdata->{$job->{metagenome_id}};
}
if ($cgi->param('verbosity') eq 'verbose' || $cgi->param('verbosity') eq 'full') {
if ($jobdata->{$job->{metagenome_id}}) {
if ($jobdata->{$job->{metagenome_id}}->{project}) {
$obj->{project_name} = $jobdata->{$job->{metagenome_id}}->{project}->{name} || "";
if ($jobdata->{$job->{metagenome_id}}->{project}->{data}) {

$obj->{PI} = ($jobdata->{$job->{metagenome_id}}->{project}->{data}->{PI_firstname} || "")." ".($jobdata->{$job->{metagenome_id}}->{project}->{data}->{PI_lastname} || "");
}
}
if ($jobdata->{$job->{metagenome_id}}->{sample} && $jobdata->{$job->{metagenome_id}}->{sample}->{data}) {
$obj->{country} = $jobdata->{$job->{metagenome_id}}->{sample}->{data}->{country} || "";
$obj->{biome} = $jobdata->{$job->{metagenome_id}}->{sample}->{data}->{biome} || "";
$obj->{location} = $jobdata->{$job->{metagenome_id}}->{sample}->{data}->{location} || "";
}
}
$obj->{sample} = $job->{sample} ? [ "mgs".$job->sample->ID, $cgi->url."sample/mgs".$job->sample->ID ] : undef;
$obj->{library} = $job->{library} ? [ "mgl".$job->library->ID, $cgi->url."/library/mgl".$job->library->ID ] : undef;
$obj->{version} = 1;
$obj->{sequence_type} = $job->{sequence_type};
$obj->{project} = $job->{primary_project} ? [ "mgp".$job->primary_project->id, $cgi->url."/project/mgp".$job->primary_project->id ] : undef;
$obj->{sample} = $job->{sample} ? [ "mgs".$job->sample->ID, $cgi->url."/sample/mgs".$job->sample->ID ] : undef;
$obj->{library} = $job->{library} ? [ "mgl".$job->library->ID, $cgi->url."/library/mgl".$job->library->ID ] : undef;
} elsif ($cgi->param('verbosity') ne 'minimal') {
return_data({ "ERROR" => "invalid value for option verbosity", 400);
return_data({ "ERROR" => "invalid value for option verbosity" }, 400);
}
}

push(@$objects, $obj);
}

Expand Down Expand Up @@ -262,7 +249,7 @@ sub check_pagination {
next if ($param eq 'offset');
$additional_params .= $param."=".$cgi->param($param)."&";
}
if (length($additional_params) {
if (length($additional_params)) {
chop $additional_params;
}
my $prev_offset = $offset - $limit;
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources2/project.pm
Expand Up @@ -251,7 +251,7 @@ sub check_pagination {
next if ($param eq 'offset');
$additional_params .= $param."=".$cgi->param($param)."&";
}
if (length($additional_params) {
if (length($additional_params)) {
chop $additional_params;
}
my $prev_offset = $offset - $limit;
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources2/sample.pm
Expand Up @@ -250,7 +250,7 @@ sub check_pagination {
next if ($param eq 'offset');
$additional_params .= $param."=".$cgi->param($param)."&";
}
if (length($additional_params) {
if (length($additional_params)) {
chop $additional_params;
}
my $prev_offset = $offset - $limit;
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources2/sequences.pm
Expand Up @@ -230,7 +230,7 @@ sub check_pagination {
next if ($param eq 'offset');
$additional_params .= $param."=".$cgi->param($param)."&";
}
if (length($additional_params) {
if (length($additional_params)) {
chop $additional_params;
}
my $prev_offset = $offset - $limit;
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/resources2/sequenceset.pm
Expand Up @@ -259,7 +259,7 @@ sub check_pagination {
next if ($param eq 'offset');
$additional_params .= $param."=".$cgi->param($param)."&";
}
if (length($additional_params) {
if (length($additional_params)) {
chop $additional_params;
}
my $prev_offset = $offset - $limit;
Expand Down