Module:Bio::DB::SeqFeature::Store

From BioPerl

Jump to: navigation, search


Pdoc documentation: Bio::DB::SeqFeature::Store CPAN documentation: Bio::DB::SeqFeature::Store

Bio::DB::SeqFeature 
The feature object customized to work well with DB::SeqFeature::Store
Bio::DB::SeqFeature::Store::GFF3Loader 
The GFF to Bio::DB::SeqFeature loader object. Envoked from the command-line via bp_seqfeature_load.PLS.

Notes

See also: HOWTO:Feature-Annotation.

To get an overview of an existing DB::SeqFeature::Store database

The following code demonstrates how to get an overview of an existing DB::SeqFeature::Store database:

#!/usr/bin/perl -w
 
use strict;
use Bio::DB::SeqFeature::Store;
 
my $db = Bio::DB::SeqFeature::Store->
  new( -adaptor => 'DBI::mysql',
       -dsn     => 'dbi:mysql:database:host',
       -user => 'my_mysql_username',
       -pass => 'my_mysql_password',
     );
 
## $db is now a DB::SeqFeature::Store object 
 
## Are sub-features being indexed?
print "Indexed sub-features? : ",
  $db->index_subfeatures, "\n";
 
## What serializer is being used?
print "The serializer is : ",
  $db->serializer, "\n";
 
## List all the feature types in the database:
print "Feature types:\n";
print join("\n", $db->types), "\n";
 
## List how many there are for each feature type in the database
print "Feature type counts:\n";
my %types = $db->types(-count => 1);
print join("\n", map { $_ . "\t". "$types{$_}" } keys %types), "\n";
 
## List the feature attributes (tags) in the database:
print "Attributes:\n";
print join("\n", $db->attributes), "\n";
 
## How many sequence ids in the database:
print "There are : ", scalar($db->seq_ids), " sequences in the database\n";
 
## How many features in the database:
print "There are : ", scalar($db->features), " features in the database\n";

Simple parsing

Sometimes wrestling with Bio::DB::SeqFeature::Store is a waste of time. Here is an example of code that 'gets the job done', and avoids using BioPerl to handle the GFF. Note this only handles the simplest cases w/o sequences and directives.

#!/usr/bin/perl -w
 
use strict;
 
use Bio::SeqIO;
 
open( GFF, '<', 'some.gff')
  or die "failed to open file : $!\n";
 
my $seqIO = Bio::SeqIO->
  new( -file => 'some.fa',
       -format => 'fasta');
 
my %scaff_lookup;
 
while(<GFF>){
  chomp;
  my @fields = split;
  my %attributes = split(/;|=/, $fields[8]);
 
  $scaff_lookup{$attributes{'ID'}} = $fields[0];
}
 
while(my $seqO = $seqIO->next_seq){
  print
    join("\t",
	 $seqO->id,
	 $seqO->length,
	 $scaff_lookup{$seqO->id}
	), "\n";
}
 
warn "OK\n";
Personal tools