[Bioperl-guts-l] bioperl-live/Bio/FeatureIO gff.pm, 1.28, 1.29 interpro.pm, 1.3, 1.4

Allen Day allenday at pub.open-bio.org
Mon Dec 13 01:54:50 EST 2004


Update of /home/repository/bioperl/bioperl-live/Bio/FeatureIO
In directory pub.open-bio.org:/tmp/cvs-serv30113/Bio/FeatureIO

Modified Files:
	gff.pm interpro.pm 
Log Message:
consolidated seq_id/seqid/id to seq_id.


Index: gff.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/FeatureIO/gff.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** gff.pm	13 Dec 2004 03:52:24 -0000	1.28
--- gff.pm	13 Dec 2004 06:54:48 -0000	1.29
***************
*** 8,12 ****
  
    my $feature; #get a Bio::SeqFeature::Annotated somehow
!   my $featureOut = Bio::FeatureIO->new(-format => 'gff', -version => 3, -fh => \*STDOUT);
    $featureOut->write_feature($feature);
  
--- 8,17 ----
  
    my $feature; #get a Bio::SeqFeature::Annotated somehow
!   my $featureOut = Bio::FeatureIO->new(-format => 'gff',
!                                        -version => 3,
!                                        -fh => \*STDOUT,
!                                        -validate_terms => 1, #boolean. validate ontology
!                                                              #terms online?  default false.
!                                       );
    $featureOut->write_feature($feature);
  
***************
*** 89,92 ****
--- 94,98 ----
  
    $self->version($arg{-version} || DEFAULT_VERSION);
+   $self->validate($arg{-validate_terms} || 0);
  
    #read headers
***************
*** 147,151 ****
    }
  
!   my $seq    = $feature->seqid->value;
    my $source = $feature->source->value;
    my $type   = $feature->type->name;
--- 153,157 ----
    }
  
!   my $seq    = $feature->seq_id->value;
    my $source = $feature->source->value;
    my $type   = $feature->type->name;
