blib/lib/Bio/DB/Das/Chado/Segment.pm

filter: Statementstmt 90.4% 19 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 92.8% 26 / 28 SCAR 0.0
CC
1
Cov
90%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Bio/DB/Das/Chado.pm ↑ Summary
1 # $Id: Segment.pm,v 1.5 2009-06-04 15:33:30 scottcain Exp $
2  
3 =head1 NAME
4  
5 Bio::DB::Das::Chado::Segment - DAS-style access to a chado database
6  
7 =head1 SYNOPSIS
8  
9 # Get a Bio::Das::SegmentI object from a Bio::DB::Das::Chado database...
10  
11 $segment = $das->segment(-name => 'Landmark',
12 -start=> $start,
13 -stop => $stop);
14  
15 @features = $segment->overlapping_features(-type=>['type1','type2']);
16 # each feature is a Bio::SeqFeatureI-compliant object
17  
18 @features = $segment->contained_features(-type=>['type1','type2']);
19  
20 @features = $segment->contained_in(-type=>['type1','type2']);
21  
22 $stream = $segment->get_feature_stream(-type=>['type1','type2','type3'];
23 while (my $feature = $stream->next_seq) {
24 # do something with feature
25 }
26  
27 $count = $segment->features_callback(-type=>['type1','type2','type3'],
28 -callback => sub { ... { }
29 );
30  
31 =head1 DESCRIPTION
32  
33 Bio::DB::Das::Chado::Segment is a simplified alternative interface to
34 sequence annotation databases used by the distributed annotation
35 system. In this scheme, the genome is represented as a series of
36 landmarks. Each Bio::DB::Das::Chado::Segment object ("segment") corresponds
37 to a genomic region defined by a landmark and a start and end position
38 relative to that landmark. A segment is created using the Bio::DasI
39 segment() method.
40  
41 Features can be filtered by the following attributes:
42  
43 1) their location relative to the segment (whether overlapping,
44 contained within, or completely containing)
45  
46 2) their type
47  
48 3) other attributes using tag/value semantics
49  
50 Access to the feature list uses three distinct APIs:
51  
52 1) fetching entire list of features at a time
53  
54 2) fetching an iterator across features
55  
56 3) a callback
57  
58 =head1 FEEDBACK
59  
60 =head2 Mailing Lists
61  
62 User feedback is an integral part of the evolution of this and other
63 Bioperl modules. Send your comments and suggestions preferably to one
64 of the Bioperl mailing lists. Your participation is much appreciated.
65  
66 bioperl-l@bio.perl.org
67  
68 =head2 Reporting Bugs
69  
70 Report bugs to the Bioperl bug tracking system to help us keep track
71 the bugs and their resolution. Bug reports can be submitted via email
72 or the web:
73  
74 bioperl-bugs@bio.perl.org
75 http://bio.perl.org/bioperl-bugs/
76  
77 =head1 AUTHOR - Scott Cain
78  
79 Email cain@cshl.org
80  
81 =head1 APPENDIX
82  
83 The rest of the documentation details each of the object
84 methods. Internal methods are usually preceded with a _
85  
86 =cut
87  
88 package Bio::DB::Das::Chado::Segment;
89  
90 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 1 ▶use Carp qw(carp croak cluck confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
92 1 ▶use Bio::Root::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 1 ▶use Bio::SeqI;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 1 ▶use Bio::Das::SegmentI;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 1 ▶use Bio::DB::Das::Chado;
Subroutine BEGIN: called CC=1 SCAR=0.0
96 1 ▶use Bio::DB::Das::Chado::Segment::Feature;
Subroutine BEGIN: called CC=1 SCAR=2.6
97 use Bio::DB::GFF::Typename;
98 use Data::Dumper;
99 #dgg;not working# use Bio::Species;
100  
101 use constant DEBUG => 0;
102  
103 use vars qw(@ISA $VERSION);
104 @ISA = qw(Bio::Root::Root Bio::SeqI Bio::Das::SegmentI Bio::DB::Das::Chado);
105 $VERSION = 0.34;
106  
107 #use overload '""' => 'asString';
108  
109 # construct a virtual segment that works in a lazy way
110 sub new {
111 #validate that the name/accession is valid, and start and end are valid,
112 #then return a new segment
113  
114 my $self = {};
115 my $class_type = shift;
116  
117 my ( $name,$factory,$base_start,$stop,$db_id,$target,$feature_id,$srcf_id ) = @_;
118  
119 bless $self, ref $class_type || $class_type;
120 $self->{'factory'} = $factory;
121 $self->{'name'} = $name;
122  
123 $self->feature_id($feature_id) if $feature_id;
124  
125 $target ||=0;
126 my $strand;
127  
128  
129 warn "na:$name, id:$db_id, $factory\n" if DEBUG;
130 warn "base_start = $base_start, stop = $stop\n" if DEBUG;
131 # clicking on the help in gbrowse calls this constructor without a
132 # name. return to avoid performances issues
133 if (! defined ($name)) {
134 return;
135 }
136 # $self->Bio::Root::Root->throw("start value less than 1\n")
137 # if ( defined $base_start && $base_start < 1 );
138 $base_start = $base_start ? int($base_start) : 1;
139 my $interbase_start = $base_start - 1;
140  
141 my $quoted_name = $factory->dbh->quote( lc $name );
142  
143 warn "quoted name:$quoted_name\n" if DEBUG;
144  
145 # need to change this query to allow for Target queries
146  
147 ##URGI - Changed the request to be sure we are getting the srcfeature_id of type 'reference class'
148 ##from gbrowse configuration file
149 ##We also check if we are not in the recursive call from feactory->segment, in this case we already set the ref feature_id
150 ##for reference class feature.
151  
152 ##minor change: calling name2term with no arg returna a hashref (as documented)
153 ##so if $factory->default_class() is empty, you would get a hashref in $refclass
154  
155 my $refclass = $factory->default_class()
156 ? $factory->name2term($factory->default_class())
157 : undef;
158  
159 my $ref_feature_id = $factory->refclass_feature_id() || undef;
160  
161 my $where_part = " and rank = $target " if(defined($target));
162  
163 if(defined($ref_feature_id)){
164 $where_part .= " and fl.srcfeature_id = $ref_feature_id ";
165 }
166 else{
167 $where_part .= " and srcf.type_id = $refclass " if(defined($refclass));
168 }
169  
170 $where_part .= " and srcf.is_obsolete = false " unless $self->factory->allow_obsolete;
171  
172 $where_part .= " and srcf.organism_id = ".$self->factory->organism_id
173 if $self->factory->organism_id;
174  
175 warn $where_part if DEBUG;
176  
177 my $srcfeature_query = $factory->dbh->prepare( "
178 select srcfeature_id from featureloc fl
179 join feature srcf on (fl.srcfeature_id = srcf.feature_id)
180 where fl.feature_id = ? " . $where_part
181 );
182  
183 #my $srcfeature_query = $factory->dbh->prepare( "
184 # select srcfeature_id from featureloc
185 # where feature_id = ? and rank = $target
186 # " );
187  
188 my $landmark_is_src_query = $factory->dbh->prepare( "
189 select f.name,f.feature_id,f.seqlen,f.type_id,f.is_obsolete
190 from feature f
191 where f.feature_id = ?
192 " );
193  
194 #not used any more
195 #my $feature_query = $factory->dbh->prepare( "
196 # select f.name,f.feature_id,f.seqlen,f.type_id,fl.fmin,fl.fmax,fl.strand
197 # from feature f, featureloc fl,f.is_obsolete
198 # where fl.feature_id = ? and
199 # ? = f.feature_id
200 # " );
201  
202 my $fetch_uniquename_query = $factory->dbh->prepare( "
203 select f.name,fl.fmin,fl.fmax,f.uniquename,f.is_obsolete,fl.srcfeature_id,fl.strand
204 from feature f, featureloc fl
205 where f.feature_id = ? and
206 f.feature_id = fl.feature_id
207 ");
208  
209 my $ref = $self->_search_by_name( $factory, $quoted_name, $db_id, $feature_id );
210  
211 #returns either a feature_id scalar (if there is only one result)
212 #or an arrayref (of feature_ids) if there is more than one result
213 #or nothing if there is no result
214  
215 if ( ref $ref eq 'ARRAY' ) { #more than one result returned
216  
217 warn "\n\n@$ref\n\n";
218  
219 my @segments;
220  
221 foreach my $feature_id (@$ref) {
222  
223 $fetch_uniquename_query->execute($feature_id )
224 or Bio::Root::Root->throw("fetching uniquename from feature_id failed") ;
225  
226 my $hashref = $fetch_uniquename_query->fetchrow_hashref;
227  
228 next if ($$hashref{'is_obsolete'} and !$self->factory->allow_obsolete);
229  
230 warn "$base_start, $stop\n" if DEBUG;
231  
232 warn "Looping through feature_ids in constructor:\n"
233 .Dumper($hashref) if DEBUG;
234  
235 $base_start = $base_start ? $base_start : $$hashref{fmin} + 1;
236 $stop = $stop ? $stop : $$hashref{fmax};
237 $db_id = $$hashref{uniquename};
238 $srcf_id = $$hashref{srcfeature_id};
239 $name = $$hashref{name};
240  
241 next if (!defined ($base_start) or !defined($stop) or !defined($db_id));
242  
243 warn "calling factory->segment with name:$name, start:$base_start, stop:$stop, db_id:$db_id, srcfeature_id:$srcf_id\n" if DEBUG;
244 push @segments, $factory->segment(-name=>$name,-start=>$base_start,-stop=>$stop,-db_id=>$db_id,-feature_id=>$feature_id,-srcfeature_id=>$srcf_id);
245  
246 warn "segments array in constructor:@segments" if DEBUG;
247  
248 #reset these variables so subsequent passes through the loop wont be confused
249 $base_start ='';
250 $stop ='';
251 $db_id ='';
252 $strand ='';
253 $srcf_id ='';
254 }
255  
256 $landmark_is_src_query->finish;
257 $fetch_uniquename_query->finish;
258 $srcfeature_query->finish;
259 if (@segments < 2) {
260 return $segments[0]; #I don't think this should ever happen
261 }
262 elsif (wantarray) {
263 return @segments;
264 }
265 else {
266 warn "The query for $name returned multiple segments\nPlease call in a list context to get them all";
267 Bio::Root::Root->throw("multiple segment exception") ;
268 }
269 }
270 elsif ( ref $ref eq 'SCALAR' ) { #one result returned
271  
272 my $landmark_feature_id = $$ref;
273  
274 warn "landmark feature_id:$landmark_feature_id" if DEBUG;
275  
276 $srcfeature_query->execute($landmark_feature_id)
277 or Bio::Root::Root->throw("finding srcfeature_id failed");
278  
279 my $hash_ref = $srcfeature_query->fetchrow_hashref;
280 my $srcfeature_id =
281 $$hash_ref{'srcfeature_id'}
282 ? $$hash_ref{'srcfeature_id'}
283 : $landmark_feature_id;
284  
285 warn "srcfeature_id:$srcfeature_id" if DEBUG;
286  
287 ###URGI Is it the right place to set it?
288 #but don't set it if creating a feature for a hit object
289 $factory->refclass_feature_id($srcfeature_id)
290 unless defined($target);
291  
292 if ( $landmark_feature_id == $srcfeature_id ) {
293  
294 $landmark_is_src_query->execute($landmark_feature_id)
295 or Bio::Root::Root->throw("something else failed");
296 $hash_ref = $landmark_is_src_query->fetchrow_hashref;
297  
298 warn "skipping feature_id $$hash_ref{feature_id}"
299 if (DEBUG and
300 $$hash_ref{'is_obsolete'} and
301 !$self->factory->allow_obsolete);
302 next if ($$hash_ref{'is_obsolete'} and !$self->factory->allow_obsolete);
303  
304 $name = $$hash_ref{'name'};
305  
306 my $length = $$hash_ref{'seqlen'};
307 my $type = $factory->term2name( $$hash_ref{'type_id'} );
308  
309 if ( $$hash_ref{'fmin'} ) {
310 $interbase_start = $$hash_ref{'fmin'};
311 $base_start = $interbase_start + 1;
312 $stop = $$hash_ref{'fmax'};
313 $strand = $$hash_ref{'strand'};
314 }
315  
316 warn "base_start:$base_start, stop:$stop, length:$length" if DEBUG;
317  
318 if( defined($interbase_start) and $interbase_start < 0) {
319 $self->warn("start value ($interbase_start) less than zero,"
320 ." resetting to zero") if DEBUG;
321 $base_start = 1;
322 $interbase_start = 0;
323 }
324  
325 if( defined($stop) and defined($length) and $stop > $length ){
326 $self->warn("end value ($stop) greater than length ($length),"
327 ." truncating to $length") if DEBUG;
328 $stop = $length;
329 }
330 $stop = $stop ? int($stop) : $length;
331 $length = $stop - $interbase_start;
332  
333 warn "base_start:$base_start, stop:$stop, length:$length" if DEBUG;
334  
335 $self->feature_id($landmark_feature_id);
336 $self->start($base_start);
337 $self->end($stop);
338 $self->{'length'} = $length;
339 # cluck "i'm in new";
340 # $self->srcfeature_id($srcfeature_id);
341 $self->{'srcfeature_id'} = $srcfeature_id;
342 $self->class($type);
343 $self->name($name);
344 $self->strand($strand);
345  
346 my $source = $self->source();
347 my $type_obj = Bio::DB::GFF::Typename->new(
348 $type,
349 $source);
350  
351 $self->type($type_obj);
352  
353 # warn $self, ref $self, Dumper($self) if DEBUG;
354
355 $fetch_uniquename_query->finish;
356 $srcfeature_query->finish;
357 $landmark_is_src_query->finish;
358 return $self;
359 }
360  
361 else { #return a Feature object for the feature_id
362 warn $landmark_feature_id if DEBUG;
363 warn $factory,$base_start,$stop,$strand if DEBUG;
364  
365 #unless ($landmark_feature_id && $base_start && $stop) {
366 $fetch_uniquename_query->execute($landmark_feature_id);
367 my $resultref = $fetch_uniquename_query->fetchrow_hashref;
368 warn Dumper($resultref) if DEBUG;
369 $base_start = $$resultref{'fmin'} +1;
370 $stop = $$resultref{'fmax'};
371 $strand = $$resultref{'strand'};
372 warn "after fetching coord info: $base_start, $stop, $strand"
373 if DEBUG;
374 #}
375  
376 my ($feat) = $self->features(
377 -feature_id => $landmark_feature_id,
378 -factory => $factory,
379 -start => $base_start,
380 -stop => $stop,
381 -strand => $strand, );
382 $fetch_uniquename_query->finish;
383 $srcfeature_query->finish;
384 $landmark_is_src_query->finish;
385 return $feat;
386 }
387 }
388 else {
389 $fetch_uniquename_query->finish;
390 $landmark_is_src_query->finish;
391 $srcfeature_query->finish;
392 warn "no segment found" if DEBUG;
393 return; #nothing returned
394 }
395 }
396  
397 =head2 name
398  
399 Title : name
400 Usage : $segname = $seg->name();
401 Function: Returns the name of the segment
402 Returns : see above
403 Args : none
404 Status : public
405  
406 =cut
407  
408 sub name {
409 my $self = shift;
410 return undef unless ref $self;
411 return $self->{'name'}
412 }
413  
414 =head2 feature_id()
415  
416 Title : feature_id
417 Usage : $obj->feature_id($newval)
418 Function: holds feature.feature_id
419 Returns : value of feature_id (a scalar)
420 Args : on set, new value (a scalar or undef, optional)
421  
422  
423 =cut
424  
425 sub feature_id {
426 my $self = shift;
427  
428 return $self->{'feature_id'} = shift if @_;
429 return $self->{'feature_id'} if $self->{'feature_id'};
430  
431 my $dbh = $self->factory->dbh;
432  
433 warn $self->name;
434 warn $self->type;
435 $self->factory->name2term($self->type);
436  
437 my $name = $self->name;
438 my $org_id = $self->factory->organism_id;
439 my $type_id = $self->factory->name2term($self->type);
440  
441 my $query = "SELECT feature_id FROM feature WHERE (name = ? OR uniquename = ?)
442 AND type_id = ? ";
443  
444 my @args = ($name,$name,$type_id);
445 if ($org_id) {
446 $query .= " AND organism_id = ?";
447 push @args, $org_id;
448 }
449 my $sth = $dbh->prepare($query);
450 $sth->execute(@args);
451 return if $sth->rows > 1;
452
453 my ($feature_id) = $sth->fetchrow_array;
454 $self->{'feature_id'} = $feature_id;
455 return $self->{'feature_id'};
456 }
457  
458 *primary_id = \&feature_id;
459  
460 =head2 strand()
461  
462 Title : strand
463 Usage : $obj->strand()
464 Function: Returns the strand of the feature. Unlike the other
465 methods, the strand cannot be changed once the object is
466 created (due to coordinate considerations).
467 corresponds to featureloc.strand
468 Returns : -1, 0, or 1
469 Args : on set, new value (a scalar or undef, optional)
470  
471  
472 =cut
473  
474 sub strand {
475 my $self = shift;
476  
477 return $self->{'strand'} = shift if @_;
478 return $self->{'strand'} || 0;
479 }
480  
481 *abs_strand = \&strand;
482  
483 =head2 attributes
484  
485 Title : attributes
486 Usage : @attributes = $obj->attributes;
487 Function: get the "attributes" of this segment
488 Returns : An array of strings
489 Args : None
490  
491 This is a object-specific wrapper on the more generic attributes
492 method in Bio::DB::Das::Chado.
493  
494 =cut
495  
496  
497 sub attributes {
498 my $self = shift;
499 my $factory = $self->factory;
500 defined(my $id = $self->id) or return;
501 $factory->attributes($id,@_);
502 }
503  
504  
505 =head2 _search_by_name
506  
507 Title : _search_by_name
508 Usage : _search_by_name($name);
509 Function: Searches for segments based on a name
510 Returns : Either a scalar (a feature_id) or an arrary ref (containing feature_ids)
511 Args : A string (name)
512 Status : private (used by new)
513  
514 =cut
515  
516 sub _search_by_name {
517 my $self = shift;
518 my ($factory,$quoted_name,$db_id,$feature_id) = @_;
519  
520 my $fulltext = $factory->fulltext;
521  
522 warn "_search_by_name args:@_" if DEBUG;
523  
524 my $obsolete_part = "";
525 $obsolete_part = " and is_obsolete = false " unless $self->factory->allow_obsolete;
526  
527 $obsolete_part .= " and organism_id = ".$self->factory->organism_id
528 if $self->factory->organism_id;
529  
530 my $sth;
531 if ($feature_id) {
532 $sth = $factory->dbh->prepare("
533 select name,feature_id,seqlen from feature
534 where feature_id = $feature_id $obsolete_part");
535 }
536 elsif ($db_id) {
537 $sth = $factory->dbh->prepare ("
538 select name,feature_id,seqlen from feature
539 where uniquename = \'$db_id\' $obsolete_part ");
540  
541 }
542 else {
543 #can't use FTS here as exact names are required
544 $sth = $factory->dbh->prepare ("
545 select name,feature_id,seqlen from feature
546 where lower(name) = $quoted_name $obsolete_part ");
547 }
548
549 $sth->execute or Bio::Root::Root->throw("unable to validate name/length");
550
551 my $where_part = '';
552 $where_part = " and f.organism_id = ".$self->factory->organism_id
553 if $self->factory->organism_id;
554 $where_part .= " and f.is_obsolete = 'false' "
555 unless $self->factory->allow_obsolete;
556
557 my $rows_returned = $sth->rows;
558 if ($rows_returned == 0) { #look in synonym for an exact match
559 warn "looking for a synonym to $quoted_name" if DEBUG;
560 my $isth;
561 if ($self->factory->use_all_feature_names()) {
562  
563 my $optional_full_text;
564 if ($fulltext) {
565 $optional_full_text
566 = "afn.searchable_name @@ plainto_tsquery($quoted_name) $where_part";
567 }
568 else {
569 $optional_full_text
570 = "lower(afn.name) = $quoted_name $where_part";
571 }
572  
573 $isth = $factory->dbh->prepare ("
574 select afn.feature_id from all_feature_names afn, feature f
575 where afn.feature_id = f.feature_id and
576 f.is_obsolete = 'false' and
577 $optional_full_text
578 ");
579  
580 }
581 else {
582 my $full_text_options;
583 if ($fulltext) {
584 $full_text_options
585 = "s.searchable_synonym_sgml @@ plainto_tsquery($quoted_name) $where_part";
586 }
587 else {
588 $full_text_options
589 = "lower(s.synonym_sgml) = $quoted_name $where_part";
590 }
591 $isth = $factory->dbh->prepare ("
592 select fs.feature_id from feature_synonym fs, synonym s, feature f
593 where fs.synonym_id = s.synonym_id and
594 f.feature_id = fs.feature_id and
595 f.is_obsolete = 'false' and
596 $full_text_options
597 ");
598 }
599 $isth->execute or Bio::Root::Root->throw("query for name in synonym failed");
600 $rows_returned = $isth->rows;
601  
602 if ($rows_returned == 0) { #look in dbxref for accession number match
603 warn "looking in dbxref for $quoted_name" if DEBUG;
604  
605 my $full_text_option;
606 if ($fulltext) {
607 $full_text_option = "d.searchable_accession @@ plainto_tsquery($quoted_name) $where_part";
608 }
609 else {
610 $full_text_option = "lower(d.accession) = $quoted_name $where_part";
611 }
612  
613 $isth = $factory->dbh->prepare ("
614 select fd.feature_id from feature_dbxref fd, dbxref d, feature f
615 where fd.dbxref_id = d.dbxref_id and
616 f.feature_id = fd.feature_id and
617 f.is_obsolete = 'false' and
618 $full_text_option");
619 $isth->execute or Bio::Root::Root->throw("query for accession failed");
620 $rows_returned = $isth->rows;
621  
622 $sth->finish;
623 $isth->finish;
624 return if $rows_returned == 0;
625  
626 if ($rows_returned == 1) {
627 my $hashref = $isth->fetchrow_hashref;
628 my $feature_id = $$hashref{'feature_id'};
629 $sth->finish;
630 $isth->finish;
631 return \$feature_id;
632 } else {
633 my @feature_ids;
634 while (my $hashref = $isth->fetchrow_hashref) {
635 push @feature_ids, $$hashref{'feature_id'};
636 }
637 $sth->finish;
638 $isth->finish;
639 return \@feature_ids;
640 }
641  
642 } elsif ($rows_returned == 1) {
643 my $hashref = $isth->fetchrow_hashref;
644 my $feature_id = $$hashref{'feature_id'};
645 warn "found $feature_id in feature_synonym" if DEBUG;
646 $sth->finish;
647 $isth->finish;
648 return \$feature_id;
649 } else {
650 my @feature_ids;
651 while (my $hashref = $isth->fetchrow_hashref) {
652 push @feature_ids, $$hashref{'feature_id'};
653 }
654 $sth->finish;
655 $isth->finish;
656 return \@feature_ids;
657 }
658  
659 } elsif ($rows_returned == 1) {
660 my $hashref = $sth->fetchrow_hashref;
661 my $feature_id = $$hashref{'feature_id'};
662 warn "feature_id in _search_by_name:$feature_id" if DEBUG;
663 $sth->finish;
664 return \$feature_id;
665 } else {
666 my @feature_ids;
667 while (my $hashref = $sth->fetchrow_hashref) {
668 warn "feature_ids in _search_by_name$$hashref{'feature_id'}" if DEBUG;
669 push @feature_ids, $$hashref{'feature_id'};
670 }
671 $sth->finish;
672 return \@feature_ids;
673 }
674 }
675  
676 =head2 class
677  
678 Needed for backward compatability; always returns 'Sequence'.
679  
680 =cut
681  
682 sub class {
683 return 'Sequence';
684 }
685  
686 =head2 type
687  
688 Title : type
689 Usage : $obj->type($newval)
690 Function: used to be alias of class() for backward compatibility,
691 now behaves the same as Bio::DB::Das::Chado::Segment::Feature->type
692 Returns : A Bio::DB::GFF::Typename object
693 Args : on set, new value: Bio::DB::GFF::Typename object
694  
695 =cut
696  
697 sub type {
698 my $self = shift;
699  
700 return $self->{'type'} = shift if @_;
701 return $self->{'type'};
702 }
703  
704  
705 #*type = \&class;
706  
707 =head2 seq_id
708  
709 Title : seq_id
710 Usage : $ref = $s->seq_id
711 Function: return the ID of the landmark, aliased to name() for backward compatibility
712 Returns : a string
713 Args : none
714 Status : Public
715  
716 =cut
717  
718 *seq_id = \&name;
719  
720 =head2 start
721  
722 Title : start
723 Usage : $s->start
724 Function: start of segment
725 Returns : integer
726 Args : none
727 Status : Public
728  
729 =cut
730  
731 sub start {
732 my $self = shift;
733 return undef unless ref $self;
734 return $self->{'start'} = shift if @_;
735 return $self->{'start'} if $self->{'start'};
736 return undef;
737  
738 }
739  
740 =head2 low
741  
742 Title : low
743 Usage : $s->low
744 Function: start of segment
745 Returns : integer
746 Args : none
747 Status : Public
748  
749 Alias of start for backward compatibility
750  
751 =cut
752  
753 *low = \&start;
754  
755 =head2 end
756  
757 Title : end
758 Usage : $s->end
759 Function: end of segment
760 Returns : integer
761 Args : none
762 Status : Public
763  
764 =cut
765  
766 sub end {
767 my $self = shift;
768 return undef unless ref $self;
769 return $self->{'end'} = shift if @_;
770 return $self->{'end'} if $self->{'end'};
771 return undef;
772 }
773  
774 =head2 high
775  
776 Title : high
777 Usage : $s->high
778 Function: end of segment
779 Returns : integer
780 Args : none
781 Status : Public
782  
783 Alias of end for backward compatiblity
784  
785 =cut
786  
787 *high = \&end;
788  
789 =head2 stop
790  
791 Title : stop
792 Usage : $s->stop
793 Function: end of segment
794 Returns : integer
795 Args : none
796 Status : Public
797  
798 Alias of end for backward compatiblity
799  
800 =cut
801  
802 *stop = \&end;
803  
804 =head2 length
805  
806 Title : length
807 Usage : $s->length
808 Function: length of segment
809 Returns : integer
810 Args : none
811 Status : Public
812  
813 Returns the length of the segment. Always a positive number.
814  
815 =cut
816  
817 sub length { shift->{length} }
818  
819 =head2 features
820  
821 Title : features
822 Usage : @features = $s->features(@args)
823 Function: get features that overlap this segment
824 Returns : a list of Bio::SeqFeatureI objects
825 Args : see below
826 Status : Public
827  
828 This method will find all features that intersect the segment in a
829 variety of ways and return a list of Bio::SeqFeatureI objects. The
830 feature locations will use coordinates relative to the reference
831 sequence in effect at the time that features() was called.
832  
833 The returned list can be limited to certain types, attributes or
834 range intersection modes. Types of range intersection are one of:
835  
836 "overlaps" the default
837 "contains" return features completely contained within the segment
838 "contained_in" return features that completely contain the segment
839  
840 Two types of argument lists are accepted. In the positional argument
841 form, the arguments are treated as a list of feature types. In the
842 named parameter form, the arguments are a series of -name=E<gt>value
843 pairs.
844  
845 Argument Description
846 -------- ------------
847  
848 -types An array reference to type names in the format
849 "method:source"
850  
851 -attributes A hashref containing a set of attributes to match
852  
853 -rangetype One of "overlaps", "contains", or "contained_in".
854  
855 -iterator Return an iterator across the features.
856  
857 -callback A callback to invoke on each feature
858  
859 The -attributes argument is a hashref containing one or more
860 attributes to match against:
861  
862 -attributes => { Gene => 'abc-1',
863 Note => 'confirmed' }
864  
865 Attribute matching is simple string matching, and multiple attributes
866 are ANDed together. More complex filtering can be performed using the
867 -callback option (see below).
868  
869 If -iterator is true, then the method returns an object reference that
870 implements the next_seq() method. Each call to next_seq() returns a
871 new Bio::SeqFeatureI object.
872  
873 If -callback is passed a code reference, the code reference will be
874 invoked on each feature returned. The code will be passed two
875 arguments consisting of the current feature and the segment object
876 itself, and must return a true value. If the code returns a false
877 value, feature retrieval will be aborted.
878  
879 -callback and -iterator are mutually exclusive options. If -iterator
880 is defined, then -callback is ignored.
881  
882 =cut
883  
884 sub features {
885 my $self = shift;
886  
887 warn "Segment->features() args:@_" if DEBUG;
888  
889 my @sub_args = @_;
890  
891 # In some cases (url search : ?name=foo) $self isn't a hash ref ie
892 # object but a simple scalar ie string. So we need to get the
893 # factory the right way before accessing it
894 my ($factory,$feature_id);
895 if (ref ($self) && $self->factory->do2Level) {
896 return $self->_features2level(@sub_args);
897 }# should put an else here to try to get the factory from @_
898 else {
899 if ($sub_args[0] and $sub_args[0] =~ /^-/) {
900 my %args = @_;
901 $factory = $args{-factory} if ($args{-factory});
902 $feature_id = $args{-feature_id} if ($args{-feature_id});
903 }
904 }
905  
906 my ($types,$type_placeholder,$attributes,$rangetype,$iterator,$callback,$base_start,$stop,$seq_id,$end);
907 if (ref($self) and $sub_args[0] and $sub_args[0] =~ /^-/) {
908 ($types,$type_placeholder,$attributes,$rangetype,$iterator,$callback,$base_start,$stop,$seq_id,$end) =
909 $self->_rearrange([qw(TYPES
910 TYPE
911 ATTRIBUTES
912 RANGETYPE
913 ITERATOR
914 CALLBACK
915 START
916 STOP
917 SEQ_ID
918 END )],@sub_args);
919 warn "type and types after calling _rearrange:$type_placeholder,$types" if DEBUG;
920 }
921 elsif (defined $factory and $sub_args[0] and $sub_args[0] =~ /^-/) {
922 ($types,$type_placeholder,$attributes,$rangetype,$iterator,$callback,$base_start,$stop,$seq_id,$end) =
923 $factory->_rearrange([qw(TYPES
924 TYPE
925 ATTRIBUTES
926 RANGETYPE
927 ITERATOR
928 CALLBACK
929 START
930 STOP
931 SEQ_ID
932 END )],@sub_args);
933 warn "type and types after calling factory->_rearrange:$type_placeholder,$types" if DEBUG;
934
935 }
936 else {
937 warn "didn't call rearrange" if DEBUG;
938 $types = \@sub_args;
939 }
940  
941 #UGG, allow both -types and -type to be used in the args
942 if ($type_placeholder and !$types) {
943 if (ref $type_placeholder eq 'ARRAY') {
944 $types = $type_placeholder;
945 }
946 else {
947 $$types[0] = $type_placeholder;
948 }
949 warn "what sort of thing is type_placeholder?:".ref $type_placeholder if DEBUG;
950 }
951  
952 warn "@$types\n" if (defined $types and DEBUG);
953 warn $factory if DEBUG;
954  
955 $factory ||=$self->factory();
956 my $feat = Bio::DB::Das::Chado::Segment::Feature->new();
957 my @features;
958  
959  
960 my ($interbase_start,$rend,$srcfeature_id,$sql_types);
961 if (!$feature_id) {
962 $rangetype ||='overlaps';
963  
964 # set range variable
965  
966 $base_start = defined $base_start ? $base_start : $self->start;
967 $interbase_start = $base_start -1;
968 $end ||= $stop;
969 $rend = defined $end ? $end : $self->end;
970 # my $sql_range;
971 # if ($rangetype eq 'contains') {
972 #
973 # $sql_range = " fl.fmin >= $interbase_start and fl.fmax <= $rend ";
974 #
975 # } elsif ($rangetype eq 'contained_in') {
976 #
977 # $sql_range = " fl.fmin <= $interbase_start and fl.fmax >= $rend ";
978 #
979 # } else { #overlaps is the default
980 #
981 # $sql_range = " fl.fmin <= $rend and fl.fmax >= $interbase_start ";
982
983 # }
984  
985 # set type variable
986  
987 #$sql_types = '';
988  
989 my $valid_type = undef;
990 if ($types && scalar @$types != 0) {
991  
992 warn "first type:$$types[0]\n" if DEBUG;
993  
994 if (ref $$types[0] eq 'ARRAY') {
995 @$types = @{$$types[0]};
996 warn "first type after deref:$$types[0]\n" if DEBUG;
997 }
998  
999 my $temp_type = $$types[0];
1000 my $temp_source = '';
1001 if ($$types[0] =~ /(.*):(.*)/) {
1002 $temp_type = $1;
1003 $temp_source = $2;
1004 }
1005  
1006 $valid_type = $factory->name2term($temp_type);
1007 $self->throw("feature type: '$temp_type' is not recognized") unless $valid_type;
1008  
1009 my $temp_dbxref = $factory->source2dbxref($temp_source);
1010 if ($temp_source && $temp_dbxref) {
1011 $sql_types .= "((f.type_id = $valid_type and fd.dbxref_id = $temp_dbxref)";
1012 } else {
1013 $sql_types .= "((f.type_id = $valid_type)";
1014 }
1015  
1016 if (scalar @$types > 1) {
1017 for(my $i=1;$i<(scalar @$types);$i++) {
1018  
1019 $temp_type = $$types[$i];
1020 $temp_source = '';
1021 if ($$types[$i] =~ /(.*):(.*)/) {
1022 $temp_type = $1;
1023 $temp_source = $2;
1024 }
1025 warn "more types:$$types[$i]\n" if DEBUG;
1026  
1027 $valid_type = $factory->name2term($temp_type);
1028 $self->throw("feature type: '$temp_type' is not recognized") unless $valid_type;
1029  
1030 $temp_dbxref=$factory->source2dbxref($temp_source);
1031 if ($temp_source && $temp_dbxref) {
1032 $sql_types .= " OR \n (f.type_id = $valid_type and fd.dbxref_id = $temp_dbxref)";
1033 } else {
1034 $sql_types .= " OR \n (f.type_id = $valid_type)";
1035 }
1036 }
1037 }
1038 $sql_types .= ") ";
1039 }
1040  
1041 # $factory->dbh->trace(1) if DEBUG;
1042  
1043 $srcfeature_id = $self->{srcfeature_id} if ref $self;
1044 if (!$srcfeature_id && defined($seq_id)) {
1045 #if the seq_id arg was passed in, we should only look on that feature
1046 my $srcfeature_query = "SELECT feature_id FROM feature where lower(uniquename) = ? ";
1047 $srcfeature_query .= "and organism_id = ".$factory->organism_id
1048 if $factory->organism_id;
1049 my $srcf_query_handle= $factory->dbh->prepare($srcfeature_query);
1050 $srcf_query_handle->execute(lc($seq_id));
1051 ($srcfeature_id) = $srcf_query_handle->fetchrow_array;
1052 warn "found srcfeature_id:$srcfeature_id" if DEBUG;
1053 }
1054  
1055  
1056 }
1057 my $select_part = "select distinct f.name,fl.fmin,fl.fmax,fl.strand,fl.phase,"
1058 ."fl.locgroup,fl.srcfeature_id,f.type_id,f.uniquename,"
1059 ."f.feature_id, af.significance as score, "
1060 ."fd.dbxref_id,f.is_obsolete ";
1061  
1062 my $order_by = "order by f.type_id,fl.fmin ";
1063  
1064 warn $feature_id if DEBUG;
1065  
1066 my $where_part;
1067 my $from_part;
1068 if ($feature_id) {
1069 $from_part = "from (feature f join featureloc fl ON (f.feature_id = fl.feature_id)) "
1070 ."left join feature_dbxref fd ON (f.feature_id = fd.feature_id
1071 AND fd.dbxref_id in (select dbxref_id from dbxref where db_id=".$factory->gff_source_db_id.")) "
1072 ."left join analysisfeature af ON (f.feature_id = af.feature_id)";
1073  
1074 $where_part = "where f.feature_id = $feature_id and fl.rank=0 ";
1075  
1076 ##URGI Added a sub request to get the refclass srcfeature id to map all the features from this reference region.
1077 ##We then filter and are sure that we are getting the features located on the reference feature with the good
1078 ##coordinates.
1079 my $refclass = $factory->name2term($factory->default_class());
1080 my $refclass_feature_id = $factory->refclass_feature_id() || undef;
1081  
1082 #In case we already have the reference class feature_id
1083 if(defined($refclass_feature_id) and defined($srcfeature_id)){
1084 $where_part .= " and fl.srcfeature_id = $refclass_feature_id ";
1085 }
1086 elsif($refclass){
1087 #From the type_id of the reference class and the feature_id we are working with
1088 #we get the srcfeature_id of the reference class feature
1089 my $srcquery = "select srcfeature_id ";
1090 $srcquery .= "from featureloc fl join feature f on (fl.srcfeature_id = f.feature_id) ";
1091 $srcquery .= "where fl.feature_id = ? and f.type_id = ?";
1092  
1093 my $sth = $factory->dbh->prepare($srcquery);
1094 $sth->execute($feature_id,$refclass) or $self->throw("refclass_srcfeature query failed");
1095 my $hashref = $sth->fetchrow_hashref();
1096 my $srcfeature_id = $hashref->{srcfeature_id} || undef;
1097 $where_part .= " and fl.srcfeature_id = $srcfeature_id " if(defined($srcfeature_id));
1098 $sth->finish;
1099 }
1100  
1101 } else {
1102 my ($featureslice,$morewhere);
1103 if ($factory->srcfeatureslice
1104 && $srcfeature_id
1105 && defined $interbase_start
1106 && defined $rend){
1107 $featureslice = "featureloc_slice($srcfeature_id,$interbase_start, $rend)";
1108 warn "using featureloc_slice" if DEBUG;
1109 }elsif (defined $interbase_start && defined $rend){
1110 $featureslice = "featureslice($interbase_start, $rend)";
1111 }else {
1112 $featureslice = "featureloc";
1113 $morewhere = " and fl.srcfeature_id = $srcfeature_id " if defined($srcfeature_id);
1114 }
1115 $from_part = "from (feature f left join $featureslice fl ON (f.feature_id = fl.feature_id)) "
1116 ."left join feature_dbxref fd ON (f.feature_id = fd.feature_id
1117 AND fd.dbxref_id in (select dbxref_id from dbxref where db_id=".$factory->gff_source_db_id.")) "
1118 ."left join analysisfeature af ON (f.feature_id = af.feature_id)";
1119  
1120 $where_part = "where fl.rank=0 ";
1121 $where_part .= " and $sql_types "
1122 if defined ($sql_types);
1123 $where_part .= $morewhere if $morewhere;
1124 }
1125  
1126 #the ref $self check had to be added here to make gbrowse_details work
1127 #The good news is that gbrowse_details should always be calling with the
1128 #feature_id, so this won't be needed anyway.
1129 $where_part .= " and f.organism_id = ".$self->factory->organism_id
1130 if (ref $self && $self->factory->organism_id);
1131  
1132 my $query = "$select_part\n$from_part\n$where_part\n$order_by\n";
1133  
1134 #Recursive Mapping
1135 # Construct a query that recursively maps clone's features on
1136 # the underlying chromosome
1137 if ($factory->recursivMapping && ! $feature_id){
1138 my $qFrom=$from_part;
1139 $qFrom =~ s/featureslice/recurs_featureslice/g;
1140 $query="$select_part\n$from_part\n$where_part\nUNION\n$select_part\n$qFrom\n$where_part\norder by type_id, fmin";
1141 }
1142 $query =~ s/\s+/ /gs if DEBUG;
1143 warn $query if DEBUG;
1144 #END Recursive Mapping
1145  
1146  
1147 $factory->dbh->do("set enable_seqscan=0");
1148 # $factory->dbh->do("set enable_hashjoin=0");
1149  
1150 warn "Segement->features query:$query" if DEBUG;
1151  
1152 my $feature_query = $factory->dbh->prepare($query);
1153  
1154 $feature_query->execute or $self->throw("feature query failed");
1155 # $factory->dbh->do("set enable_hashjoin=1");
1156 $factory->dbh->do("set enable_seqscan=1");
1157  
1158 if ($feature_query->rows < 1
1159 and $sql_types
1160 and !defined($interbase_start)
1161 and !defined($rend)) {
1162 #standard feature query failed to find anything
1163 #try looking for srcfeatures:
1164 my $srcfeature_query = "SELECT f.name,f.type_id,f.uniquename,f.feature_id, fd.dbxref_id,f.is_obsolete,f.seqlen FROM feature f left join feature_dbxref fd ON (f.feature_id = fd.feature_id AND fd.dbxref_id in (select dbxref_id from dbxref where db_id=2)) WHERE $sql_types order by f.type_id";
1165 warn "srcfeature_query:$srcfeature_query" if DEBUG;
1166  
1167 $feature_query = $factory->dbh->prepare($srcfeature_query);
1168 $feature_query->execute or $self->throw("srcfeature query failed");
1169 }
1170  
1171 # Old query (doesn't use RTree index):
1172 #
1173 # select distinct f.name,fl.fmin,fl.fmax,fl.strand,f.type_id,f.feature_id
1174 # from feature f, featureloc fl
1175 # where
1176 # $sql_types
1177 # fl.srcfeature_id = $srcfeature_id and
1178 # f.feature_id = fl.feature_id and
1179 # $sql_range
1180 # order by type_id
1181  
1182  
1183  
1184  
1185 #$factory->dbh->trace(0);
1186 #take these results and create a list of Bio::SeqFeatureI objects
1187 #
1188  
1189 # my $sth_srcfeature_id_to_name = $self->factory->dbh->prepare("
1190 # select name from feature where feature_id = ?;");
1191  
1192 while (my $hashref = $feature_query->fetchrow_hashref) {
1193  
1194 warn "dbstart:$$hashref{fmim}, dbstop:$$hashref{fmax}" if DEBUG;
1195 warn "start:$base_start, stop:$stop\n" if DEBUG;
1196  
1197 warn "skipping feature_id $$hashref{feature_id} because it is obsolete"
1198 if (DEBUG and
1199 $$hashref{is_obsolete} and !$self->factory->allow_obsolete);
1200 next if ($$hashref{is_obsolete} and !$self->factory->allow_obsolete);
1201  
1202 if ($feature_id &&
1203 defined($stop) && $stop != $$hashref{fmax} ) {
1204 $stop = $$hashref{fmin} + $stop + 1;
1205 } elsif (defined($$hashref{seqlen})) {
1206 $stop = $$hashref{seqlen};
1207 } else {
1208 $stop = $$hashref{fmax};
1209 }
1210  
1211 if ($feature_id &&
1212 defined($base_start) && defined($$hashref{fmin}) && $base_start != ($$hashref{fmin}+1) ) {
1213 my $interbase_start = $$hashref{fmin} + $base_start - 1;
1214 $base_start = $interbase_start + 1;
1215 } elsif (defined($$hashref{seqlen})) {
1216 $base_start = 1;
1217 } else {
1218 my $interbase_start = $$hashref{fmin};
1219 $base_start = $interbase_start +1;
1220 }
1221 warn "base_start:$base_start, end:$stop" if DEBUG;
1222  
1223 my $source = $factory->dbxref2source($$hashref{dbxref_id}) || "" ;
1224 my $type = Bio::DB::GFF::Typename->new(
1225 $factory->term2name($$hashref{type_id}),
1226 $source);
1227  
1228 if (defined $$hashref{seqlen}) { #this is a srcfeature
1229 $feat = Bio::DB::Das::Chado::Segment::Feature->new(
1230 $factory,
1231 undef,
1232 undef,
1233 $base_start,$stop,
1234 $type,
1235 undef,
1236 undef,
1237 undef,
1238 $$hashref{name},
1239 $$hashref{uniquename},
1240 $$hashref{feature_id}
1241 );
1242 }
1243 else {
1244 $feat = Bio::DB::Das::Chado::Segment::Feature->new(
1245 $factory,
1246 $feature_id? undef :$self, #only give the segment as the
1247 # parent if the feature_id wasn't
1248 # provided
1249 $feature_id ?
1250 $factory->srcfeature2name($$hashref{'srcfeature_id'})
1251 :$self->seq_id,
1252  
1253 $base_start,$stop,
1254 $type,
1255 $$hashref{score},
1256 $$hashref{strand},
1257 $$hashref{phase},
1258 $$hashref{name},
1259 $$hashref{uniquename},$$hashref{feature_id});
1260 }
1261  
1262 push @features, $feat;
1263  
1264 my $fstart = $feat->start() if DEBUG;
1265 my $fend = $feat->end() if DEBUG;
1266 # warn "$feat->{annotation}, $$hashref{nbeg}, $fstart, $$hashref{nend}, $fend\n" if DEBUG;
1267 }
1268  
1269 warn "returning @features\n" if DEBUG;
1270  
1271 $feature_query->finish;
1272 if ($iterator) {
1273 warn "using Bio::DB::Das::ChadoIterator\n" if DEBUG;
1274 return Bio::DB::Das::ChadoIterator->new(\@features) if @features;
1275 } elsif (wantarray) {
1276 return @features;
1277 } elsif (@features >0) {
1278 return \@features;
1279 } else {
1280 return;
1281 }
1282 }
1283  
1284 =head2 _features2level
1285  
1286 See: features
1287  
1288 Its a crude copy past from feature + additionnal code to handle
1289 prefetching of 2 levels features. The generated query is ~ as
1290 performant as the one generated by features, and the calls to
1291 Bio::DB::Das::Chado::Segment->sub_SeqFeatures are avoided, but this
1292 doesn't lead to a huge performace boost.
1293  
1294 If a further development increases the performances provided by this 2
1295 level prefetch, we will need to refactor features and _features2level
1296 to avoid code duplication
1297  
1298 =cut
1299  
1300 sub _features2level(){
1301 my $self = shift;
1302  
1303 warn "Segment->_features2level() args:@_\n" if DEBUG;
1304  
1305 my ($types,$type_placeholder,$attributes,$rangetype,$iterator,$callback,$base_start,$stop,$feature_id,$factory);
1306 if ($_[0] and $_[0] =~ /^-/) {
1307 ($types,$type_placeholder,$attributes,$rangetype,$iterator,$callback,$base_start,$stop,$feature_id,$factory) =
1308 $self->_rearrange([qw(TYPES
1309 TYPE
1310 ATTRIBUTES
1311 RANGETYPE
1312 ITERATOR
1313 CALLBACK
1314 START
1315 STOP
1316 FEATURE_ID
1317 FACTORY)],@_);
1318 warn "$types\n" if DEBUG;
1319 } else {
1320 $types = \@_;
1321 }
1322  
1323 #UGG, allow both -types and -type to be used in the args
1324 if ($type_placeholder and !$types) {
1325 $types = $type_placeholder;
1326 }
1327  
1328 warn "@$types\n" if (defined $types and DEBUG);
1329  
1330 $factory ||=$self->factory();
1331 my $feat = Bio::DB::Das::Chado::Segment::Feature->new();
1332 my @features;
1333  
1334  
1335 my ($interbase_start,$rend,$srcfeature_id,$sql_types);
1336 unless ($feature_id) {
1337 $rangetype ||='overlaps';
1338  
1339 # set range variable
1340  
1341 $base_start = $self->start;
1342 $interbase_start = $base_start -1;
1343 $rend = $self->end;
1344  
1345 $sql_types = '';
1346  
1347 my $valid_type = undef;
1348 if (scalar @$types != 0) {
1349  
1350 warn "first type:$$types[0]\n" if DEBUG;
1351  
1352 my $temp_type = $$types[0];
1353 my $temp_source = '';
1354 if ($$types[0] =~ /(.*):(.*)/) {
1355 $temp_type = $1;
1356 $temp_source = $2;
1357 }
1358  
1359 $valid_type = $factory->name2term($temp_type);
1360 $self->throw("feature type: '$temp_type' is not recognized") unless $valid_type;
1361  
1362 my $temp_dbxref = $factory->source2dbxref($temp_source);
1363 if ($temp_source && $temp_dbxref) {
1364 $sql_types .= "((f.type_id = $valid_type and fd.dbxref_id = $temp_dbxref)";
1365 } else {
1366 $sql_types .= "((f.type_id = $valid_type)";
1367 }
1368  
1369 if (scalar @$types > 1) {
1370 for (my $i=1;$i<(scalar @$types);$i++) {
1371
1372 $temp_type = $$types[$i];
1373 $temp_source = '';
1374 if ($$types[$i] =~ /(.*):(.*)/) {
1375 $temp_type = $1;
1376 $temp_source = $2;
1377 }
1378 warn "more types:$$types[$i]\n" if DEBUG;
1379  
1380 $valid_type = $factory->name2term($temp_type);
1381 $self->throw("feature type: '$temp_type' is not recognized") unless $valid_type;
1382  
1383 $temp_dbxref=$factory->source2dbxref($temp_source);
1384 if ($temp_source && $temp_dbxref) {
1385 $sql_types .= " OR \n (f.type_id = $valid_type and fd.dbxref_id = $temp_dbxref)";
1386 } else {
1387 $sql_types .= " OR \n (f.type_id = $valid_type)";
1388 }
1389 }
1390 }
1391 $sql_types .= ") ";
1392 }
1393  
1394 # $factory->dbh->trace(1) if DEBUG;
1395  
1396 $srcfeature_id = $self->{srcfeature_id};
1397  
1398 }
1399 my $select_part = "select distinct f.name,fl.fmin,fl.fmax,fl.strand,fl.phase,"
1400 ."fl.locgroup,fl.srcfeature_id,f.type_id,f.uniquename,"
1401 ."f.feature_id, af.significance as score, "
1402 ."fd.dbxref_id,f.is_obsolete ";
1403  
1404 my $order_by = "order by f.type_id,fl.fmin ";
1405  
1406 my $where_part;
1407 my $from_part;
1408 if ($feature_id) {
1409 $from_part = "from (feature f join featureloc fl ON (f.feature_id = fl.feature_id)) "
1410 ."left join feature_dbxref fd ON
1411 (f.feature_id = fd.feature_id
1412 AND fd.dbxref_id in (select dbxref_id from dbxref where db_id=".$factory->gff_source_db_id.")) "
1413 ."left join analysisfeature af ON (af.feature_id = f.feature_id) ";
1414  
1415 $where_part = " where f.feature_id = $feature_id and fl.rank=0 ";
1416 $where_part .= " and f.organism_id = ".$self->factory->organism_id
1417 if $self->factory->organism_id;
1418  
1419 ##URGI Added a sub request to get the refclass srcfeature id to map all the features from this reference region.
1420 ##We then filter and are sure that we are getting the features located on the reference feature with the good
1421 ##coordinates.
1422 my $refclass = $factory->name2term($factory->default_class());
1423 my $refclass_feature_id = $factory->refclass_feature_id() || undef;
1424  
1425 #In case we already have the reference class feature_id
1426 if(defined($refclass_feature_id)){
1427 $where_part .= " and fl.srcfeature_id = $refclass_feature_id ";
1428 }
1429 elsif($refclass){
1430 #From the type_id of the reference class and the feature_id we are working with
1431 #we get the srcfeature_id of the reference class feature
1432 my $srcquery = "select srcfeature_id ";
1433 $srcquery .= "from featureloc fl join feature f on (fl.srcfeature_id = f.feature_id) ";
1434 $srcquery .= "where fl.feature_id = ? and f.type_id = ?";
1435  
1436 my $sth = $factory->dbh->prepare($srcquery,$refclass);
1437 $sth->execute($feature_id) or $self->throw("refclass_srcfeature query failed");
1438 my $hashref = $sth->fetchrow_hashref();
1439 my $srcfeature_id = $hashref->{srcfeature_id} || undef;
1440 $where_part .= " and fl.srcfeature_id = $srcfeature_id " if(defined($srcfeature_id));
1441 $sth->finish;
1442 }
1443  
1444 } else {
1445 my $featureslice;
1446 if ($factory->srcfeatureslice){
1447 $featureslice = "featureloc_slice($srcfeature_id,$interbase_start, $rend)";
1448 }else{
1449 $featureslice = "featureslice($interbase_start, $rend)";
1450 }
1451 $from_part = "from ((feature f join $featureslice fl ON (f.feature_id = fl.feature_id)) "
1452 ."left join feature_dbxref fd ON
1453 (f.feature_id = fd.feature_id
1454 AND fd.dbxref_id in (select dbxref_id from dbxref where db_id=".$factory->gff_source_db_id.")) "
1455 ."left join analysisfeature af ON (af.feature_id = f.feature_id)) "
1456 .'left join feature_relationship fr on (f.feature_id = fr.object_id) left join feature sub_f on (sub_f.feature_id = fr.subject_id) left join featureloc sub_fl on (sub_f.feature_id=sub_fl.feature_id) ';
1457  
1458 $where_part = "where $sql_types "
1459 ." and fl.srcfeature_id = $srcfeature_id and fl.rank=0 "
1460 .' AND (fl.locgroup=sub_fl.locgroup OR sub_fl.locgroup is null) ';
1461 }
1462  
1463
1464  
1465 $select_part .= ', sub_f.name as sname,sub_fl.fmin as sfmin,sub_fl.fmax as sfmax,sub_fl.strand as sstrand,sub_fl.phase as sphase,sub_fl.locgroup as slocgroup,sub_f.type_id as stype_id,sub_f.uniquename as suniquename,sub_f.feature_id as sfeature_id';
1466 my $query = "$select_part\n $from_part\n$where_part\n$order_by\n";
1467  
1468  
1469  
1470  
1471 $query =~ s/\s+/ /gs if DEBUG;
1472 warn $query if DEBUG;
1473  
1474 warn "Segement->features query:$query" if DEBUG;
1475  
1476 my $sth = $factory->dbh->prepare($query);
1477  
1478 $sth->execute or $self->throw("feature query failed");
1479 # $factory->dbh->do("set enable_hashjoin=1");
1480  
1481  
1482 #2Level Optimisation
1483 #each feature is spaned over several tuples, each of which store a different SUBfeature (only one tuple if no subfeat of course)
1484  
1485 while (my $hashref = $sth->fetchrow_hashref) {
1486  
1487 warn "dbstart:$$hashref{fmim}, dbstop:$$hashref{fmax}" if DEBUG;
1488 warn "start:$base_start, stop:$stop\n" if DEBUG;
1489  
1490 next if ($$hashref{is_obsolete} and !$self->factory->allow_obsolete);
1491  
1492 if ( !defined ($feat->feature_id) || $feat->feature_id != $$hashref{feature_id}) {
1493 #either first feature or new feature
1494 if (defined ($feat->feature_id) && $feat->feature_id != $$hashref{feature_id}) {
1495 # not the first feat , adding the previous feat
1496 push @features, $feat;
1497  
1498 }
1499 if ($feature_id &&
1500 defined($stop) && $stop != $$hashref{fmax} ) {
1501 $stop = $$hashref{fmin} + $stop + 1;
1502 } else {
1503 $stop = $$hashref{fmax};
1504 }
1505 if ($feature_id &&
1506 defined($base_start) && $base_start != ($$hashref{fmin}+1) ) {
1507 my $interbase_start = $$hashref{fmin} + $base_start - 1;
1508 $base_start = $interbase_start + 1;
1509 } else {
1510 my $interbase_start = $$hashref{fmin};
1511 $base_start = $interbase_start +1;
1512 }
1513 warn "base_start:$base_start, end:$stop" if DEBUG;
1514  
1515 my $source = $factory->dbxref2source($$hashref{dbxref_id}) || "" ;
1516 my $type = Bio::DB::GFF::Typename->new(
1517 $factory->term2name($$hashref{type_id}),
1518 $source);
1519  
1520 $feat = Bio::DB::Das::Chado::Segment::Feature->new(
1521 $factory,
1522 $feature_id? undef :$self, #only give the segment as the
1523 # parent if the feature_id wasn't
1524 # provided
1525 $feature_id ?
1526 $factory->srcfeature2name($$hashref{'srcfeature_id'})
1527 :$self->seq_id,
1528  
1529 $base_start,$stop,
1530 $type,
1531 $$hashref{score},
1532 $$hashref{strand},
1533 $$hashref{phase},
1534 $$hashref{name},
1535 $$hashref{uniquename},
1536 $$hashref{feature_id});
1537 print STDERR "Created Feature obj $$hashref{name}][[$$hashref{feature_id}][$$hashref{'srcfeature_id'}]\n" if DEBUG;
1538 }
1539 #handling sub feat, if any
1540 if ($$hashref{sfeature_id}) {
1541 if ($feature_id &&
1542 defined($stop) && $stop != $$hashref{sfmax} ) {
1543 $stop = $$hashref{sfmin} + $stop + 1;
1544 } else {
1545 $stop = $$hashref{fmax};
1546 }
1547 if ($feature_id &&
1548 defined($base_start) && $base_start != ($$hashref{sfmin}+1) ) {
1549 my $interbase_start = $$hashref{sfmin} + $base_start - 1;
1550 $base_start = $interbase_start + 1;
1551 } else {
1552 my $interbase_start = $$hashref{sfmin};
1553 $base_start = $interbase_start +1;
1554 }
1555 warn "base_start:$base_start, end:$stop" if DEBUG;
1556  
1557 my $source = $factory->dbxref2source($$hashref{dbxref_id}) || "" ;
1558 my $type = Bio::DB::GFF::Typename->new(
1559 $factory->term2name($$hashref{stype_id}),
1560 $source);
1561  
1562 my $subFeat = Bio::DB::Das::Chado::Segment::Feature->new(
1563 $factory,
1564 $feat,
1565 $feature_id ? $factory->srcfeature2name($$hashref{'srcfeature_id'}):$self->seq_id,
1566 #$base_start,$stop,
1567 $$hashref{sfmin} + 1, $$hashref{sfmax},
1568 $type,
1569 $$hashref{score}, #TODO : add the subfeat score, not the feat
1570 $$hashref{sstrand},
1571 $$hashref{sphase},
1572 $$hashref{sname},
1573 $$hashref{suniquename},$$hashref{sfeature_id});
1574  
1575 #adding the subfeat to its parent, ie $feat
1576 # $feat->subfeatures($subFeat);
1577 $feat->add_subfeature($subFeat);
1578 #warn $feat->feature_id . ":".$feat->start ."..".$feat->end ." base_start:$base_start, end:$stop";
1579 } #end of the subfeat handling
1580
1581  
1582 my $fstart = $feat->start() if DEBUG;
1583 my $fend = $feat->end() if DEBUG;
1584 # warn "$feat->{annotation}, $$hashref{nbeg}, $fstart, $$hashref{nend}, $fend\n" if DEBUG;
1585  
1586 } #end while hashref loop
1587  
1588 #We check if the last feature creatd is the same as the last pushed in the array
1589 if(@features > 0 && $features[-1]->feature_id() ne $feat->feature_id()){
1590 push @features, $feat;
1591 }
1592  
1593 $sth->finish;
1594 if ($iterator) {
1595 warn "using Bio::DB::Das::ChadoIterator\n" if DEBUG;
1596 return Bio::DB::Das::ChadoIterator->new(\@features) if @features;
1597 } elsif (wantarray) {
1598 return @features;
1599 } else {
1600 return \@features;
1601 }
1602 }
1603  
1604  
1605 =head2 get_all_SeqFeature, get_SeqFeatures, top_SeqFeatures, all_SeqFeatures
1606  
1607 Title : get_all_SeqFeature, get_SeqFeatures, top_SeqFeatures, all_SeqFeatures
1608 Usage : $s->get_all_SeqFeature()
1609 Function: get the sequence string for this segment
1610 Returns : a string
1611 Args : none
1612 Status : Public
1613  
1614 Several aliases of features() for backward compatibility
1615  
1616 =cut
1617  
1618 *get_all_SeqFeature = *top_SeqFeatures = *all_SeqFeatures = \&features;
1619  
1620 sub get_SeqFeatures {return}
1621  
1622 =head2 dna
1623  
1624 Title : dna
1625 Usage : $s->dna
1626 Function: get the dna string this segment
1627 Returns : a string
1628 Args : none
1629 Status : Public
1630  
1631 Returns the sequence for this segment as a string.
1632  
1633 =cut
1634  
1635 sub dna {
1636 my $self = shift;
1637 my %arg = @_;
1638 my ($ref,$class,$base_start,$stop,$strand)
1639 = @{$self}{qw(sourceseq class start end strand)};
1640  
1641 warn "ref:$ref, class:$class, $base_start..$stop, ($strand)\n" if DEBUG;
1642  
1643 if($arg{self}){
1644 my $r_id = $self->feature_id;
1645
1646 $self->warn("FIXME: incomplete implementation of alternate sequence selection") if $self->verbose;
1647
1648 my $sth = $self->factory->dbh->prepare("
1649 select residues from feature
1650 where feature_id = ?");
1651  
1652 $sth->execute($r_id) or $self->throw("seq query failed");
1653
1654 my $array_ref = $sth->fetchrow_arrayref;
1655 my $seq = $$array_ref[0];
1656  
1657 $sth->finish;
1658 return $seq;
1659 }
1660  
1661 my $feat_id = $self->{srcfeature_id};
1662  
1663 my $has_start = defined $base_start;
1664 my $has_stop = defined $stop;
1665  
1666 my $reversed;
1667 if ($has_start && $has_stop && $base_start > $stop) {
1668 $reversed++;
1669 ($base_start,$stop) = ($stop,$base_start);
1670 } elsif ($strand && $strand < 0 ) {
1671 $reversed++;
1672 }
1673  
1674 my $sth;
1675 if (!$has_start and !$has_stop) {
1676 $sth = $self->factory->dbh->prepare("
1677 select residues from feature
1678 where feature_id = $feat_id ");
1679 } elsif (!$has_start) {
1680 $sth = $self->factory->dbh->prepare("
1681 select substring(residues for $stop) from feature
1682 where feature_id = $feat_id ");
1683 } elsif (!$has_stop) {
1684 $sth = $self->factory->dbh->prepare("
1685 select substring(residues from $base_start) from feature
1686 where feature_id = $feat_id ");
1687 } else { #has both start and stop
1688 my $sslen = $stop-$base_start+1;
1689 $sth = $self->factory->dbh->prepare("
1690 select substring(residues from $base_start for $sslen) from feature
1691 where feature_id = $feat_id ");
1692 }
1693  
1694 $sth->execute or $self->throw("seq query failed");
1695
1696 my $array_ref = $sth->fetchrow_arrayref;
1697 my $seq = $$array_ref[0];
1698 $sth->finish;
1699  
1700 if ($reversed) {
1701 $seq = reverse $seq;
1702 $seq =~ tr/gatcGATC/ctagCTAG/;
1703 }
1704  
1705 return $seq;
1706 }
1707  
1708 sub subseq {
1709 my $self = shift;
1710 my ($start, $stop) = @_;
1711 $start--;
1712  
1713 my $dna = $self->dna;
1714 my $length = $stop - $start + 1;
1715  
1716 my $substr = substr($dna, $start, $length);
1717  
1718 my $subseqobj = Bio::Seq->new( -display_id => $self->seq_id,
1719 -seq => $substr);
1720  
1721 return $subseqobj;
1722 }
1723  
1724 =head2 seq
1725  
1726 Title : seq
1727 Usage : $s->seq
1728 Function: get a Bio::Seq object for this segment
1729 Returns : a Bio::Seq object
1730 Args : none
1731 Status : Public
1732  
1733 Returns the sequence for this segment as a Bio::Seq object.
1734  
1735 =cut
1736  
1737 sub seq {
1738 my $self = shift;
1739  
1740 my $seqobj = Bio::Seq->new(
1741 -display_id => $self->seq_id
1742 .":".$self->start
1743 ."..".$self->end,
1744 -seq => $self->dna,
1745 );
1746  
1747 return $seqobj;
1748 }
1749  
1750 *protein = \&dna;
1751  
1752 =head2 factory
1753  
1754 Title : factory
1755 Usage : $factory = $s->factory
1756 Function: return the segment factory
1757 Returns : a Bio::DasI object
1758 Args : see below
1759 Status : Public
1760  
1761 This method returns a Bio::DasI object that can be used to fetch
1762 more segments. This is typically the Bio::DasI object from which
1763 the segment was originally generated.
1764  
1765 =cut
1766  
1767 sub factory {my $self = shift;
1768 confess "self is not an object" unless ref $self;
1769 return $self->{factory} }
1770  
1771 =head2 srcfeature_id
1772  
1773 Title : srcfeature_id
1774 Usage : $obj->srcfeature_id($newval)
1775 Function: undocumented method by Scott Cain
1776 Returns : value of srcfeature_id (a scalar)
1777 Args : on set, new value (a scalar or undef, optional)
1778  
1779  
1780 =cut
1781  
1782 sub srcfeature_id {
1783 my $self = shift;
1784  
1785 return $self->{'srcfeature_id'} = shift if @_;
1786
1787 confess "how did I get into srcfeature_id method" if (DEBUG and !ref $self);
1788 return $self->{'srcfeature_id'};
1789 }
1790  
1791 =head2 source
1792  
1793 Title : source
1794 Usage : $obj->source($newval)
1795 Function: Returns the source; sets with an argument
1796 Returns : A string that is the source
1797 Args : A string to set the source
1798  
1799 =cut
1800  
1801 sub source {
1802 my $self = shift;
1803 my $source;
1804  
1805 return $self->{'source'} = shift if @_;
1806 return $self->{'source'} if defined ($self->{'source'});
1807
1808 #fine, not set, get by query
1809  
1810 my $query = "SELECT dbx.accession FROM feature_dbxref fd
1811 JOIN dbxref dbx USING (dbxref_id)
1812 WHERE fd.feature_id = ?
1813 AND dbx.db_id = ?";
1814 my $sth = $self->factory->dbh->prepare($query);
1815 $sth->execute($self->feature_id, $self->factory->gff_source_db_id)
1816 or $self->throw("failed to get source via query");
1817  
1818 ($source) = $sth->fetchrow_array;
1819  
1820 $sth->finish;
1821 return $source;
1822 }
1823  
1824 =head2 source_tag
1825  
1826 Title : source_tag
1827 Function: aliased to source() for Bio::SeqFeatureI compatibility
1828  
1829 =cut
1830  
1831 *source_tag = \&source;
1832  
1833 =head2 alphabet
1834  
1835 Title : alphabet
1836 Usage : $obj->alphabet($newval)
1837 Function: Returns the sequence "type", ie, dna
1838 Returns : scalar 'dna'
1839 Args : None
1840  
1841  
1842 =cut
1843  
1844 sub alphabet {
1845 return 'dna';
1846 }
1847  
1848 =head2 display_id, display_name, accession_number, desc
1849  
1850 Title : display_id, display_name, accession_number, desc
1851 Usage : $s->display_name()
1852 Function: Alias of name()
1853 Returns : string
1854 Args : none
1855  
1856 Several aliases for name; it may be that these could do something better than
1857 just giving back the name.
1858  
1859 =cut
1860  
1861 *display_id = *display_name = *accession_number = \&name;
1862 # *desc =
1863  
1864 #dgg patch for SeqI.desc -- use ref segment Note property for description
1865 sub desc {
1866 my $self= shift;
1867 return $self->{'desc'} if defined $self->{'desc'};
1868  
1869 my $sth = $self->factory->dbh->prepare( "select value from featureprop
1870 where feature_id = ? and type_id in (select cvterm_id from cvterm where name = 'Note') ");
1871 $sth->execute( $self->feature_id );
1872 my $hashref = $sth->fetchrow_hashref();
1873  
1874 $sth->finish;
1875 return $self->{'desc'}= $hashref->{value};
1876 }
1877  
1878 #dgg patch for SeqI -- Bio::SeqI::species
1879 sub species {
1880 my $self= shift;
1881 return $self->{'species'} if defined $self->{'species'};
1882  
1883 my $sth = $self->factory->dbh->prepare( "select genus,species from organism
1884 where organism_id = (select organism_id from feature where feature_id = ?) ");
1885 cluck "i'm in species";
1886 $sth->execute( $self->srcfeature_id );
1887 my $hashref = $sth->fetchrow_hashref();
1888 $sth->finish;
1889
1890 ## this is dying; why? dgg
1891 # my $spp= Bio::Species->new( -classification => [ $hashref->{species}, $hashref->{genus} ] );
1892
1893 my $spp= $hashref->{genus}.' '.$hashref->{species}; # works for display uses
1894 return $self->{'species'}= $spp;
1895 }
1896  
1897  
1898 =head2 primary_seq
1899  
1900 Title : primary_seq
1901 Usage : $s->primary_seq()
1902 Function: Get a Bio::PrimarySeqI compliant object
1903 Returns : Bio::PrimarySeqI
1904 Args : none
1905  
1906 =cut
1907  
1908 sub primary_seq {
1909 my $self = shift;
1910  
1911 return Bio::PrimarySeq->new(
1912 -seq => $self->seq->seq,
1913 -display_id => $self->display_id,
1914 -accession_number => $self->accession_number,
1915 -primary_id => $self->primary_id,
1916 -desc => $self->desc,
1917 );
1918 }
1919  
1920  
1921 =head2 get_feature_stream
1922  
1923 Title : get_feature_stream
1924 Usage : $db->get_feature_stream(@args)
1925 Function: creates a feature iterator
1926 Returns : A Bio::DB::Das::ChadoIterator object
1927 Args : The same arguments as the feature method
1928  
1929 get_feature_stream has an alias called get_seq_stream for backward
1930 compatability.
1931  
1932 =cut
1933  
1934 sub get_feature_stream {
1935 my $self = shift;
1936 my @args = @_;
1937 warn "get_feature_stream args: @_\n" if DEBUG;
1938 my $features = $self->features(@args);
1939 warn "using get_feature_stream\n" if DEBUG;
1940 warn "feature array: $features\n" if DEBUG;
1941 warn "first feature: $$features[0]\n" if DEBUG;
1942 return Bio::DB::Das::ChadoIterator->new($features) if $features;
1943 return Bio::DB::Das::ChadoIterator->new([]);
1944 }
1945  
1946 #dgg patch for DasI need
1947 *get_seq_stream = \&get_feature_stream;
1948  
1949 =head2 clone
1950  
1951 Title : clone
1952 Usage : $copy = $s->clone
1953 Function: make a copy of this segment
1954 Returns : a Bio::DB::GFF::Segment object
1955 Args : none
1956 Status : Public
1957  
1958 =cut
1959  
1960 # deep copy of the thing
1961 sub clone {
1962 my $self = shift;
1963 my %h = %$self;
1964 return bless \%h,ref($self);
1965 }
1966  
1967 =head2 sourceseq
1968  
1969 Title : sourceseq
1970 Usage : $obj->sourceseq($newval)
1971 Function: undocumented method by Scott Cain
1972 Returns : value of sourceseq (a scalar)
1973 Args : on set, new value (a scalar or undef, optional)
1974  
1975  
1976 =cut
1977  
1978 sub sourceseq {
1979 my $self = shift;
1980  
1981 return $self->{'sourceseq'} if $self->{'sourceseq'};
1982  
1983 my $dbh = $self->factory->dbh;
1984 my $sourceseq_query = $dbh->prepare("
1985 select name from feature where feature_id = ?");
1986  
1987 $sourceseq_query->execute($self->srcfeature_id)
1988 or $self->throw("getting sourceseq name query failed");
1989  
1990 return if $sourceseq_query->rows < 1;
1991 my $hashref = $sourceseq_query->fetchrow_hashref;
1992
1993 $sourceseq_query->finish;
1994 $self->{'sourceseq'} = $$hashref{'name'};
1995 return $self->{'sourceseq'};
1996 }
1997  
1998 =head2 refseq
1999  
2000 Title : refseq
2001 Usage : $s->refseq
2002 Function: get or set the reference sequence
2003 Returns : a string
2004 Args : none
2005 Status : Public
2006  
2007 Examine or change the reference sequence. This is an alias to
2008 sourceseq(), provided here for API compatibility with
2009 Bio::DB::GFF::RelSegment.
2010  
2011 =cut
2012  
2013 *refseq = \&sourceseq;
2014  
2015 =head2 abs_ref
2016  
2017 Title : abs_ref
2018 Usage : $obj->abs_ref()
2019 Function: Alias of sourceseq
2020 Returns : value of sourceseq (a scalar)
2021 Args : none
2022  
2023 Alias of sourceseq for backward compatibility
2024  
2025 =cut
2026  
2027 *abs_ref = \&sourceseq;
2028  
2029 =head2 abs_start
2030  
2031 Title : abs_start
2032 Usage : $obj->abs_start()
2033 Function: Alias of start
2034 Returns : value of start (a scalar)
2035 Args : none
2036  
2037 =cut
2038  
2039 *abs_start = \&start;
2040  
2041 =head2 abs_end
2042  
2043 Title : abs_end
2044 Usage : $obj->abs_end()
2045 Function: Alias of end
2046 Returns : value of end (a scalar)
2047 Args : none
2048  
2049 =cut
2050  
2051 *abs_end = \&end;
2052  
2053 =head2 asString
2054  
2055 Title : asString
2056 Usage : $s->asString
2057 Function: human-readable string for segment
2058 Returns : a string
2059 Args : none
2060 Status : Public
2061  
2062 Returns a human-readable string representing this sequence. Format
2063 is:
2064  
2065 sourceseq:start,stop
2066  
2067 =cut
2068  
2069 sub asString {
2070 my $self = shift;
2071 unless (ref $self) {
2072 warn "in asString with no self";
2073 return unless ref $self;
2074 }
2075 my $label = $self->refseq;
2076 my $start = $self->start;
2077 my $stop = $self->stop;
2078 return "$label:$start,$stop";
2079 }
2080  
2081 sub rel2abs {
2082 shift;
2083 return @_;
2084 }
2085  
2086  
2087 1;
« blib/lib/Bio/DB/Das/Chado.pm ↑ Summary