[Bio] / SeedViewer / MetagenomeAnalysis.pm Repository:
ViewVC logotype

Diff of /SeedViewer/MetagenomeAnalysis.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8, Wed May 7 20:31:19 2008 UTC revision 1.10, Wed Jun 11 15:17:20 2008 UTC
# Line 10  Line 10 
10    
11  1;  1;
12    
   
   
13  use constant QUERY_DEFAULTS =>  use constant QUERY_DEFAULTS =>
14    { 1 => { evalue => '1e-05', align_len => 50 }, # RDP    { 1 => { evalue => '1e-05', align_len => 50 }, # RDP
15      2 => { evalue => '0.01' }, # SEED      2 => { evalue => '0.01' }, # SEED
# Line 21  Line 19 
19      6 => { evalue => '0.01' }, # Subsystem      6 => { evalue => '0.01' }, # Subsystem
20    };    };
21    
   
   
   
22  sub new {  sub new {
23    my ($class, $job) = @_;    my ($class, $job) = @_;
24    
# Line 80  Line 75 
75    
76  }  }
77    
   
   
   
78  sub job {  sub job {
79    return $_[0]->{job};    return $_[0]->{job};
80  }  }
# Line 100  Line 92 
92    return $_[0]->{dbtable};    return $_[0]->{dbtable};
93  }  }
94    
95    sub dbtable_best_psc {
96      unless (defined $_[0]->{dbtable}) {
97        $_[0]->{dbtable} = 'tax_sim_best_by_psc_'.$_[0]->job->id;
98      }
99      return $_[0]->{dbtable};
100    }
101    
102    sub dbtable_best_iden {
103      unless (defined $_[0]->{dbtable}) {
104        $_[0]->{dbtable} = 'tax_sim_best_by_iden_'.$_[0]->job->id;
105      }
106      return $_[0]->{dbtable};
107    }
108    
109  sub get_key2taxa_mapping {  sub get_key2taxa_mapping {
110    
# Line 332  Line 337 
337  #******************************************************************************  #******************************************************************************
338    
339    
   
   
   
340  =pod  =pod
341    
342  =item * B<get_sequence> (I<sequence_id>)  =item * B<get_sequence> (I<sequence_id>)
# Line 377  Line 379 
379  sub get_hits_count {  sub get_hits_count {
380    my ($self, $dataset) = @_;    my ($self, $dataset) = @_;
381    
382    my $table = $self->dbtable;    my $table = $self->dbtable_best_psc;
383    my $dbid  = $self->get_dataset_id($dataset);    my $dbid  = $self->get_dataset_id($dataset);
384    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
385    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
386    
387    my $sth = $self->dbh->prepare("select count(*) from ( select id1, min(rank_psc) from $table where dbid=$dbid $where group by id1) as b");    my $sth = $self->dbh->prepare("select count(distinct id1) from  $table where dbid=$dbid $where");
388    $sth->execute;    $sth->execute;
389    my ($result) = $sth->fetchrow_array;    my ($result) = $sth->fetchrow_array;
390    
# Line 407  Line 409 
409  sub get_group_counts {  sub get_group_counts {
410    my ($self, $dataset, $group, $filter1, $filter2) = @_;    my ($self, $dataset, $group, $filter1, $filter2) = @_;
411    
412    my $table = $self->dbtable;    my $table = $self->dbtable_best_psc;
413    my $dbid  = $self->get_dataset_id($dataset);    my $dbid  = $self->get_dataset_id($dataset);
414    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
415    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
# Line 418  Line 420 
420    push @filters, "tax_group_2='$filter2'" if($filter2);    push @filters, "tax_group_2='$filter2'" if($filter2);
421    my $filter = (scalar(@filters)) ? 'and '.join(' and ', @filters) : '';    my $filter = (scalar(@filters)) ? 'and '.join(' and ', @filters) : '';
422    
423    my $sth = $self->dbh->prepare("select s.$group as tax, count(*) as num from ( select id1, min(rank_psc) as rank from $table where dbid=$dbid $where group by id1) as b inner join $table as s on b.id1=s.id1 and b.rank=s.rank_psc where dbid=$dbid $filter group by s.$group");    my $sth = $self->dbh->prepare("select $group as tax, count(*) as num from $table where dbid=$dbid $where $filter group by tax");
424    $sth->execute;    $sth->execute;
425    my $result = $sth->fetchall_arrayref();    my $result = $sth->fetchall_arrayref();
426    
# Line 439  Line 441 
441  sub get_taxa_counts {  sub get_taxa_counts {
442    my ($self, $dataset) = @_;    my ($self, $dataset) = @_;
443    
444    my $table = $self->dbtable;    my $table = $self->dbtable_best_psc;
445    my $dbid  = $self->get_dataset_id($dataset);    my $dbid  = $self->get_dataset_id($dataset);
446    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
447    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
448    
449    my $sth = $self->dbh->prepare("select s.tax_str as tax, count(*) as num from ( select id1, min(rank_psc) as rank from $table where dbid=$dbid $where group by id1) as b inner join $table as s on b.id1=s.id1 and b.rank=s.rank_psc where dbid=$dbid group by s.tax_str");    my $sth = $self->dbh->prepare("select tax_str as tax, count(*) from $table where dbid=$dbid group by tax");
450    
451    $sth->execute;    $sth->execute;
452    my $result = $sth->fetchall_arrayref();    my $result = $sth->fetchall_arrayref();
# Line 466  Line 468 
468  sub get_subsystem_counts {  sub get_subsystem_counts {
469    my ($self, $dataset) = @_;    my ($self, $dataset) = @_;
470    
471    my $table = $self->dbtable;    my $table = $self->dbtable_best_psc;
472    my $dbid  = $self->get_dataset_id($dataset);    my $dbid  = $self->get_dataset_id($dataset);
473    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
474    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
475    
476    #print STDERR "select s.tax_group_1, s.tax_group_2, s.tax_group_3, s.tax_str, count(*) as num from ( select id1, min(rank_psc) as rank from $table where dbid=$dbid $where group by id1) as b inner join $table as s on b.id1=s.id1 and b.rank=s.rank_psc where dbid=$dbid group by s.tax_group_1, s.tax_group_2, s.tax_group_3";    my $sth = $self->dbh->prepare("select tax_group_1, tax_group_2, tax_group_3, tax_str, count(*) as num from $table where dbid=$dbid group by tax_group_1, tax_group_2, tax_group_3, tax_str");
  #die;  
   my $sth = $self->dbh->prepare("select s.tax_group_1, s.tax_group_2, s.tax_group_3, s.tax_str, count(*) as num from ( select id1, min(rank_psc) as rank from $table where dbid=$dbid $where group by id1) as b inner join $table as s on b.id1=s.id1 and b.rank=s.rank_psc where dbid=$dbid group by s.tax_group_1, s.tax_group_2, s.tax_group_3");  
477    
478    $sth->execute;    $sth->execute;
479    my $result = $sth->fetchall_arrayref();    my $result = $sth->fetchall_arrayref();
# Line 497  Line 497 
497  sub get_sequence_subset {  sub get_sequence_subset {
498    my ($self, $dataset, $filter) = @_;    my ($self, $dataset, $filter) = @_;
499    
500    my $table = $self->dbtable;    my $table = $self->dbtable_best_psc;
501    my $dbid  = $self->get_dataset_id($dataset);    my $dbid  = $self->get_dataset_id($dataset);
502    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
503    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
504    
505    my $sth = $self->dbh->prepare("select s.id1, s.ali_ln, s.id2, s.tax_str from ( select id1, min(rank_psc) as rank from $table where dbid=$dbid $where group by id1) as b inner join $table as s on b.id1=s.id1 and b.rank=s.rank_psc where dbid=$dbid and s.tax_str like '$filter%'");    my $sth = $self->dbh->prepare("select id1, ali_ln, id2, tax_str from $table where dbid=$dbid $where and tax_str like '$filter%'");
   
506    $sth->execute;    $sth->execute;
507    my $result = $sth->fetchall_arrayref();    my $result = $sth->fetchall_arrayref();
508    
# Line 526  Line 525 
525  sub get_recruitment_plot_data {  sub get_recruitment_plot_data {
526    my ($self, $genome) = @_;    my ($self, $genome) = @_;
527    
528    my $table = $self->dbtable;    my $table = $self->dbtable_best_psc;
529    my $dbid  = $self->get_dataset_id("SEED");    my $dbid  = $self->get_dataset_id("SEED");
530    my $where = $self->get_where_clause();    my $where = $self->get_where_clause();
531    $where = ($where) ? "and $where" : '';    $where = ($where) ? "and $where" : '';
532    
533    my ($tax_id) = $self->dbh->selectrow_array("select tax_str from rdp_to_tax where seq_num='". $genome . "'");    my ($tax_id) = $self->dbh->selectrow_array("select tax_str from rdp_to_tax where seq_num='". $genome . "'");
534    
535    my $sth = $self->dbh->prepare("select s.id1, s.id2, s.b2, s.e2, s.logpsc from ( select id1, min(rank_psc) as rank from $table where dbid=$dbid $where group by id1) as b inner join $table as s on b.id1=s.id1 and b.rank=s.rank_psc where dbid=$dbid and s.tax_str='$tax_id'");    if($tax_id =~ /(\S+)\s/){
536        $tax_id = $1;
537      }
538      my $sth = $self->dbh->prepare("select id1, id2, b2, e2, logpsc from $table where dbid=$dbid $where and tax_str='$tax_id'");
539    
540    $sth->execute;    $sth->execute;
541    my $result = $sth->fetchall_arrayref();    my $result = $sth->fetchall_arrayref();

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3