***************
*** 173,181 ****
  sub _write_feature_3 {
    my($self,$feature) = @_;
!      # it is a mystery to Chad which applies here: id(), seqid() (deprecated), seqid(), ???
!      # it is also a mystery why calls violating Demeter would be made when there are no assurances
!      # the first call in the chain will succeed
!      # I fixed those.
!   my $seq    = $feature->seqid->value || $feature->id;
    my $source;
    if ($feature->source()) {
--- 179,183 ----
  sub _write_feature_3 {
    my($self,$feature) = @_;
!   my $seq    = $feature->seq_id->value;
    my $source;
    if ($feature->source()) {
***************
*** 255,259 ****
  
    return undef unless $gff_string;
!     
    if($gff_string =~ /^##/ or $gff_string =~ /^>/){
      $self->_handle_directive($gff_string);
--- 257,261 ----
  
    return undef unless $gff_string;
! 
    if($gff_string =~ /^##/ or $gff_string =~ /^>/){
      $self->_handle_directive($gff_string);
***************
*** 308,312 ****
  	push(@all_feats, $feat);
      }
!     
      # assemble the top-level features
      foreach $feat (@all_feats) {
--- 310,314 ----
  	push(@all_feats, $feat);
      }
! 
      # assemble the top-level features
      foreach $feat (@all_feats) {
***************
*** 391,395 ****
    my($seq,$source,$type,$start,$end,$score,$strand,$phase,$attribute_string) = split /\t/, $feature_string;
  
!   $feat->seqid($seq);
    $feat->source($source);
    $feat->start($start) unless $start eq '.';
--- 393,397 ----
    my($seq,$source,$type,$start,$end,$score,$strand,$phase,$attribute_string) = split /\t/, $feature_string;
  
!   $feat->seq_id($seq);
    $feat->source($source);
    $feat->start($start) unless $start eq '.';
***************
*** 398,417 ****
    $feat->score($score);
    $feat->phase($phase);
- #  $feat->frame($phase); NO!
  
!   my $feature_type;
!   if($type =~ /^\D+:\d+$/){
!     #looks like an identifier
!     ($feature_type) = $self->so->find_terms(-identifier => $type);
    } else {
-     #looks like a name
-     ($feature_type) = $self->so->find_terms(-name => $type);
-   }
  
!   if(!$feature_type){
!     $self->throw("couldn't find ontology term for '$type'.");
    }
!   my $fta = Bio::Annotation::OntologyTerm->new();
!   $fta->term($feature_type);
    $feat->type($fta);
  
--- 400,431 ----
    $feat->score($score);
    $feat->phase($phase);
  
!   my $fta = Bio::Annotation::OntologyTerm->new();
! 
!   if($self->validate()){
! 
!     my $feature_type;
!     if($type =~ /^\D+:\d+$/){
!       #looks like an identifier
!       ($feature_type) = $self->so->find_terms(-identifier => $type);
!     } else {
!       #looks like a name
!       ($feature_type) = $self->so->find_terms(-name => $type);
!     }
! 
!     if(!$feature_type){
!       $self->throw("couldn't find ontology term for '$type'.");
!     }
!     $fta->term($feature_type);
    } else {
  
!     if($type =~ /^\D+:\d+$/){
!       #looks like an identifier
!       $fta->identifier($type)
!     } else {
!       $fta->name($type);
!     }
    }
! 
    $feat->type($fta);
  
***************
*** 444,454 ****
    #Handle Ontology_term attributes
    if($attr{Ontology_term}){
- 
      foreach my $id (@{ $attr{Ontology_term} }){
!       my $ont_name = Bio::Ontology::OntologyStore->guess_ontology($id);
!       my $ont = Bio::Ontology::OntologyStore->get_ontology($ont_name);
!       my($term) = $ont->find_terms(-identifier => $id);
        my $a = Bio::Annotation::OntologyTerm->new();
!       $a->term($term);
        $feat->add_Annotation('Ontology_term',$a);
      }
--- 458,474 ----
    #Handle Ontology_term attributes
    if($attr{Ontology_term}){
      foreach my $id (@{ $attr{Ontology_term} }){
! 
        my $a = Bio::Annotation::OntologyTerm->new();
! 
!       if($self->validate()){
!         my $ont_name = Bio::Ontology::OntologyStore->guess_ontology($id);
!         my $ont = Bio::Ontology::OntologyStore->get_ontology($ont_name);
!         my($term) = $ont->find_terms(-identifier => $id);
!         $a->term($term);
!       } else {
!         $a->identifier($id);
!       }
! 
        $feat->add_Annotation('Ontology_term',$a);
      }
***************
*** 484,488 ****
          $strand = '';
        }
!       
        $a->strand($strand) if $strand;
        $feat->add_Annotation('Target',$a); 
--- 504,508 ----
          $strand = '';
        }
! 
        $a->strand($strand) if $strand;
        $feat->add_Annotation('Target',$a); 
***************
*** 593,596 ****
--- 613,634 ----
    return $self->{so};
  }
+ 
+ =head2 validate()
+ 
+  Usage   : $obj->validate($newval)
+  Function: true if encountered ontology terms in next_feature()
+            mode should be validated.
+  Returns : value of validate (a scalar)
+  Args    : on set, new value (a scalar or undef, optional)
+ 
+ 
+ =cut
+ 
+ sub validate {
+   my($self,$val) = @_;
+   $self->{'validate'} = $val if defined($val);
+   return $self->{'validate'};
+ }
+ 
  
  1;

Index: interpro.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/FeatureIO/interpro.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** interpro.pm	13 Dec 2004 03:52:24 -0000	1.3
--- interpro.pm	13 Dec 2004 06:54:48 -0000	1.4
***************
*** 75,79 ****
  
          my $t = Bio::Annotation::OntologyTerm->new(-identifier => 'SO:0000001', -name => 'region');
!         $feature->add_Annotation('type',$t);
  
          my $c = Bio::Annotation::Comment->new(-tagname => 'comment', -text => $iNode->getAttribute('name'));
--- 75,79 ----
  
          my $t = Bio::Annotation::OntologyTerm->new(-identifier => 'SO:0000001', -name => 'region');
!         $feature->add_Annotation('feature_type',$t);
  
          my $c = Bio::Annotation::Comment->new(-tagname => 'comment', -text => $iNode->getAttribute('name'));



More information about the Bioperl-guts-l mailing list