[Bioperl-guts-l] [14840] bioperl-live/trunk/Bio: Allow other Bio::SeqFeature::CollectionI

Christopher John Fields cjfields at dev.open-bio.org
Fri Aug 29 12:45:38 EDT 2008


Revision: 14840
Author:   cjfields
Date:     2008-08-29 12:45:38 -0400 (Fri, 29 Aug 2008)

Log Message:
-----------
Allow other Bio::SeqFeature::CollectionI

Modified Paths:
--------------
    bioperl-live/trunk/Bio/Assembly/Contig.pm
    bioperl-live/trunk/Bio/SeqFeature/Collection.pm

Modified: bioperl-live/trunk/Bio/Assembly/Contig.pm
===================================================================
--- bioperl-live/trunk/Bio/Assembly/Contig.pm	2008-08-29 14:58:09 UTC (rev 14839)
+++ bioperl-live/trunk/Bio/Assembly/Contig.pm	2008-08-29 16:45:38 UTC (rev 14840)
@@ -224,6 +224,7 @@
  Returns   : Bio::Assembly::Contig
  Args      : -id => contig unique ID
              -source => string for the sequence assembly program used
+             -collection => Bio::SeqFeature::Collection instance
 
 =cut
 
@@ -234,7 +235,7 @@
 
     my $self = $class->SUPER::new(@args);
 
-    my ($src, $id) = $self->_rearrange([qw(SOURCE ID)], @args);
+    my ($src, $id, $collection) = $self->_rearrange([qw(SOURCE ID COLLECTION)], @args);
     $src && $self->source($src);
     ($id && $self->id($id)) || ($self->{'_id'} = 'NoName'); # Alignment (contig) name
     ($id && $self->id($id)) || ($self->{'_source'} = 'Unknown'); # Program used to build the contig
@@ -253,7 +254,14 @@
     $self->{'_nof_residues'} = 0;
     $self->{'_nof_seqs'} = 0;
     # $self->{'_nof_segments'} = 0; # Let's not make it heavier than needed by now...
-    $self->{'_sfc'} = Bio::SeqFeature::Collection->new();
+    
+    # for cases where SF::Collection is shared between Bio::Assembly::Contig 
+    if ($collection) {
+        $self->throw("Collection must implement Bio::SeqFeature::CollectionI") unless $collection->isa('Bio::SeqFeature::CollectionI');
+        $self->{'_sfc'} = $collection;
+    } else {
+        $self->{'_sfc'} = Bio::SeqFeature::Collection->new()
+    }
 
     # Assembly specifics
     $self->{'_assembly'} = undef; # Reference to a Bio::Assembly::Scaffold object, if contig belongs to one.

Modified: bioperl-live/trunk/Bio/SeqFeature/Collection.pm
===================================================================
--- bioperl-live/trunk/Bio/SeqFeature/Collection.pm	2008-08-29 14:58:09 UTC (rev 14839)
+++ bioperl-live/trunk/Bio/SeqFeature/Collection.pm	2008-08-29 16:45:38 UTC (rev 14840)
@@ -136,7 +136,7 @@
 use Bio::SeqFeature::Generic;
 use Storable qw(freeze thaw);
 
-use base qw(Bio::Root::Root);
+use base qw(Bio::Root::Root Bio::SeqFeature::CollectionI);
 
 
 # This may need to get re-optimized for BDB usage as these




More information about the Bioperl-guts-l mailing list