Bio-FeatureIO

 view release on metacpan or  search on metacpan

lib/Bio/FeatureIO.pm  view on Meta::CPAN

300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
    my ($self) = $class->SUPER::new(@args); 
    $self->_initialize(@args);
    return $self;
 
  } else {
 
        my %param = @args;
 
        @param{ map { lc $_ } keys %param } = values %param; # lowercase keys
        my $format = $param{'-format'} ||
      $class->_guess_format( $param{-file} || $ARGV[0] );
         
        if( ! $format ) {
      if ($param{-file}) {
        $format = $class->_guess_format($param{-file});
      } elsif ($param{-fh}) {
        $format = $class->_guess_format(undef);
      }
        }
        $format = "\L$format"# normalize capitalization to lower case
        return unless( $class->_load_format_module($format) );
        return "Bio::FeatureIO::$format"->new(@args);
 
  }
}
 
=head2 newFh

lib/Bio/FeatureIO.pm  view on Meta::CPAN

483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
Args    : newvalue (optional)
 
 
=cut
 
sub _filehandle {
    my ($self,@args) = @_;
    return $self->_fh(@args);
}
 
=head2 _guess_format
 
 Title   : _guess_format
 Usage   : $obj->_guess_format($filename)
 Function: guess format based on file suffix
 Example :
 Returns : guessed format of filename (lower case)
 Args    :
 Notes   : See "SUPPORTED FORMATS"
 
=cut
 
sub _guess_format {
   my $class = shift;
   return unless $_ = shift;
   return 'gff'     if /\.gff3?$/i;
   return 'gff'     if /\.gtf$/i;
   return 'bed'     if /\.bed$/i;
   return 'ptt'     if /\.ptt$/i;
 
   return 'gff'; #the default
}

lib/Bio/FeatureIO/gff.pm  view on Meta::CPAN

665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
    $feat->add_Annotation('Dbxref',$a);
  }
}
 
#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);
  }
}



( run in 0.323 second using v1.01-cache-2.11-cpan-e5176c747c2 )