Langue: en

Version: 2010-05-19 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)


Bio::DB::SeqFeature::Store::DBI::Pg -- Mysql implementation of Bio::DB::SeqFeature::Store


   use Bio::DB::SeqFeature::Store;
   # Open the sequence database
   my $db = Bio::DB::SeqFeature::Store->new(-adaptor => 'DBI::Pg',
                                           -dsn     => 'dbi:Pg:test');
   # get a feature from somewhere
   my $feature = Bio::SeqFeature::Generic->new(...);
   # store it
   $db->store($feature) or die "Couldn't store!";
   # primary ID of the feature is changed to indicate its primary ID
   # in the database...
   my $id = $feature->primary_id;
   # get the feature back out
   my $f  = $db->fetch($id);
   # change the feature and update it
   $db->update($f) or die "Couldn't update!";
   # searching...
   # id
   my @features = $db->fetch_many(@list_of_ids);
   # name
   @features = $db->get_features_by_name('ZK909');
   # alias
   @features = $db->get_features_by_alias('sma-3');
   # type
   @features = $db->get_features_by_name('gene');
   # location
   @features = $db->get_features_by_location(-seq_id=>'Chr1',-start=>4000,-end=>600000);
   # attribute
   @features = $db->get_features_by_attribute({description => 'protein kinase'})
   # the GFF "Note" field
   @result_list = $db->search_notes('kinase');
   # arbitrary combinations of selectors
   @features = $db->features(-name => $name,
                             -type => $types,
                             -seq_id => $seqid,
                             -start  => $start,
                             -end    => $end,
                             -attributes => $attributes);
   # ...using an iterator
   my $iterator = $db->get_seq_stream(-name => $name,
                                      -type => $types,
                                      -seq_id => $seqid,
                                      -start  => $start,
                                      -end    => $end,
                                      -attributes => $attributes);
   while (my $feature = $iterator->next_seq) {
     # do something with the feature
   # ...limiting the search to a particular region
   my $segment  = $db->segment('Chr1',5000=>6000);
   my @features = $segment->features(-type=>['mRNA','match']);
   # getting & storing sequence information
   # Warning: this returns a string, and not a PrimarySeq object
   my $sequence = $db->fetch_sequence('Chr1',5000=>6000);
   # what feature types are defined in the database?
   my @types    = $db->types;
   # create a new feature in the database
   my $feature = $db->new_feature(-primary_tag => 'mRNA',
                                  -seq_id      => 'chr3',
                                  -start      => 10000,
                                  -end        => 11000);


Bio::DB::SeqFeature::Store::Pg is the Mysql adaptor for Bio::DB::SeqFeature::Store. You will not create it directly, but instead use Bio::DB::SeqFeature::Store->new() to do so.

See Bio::DB::SeqFeature::Store for complete usage instructions.

Using the Mysql adaptor

Before you can use the adaptor, you must use the Pgadmin tool to create a database and establish a user account with write permission. In order to use ``fast'' loading, the user account must have ``file'' privileges.

To establish a connection to the database, call Bio::DB::SeqFeature::Store->new(-adaptor=>'DBI::Pg',@more_args). The additional arguments are as follows:

   Argument name       Description
   -------------       -----------
  -dsn              The database name. You can abbreviate 
                    "dbi:Pg:foo" as "foo" if you wish.
  -user             Username for authentication.
  -pass             Password for authentication.
  -namespace        A prefix to attach to each table. This allows you
                    to have several virtual databases in the same
                    physical database.
  -temp             Boolean flag. If true, a temporary database
                    will be created and destroyed as soon as
                    the Store object goes out of scope. (synonym -temporary)
  -autoindex        Boolean flag. If true, features in the database will be
                    reindexed every time they change. This is the default.
  -tmpdir           Directory in which to place temporary files during "fast" loading.
                    Defaults to File::Spec->tmpdir(). (synonyms -dump_dir, -dumpdir, -tmp)
  -dbi_options      A hashref to pass to DBI->connect's 4th argument, the "attributes."
                    (synonyms -options, -dbi_attr)
  -write            Pass true to open database for writing or updating.

If successful, a new instance of Bio::DB::SeqFeature::Store::DBI::Pg will be returned.

In addition to the standard methods supported by all well-behaved Bio::DB::SeqFeature::Store databases, several following adaptor-specific methods are provided. These are described in the next sections.


  Title   : types
  Usage   : @type_list = $db->types
  Function: Get all the types in the database
  Returns : array of Bio::DB::GFF::Typename objects
  Args    : none
  Status  : public