Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
8ac6478
added heartbeat resource
Feb 9, 2015
ff6131c
Merge pull request #680 from paczian/develop
Feb 9, 2015
98334a8
fix function name
teharrison Feb 9, 2015
593d9dc
minor tweaks to how inbox nodes are found
Feb 12, 2015
b534363
fixed function name
Feb 12, 2015
31d64ac
fix job creation api
teharrison Feb 12, 2015
d621a2a
bug fixes to job submission
teharrison Feb 12, 2015
c20a36a
Merge pull request #681 from teharrison/develop
teharrison Feb 12, 2015
cc36877
add 'id' to verbose output
teharrison Feb 13, 2015
494efbd
have auth type in datatoken
teharrison Feb 13, 2015
0c32b55
change inbox nodes to be owned by user with mgrast added to ACLs
teharrison Feb 13, 2015
e1a431f
Merge pull request #682 from teharrison/develop
teharrison Feb 13, 2015
23874a4
Merge branch 'develop' of github.com:MG-RAST/MG-RAST into develop
Feb 17, 2015
13e8622
updated to unified authHeader
Feb 17, 2015
36da604
Merge pull request #683 from paczian/develop
Feb 17, 2015
bfa9df9
added user impersonation
Feb 17, 2015
c66da37
fixed bug in impersonation
Feb 17, 2015
98a0f79
fixed typo
Feb 17, 2015
08546a1
fixed another typo
Feb 17, 2015
a834028
added token creation / refresh to impersonate
Feb 17, 2015
f928468
fixed bugs in impersonate refresh webkey
Feb 17, 2015
293952f
Merge pull request #684 from paczian/develop
Feb 17, 2015
ebef96b
added expiration to token
Feb 17, 2015
277ba4f
Merge pull request #685 from paczian/develop
Feb 17, 2015
48c8581
add awe function
teharrison Feb 17, 2015
f6174ce
add inbox awe job info to nodes, calculate file_info and refresh job …
teharrison Feb 17, 2015
2d33195
resolve conflict
teharrison Feb 17, 2015
db33bbc
correct variable name
teharrison Feb 17, 2015
972062b
added pipeline job info to input file node attributes
teharrison Feb 17, 2015
7d348fe
set type for excel files
teharrison Feb 18, 2015
1c3b454
set type for excel files
teharrison Feb 18, 2015
b15674e
add delete function
teharrison Feb 18, 2015
75a6f74
status message updates
teharrison Feb 18, 2015
e1b9f05
accept delete method
teharrison Feb 18, 2015
e9de7bf
fix filename
teharrison Feb 18, 2015
d1b731b
fix status message
teharrison Feb 18, 2015
8d9f3e4
check if stats has been ran previously
teharrison Feb 19, 2015
74cf660
update shock node after validation
teharrison Feb 19, 2015
b69b946
update output filenames
teharrison Feb 19, 2015
784c6fe
add rename and single file view, update workflows
teharrison Feb 19, 2015
7b7e1fb
typo fixes
teharrison Feb 19, 2015
2d4a6d2
fix sff2fastq output filename
teharrison Feb 20, 2015
f54477b
add seq stats calc to output of sff2fastq workflow
teharrison Feb 20, 2015
69a5548
add seq stats calc to output of pair_join workflow
teharrison Feb 20, 2015
632da5a
added view_inbox_actions method
Feb 23, 2015
4e41d7f
added state option to inbox action query
Feb 23, 2015
a3c73ac
Merge pull request #687 from paczian/develop
teharrison Feb 23, 2015
a5de3ec
attribute update
teharrison Feb 23, 2015
124a50c
add seq stats calc to output of workflows
teharrison Feb 23, 2015
d2c7afc
add seq stats calc to output of workflows
teharrison Feb 23, 2015
6671d4f
update job creation defaults
teharrison Feb 23, 2015
868995d
resolve conflicts, add pending to request list
teharrison Feb 23, 2015
3de4d16
Merge pull request #686 from teharrison/develop
teharrison Feb 23, 2015
059e606
typo
teharrison Feb 23, 2015
79e8099
Merge pull request #688 from teharrison/develop
teharrison Feb 23, 2015
d9cb289
added cite MG-RAST API button
Mar 3, 2015
e07a966
Merge pull request #689 from paczian/develop
Mar 3, 2015
393ed56
added heartbeat check for SHOCK and AWE before submission
Mar 3, 2015
739ee0a
Merge pull request #690 from paczian/develop
Mar 3, 2015
4146e41
support in analysis perl module and matrix resourse for multiple vers…
teharrison Mar 6, 2015
a526451
clean up info struct
teharrison Mar 6, 2015
ab4d801
Merge pull request #692 from teharrison/develop
jaredbischof Mar 6, 2015
0842e1c
added missing action registration
Mar 12, 2015
0e27131
fixed semicolon
Mar 12, 2015
8cc240c
Merge pull request #693 from paczian/develop
Mar 12, 2015
c123ba1
fixed unknown number
Mar 12, 2015
1b38fa0
Merge pull request #694 from paczian/develop
Mar 12, 2015
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
6 changes: 3 additions & 3 deletions src/MGRAST/cgi/api.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (lc($request_method) eq 'options') {
-status => 200,
-type => 'text/plain',
-charset => 'UTF-8',
-Access_Control_Allow_Methods => 'POST, GET, OPTIONS, PUT',
-Access_Control_Allow_Methods => 'POST, GET, OPTIONS, PUT, DELETE',
-Access_Control_Allow_Headers => 'AUTH, AUTHORIZATION'
);
print "";
Expand Down Expand Up @@ -148,12 +148,12 @@ else {

# check for authentication
my $user;
if ($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_AUTHORIZATION') || $cgi->param('authorization')) {
if ($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_Authorization') || $cgi->param('authorization')) {
eval {
require Auth;
Auth->import();
my $message;
($user, $message) = Auth::authenticate($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_AUTHORIZATION') || $cgi->param('authorization'));
($user, $message) = Auth::authenticate($cgi->http('HTTP_AUTH') || $cgi->param('auth') || $cgi->http('HTTP_Authorization') || $cgi->param('authorization'));
unless($user) {
unless ($message eq "valid kbase user") {
print $cgi->header( -type => 'application/json',
Expand Down
53 changes: 33 additions & 20 deletions src/MGRAST/html/js/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,26 +711,39 @@ function check_submitable () {
}

function submit_job () {
document.getElementById("submit_job_button").disabled = true;
var seq_files = selected_sequence_files.join('|');
$.ajax({ async: false, type: "POST", url: "metagenomics.cgi", data: { page: "Upload", action: "check_for_duplicates", seqfiles: seq_files }, success: function (result) {
if (result == "unique") {
document.forms.submission_form.submit();
} else if (result.match(/ERROR/) ) {
alert(result);
return false;
} else {
if ( confirm(result) ) {
// If the user allows a duplicate to be loaded into the system, we call a perl subroutine that
// will e-mail mg-rast@mcs.anl.gov if the duplicate is over 1GB in size (or whatever limit is set in Conf.pm)
$.ajax({ async: false, type: "POST", url: "metagenomics.cgi", data: { page: "Upload", action: "send_email_for_duplicate_submission", seqfiles: seq_files } });
document.forms.submission_form.submit();
} else {
document.getElementById("submit_job_button").disabled = false;
return false;
}
}
}});
// test if AWE and SHOCK are up
jQuery.getJSON( "http://api.metagenomics.anl.gov/heartbeat/AWE", function(data) {
if (data.status != 1) {
alert("Our submission pipeline is currently out of service. Please try again later.");
return;
}
jQuery.getJSON( "http://api.metagenomics.anl.gov/heartbeat/SHOCK", function(data) {
if (data.status != 1) {
alert("Our submission pipeline is currently out of service. Please try again later.");
return;
}
document.getElementById("submit_job_button").disabled = true;
var seq_files = selected_sequence_files.join('|');
$.ajax({ async: false, type: "POST", url: "metagenomics.cgi", data: { page: "Upload", action: "check_for_duplicates", seqfiles: seq_files }, success: function (result) {
if (result == "unique") {
document.forms.submission_form.submit();
} else if (result.match(/ERROR/) ) {
alert(result);
return false;
} else {
if ( confirm(result) ) {
// If the user allows a duplicate to be loaded into the system, we call a perl subroutine that
// will e-mail mg-rast@mcs.anl.gov if the duplicate is over 1GB in size (or whatever limit is set in Conf.pm)
$.ajax({ async: false, type: "POST", url: "metagenomics.cgi", data: { page: "Upload", action: "send_email_for_duplicate_submission", seqfiles: seq_files } });
document.forms.submission_form.submit();
} else {
document.getElementById("submit_job_button").disabled = false;
return false;
}
}
}});
});
});
}

function toggle (id) {
Expand Down
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
11 changes: 8 additions & 3 deletions src/MGRAST/lib/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ sub authenticate {
if ($pref->[0]->value < time) {
$pref->[0]->value(time + 1209600);
}
my $skeytimeout = $pref->[0]->value();
$pref = $master->Preferences->get_objects( { name => 'WebServicesKey', user => $us } );
my $cgi = new CGI;
my $verbose = "";
if ($cgi->param('verbosity') && $cgi->param('verbosity') eq 'verbose') {
$verbose = ', "login": "'.$us->{login}.'", "firstname": "'.$us->{firstname}.'", "lastname": "'.$us->{lastname}.'", "email": "'.$us->{email}.'"';

$verbose = ', "login":"'.$us->{login}.'", "firstname":"'.$us->{firstname}.'", "lastname":"'.$us->{lastname}.'", "email":"'.$us->{email}.'", "id":"mgu'.$us->{_id}.'"';
# SHOCK preferences
my $prefs = $master->Preferences->get_objects({ user => $us, name => "shock_pref_node" });
if (scalar(@$prefs)) {
Expand Down Expand Up @@ -77,7 +77,7 @@ sub authenticate {
-status => 200,
-charset => 'UTF-8',
-Access_Control_Allow_Origin => '*' );
print '{ "token": "'.$pref->[0]->value.'"'.$verbose.' }';
print '{ "token": "'.$pref->[0]->value.'", "expiration": "'.$skeytimeout.'"'.$verbose.' }';
exit;
} else {
return (undef, "api access not enabled for this user");
Expand Down Expand Up @@ -213,6 +213,11 @@ sub authenticate {
}
}
}

# check for MG-RAST default auth header
if ($auth_value =~ /^mgrast /) {
$auth_value =~ s/^mgrast //;
}

# check for the preference setting for the defined authentication source and value
my $preference = $master->Preferences->get_objects( { name => $auth_source, value => $auth_value } );
Expand Down
1 change: 1 addition & 0 deletions src/MGRAST/lib/WebPage/Analysis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ sub init {
$self->application->register_action($self, 'workbench_blat_output', 'workbench_blat_output');
$self->application->register_action($self, 'qiime_export_visual', 'qiime_export_visual');
$self->application->register_action($self, 'phylogeny_visual', 'phylogeny_visual');
$self->application->register_action($self, 'single_visual', 'single_visual');

my $mgdb = MGRAST::Analysis->new( $self->app->data_handle('MGRAST')->db_handle );
unless ($mgdb) {
Expand Down
2 changes: 1 addition & 1 deletion src/MGRAST/lib/WebPage/Home.pm
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ END

$content .= "<p style='color:#8FBC3F;text-align:left;font-size:9px;margin-top:3px;'>This work was supported in part by the Office of Advanced Scientific Computing Research, Office of Science, U.S. Department of Energy, under Contract DE-AC02-06CH11357.</p>";

$content .= "<a href=\"http://www.biomedcentral.com/1471-2105/9/386\" target=\"_blank\"><p style='border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; color: white; padding: 5px 0px 3px 10px; color: white; font-size:14; background-color: #5281B0; width: 100px; float: left; margin-right: 10px; top: -12px; position: relative;'>cite MG-RAST</p></a>";
$content .= "<a href=\"http://www.biomedcentral.com/1471-2105/9/386\" target=\"_blank\"><p style='border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; color: white; padding: 5px 0px 3px 10px; color: white; font-size:14; background-color: #5281B0; width: 100px; float: left; margin-right: 10px; top: -12px; position: relative;'>cite MG-RAST</p></a><a href=\"http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1004008\" target=\"_blank\" style=\"float: right;\"><p style='border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; color: white; padding: 5px 0px 3px 10px; color: white; font-size:14; background-color: #5281B0; width: 120px; float: left; margin-right: 10px; top: -12px; position: relative;'>cite MG-RAST API</p></a>";

#$content .= "<p style='color:#8FBC3F;text-align:left;font-size:9px;margin-top:3px;'><em>The Metagenomics RAST server - A public resource for the automatic phylogenetic and functional analysis of metagenomes</em> F. Meyer, D. Paarmann, M. D'Souza, R. Olson , E. M. Glass, M. Kubal, T. Paczian , A. Rodriguez , R. Stevens, A. Wilke, J. Wilkening, R. A. Edwards<br/><em>BMC Bioinformatics 2008, 9:386
#, [<a href=\"http://www.biomedcentral.com/1471-2105/9/386\" target=\"_blank\">article</a>]</em></p>";
Expand Down
4 changes: 4 additions & 0 deletions src/MGRAST/lib/WebPage/MetagenomeOverview.pm
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ sub output {
my $diff = ($qc_fail_seqs + $ann_aa_reads + $ann_rna_reads) - $raw_seqs;
$ann_rna_reads = ($diff > $ann_rna_reads) ? 0 : $ann_rna_reads - $diff;
}
my $diff = $raw_seqs - ($qc_fail_seqs + $unkn_aa_reads + $ann_aa_reads + $ann_rna_reads);
if ($unknown_all < $diff) {
$unknown_all = $diff;
}
}

($qc_fail_seqs, $unknown_all, $unkn_aa_reads, $ann_aa_reads, $ann_rna_reads) =
Expand Down
131 changes: 131 additions & 0 deletions src/MGRAST/lib/resources/heartbeat.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package resources::heartbeat;

use strict;
use warnings;
no warnings('once');

use parent qw(resources::resource);

# Override parent constructor
sub new {
my ($class, @args) = @_;

# Call the constructor of the parent class
my $self = $class->SUPER::new(@args);

# Add name / attributes
$self->{name} = "heartbeat";
$self->{services} = { 'FTP' => 'ftp://ftp.metagenomics.anl.gov',
'website' => 'http://metagenomics.anl.gov/',
'SHOCK' => $Conf::shock_url,
'AWE' => $Conf::awe_url,
'M5NR' => $Conf::m5nr_solr,
'solr' => $Conf::job_solr,
'postgres' => 'db',
'mySQL' => 'db' };
$self->{attributes} = { "service" => [ 'string', "cv", [ ['FTP', 'file server'],
['website', 'MG-RAST website'],
['SHOCK', 'object storage'],
['AWE', 'worker engine'],
['M5NR', 'non-redundant sequence database'],
['solr', 'search engine'],
['postgres', 'analysis database'],
['mySQL', 'job database']
] ],
"status" => [ 'boolean', 'service is up or not' ],
"url" => [ 'url', 'resource location of this resource']
};
return $self;
}

# resource is called without any parameters
# this method must return a description of the resource
sub info {
my ($self) = @_;
my $content = { 'name' => $self->name,
'url' => $self->cgi->url."/".$self->name,
'description' => "Status of services",
'type' => 'object',
'documentation' => $self->cgi->url.'/api.html#'.$self->name,
'requests' => [ { 'name' => "info",
'request' => $self->cgi->url."/".$self->name,
'description' => "Returns description of parameters and attributes.",
'method' => "GET" ,
'type' => "synchronous" ,
'attributes' => "self",
'parameters' => { 'options' => {},
'required' => {},
'body' => {} }
},
{ 'name' => "instance",
'request' => $self->cgi->url."/".$self->name."/{SERVICE}",
'description' => "Returns the status of a service.",
'example' => [ 'curl -X GET -H "auth: auth_key" "'.$self->cgi->url."/".$self->name.'/M5NR"',
"status of the M5NR service" ],
'method' => "GET" ,
'type' => "synchronous" ,
'attributes' => $self->attributes,
'parameters' => { 'options' => {},
'required' => { "service" => [ "cv", $self->{attributes}->{service}->[2] ] },
'body' => {} }
} ]
};
$self->return_data($content);
}

# the resource is called with a service parameter
sub instance {
my ($self) = @_;

# check id format
my $rest = $self->rest;
my $id = $rest->[0];
if (! $self->{services}->{$id}) {
$self->return_data( {"ERROR" => "invalid service name: " . $rest->[0]}, 400 );
}

my $status = 0;

if ($self->{services}->{$id} eq 'db') {
if ($id eq 'postgres') {
my $dbh = DBI->connect(
"DBI:Pg:database=".$Conf::mgrast_db.";host=".$Conf::mgrast_dbhost.";".$Conf::pgsslcert,
$Conf::mgrast_dbuser,
$Conf::mgrast_dbpass
);
if ($dbh) {
$status = 1;
}
} else {
my $jobcache_db = $Conf::mgrast_jobcache_db;
my $jobcache_host = $Conf::mgrast_jobcache_host;
my $jobcache_user = $Conf::mgrast_jobcache_user;
my $jobcache_password = $Conf::mgrast_jobcache_password;
my $dbh = DBI->connect("DBI:mysql:database=".$jobcache_db.";host=".$jobcache_host.";",
$jobcache_user,
$jobcache_password);
if ($dbh) {
$status = 1;
}
}
} else {
my $ua = $self->agent;
$ua->timeout(10);

my $url = $self->{services}->{$id};
my $response = $ua->get($url);
if ($response->is_success) {
$status = 1;
}
}

my $obj = {};
$obj->{service} = $id;
$obj->{status} = $status;
$obj->{url} = $self->cgi->url."/".$self->name."/".$id;

# check the status service
$self->return_data($obj, undef, 1);
}

1;
Loading