MUSIGHBA1 no longer works as a primary ID, LOCUS apparently is not indexed; fixing
[bioperl-live.git] / Bio / DB / Ace.pm
blob87dac21e7627b9db922bd7f0a166f35f87fd4311
3 # BioPerl module for Bio::DB::Ace
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Ewan Birney <birney@ebi.ac.uk>
9 # Copyright Ewan Birney
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::DB::Ace - Database object interface to ACeDB servers
19 =head1 SYNOPSIS
21 $db = Bio::DB::Ace->new( -server => 'myace.server.com', port => '120000');
23 $seq = $db->get_Seq_by_id('J00522'); # Unique ID
25 # or ...
27 $seq = $db->get_Seq_by_acc('J00522'); # Accession Number
29 =head1 DESCRIPTION
31 This provides a standard BioPerl database access to Ace, using Lincoln Steins
32 excellent AcePerl module. You need to download and install the aceperl module from
34 http://stein.cshl.org/AcePerl/
36 before this interface will work.
38 This interface is designed at the moment to work through a aceclient/aceserver
39 type mechanism
41 =head1 INSTALLING ACEPERL
43 Download the latest aceperl tar file, gunzip/untar and cd into the directory.
44 This is a standard CPAN-style directory, so if you go
46 Perl Makefile.PL
47 make
48 <become root>
49 make install
51 Then you will have installed Aceperl. Use the PREFIX mechanism to install elsewhere.
53 =head1 FEEDBACK
55 =head2 Mailing Lists
57 User feedback is an integral part of the evolution of this
58 and other Bioperl modules. Send your comments and suggestions preferably
59 to one of the Bioperl mailing lists.
60 Your participation is much appreciated.
62 bioperl-l@bioperl.org - General discussion
63 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
65 =head2 Support
67 Please direct usage questions or support issues to the mailing list:
69 I<bioperl-l@bioperl.org>
71 rather than to the module maintainer directly. Many experienced and
72 reponsive experts will be able look at the problem and quickly
73 address it. Please include a thorough description of the problem
74 with code and data examples if at all possible.
76 =head2 Reporting Bugs
78 Report bugs to the Bioperl bug tracking system to help us keep track
79 the bugs and their resolution. Bug reports can be submitted via the
80 web:
82 https://redmine.open-bio.org/projects/bioperl/
84 =head1 AUTHOR - Ewan Birney
86 Email birney@ebi.ac.uk
88 =head1 APPENDIX
90 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
92 =cut
94 # Let the code begin...
96 package Bio::DB::Ace;
97 use strict;
99 # Object preamble - inherits from Bio::DB::RandomAccessI
101 use Bio::Seq;
103 BEGIN {
104 eval "require Ace;";
105 if( $@) {
106 print STDERR "You have not installed Ace.pm.\n Read the docs in Bio::DB::Ace for more information about how to do this.\n It is very easy\n\nError message $@";
111 use base qw(Bio::DB::RandomAccessI);
113 # new() is inherited from Bio::DB::Abstract
115 # _initialize is where the heavy stuff will happen when new is called
117 sub new {
118 my($class,@args) = @_;
119 my $self = $class->SUPER::new(@args);
120 my ($host,$port) = $self->_rearrange([qw(
121 HOST
122 PORT
124 @args,
127 if( !$host || !$port ) {
128 $self->throw("Must have a host and port for an acedb server to work");
131 my $aceobj = Ace->connect(-host => $host,
132 -port => $port) ||
133 $self->throw("Could not make acedb object to $host:$port");
135 $self->_aceobj($aceobj);
138 return $self;
141 =head2 get_Seq_by_id
143 Title : get_Seq_by_id
144 Usage : $seq = $db->get_Seq_by_id($uid);
145 Function: Gets a Bio::Seq object by its unique identifier/name
146 Returns : a Bio::Seq object
147 Args : $id : the id (as a string) of the desired sequence entry
149 =cut
151 sub get_Seq_by_id {
152 my $self = shift;
153 my $id = shift or $self->throw("Must supply an identifier!\n");
154 my $ace = $self->_aceobj();
155 my ($seq,$dna,$out);
157 $seq = $ace->fetch( 'Sequence' , $id);
159 # get out the sequence somehow!
161 $dna = $seq->asDNA();
163 $dna =~ s/^>.*\n//;
164 $dna =~ s/\n//g;
166 $out = Bio::Seq->new( -id => $id, -alphabet => 'Dna', -seq => $dna, -name => "Sequence from Bio::DB::Ace $id");
167 return $out;
171 =head2 get_Seq_by_acc
173 Title : get_Seq_by_acc
174 Usage : $seq = $db->get_Seq_by_acc($acc);
175 Function: Gets a Bio::Seq object by its accession number
176 Returns : a Bio::Seq object
177 Args : $acc : the accession number of the desired sequence entry
180 =cut
182 sub get_Seq_by_acc {
184 my $self = shift;
185 my $acc = shift or $self->throw("Must supply an accession number!\n");
187 return $self->get_Seq_by_id($acc);
190 =head2 _aceobj
192 Title : _aceobj
193 Usage : $ace = $db->_aceobj();
194 Function: Get/Set on the acedb object
195 Returns : Ace object
196 Args : New value of the ace object
198 =cut
200 sub _aceobj {
201 my ($self,$arg) = @_;
203 if( $arg ) {
204 $self->{'_aceobj'} = $arg;
207 return $self->{'_aceobj'};