[Bioperl-guts-l] [15415] bioperl-live/branches/branch-1-6: * delete Bio::DB::SeqFeature:: Store::DBI::Pg per Scott Cain
Christopher John Fields
cjfields at dev.open-bio.org
Wed Jan 21 11:44:37 EST 2009
Revision: 15415
Author: cjfields
Date: 2009-01-21 11:44:37 -0500 (Wed, 21 Jan 2009)
Log Message:
-----------
* delete Bio::DB::SeqFeature::Store::DBI::Pg per Scott Cain
* reconfigure Build.PL to remove said configuration
Modified Paths:
--------------
bioperl-live/branches/branch-1-6/Build.PL
Removed Paths:
-------------
bioperl-live/branches/branch-1-6/Bio/DB/SeqFeature/Store/DBI/Pg.pm
Deleted: bioperl-live/branches/branch-1-6/Bio/DB/SeqFeature/Store/DBI/Pg.pm
===================================================================
--- bioperl-live/branches/branch-1-6/Bio/DB/SeqFeature/Store/DBI/Pg.pm 2009-01-21 15:06:19 UTC (rev 15414)
+++ bioperl-live/branches/branch-1-6/Bio/DB/SeqFeature/Store/DBI/Pg.pm 2009-01-21 16:44:37 UTC (rev 15415)
@@ -1,1753 +0,0 @@
-package Bio::DB::SeqFeature::Store::DBI::Pg;
-use DBD::Pg qw(:pg_types);
-# $Id: Pg.pm 14656 2008-04-14 15:05:37Z lstein $
-
-=head1 NAME
-
-Bio::DB::SeqFeature::Store::DBI::Pg -- Mysql implementation of Bio::DB::SeqFeature::Store
-
-=head1 SYNOPSIS
-
- 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
- $f->start(100);
- $db->update($f) or die "Couldn't update!";
-
- # searching...
- # ...by id
- my @features = $db->fetch_many(@list_of_ids);
-
- # ...by name
- @features = $db->get_features_by_name('ZK909');
-
- # ...by alias
- @features = $db->get_features_by_alias('sma-3');
-
- # ...by type
- @features = $db->get_features_by_name('gene');
-
- # ...by location
- @features = $db->get_features_by_location(-seq_id=>'Chr1',-start=>4000,-end=>600000);
-
- # ...by attribute
- @features = $db->get_features_by_attribute({description => 'protein kinase'})
-
- # ...by the GFF "Note" field
- @result_list = $db->search_notes('kinase');
-
- # ...by 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
- $db->insert_sequence('Chr1','GATCCCCCGGGATTCCAAAA...');
- 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);
-
-=head1 DESCRIPTION
-
-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-E<gt>new() to do so.
-
-See L<Bio::DB::SeqFeature::Store> for complete usage instructions.
-
-=head2 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-E<gt>new(-adaptor=E<gt>'DBI::Pg', at 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.
-
-=cut
-
-use strict;
-
-use base 'Bio::DB::SeqFeature::Store';
-use Bio::DB::SeqFeature::Store::DBI::Iterator;
-use DBI;
-use Memoize;
-use Cwd 'abs_path';
-use Bio::DB::GFF::Util::Rearrange 'rearrange';
-use File::Spec;
-use constant DEBUG=>0;
-
-# from the MySQL documentation...
-# WARNING: if your sequence uses coordinates greater than 2 GB, you are out of luck!
-use constant MAX_INT => 2_147_483_647;
-use constant MIN_INT => -2_147_483_648;
-use constant MAX_BIN => 1_000_000_000; # size of largest feature = 1 Gb
-use constant MIN_BIN => 1000; # smallest bin we'll make - on a 100 Mb chromosome, there'll be 100,000 of these
-
-memoize('_typeid');
-memoize('_locationid');
-memoize('_attributeid');
-memoize('dump_path');
-
-###
-# object initialization
-#
-sub init {
- my $self = shift;
- my ($dsn,
- $is_temporary,
- $autoindex,
- $namespace,
- $dump_dir,
- $user,
- $pass,
- $dbi_options,
- $writeable,
- $create,
- $schema,
- ) = rearrange(['DSN',
- ['TEMP','TEMPORARY'],
- 'AUTOINDEX',
- 'NAMESPACE',
- ['DUMP_DIR','DUMPDIR','TMP','TMPDIR'],
- 'USER',
- ['PASS','PASSWD','PASSWORD'],
- ['OPTIONS','DBI_OPTIONS','DBI_ATTR'],
- ['WRITE','WRITEABLE'],
- 'CREATE',
- 'SCHEMA'
- ], at _);
-
-
- $dbi_options ||= {};
- $writeable = 1 if $is_temporary or $dump_dir;
-
- $dsn or $self->throw("Usage: ".__PACKAGE__."->init(-dsn => \$dbh || \$dsn)");
-
- my $dbh;
- if (ref $dsn) {
- $dbh = $dsn;
- } else {
- $dsn = "dbi:Pg:$dsn" unless $dsn =~ /^dbi:/;
- $dbh = DBI->connect($dsn,$user,$pass,$dbi_options) or $self->throw($DBI::errstr);
- }
- $self->{'original_arguments'} = {
- 'dsn' => $dsn,
- 'user' => $user,
- 'pass' => $pass,
- 'dbh_options' => $dbi_options,
- };
- $self->{dbh} = $dbh;
- $self->{dbh}->{InactiveDestroy} = 1;
- $self->{is_temp} = $is_temporary;
- $self->{namespace} = $namespace;
- $self->{writeable} = $writeable;
- $self->schema($schema) if ($schema);
-
- $self->default_settings;
- $self->autoindex($autoindex) if defined $autoindex;
- $self->dumpdir($dump_dir) if $dump_dir;
- if ($self->is_temp) {
- $self->init_tmp_database();
- } elsif ($create) {
- $self->init_database('erase');
- }
-}
-
-sub writeable { shift->{writeable} }
-
-sub can_store_parentage { 1 }
-
-sub table_definitions {
- my $self = shift;
- return {
- feature => <<END,
-(
- id serial primary key,
- typeid int not null,
- seqid int,
- start int,
- "end" int,
- strand int default 0,
- tier int,
- bin int,
- indexed int default 1,
- object bytea not null
-);
- CREATE INDEX feature_stuff ON feature(seqid,tier,bin,typeid);
- CREATE INDEX feature_typeid ON feature(typeid);
-END
-
- locationlist => <<END,
-(
- id serial primary key,
- seqname varchar(50) not null
-); CREATE INDEX locationlist_seqname ON locationlist(seqname);
-END
-
- typelist => <<END,
-(
- id serial primary key,
- tag varchar(100) not null
-); CREATE INDEX typelist_tab ON typelist(tag);
-END
- name => <<END,
-(
- id int not null,
- name varchar(128) not null,
- display_name int default 0
-);
- CREATE INDEX name_id ON name(id);
- CREATE INDEX name_name ON name(name);
-END
-
- attribute => <<END,
-(
- id int not null,
- attribute_id int not null,
- attribute_value text
-);
- CREATE INDEX attribute_id ON attribute(id);
- CREATE INDEX attribute_id_val ON attribute(attribute_id,SUBSTR(attribute_value, 1, 10));
-END
-
- attributelist => <<END,
-(
- id serial primary key,
- tag varchar(50) not null
-);
- CREATE INDEX attributelist_tag ON attributelist(tag);
-END
- parent2child => <<END,
-(
- id int not null,
- child int not null
-);
- CREATE INDEX parent2child_id_child ON parent2child(id,child);
-END
-
- meta => <<END,
-(
- name varchar(128) primary key,
- value varchar(128) not null
-)
-END
- sequence => <<END,
-(
- id int not null,
- "offset" int not null,
- sequence text,
- primary key(id,"offset")
-)
-END
- };
-}
-
-###
-# default settings -- will create and populate meta table if needed
-#
-sub default_settings {
- my $self = shift;
- $self->maybe_create_meta();
- $self->SUPER::default_settings;
- $self->autoindex(1);
- $self->dumpdir(File::Spec->tmpdir);
-}
-
-
-###
-# retrieve database handle
-#
-sub dbh {
- my $self = shift;
- my $d = $self->{dbh};
- $self->{dbh} = shift if @_;
@@ Diff output truncated at 10000 characters. @@
More information about the Bioperl-guts-l
mailing list