[Bioperl-guts-l] [14825] bioperl-live/trunk: added an option to bp_seqfeature_load to ignore ##sequence-region directives in the gff3 file

Lincoln Stein lstein at dev.open-bio.org
Mon Aug 25 11:40:28 EDT 2008


Revision: 14825
Author:   lstein
Date:     2008-08-25 11:40:28 -0400 (Mon, 25 Aug 2008)

Log Message:
-----------
added an option to bp_seqfeature_load to ignore ##sequence-region directives in the gff3 file

Modified Paths:
--------------
    bioperl-live/trunk/Bio/DB/SeqFeature/Store/GFF3Loader.pm
    bioperl-live/trunk/Bio/Graphics/FeatureFile.pm
    bioperl-live/trunk/scripts/Bio-SeqFeature-Store/bp_seqfeature_load.PLS
    bioperl-live/trunk/t/BioDBSeqFeature.t

Modified: bioperl-live/trunk/Bio/DB/SeqFeature/Store/GFF3Loader.pm
===================================================================
--- bioperl-live/trunk/Bio/DB/SeqFeature/Store/GFF3Loader.pm	2008-08-22 18:02:21 UTC (rev 14824)
+++ bioperl-live/trunk/Bio/DB/SeqFeature/Store/GFF3Loader.pm	2008-08-25 15:40:28 UTC (rev 14825)
@@ -125,6 +125,9 @@
  -tmp               Indicate a temporary directory to use when loading non-normalized
                        features.
 
+ -ignore_seqregion  Ignore ##sequence-region directives. The default is to create a
+                       feature corresponding to the directive.
+
 When you call new(), a connection to a Bio::DB::SeqFeature::Store
 database should already have been established and the database
 initialized (if appropriate).
@@ -158,8 +161,31 @@
 
 =cut
 
-# sub new { } inherited
+sub new { 
+    my $class = shift;
+    my $self  = $class->SUPER::new(@_);
+    my ($ignore_seqregion) = rearrange(['IGNORE_SEQREGION'], at _);
+    $self->ignore_seqregion($ignore_seqregion);
+    $self;
+}
 
+=head2 ignore_seqregion
+
+  $ignore_it = $loader->ignore_seqregion([$new_flag])
+
+Get or set the ignore_seqregion flag, which if true, will cause 
+GFF3 ##sequence-region directives to be ignored. The default behavior
+is to create a feature corresponding to the region.
+
+=cut
+
+sub ignore_seqregion {
+    my $self = shift;
+    my $d    = $self->{ignore_seqregion};
+    $self->{ignore_seqregion} = shift if @_;
+    $d;
+}
+
 =head2 load
 
  Title   : load
@@ -398,7 +424,8 @@
     return;
   }
 
-  if ($instruction =~ /sequence-region\s+(.+)\s+(-?\d+)\s+(-?\d+)/i) {
+  if ($instruction =~ /sequence-region\s+(.+)\s+(-?\d+)\s+(-?\d+)/i 
+      && !$self->ignore_seqregion()) {
       my($ref,$start,$end,$strand)    = $self->_remap($1,$2,$3,+1);
       my $feature = $self->sfclass->new(-name        => $ref,
 					-seq_id      => $ref,

Modified: bioperl-live/trunk/Bio/Graphics/FeatureFile.pm
===================================================================
--- bioperl-live/trunk/Bio/Graphics/FeatureFile.pm	2008-08-22 18:02:21 UTC (rev 14824)
+++ bioperl-live/trunk/Bio/Graphics/FeatureFile.pm	2008-08-25 15:40:28 UTC (rev 14825)
@@ -1116,15 +1116,6 @@
   my $self = shift;
   my $types = $self->{types} or return;
   return @$types;
-#   my @types;
-#   for my $t (@$types) {
-#       if (my $ftype = $self->setting($t=>'feature')) {
-# 	  push @types,shellwords($ftype);
-#       } else {
-# 	  push @types,$t;
-#       }
-#   }
-#   return @types;
 }
 
 sub labels {

Modified: bioperl-live/trunk/scripts/Bio-SeqFeature-Store/bp_seqfeature_load.PLS
===================================================================
--- bioperl-live/trunk/scripts/Bio-SeqFeature-Store/bp_seqfeature_load.PLS	2008-08-22 18:02:21 UTC (rev 14824)
+++ bioperl-live/trunk/scripts/Bio-SeqFeature-Store/bp_seqfeature_load.PLS	2008-08-25 15:40:28 UTC (rev 14825)
@@ -14,6 +14,7 @@
 my $VERBOSE  = 1;
 my $FAST     = 0;
 my $TMP      = File::Spec->tmpdir();
+my $IGNORE_SEQREGION   = 0;
 my $CREATE   = 0;
 my $USER     = '';
 my $PASS     = '';
@@ -24,6 +25,7 @@
 	   'adaptor=s'   => \$ADAPTOR,
 	   'verbose!'    => \$VERBOSE,
 	   'fast'       => \$FAST,
+	   'ignore-seqregion' => \$IGNORE_SEQREGION,
 	   'T|temporary-directory=s' => \$TMP,
 	   'create'      => \$CREATE,
 	   'user=s'      => \$USER,
@@ -41,6 +43,9 @@
           -c --create     Create the database and reinitialize it (will erase contents)
           -u --user       User to connect to database as
           -p --password   Password to use to connect to database
+          -i --ignore-seqregion
+                          If true, then ignore ##sequence-region directives in the
+                          GFF3 file (default, create a feature for each region)
 END
 
 if ($FAST) {
@@ -58,7 +63,8 @@
 					    -user    => $USER,
 					    -pass    => $PASS,
 					    -write    => 1,
-					    -create   => $CREATE)
+					    -create   => $CREATE,
+    )
   or die "Couldn't create connection to the database";
 
 $store->init_database('erase') if $CREATE;
@@ -67,7 +73,9 @@
 							 -sf_class => $SFCLASS,
 							 -verbose  => $VERBOSE,
 							 -tmpdir   => $TMP,
-							 -fast     => $FAST)
+							 -fast     => $FAST,
+							 -ignore_seqregion => $IGNORE_SEQREGION,
+    )
   or die "Couldn't create GFF3 loader";
 
 # on signals, give objects a chance to call their DESTROY methods

Modified: bioperl-live/trunk/t/BioDBSeqFeature.t
===================================================================
--- bioperl-live/trunk/t/BioDBSeqFeature.t	2008-08-22 18:02:21 UTC (rev 14824)
+++ bioperl-live/trunk/t/BioDBSeqFeature.t	2008-08-25 15:40:28 UTC (rev 14825)
@@ -2,7 +2,7 @@
 # $Id$
 
 use strict;
-use constant TEST_COUNT => 57;
+use constant TEST_COUNT => 59;
 
 BEGIN {
     use lib 't/lib';
@@ -186,4 +186,18 @@
     exit 0;
 }
 
+# test the -ignore_seqregion flag
+
+# the original should have a single feature named 'Contig1'
+my @f   = $db->get_features_by_name('Contig1');
+is(scalar @f,1);
+
+$db     = eval { Bio::DB::SeqFeature::Store->new(@args) };
+$loader = eval { Bio::DB::SeqFeature::Store::GFF3Loader->new(-store=>$db,
+							     -ignore_seqregion=>1)
+               };
+$loader->load($gff_file);
+ at f      = $db->get_features_by_name('Contig1');
+is(scalar @f,0);
+
 }




More information about the Bioperl-guts-l mailing list