Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ef900ac
Merge pull request #525 from MG-RAST/develop
wilke Apr 16, 2014
68117b3
Merge pull request #532 from MG-RAST/develop
teharrison May 16, 2014
c2a449d
Merge pull request #539 from MG-RAST/develop
teharrison Jun 13, 2014
6ce5d08
Merge pull request #541 from paczian/master
Jun 17, 2014
8589535
Merge pull request #542 from MG-RAST/hotfix-3.10.1
Jun 17, 2014
09129e6
Merge pull request #543 from paczian/master
Jun 23, 2014
66046b4
Merge pull request #544 from paczian/master
Jun 24, 2014
f3a1058
Merge pull request #545 from MG-RAST/hotfix-3.3.11.2
Jun 24, 2014
1d71b88
add error if paginated offset larger than total
teharrison Jun 27, 2014
65c5c39
update mixs metadata retrieval
teharrison Jun 27, 2014
71c8469
fix syntax and CGI header bugs
teharrison Jun 27, 2014
8ac02d3
Merge pull request #546 from teharrison/develop
teharrison Jun 27, 2014
23e1d6a
fix offset out of bound error
teharrison Jun 27, 2014
53ac000
Merge pull request #547 from teharrison/develop
teharrison Jun 27, 2014
8c1190b
added server resource
Jul 2, 2014
32751e0
fix required options
teharrison Jul 2, 2014
ef89cf2
Merge pull request #549 from teharrison/develop
teharrison Jul 2, 2014
8da383d
Merge branch 'develop' of github.com:MG-RAST/MG-RAST
Jul 8, 2014
c78c203
added create and update to user resource
Jul 9, 2014
453b367
Merge pull request #548 from paczian/master
Jul 9, 2014
1fbe171
Reformatted comments to SQL compliant
danielolson5 Jul 10, 2014
1cc10c6
Merge pull request #550 from danielolson5/develop
wilke Jul 10, 2014
66e38be
removed collections from memcache
Jul 17, 2014
9863016
added error output for page->output when in developer mode
Jul 17, 2014
a79272a
Merge pull request #551 from paczian/master
Jul 21, 2014
85d1227
Merge branch 'master' of github.com:MG-RAST/MG-RAST into hotfix-3.3.3.4
Jul 21, 2014
c5708ca
added all the user commands
Jul 21, 2014
263d46c
user stuff
Jul 21, 2014
a38f3b5
merge
Jul 21, 2014
e904675
fixed invalid array reference
Jul 21, 2014
1ca8243
Merge pull request #1 from paczian/master
Jul 21, 2014
22ba950
Merge pull request #552 from paczian/develop
teharrison Jul 21, 2014
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/Babel/bin/create_pg_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ CREATE INDEX ontologies_type ON ontologies (source);
CREATE INDEX sources_name ON sources (name);
CREATE INDEX sources_type ON sources (type);

# load ontologies table
/* load ontologies table */
INSERT INTO ontologies (level1,level2,level3,level4,id,source) SELECT level1,level2,level3,level4,id,12 FROM ontology_kegg;
INSERT INTO ontologies (level1,level2,level3,level4,id,source) SELECT level1,level2,level3,level4,id,14 FROM ontology_seed;
INSERT INTO ontologies (level1,level2,level3,id,source) SELECT level1,level2,level3,id,10 FROM ontology_eggnog WHERE type='COG';
Expand Down
33 changes: 33 additions & 0 deletions src/MGRAST/lib/Metadata.pm
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,39 @@ sub get_job_metadata {
return exists($data->{$job->job_id}) ? $data->{$job->job_id} : {};
}

sub get_job_mixs {
my ($self, $job) = @_;

my $mixs = {};
$mixs->{project_id} = "";
$mixs->{project_name} = "";
$mixs->{PI_firstname} = "";
$mixs->{PI_lastname} = "";
eval {
$mixs->{project_id} = 'mgp'.$job->primary_project->{id};
$mixs->{project_name} = $job->primary_project->{name};
};
eval {
my $pdata = $job->primary_project->data;
$mixs->{PI_firstname} = $pdata->{PI_firstname};
$mixs->{PI_lastname} = $pdata->{PI_lastname};
};
my $lat_lon = $job->lat_lon;
$mixs->{latitude} = (@$lat_lon > 1) ? $lat_lon->[0] : "";
$mixs->{longitude} = (@$lat_lon > 1) ? $lat_lon->[1] : "";
$mixs->{country} = $job->country || "";
$mixs->{location} = $job->location || "";
$mixs->{biome} = $job->biome || "";
$mixs->{feature} = $job->feature || "";
$mixs->{material} = $job->material || "";
$mixs->{seq_method} = $job->seq_method || "";
$mixs->{sequence_type} = $job->seq_type || "";
$mixs->{collection_date} = $job->collection_date || "";
$mixs->{env_package_type} = $job->env_package_type || "";

return $mixs;
}

=pod

