Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8007854
new metadata template
Mar 14, 2014
466cb23
added user and project to job_options
Mar 17, 2014
7481283
Merge pull request #511 from teharrison/develop
teharrison Mar 17, 2014
c87f0f5
added verbose option to user info
Mar 17, 2014
feb0e9d
Merge pull request #512 from paczian/master
Mar 17, 2014
52897ea
fix project in pipeline options
Mar 17, 2014
d937bcb
Merge pull request #513 from teharrison/develop
teharrison Mar 17, 2014
da1b06a
switch from user login to user id as refrence in awe
Mar 17, 2014
ca52d0e
Merge pull request #514 from teharrison/develop
teharrison Mar 17, 2014
1d65141
api: update user resource to use ID and login
Mar 17, 2014
a23823d
add api resource for getting pipeline info
Mar 17, 2014
ca18a8f
api: update awe query
Mar 18, 2014
b992f59
Merge pull request #515 from teharrison/develop
teharrison Mar 18, 2014
90d4f3e
api: pipeline, added minimal view
teharrison Mar 18, 2014
610d0aa
api pipeline updates
teharrison Mar 19, 2014
0d15aed
Merge pull request #517 from teharrison/develop
teharrison Mar 19, 2014
d33f4b7
fix url
Mar 20, 2014
a1799b9
Merge branch 'develop' of git@github.com:teharrison/MG-RAST into develop
Mar 20, 2014
a143e33
api pipeline: fix bad timestamps
Mar 20, 2014
0180713
Merge pull request #518 from teharrison/develop
teharrison Mar 20, 2014
3386461
added validation to the number fields in the pipeline options
Mar 27, 2014
5d66c61
fixed error log spam of: uninitialized value in string eq at /WebAppl…
Mar 31, 2014
b89ef30
fixed error log spam of: uninitialized value in exists at /Analysis.p…
Mar 31, 2014
79a7f44
fixed error log spam of: uninitialized value in string at upload.cgi…
Mar 31, 2014
d1a0a16
Merge pull request #520 from teharrison/develop
teharrison Mar 31, 2014
c61efd5
Merge branch 'develop' of github.com:MG-RAST/MG-RAST
Apr 1, 2014
eafdf76
fixed uninitialized string warnings
Apr 1, 2014
b1067b1
functional tree will now show more than 2 mgs
Apr 1, 2014
cf72bfe
updated webkey behavior to be more user friendly
Apr 1, 2014
b0dd675
fixed some layout issues with the updated webkey handling
Apr 1, 2014
b0beb4f
add 'onotlogy' retrieval for metadata api
teharrison Apr 14, 2014
2c92cf1
typo fixes
Apr 14, 2014
d8c0312
Merge pull request #522 from teharrison/develop
jaredbischof Apr 14, 2014
3e79c30
Merge branch 'develop' of github.com:MG-RAST/MG-RAST
Apr 16, 2014
cb287dd
fixed workbench for all annotations
Apr 16, 2014
8b9c379
Merge pull request #519 from paczian/master
jaredbischof Apr 16, 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
Binary file not shown.
7 changes: 6 additions & 1 deletion src/MGRAST/cgi/api.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ my $cgi = new CGI;
my $json = new JSON;
$json = $json->utf8();

my %private_resources = ('notebook' => 1, 'resource' => 1, 'status' => 1, 'user' => 1, 'job' => 1);
my %private_resources = ( 'job' => 1,
'notebook' => 1,
'pipeline' => 1,
'resource' => 1,
'status' => 1,
'user' => 1 );

