Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

added metagenome name to 'columns' attribute of matrix resource #218

Merged
merged 2 commits into from

2 participants

Travis Harrison Jared Bischof
Travis Harrison
Owner

No description provided.

Jared Bischof jaredbischof merged commit ff9cb0e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 3, 2013
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 5 deletions.
  1. +13 −4 src/MGRAST/lib/Analysis.pm
  2. +3 −1 src/MGRAST/lib/resources2/matrix.pm
17 src/MGRAST/lib/Analysis.pm
View
@@ -65,6 +65,7 @@ sub new {
jobs => [], # array: job_id
job_map => {}, # hash: mg_id => job_id
mg_map => {}, # hash: job_id => mg_id
+ name_map => {}, # hash: mg_id => job_name
sources => $srcs, # hash: source_name => { col => value }
id_src => \%idsrc, # hash: source_id => source_name
src_id => \%srcid, # hash: source_name => source_id
@@ -127,6 +128,10 @@ sub _mg_map {
my ($self) = @_;
return $self->{mg_map};
}
+sub _name_map {
+ my ($self) = @_;
+ return $self->{name_map};
+}
sub _id_src {
my ($self) = @_;
return $self->{id_src};
@@ -178,6 +183,7 @@ sub add_jobs {
# set values for $self->{jobs} and $self->{jtbl} based on metagenome_id list
sub set_jobs {
my ($self, $mgids, $jids) = @_;
+ $self->{name_map} = {};
if (defined($jids)) {
$self->{job_map} = $self->_get_jobid_map($mgids, 1);
} else {
@@ -203,7 +209,7 @@ sub _set_data {
}
sub _get_jobid_map {
- my ($self, $mgids, $jids) = @_;
+ my ($self, $mgids, $jids, $no_names) = @_;
unless ($mgids && scalar(@$mgids)) {
return {};
}
@@ -211,9 +217,12 @@ sub _get_jobid_map {
my $list = join(",", map {"'$_'"} @$mgids);
my $rows;
if ($jids) {
- $rows = $self->_jcache->selectall_arrayref("SELECT metagenome_id, job_id FROM Job WHERE job_id IN ($list) AND viewable = 1");
+ $rows = $self->_jcache->selectall_arrayref("SELECT metagenome_id, job_id, name FROM Job WHERE job_id IN ($list) AND viewable = 1");
} else {
- $rows = $self->_jcache->selectall_arrayref("SELECT metagenome_id, job_id FROM Job WHERE metagenome_id IN ($list) AND viewable = 1");
+ $rows = $self->_jcache->selectall_arrayref("SELECT metagenome_id, job_id, name FROM Job WHERE metagenome_id IN ($list) AND viewable = 1");
+ }
+ unless ($no_names) {
+ map { $self->{name_map}->{$_->[0]} = $_->[2] } @$rows;
}
if ($rows && (@$rows > 0)) {
%$hash = map { $_->[0], $_->[1] } @$rows;
@@ -909,7 +918,7 @@ sub metagenome_search {
return [];
}
# [ mgid ]
- return [ keys %{$self->_get_jobid_map($rows, 1)} ];
+ return [ keys %{$self->_get_jobid_map($rows, 1, 1)} ];
}
####################
4 src/MGRAST/lib/resources2/matrix.pm
View
@@ -341,9 +341,11 @@ sub prepare_data {
}
my $mddb = MGRAST::Metadata->new();
my $meta = $mddb->get_jobs_metadata_fast([keys %$col_ids], 1);
+ my $name = $mgdb->_name_map();
foreach my $cid (sort {$col_ids->{$a} <=> $col_ids->{$b}} keys %$col_ids) {
my $cmd = exists($meta->{$cid}) ? $meta->{$cid} : undef;
- push @$bcols, { id => 'mgm'.$cid, metadata => $cmd };
+ my $cnm = exists($name->{$cid}) ? $name->{$cid} : undef;
+ push @$bcols, { id => 'mgm'.$cid, name => $cnm, metadata => $cmd };
}
my $obj = { "id" => join(";", sort map { $_->{id} } @$bcols).'_'.$glvl.'_'.$source.'_'.$rtype,
Something went wrong with that request. Please try again.