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
4 changes: 2 additions & 2 deletions src/MGRAST/lib/Analysis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use File::Temp qw/ tempfile tempdir /;
1;

sub new {
my ($class, $job_dbh, $dbh) = @_;
my ($class, $job_dbh, $dbh, $version) = @_;

# get ach object if have lib
my $ach = undef;
Expand Down Expand Up @@ -102,7 +102,7 @@ sub new {
id_src => \%idsrc, # hash: source_id => source_name
src_id => \%srcid, # hash: source_name => source_id
expire => $Conf::web_memcache_expire || 172800, # use config or 48 hours
version => $Conf::m5nr_annotation_version || 1,
version => $version || $Conf::m5nr_annotation_version || 1,
mgrast_token => $mgrast_token,
jtbl => { md5 => 'job_md5s',
ontology => 'job_ontologies',
Expand Down
86 changes: 19 additions & 67 deletions src/MGRAST/lib/resources/inbox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ sub new {

# Add name / attributes
$self->{name} = "inbox";
$self->{base_attr} = {
'id' => ['string', "user id"],
'user' => ['string', "user login"],
'status' => ['string', "status message"],
'timestamp' => ['string', "timestamp for return of this query"]
};
$self->{stat_attr} = {%{$self->{base_attr}}, ('stats_info' => ['hash', 'key value pairs describing file info'])};
$self->{id_attr} = {%{$self->{base_attr}}, ('awe_id' => ['string', "url/id of awe job" ])};
$self->{states} = ["completed", "deleted", "suspend", "in-progress", "pending", "queued"];
$self->{user_auth} = "mgrast";
if ($self->token =~ /globusonline/) {
Expand Down Expand Up @@ -64,7 +72,7 @@ sub info {
'type' => "synchronous",
'attributes' => {
'id' => [ 'string', "user id" ],
'user' => [ 'string', "user name" ],
'user' => [ 'string', "user login" ],
'timestamp' => [ 'string', "timestamp for return of this query" ],
'files' => [ 'list', [ 'object', [
{ 'filename' => [ 'string', "path of file from within user inbox" ],
Expand All @@ -87,12 +95,7 @@ sub info {
"rename file 'sequences.fastq' in user inbox, auth is required" ],
'method' => "GET",
'type' => "synchronous",
'attributes' => {
'id' => [ 'string', "user id" ],
'user' => [ 'string', "user name" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{base_attr},
'parameters' => {
'options' => { map { $_, ["boolean", "If true show the given state"] } @{$self->{states}} },
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ] },
Expand All @@ -106,12 +109,7 @@ sub info {
"upload file 'sequences.fastq' to user inbox, auth is required" ],
'method' => "POST",
'type' => "synchronous",
'attributes' => {
'id' => [ 'string', "user id" ],
'user' => [ 'string', "user name" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{base_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ] },
Expand All @@ -125,12 +123,7 @@ sub info {
"rename file 'sequences.fastq' in user inbox, auth is required" ],
'method' => "PUT",
'type' => "synchronous",
'attributes' => {
'id' => [ 'string', "user id" ],
'user' => [ 'string', "user name" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{base_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ],
Expand All @@ -145,12 +138,7 @@ sub info {
"delete file 'sequences.fastq' from user inbox, auth is required" ],
'method' => "DELETE",
'type' => "synchronous",
'attributes' => {
'id' => [ 'string', "user id" ],
'user' => [ 'string', "user name" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{base_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ],
Expand All @@ -165,13 +153,7 @@ sub info {
"get basic info for file with given id in user inbox, auth is required" ],
'method' => "GET",
'type' => "synchronous",
'attributes' => {
'id' => [ 'string', "user login" ],
'user' => [ 'string', "user name" ],
'stats_info' => [ 'hash', 'key value pairs describing file info' ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{stat_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ],
Expand All @@ -186,13 +168,7 @@ sub info {
"runs seq stats on file with given id in user inbox, auth is required" ],
'method' => "GET",
'type' => "asynchronous",
'attributes' => {
'id' => [ 'string', "user login" ],
'user' => [ 'string', "user name" ],
'awe_id' => [ 'string', "url/id of awe job" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{id_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ],
Expand All @@ -207,13 +183,7 @@ sub info {
"create fastq file from sff file with given id in user inbox, auth is required" ],
'method' => "POST",
'type' => "asynchronous",
'attributes' => {
'id' => [ 'string', "user login" ],
'user' => [ 'string', "user name" ],
'awe_id' => [ 'string', "url/id of awe job" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{id_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ] },
Expand All @@ -227,13 +197,7 @@ sub info {
"demultiplex seq file with barcode file for given ids in user inbox, auth is required" ],
'method' => "POST",
'type' => "asynchronous",
'attributes' => {
'id' => [ 'string', "user login" ],
'user' => [ 'string', "user name" ],
'awe_id' => [ 'string', "url/id of awe job" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{id_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ] },
Expand All @@ -248,13 +212,7 @@ sub info {
"merge overlapping paired-end fastq files for given ids, retain non-overlapping pairs" ],
'method' => "POST",
'type' => "asynchronous",
'attributes' => {
'id' => [ 'string', "user login" ],
'user' => [ 'string', "user name" ],
'awe_id' => [ 'string', "url/id of awe job" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{id_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ] },
Expand All @@ -271,13 +229,7 @@ sub info {
"merge overlapping paired-end fastq files then demultiplex with index file, for given ids" ],
'method' => "POST",
'type' => "asynchronous",
'attributes' => {
'id' => [ 'string', "user login" ],
'user' => [ 'string', "user name" ],
'awe_id' => [ 'string', "url/id of awe job" ],
'status' => [ 'string', "status message" ],
'timestamp' => [ 'string', "timestamp for return of this query" ]
},
'attributes' => $self->{id_attr},
'parameters' => {
'options' => {},
'required' => { "auth" => [ "string", "unique string of text generated by MG-RAST for your account" ] },
Expand Down
16 changes: 15 additions & 1 deletion src/MGRAST/lib/resources/matrix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ sub new {
organism => [ $self->source->{m5nr}, $self->source->{m5rna} ],
ontology => $self->source->{ontology}
};
$self->{ver_default} = 1;
$self->{version} = {
'1' => '20100309',
'7' => '20120401',
'9' => '20130801',
'10' => '20131215'
};
map { push @{$self->{sources}{organism}}, $_ } @{$self->source->{protein}};
map { push @{$self->{sources}{organism}}, $_ } @{$self->source->{rna}};
return $self;
Expand Down Expand Up @@ -103,6 +110,7 @@ sub info {
'filter_source' => [ 'cv', $self->{sources}{ontology} ],
'id' => [ 'string', 'one or more metagenome or project unique identifier' ],
'hide_metadata' => [ 'boolean', "if true do not return metagenome metadata in 'columns' object, default is false" ],
'version' => [ 'int', 'M5NR version, default '.$self->{ver_default} ],
'asynchronous' => [ 'boolean', "if true return process id to query status resource for results, default is false" ] },
'required' => {},
'body' => {} }
Expand Down Expand Up @@ -130,6 +138,7 @@ sub info {
'filter_source' => [ 'cv', $self->{sources}{organism} ],
'id' => [ 'string', 'one or more metagenome or project unique identifier' ],
'hide_metadata' => [ 'boolean', "if true do not return metagenome metadata in 'columns' object, default is false" ],
'version' => [ 'int', 'M5NR version, default '.$self->{ver_default} ],
'asynchronous' => [ 'boolean', "if true return process id to query status resource for results, default is false" ] },
'required' => {},
'body' => {} }
Expand All @@ -155,6 +164,7 @@ sub info {
'id' => [ "string", "one or more metagenome or project unique identifier" ],
'hide_metadata' => [ 'boolean', "if true do not return metagenome metadata in 'columns' object, default is false" ],
'hide_annotation' => [ 'boolean', "if true do not return feature metadata in 'rows' object, default is false" ],
'version' => [ 'int', 'M5NR version, default '.$self->{ver_default} ],
'asynchronous' => [ 'boolean', "if true return process id to query status resource for results, default is false" ] },
'required' => {},
'body' => {} } }
Expand Down Expand Up @@ -285,6 +295,7 @@ sub prepare_data {
my @filter = $cgi->param('filter') ? $cgi->param('filter') : ();
my $hide_md = $cgi->param('hide_metadata') ? 1 : 0;
my $hide_an = $cgi->param('hide_annotation') ? 1 : 0;
my $version = $->cgi->param('version') || $self->{ver_default};
my $leaf_node = 0;
my $prot_func = 0;
my $leaf_filter = 0;
Expand Down Expand Up @@ -314,8 +325,11 @@ sub prepare_data {
}

# initialize analysis obj with mgids
unless (exists $self->{version}{$version}) {
$self->return_data({"ERROR" => "invalid version was entered ($version). Please use one of: ".join(", ", keys %{$self->{version}})}, 404);
}
my $master = $self->connect_to_datasource();
my $mgdb = MGRAST::Analysis->new( $master->db_handle );
my $mgdb = MGRAST::Analysis->new($master->db_handle, undef, $version);
unless (ref($mgdb)) {
return ({"ERROR" => "could not connect to analysis database"}, 500);
}
Expand Down