# get request method
$ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
Expand Down
1 change: 1 addition & 0 deletions src/MGRAST/cgi/upload.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ if (scalar(@rest) && $rest[0] eq 'user_inbox') {
while(my $line=<IN>) {
$line =~ s/\s+$//;
my @array = split(/\t/, $line);
next unless ($array[1]);
my $output_file = "$array[1]";
chomp $output_file;
if($filetype eq 'fastq') {
Expand Down
9 changes: 7 additions & 2 deletions src/MGRAST/html/js/Analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ function buffer_data (source, id, selector, dataloc, mgloc, srcloc, abuloc) {
for (h=0; h<selector; h++) {
if (table_visible_columns[data_index][h] && table_visible_columns[data_index][h] != "0") {
if (abuloc && h == abuloc) {
var fid = data_array[i][h].match(/abu\(this\, (\d+)/)[1];
inf += "<td><a style='cursor:pointer' onclick='abu(null, "+fid+", null, \""+data_array[i][srcloc]+"\",\""+data_array[i][dataloc]+"\");'>"+parseInt(data_array[i][abuloc].replace(HTML_REPLACE, ''))+"</a></td>";
var fid = data_array[i][h].match(/abu\(this\, (\d+)/);
if (fid) {
fid = fid[1];
inf += "<td><a style='cursor:pointer' onclick='abu(null, "+fid+", null, \""+data_array[i][srcloc]+"\",\""+data_array[i][dataloc]+"\");'>"+parseInt(data_array[i][abuloc].replace(HTML_REPLACE, ''))+"</a></td>";
} else {
inf += "<td>"+data_array[i][h] + "</td>";
}
} else {
inf += "<td>"+data_array[i][h] + "</td>";
}
Expand Down
62 changes: 57 additions & 5 deletions src/MGRAST/html/js/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,52 @@ function init_all () {
}
}

function stop(e){
e.stopPropagation();
}

function validateTextFields() {
var boxes = { "deviation": "positive_float",
"max_ambig": "positive_int",
"max_lqb": "int",
"min_qual": "int" };

var success = true;
for (var i in boxes) {
if (boxes.hasOwnProperty(i)) {
var box = document.getElementById(i);
switch (boxes[i]) {
case "positive_float":
if (box.value == 0 || (! box.value.match(/^\d+\.?(\d+)?$/))) {
box.setAttribute('style', "border: 1px solid red; box-shadow: 0 0 7px red;");
success = false;
} else {
box.setAttribute('style', "");
}
break;
case "positive_int":
if (box.value == 0 || (! box.value.match(/^\d+$/))) {
box.setAttribute('style', "border: 1px solid red; box-shadow: 0 0 7px red;");
success = false;
} else {
box.setAttribute('style', "");
}
break;
case "int":
if (! box.value.match(/^\d+$/)) {
box.setAttribute('style', "border: 1px solid red; box-shadow: 0 0 7px red;");
success = false;
} else {
box.setAttribute('style', "");
}
break;
};
}
}

return success;
}

function update_inbox (data, files, action) {
if (data) {
var flist = DataStore['user_inbox'][user.login].files;
Expand Down Expand Up @@ -605,10 +651,14 @@ function unselect_metadata_file () {
}

function accept_pipeline_options () {
document.getElementById("sel_pip_pill").className = "pill_complete";
document.getElementById("icon_step_4").style.display = "";
toggle("sel_pip_div");
check_submitable();
if (validateTextFields()) {
document.getElementById("sel_pip_pill").className = "pill_complete";
document.getElementById("icon_step_4").style.display = "";
toggle("sel_pip_div");
check_submitable();
} else {
alert("You have entered invalid values in the highlighted fields.");
}
}

function check_submitable () {
Expand Down Expand Up @@ -763,10 +813,12 @@ function delete_dir () {
}
}

function generate_webkey (get_new) {
function generate_webkey (get_new, reactivate) {
var get_new_param = "";
if (get_new) {
get_new_param = "&generate_new_key=1";
} else if (reactivate) {
get_new_param = "&reactivate_key=1";
}
$.get("?page=Upload&action=generate_webkey"+get_new_param, function (data) {
document.getElementById('generate_key').innerHTML = data;
Expand Down
6 changes: 5 additions & 1 deletion src/MGRAST/lib/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ sub authenticate {
}
$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}.'"';
}
print $cgi->header(-type => 'application/json',
-status => 200,
-Access_Control_Allow_Origin => '*' );
print '{ "token": "'.$pref->[0]->value.'" }';
print '{ "token": "'.$pref->[0]->value.'"'.$verbose.' }';
exit;
} else {
return (undef, "api access not enabled for this user");
Expand Down
5 changes: 5 additions & 0 deletions src/MGRAST/lib/JobDB/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ sub set_filter_options {

job function that creates an options string based upon all tag / value pairs
in JobAttributes for job and sets $job->{options} to its value.
also adds 'user_name' and 'project_id' as tags
format: tag1=value1&tag2=value2 ...
returns options string

Expand All @@ -835,6 +836,10 @@ sub set_job_options {
while ( my ($t, $v) = each %$job_data ) {
push @job_opts, "$t=$v";
}
push @job_opts, "user_id=mgu".$self->owner->_id;
if ($self->primary_project) {
push @job_opts, "project_id=mgp".$self->primary_project->id;
}
my $opts_string = join("&", @job_opts);
$self->options($opts_string);

Expand Down
57 changes: 27 additions & 30 deletions src/MGRAST/lib/WebPage/Analysis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ sub workbench_export {

my @fastas = ();
foreach my $s (@$seq_data) {
if (exists $md5_data->{$s->{md5}}) {
if ($s && exists($s->{md5}) && exists($md5_data->{$s->{md5}})) {
$s->{sequence} =~ s/(.{60})/$1\n/g;
foreach my $data ( @{$md5_data->{$s->{md5}}} ) {
next unless ($data->[0]);
Expand Down Expand Up @@ -3807,6 +3807,7 @@ sub metabolism_visual {
$tabnum--;

# mgid => md5 => abundance
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
# mgid, level1, level2, level3, annotation, id, abundance, sub_abundance, exp_avg, exp_stdv, ident_avg, ident_stdv, len_avg, len_stdv, md5s

unless (scalar(@$data)) {
Expand Down Expand Up @@ -4133,42 +4134,38 @@ sub metabolism_visual {
}
my $expanded_data = [];
if (scalar(@comp_mgs) > 1) {
$pt->sample_names( [ @comp_mgs[0..1] ] );

$pt->sample_names( [ @comp_mgs ] );
$pt->coloring_method('split');
my $exp_hash = {};
foreach my $row (@$data) {
next if ($row->[1] eq "-");
next if ($row->[1] eq "Clustering-based subsystems");
if ($row->[0] eq $comp_mgs[0]) {
$exp_hash->{$row->[4]} = $row;
}
my $anno_hash = {};
my $mg2num = {};

for (my $hh=0; $hh<scalar(@comp_mgs); $hh++) {
$mg2num->{$comp_mgs[$hh]} = $hh;
}

foreach my $row (@$data) {
next if ($row->[1] eq "-");
next if ($row->[1] eq "Clustering-based subsystems");
if ($row->[0] eq $comp_mgs[1]) {
my $other = 0;
if (exists($exp_hash->{$row->[4]})) {
$other = $exp_hash->{$row->[4]}->[6];
delete $exp_hash->{$row->[4]};
}
if ($row->[6] + $other > 0) {
if ($has_three) {
push(@$expanded_data, [ 'Metabolism', $row->[1], $row->[2], $row->[3], $row->[4], [ $row->[6], $other ] ] );
} else {
push(@$expanded_data, [ 'Metabolism', $row->[1], $row->[2], $row->[4], [ $row->[6], $other ] ] );
}
}
}
my $keystring = join("", @$row[1..4]);
$anno_hash->{$keystring} = [ @$row[1..4] ];
unless (exists($exp_hash->{$keystring})) {
$exp_hash->{$keystring} = [];
}
$exp_hash->{$keystring}->[$mg2num->{$row->[0]}] = $row->[6];
}
foreach my $key (keys(%$exp_hash)) {
my $row = $exp_hash->{$key};
if ($row->[6] > 0) {
if ($has_three) {
push(@$expanded_data, [ 'Metabolism', $row->[1], $row->[2], $row->[3], $row->[4], [ 0, $row->[6] ] ] );
} else {
push(@$expanded_data, [ 'Metabolism', $row->[1], $row->[2], $row->[4], [ 0, $row->[6] ] ] );
}

foreach my $key (sort(keys(%$exp_hash))) {
my $vals = [];
for (my $ii=0; $ii<scalar(@comp_mgs); $ii++) {
push(@$vals, $exp_hash->{$key}->[$ii] || 0);
}
my $row = $anno_hash->{$key};
if ($has_three) {
push(@$expanded_data, [ 'Metabolism', $row->[0], $row->[1], $row->[2], $row->[3], $vals ] );
} else {
push(@$expanded_data, [ 'Metabolism', $row->[0], $row->[1], $row->[3], $vals ] );
}
}
} else {
Expand Down
86 changes: 71 additions & 15 deletions src/MGRAST/lib/WebPage/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ sub output {
}
}

my $webkey = $self->current_webkey();

my $user_project_ids = $user->has_right_to(undef, "edit", "project");
my $projects = [];
foreach my $pid (@$user_project_ids) {
Expand Down Expand Up @@ -226,7 +228,7 @@ sub output {
<table>
<tr style='display: none;'><td width="125px"><b>ftp</b></td><td>ftp://incoming.metagenomics.anl.gov/<span id="ftp_webkey">YOUR_PRIVATE_WEBKEY</span></td></tr>
<tr><td>http://api.metagenomics.anl.gov/1/inbox</td></tr>
<tr><td colspan=2 style='padding-top: 10px; padding-bottom: 10px;'><div id='generate_key'><input type='button' class='btn' onclick='generate_webkey();' value='generate webkey'></div></td></tr>
<tr><td colspan=2 style='padding-top: 10px; padding-bottom: 10px;'><div id='generate_key'><input type='button' class='btn' onclick='generate_webkey();' value='~. ($webkey->{key} ? ($webkey->{valid} ? "view webkey" : "re-activate webkey") : "generate webkey") . qq~'></div></td></tr>
</table>
<p><b>Note:</b> The <a href='http://blog.metagenomics.anl.gov/mg-rast-v3-2-faq/#command_line_submission' target=_blank>Blog</a> lists a number of examples for data transfer.</p>

Expand Down Expand Up @@ -752,6 +754,10 @@ sub submit_to_mgrast {
$self->application->add_message('warning', "Unable to find / create vaild project, aborting submission.");
return undef;
}
# reset job options to include project and other metadata if need
foreach my $job (@$jobs) {
$job->set_job_options();
}

my $pid = fork();

Expand Down Expand Up @@ -1047,6 +1053,33 @@ sub validate_metadata {
exit 0;
}

sub current_webkey {
my ($self) = @_;

my $application = $self->application();
my $master = $application->dbmaster();
my $user = $application->session->user();

my $existing_key = $master->Preferences->get_objects( { 'user' => $user, 'name' => 'WebServicesKey' } );
my $existing_date = $master->Preferences->get_objects( { 'user' => $user, 'name' => 'WebServiceKeyTdate' } );

my $valid = 0;
my $key = 0;
my $date = 0;

if (scalar(@$existing_key)) {
if ($existing_date->[0]->{value} > time) {
$valid = 1;
}
$key = $existing_key->[0]->{value};
$date = $existing_date->[0]->{value};
}

return { "key" => $key,
"date" => $date,
"valid" => $valid };
}

sub generate_webkey {
my ($self) = @_;

Expand All @@ -1055,13 +1088,27 @@ sub generate_webkey {
my $master = $application->dbmaster();
my $user = $application->session->user();

my $timeout = 60 * 60 * 24 * 7; # one week

my $generated = "";

my $webkey = { "key" => 0,
"date" => 0,
"valid" => 0 };

my $existing_key = $master->Preferences->get_objects( { 'user' => $user, 'name' => 'WebServicesKey' } );
my $existing_date = $master->Preferences->get_objects( { 'user' => $user, 'name' => 'WebServiceKeyTdate' } );
if (scalar(@$existing_key) && ! $cgi->param('generate_new_key')) {
$existing_key = $existing_key->[0]->{value};
$existing_date = $existing_date->[0]->{value};
$webkey->{key} = $existing_key->[0]->{value};
$webkey->{date} = $existing_date->[0]->{value};
if ($webkey->{date} > time) {
$webkey->{valid} = 1;
}

if ($cgi->param('reactivate_key')) {
my $tdate = time + $timeout;
$existing_date->[0]->value($tdate);
}
} else {
my $possible = 'abcdefghijkmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
while (length($generated) < 25) {
Expand All @@ -1076,7 +1123,6 @@ sub generate_webkey {
}
$preference = $master->Preferences->get_objects( { value => $generated } );
}
my $timeout = 60 * 60 * 24 * 7; # one week
my $tdate = time + $timeout;

my $pref = $master->Preferences->get_objects( { 'user' => $user, 'name' => 'WebServiceKeyTdate' } );
Expand All @@ -1094,20 +1140,30 @@ sub generate_webkey {
$pref = $master->Preferences->create( { 'user' => $user, 'name' => 'WebServicesKey' } );
}
$pref->value($generated);
$existing_key = $generated;
$existing_date = $tdate;

# create a symlink

$webkey->{key} = $generated;
$webkey->{date} = $tdate;
$webkey->{valid} = 1;
}

my $content = "<b>Your current WebKey:</b> <input type='text' readOnly=1 size=25 value='" . $existing_key . "'>";
my $content = "";

my ($sec,$min,$hour,$mday,$mon,$year) = localtime($existing_date);
my $tdate_readable = ($year + 1900)." ".sprintf("%02d", $mon + 1)."-".sprintf("%02d", $mday)." ".sprintf("%02d", $hour).":".sprintf("%02d", $min).".".sprintf("%02d", $sec);
$content .= " <b>valid until</b>: <input type='text' readOnly=1 size=20 value='" . $tdate_readable . "'>";
$content .= " <input type='button' class='btn' value='generate new key' onclick='generate_webkey(1);'>";
$content .= "<img src='./Html/clear.gif' onload='document.getElementById(\"ftp_webkey\").innerHTML=\"" . $existing_key . "\";document.getElementById(\"http_webkey\").innerHTML=\"" . $existing_key . "\";'>";
if ($webkey->{valid}) {

my ($sec,$min,$hour,$mday,$mon,$year) = localtime($webkey->{date});
my $tdate_readable = ($year + 1900)." ".sprintf("%02d", $mon + 1)."-".sprintf("%02d", $mday)." ".sprintf("%02d", $hour).":".sprintf("%02d", $min).".".sprintf("%02d", $sec);

$content .= "<b>Your current WebKey:</b> <input type='text' readOnly=1 size=25 value='" . $webkey->{key} . "'>";
$content .= " &nbsp;&nbsp;&nbsp;<b>valid until</b>: <input type='text' readOnly=1 size=20 value='" . $tdate_readable . "'>";
$content .= "<br><input type='button' class='btn' value='extend key validity date' onclick='generate_webkey(null, 1);' style='margin-top: 5px; margin-left: 130px;'>";

} else {
$content .= "<b>Your current WebKey:</b> " . $webkey->{key};
$content .= "<br><span style='font-weight: bold; color: red; margin-top: 3px;'>your current key has timed out and is no longer valid!</span>";
$content .= "<br><input type='button' class='btn' value='re-activate key' onclick='generate_webkey(null, 1);'>";
}

$content .= " <input type='button' class='btn' value='generate new key' onclick='generate_webkey(1);' style='margin-top: 5px; margin-left: 50px;'>";
# $content .= "<img src='./Html/clear.gif' onload='document.getElementById(\"ftp_webkey\").innerHTML=\"" . $webkey->{key} . "\";document.getElementById(\"http_webkey\").innerHTML=\"" . $webkey->{key} . "\";'>";

print $cgi->header;
print $content;
Expand Down
Loading