[Bioperl-guts-l] bioperl-live/Bio/DB/GFF/Adaptor dbi.pm,1.53,1.54

Lincoln Stein lstein at pub.open-bio.org
Tue Mar 22 11:54:37 EST 2005


Update of /home/repository/bioperl/bioperl-live/Bio/DB/GFF/Adaptor
In directory pub.open-bio.org:/tmp/cvs-serv13153/Bio/DB/GFF/Adaptor

Modified Files:
	dbi.pm 
Log Message:
get_features_by_name() now searches the aliases as well


Index: dbi.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/DB/GFF/Adaptor/dbi.pm,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** dbi.pm	21 Jul 2004 12:57:40 -0000	1.53
--- dbi.pm	22 Mar 2005 16:54:34 -0000	1.54
***************
*** 363,366 ****
--- 363,367 ----
   make_features_from_part
   make_features_by_name_where_part
+  make_features_by_alias_where_part  (for aliases)
   make_features_join_part
  
***************
*** 381,394 ****
  								 start=>$location->[1],
  								 stop =>$location->[2]}) if $location;
!   my $query  = "SELECT $select FROM $from WHERE $where AND $join";
!   $query    .= " AND $range" if $range;
!   my $sth    = $self->dbh->do_query($query, at args);
  
    my $count = 0;
!   while (my @row = $sth->fetchrow_array) {
!     $callback->(@row);
!     $count++;
    }
!   $sth->finish;
    return $count;
  }
--- 382,407 ----
  								 start=>$location->[1],
  								 stop =>$location->[2]}) if $location;
!   # group query
!   my $query1  = "SELECT $select FROM $from WHERE $where AND $join";
!   $query1    .= " AND $range" if $range;
! 
!   # alias query
!   $from  = $self->make_features_from_part(undef,{attributes=>1});
!   ($where, at args) = $self->make_features_by_alias_where_part($class,$name);  # potential bug - @args1==@args2?
! 
!   my $query2  = "SELECT $select FROM $from WHERE $where AND $join";
!   $query2    .= " AND $range" if $range;
  
    my $count = 0;
! 
!   for my $query ($query1,$query2) {
!     my $sth    = $self->dbh->do_query($query, at args);
!     while (my @row = $sth->fetchrow_array) {
!       $callback->(@row);
!       $count++;
!     }
!     $sth->finish;
    }
!   
    return $count;
  }
***************
*** 1257,1260 ****
--- 1270,1285 ----
      return ("fgroup.gclass=? AND fgroup.gname=?",$class,$name);
    }
+ }
+ 
+ sub make_features_by_alias_where_part {
+   my $self = shift;
+   my ($class,$name) = @_;
+   if ($name =~ /\*/) {
+     $name =~ tr/*/%/;
+     return ("fgroup.gclass=? AND fattribute_to_feature.fattribute_value LIKE ? AND fgroup.gid=fdata.gid AND fattribute.fattribute_name='Alias' AND fattribute_to_feature.fattribute_id=fattribute.fattribute_id AND fattribute_to_feature.fid=fdata.fid AND ftype.ftypeid=fdata.ftypeid",$class,$name)
+   } else {
+     return ("fgroup.gclass=? AND fattribute_to_feature.fattribute_value=? AND fgroup.gid=fdata.gid AND fattribute.fattribute_name='Alias' AND fattribute_to_feature.fattribute_id=fattribute.fattribute_id AND fattribute_to_feature.fid=fdata.fid AND ftype.ftypeid=fdata.ftypeid",$class,$name);
+   }
+ 
  }
  



More information about the Bioperl-guts-l mailing list