=item * B<is_job_compliant> (JobObject<job>)
Expand Down
80 changes: 40 additions & 40 deletions src/MGRAST/lib/WebPage/Analysis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6585,8 +6585,47 @@ sub selectable_metagenomes {
my $cache_key = "analysis_metagenomes_".($no_groups ? "nogroups" : "hasgroups")."_".($user ? $user->_id : "anonymous");
my $cdata = $memd->get($cache_key);

my $colls = [];
my $coll_prefs = $self->application->dbmaster->Preferences->get_objects( { application => $self->application->backend,
user => $user,
name => 'mgrast_collection' } );
if (scalar(@$coll_prefs) && (! $no_groups)) {
my $rast = $self->application->data_handle('MGRAST');
my $collections = {};
foreach my $collection_pref (@$coll_prefs) {
my ($name, $val) = split(/\|/, $collection_pref->{value});
if (! exists($collections->{$name})) {
$collections->{$name} = [];
}
my $pj = $rast->Job->get_objects( { job_id => $val })->[0];
push @{$collections->{$name}}, [ $pj->{metagenome_id}, $pj->{name} ];
}
foreach my $coll ( sort keys %$collections ) {
if ( @{$collections->{$coll}} == 0 ) { next; }
push(@$colls, { label => $coll." [".scalar(@{$collections->{$coll}})."]", value => join('||', map { $_->[0]."##".$_->[1] } @{$collections->{$coll}}) });
}
}

if ($cdata) {
# there is cached data
$memd->disconnect_all;

# if there are collections, update them in the cache data
if ($user && scalar(@$colls)) {
my $found_colls = 0;
for (my $i=0; $i<scalar(@{$cdata->[1]}); $i++) {
if ($cdata->[1]->[$i] eq 'collections') {
$cdata->[0]->[$i] = $colls;
$found_colls = 1;
last;
}
}
unless ($found_colls) {
push(@{$cdata->[1]}, "collections");
push(@{$cdata->[0]}, $colls);
}
}

return @$cdata;
}

Expand All @@ -6601,7 +6640,6 @@ sub selectable_metagenomes {
my $rast = $self->application->data_handle('MGRAST');
my $org_seen = {};
my $metagenomespub = [];
my $colls = [];
my $projs = [];
my $mgs = [];
if (ref($rast)) {
Expand Down Expand Up @@ -6657,45 +6695,6 @@ sub selectable_metagenomes {
@$projs = sort { lc($a->{label}) cmp lc($b->{label}) } @$projs;

if ($user) {

# check for collections
my $coll_prefs = $self->application->dbmaster->Preferences->get_objects( { application => $self->application->backend,
user => $user,
name => 'mgrast_collection' } );
if (scalar(@$coll_prefs) && (! $no_groups)) {
my $collections = {};
foreach my $collection_pref (@$coll_prefs) {
my ($name, $val) = split(/\|/, $collection_pref->{value});
if (! exists($collections->{$name})) {
$collections->{$name} = [];
}
my $pj;
foreach my $pmg (@$public_metagenomes) {
if ($pmg->{job_id} == $val) {
$pj = $pmg;
last;
}
}
unless ($pj) {
foreach my $mg (@$mgs) {
if (ref($mg) && (ref($mg) eq 'HASH')) {
if ($mg->{job_id} == $val) {
$pj = $mg;
last;
}
}
}
}
if ($pj) {
push @{$collections->{$name}}, [ $pj->{metagenome_id}, $pj->{name} ];
}
}
foreach my $coll ( sort keys %$collections ) {
if ( @{$collections->{$coll}} == 0 ) { next; }
push(@$colls, { label => $coll." [".scalar(@{$collections->{$coll}})."]", value => join('||', map { $_->[0]."##".$_->[1] } @{$collections->{$coll}}) });
}
}

# build hash from all accessible metagenomes
foreach my $mg_job (@$mgs) {
next if ($org_seen->{$mg_job->{metagenome_id}});
Expand All @@ -6708,6 +6707,7 @@ sub selectable_metagenomes {
}
}
}

my $groups = [];
if (scalar(@$metagenomes)) {
push(@$all_mgs, $metagenomes);
Expand Down
10 changes: 6 additions & 4 deletions src/MGRAST/lib/resources/metadata.pm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sub info {
},
{ 'name' => "export",
'request' => $self->cgi->url."/".$self->name."/export/{ID}",
'description' => "Returns full nested metadata for a project in same format as template",
'description' => "Returns full nested metadata for a project in same format as template, or metadata for a single metagenome.",
'example' => [ $self->cgi->url."/".$self->name."/export/mgp128",
'all metadata for project mgp128' ],
'method' => "GET",
Expand Down Expand Up @@ -302,9 +302,11 @@ sub instance {
) {
$self->return_data( {"ERROR" => "insufficient permissions to view this data"}, 401 );
}
# prepare data
my $dataset = $mddb->get_jobs_metadata_fast([$mgid], 1);
$self->return_data($dataset->{$mgid});
# prepare data / get mixs
my $data = $mddb->get_jobs_metadata_fast([$mgid], 1)->{$mgid};
my $mixs = $mddb->get_job_mixs($job);
$data->{mixs} = $mixs;
$self->return_data($data);
}
# bad id
else {
Expand Down
39 changes: 11 additions & 28 deletions src/MGRAST/lib/resources/metagenome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use URI::Escape;
use List::Util qw(first max min sum);
use POSIX qw(strftime floor);

use MGRAST::Metadata;
use MGRAST::Analysis;
use Conf;
use parent qw(resources::resource);
Expand Down Expand Up @@ -336,6 +337,11 @@ sub query {
}
my $obj = $self->check_pagination($data, $total, $limit);
$obj->{version} = 1;

# found nothing, return it
if (scalar(@$data) == 0) {
$self->return_data($obj);
}

if (($verb eq 'minimal') || ($verb eq 'mixs')) {
# add missing fields to solr data
Expand Down Expand Up @@ -374,10 +380,9 @@ sub prepare_data {
my $mgids = [];
@$mgids = map { $_->{metagenome_id} } @$data;
my $jobdata = {};
my $mddb;
my $mddb = undef;

if (($verb eq 'metadata') || ($verb eq 'full')) {
use MGRAST::Metadata;
$mddb = MGRAST::Metadata->new();
$jobdata = $mddb->get_jobs_metadata_fast($mgids, 1);
}
Expand Down Expand Up @@ -459,32 +464,10 @@ sub prepare_data {
$obj->{pipeline_version} = '3.0';

if (($verb eq 'mixs') || ($verb eq 'full')) {
my $mixs = {};
$mixs->{project_id} = "";
$mixs->{project_name} = "";
$mixs->{PI_firstname} = "";
$mixs->{PI_lastname} = "";
eval {
$mixs->{project_id} = 'mgp'.$job->primary_project->{id};
$mixs->{project_name} = $job->primary_project->{name};
};
eval {
my $pdata = $job->primary_project->data;
$mixs->{PI_firstname} = $pdata->{PI_firstname};
$mixs->{PI_lastname} = $pdata->{PI_lastname};
};
my $lat_lon = $job->lat_lon;
$mixs->{latitude} = (@$lat_lon > 1) ? $lat_lon->[0] : "";
$mixs->{longitude} = (@$lat_lon > 1) ? $lat_lon->[1] : "";
$mixs->{country} = $job->country || "";
$mixs->{location} = $job->location || "";
$mixs->{collection_date} = $job->collection_date || "";
$mixs->{biome} = $job->biome || "";
$mixs->{feature} = $job->feature || "";
$mixs->{material} = $job->material || "";
$mixs->{env_package_type} = $job->env_package_type || "";
$mixs->{seq_method} = $job->seq_method || "";
$mixs->{sequence_type} = $job->seq_type || "";
if (! $mddb) {
$mddb = MGRAST::Metadata->new();
}
my $mixs = $mddb->get_job_mixs($job);
if ($verb eq 'full') {
$obj->{mixs} = $mixs;
} else {
Expand Down
35 changes: 18 additions & 17 deletions src/MGRAST/lib/resources/resource.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ sub new {
204 => "No Content",
400 => "Bad Request",
401 => "Unauthorized",
404 => "Not Found",
416 => "Request Range Not Satisfiable",
500 => "Internal Server Error",
501 => "Not Implemented",
503 => "Service Unavailable",
507 => "Storing object failed",
-32602 => "Invalid params",
-32603 => "Internal error"
};
404 => "Not Found",
416 => "Request Range Not Satisfiable",
500 => "Internal Server Error",
501 => "Not Implemented",
503 => "Service Unavailable",
507 => "Storing object failed",
-32602 => "Invalid params",
-32603 => "Internal error"
};
# create object
my $self = {
format => "application/json",
Expand Down Expand Up @@ -205,7 +205,6 @@ sub pipeline_opts {
'file_type',
'filter_ambig',
'filter_ln',
'filter_options',
'max_ambig',
'max_ln',
'max_lqb',
Expand Down Expand Up @@ -297,17 +296,19 @@ sub header {
unless ($status) {
$status = 200;
}
my $header = $self->cgi->header(
-type => $self->format,
-status => $status,
-Access_Control_Allow_Origin => '*'
);
my $size = 0;
{
use bytes;
if ($text) {
$header->set('Content-Length' => length($text));
$size = length($text);
}
}
my $header = $self->cgi->header(
-type => $self->format,
-status => $status,
-Access_Control_Allow_Origin => '*',
-Content_Length => $size
);
return $header
}

Expand Down Expand Up @@ -462,7 +463,7 @@ sub return_data {
$data = { 'data' => $data };
}
$self->format("application/json");
my $data_text = $self->cgi->param('callback')."(".$self->json->encode($data).");"
my $data_text = $self->cgi->param('callback')."(".$self->json->encode($data).");";
print $self->header($status, $data_text);
print $data_text;
exit 0;
Expand Down
Loading