lib/Bio/DB/Ace.pm

filter: Statementstmt 33.3% 13 / 39 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 4 / 8 Podpod 100% 3 / 3 totaltotal 30.0% 21 / 70 CC 8 SCAR 21.1
CC
8
Cov
25%
new
20.0
get_Seq_by_id
6.0
get_Seq_by_acc
6.0
CRAP 8.2
« lib/Bio/DB/GFF/Adaptor/dbi/oracleace.pm ↑ Summary lib/Bio/DB/GFF/Adaptor/ace.pm »
1  
2 #
3 # BioPerl module for Bio::DB::Ace
4 #
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 #
7 # Cared for by Ewan Birney <birney@ebi.ac.uk>
8 #
9 # Copyright Ewan Birney
10 #
11 # You may distribute this module under the same terms as perl itself
12  
13 # POD documentation - main docs before the code
14  
15 =head1 NAME
16  
17 Bio::DB::Ace - Database object interface to ACeDB servers
18  
19 =head1 SYNOPSIS
20  
21 $db = Bio::DB::Ace->new( -server => 'myace.server.com', port => '120000');
22  
23 $seq = $db->get_Seq_by_id('J00522'); # Unique ID
24  
25 # or ...
26  
27 $seq = $db->get_Seq_by_acc('J00522'); # Accession Number
28  
29 =head1 DESCRIPTION
30  
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
33  
34 http://stein.cshl.org/AcePerl/
35  
36 before this interface will work.
37  
38 This interface is designed at the moment to work through a aceclient/aceserver
39 type mechanism
40  
41 =head1 INSTALLING ACEPERL
42  
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
45  
46 Perl Makefile.PL
47 make
48 <become root>
49 make install
50  
51 Then you will have installed Aceperl. Use the PREFIX mechanism to install elsewhere.
52  
53 =head1 FEEDBACK
54  
55 =head2 Mailing Lists
56  
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.
61  
62 bioperl-l@bioperl.org - General discussion
63 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
64  
65 =head2 Support
66  
67 Please direct usage questions or support issues to the mailing list:
68  
69 I<bioperl-l@bioperl.org>
70  
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.
75  
76 =head2 Reporting Bugs
77  
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:
81  
82 https://github.com/bioperl/bioperl-live/issues
83  
84 =head1 AUTHOR - Ewan Birney
85  
86 Email birney@ebi.ac.uk
87  
88 =head1 APPENDIX
89  
90 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
91  
92 =cut
93  
94 # Let the code begin...
95  
96 package Bio::DB::Ace;
97 1 $Bio::DB::Ace::VERSION = '1.7.3';
98 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
99  
100 # Object preamble - inherits from Bio::DB::RandomAccessI
101  
102 1 ▶use Bio::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
103  
104 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=8.1
105 1 eval "require Ace;";
106 1 ▶ if( $@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
107 0 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 $@";
108 }
109 }
110  
111  
112 1 ▶use base qw(Bio::DB::RandomAccessI);
Subroutine BEGIN: called CC=1 SCAR=0.0
113  
114 # new() is inherited from Bio::DB::Abstract
115  
116 # _initialize is where the heavy stuff will happen when new is called
117  
118 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod documented
119 0 my($class,@args) = @_;
120 0 my $self = $class->SUPER::new(@args);
121 0 my ($host,$port) = $self->_rearrange([qw(
122 HOST
123 PORT
124 )],
125 @args,
126 );
127  
128 0 ▶ if( !$host || !$port ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($host and $port) 0 0 0
Condition0%0/3
$host and $port
!ll&&!rl&&r
000
MC/DC0%0/2
$host and $port
$host $port
Truth table0%0/3
A and B
A= $hostB= $port
ABresult
0X0
100
111
129 0 $self->throw("Must have a host and port for an acedb server to work");
130 }
131  
132 0 ▶ my $aceobj = Ace->connect(-host => $host,
Condition0%0/3
'Ace'->connect('-host', $host, '-port', $port) || $self->throw("Could not make acedb object to ${host}:$port")
l!l&&r!l&&!r
000
MC/DC0%0/2
'Ace'->connect('-host', $host, '-port', $port) || $self->throw("Could not make acedb object to ${host}:$port")
'Ace'->connect('-host', $host, '-port', $port) $self->throw("Could not make acedb object to ${host}:$port")
Truth table0%0/3
A || B
A= 'Ace'->connect('-host', $host, '-port', $port)B= $self->throw("Could not make acedb object to ${host}:$port")
ABresult
1X1
011
000
133 -port => $port) ||
134 $self->throw("Could not make acedb object to $host:$port");
135  
136 0 $self->_aceobj($aceobj);
137  
138  
139 0 return $self;
140 }
141  
142 =head2 get_Seq_by_id
143  
144 Title : get_Seq_by_id
145 Usage : $seq = $db->get_Seq_by_id($uid);
146 Function: Gets a Bio::Seq object by its unique identifier/name
147 Returns : a Bio::Seq object
148 Args : $id : the id (as a string) of the desired sequence entry
149  
150 =cut
151  
152 0 ▶sub get_Seq_by_id {
Subroutine get_Seq_by_id: not called CC=2 SCAR=17.9
Pod documented
153 0 my $self = shift;
154 0 ▶ my $id = shift or $self->throw("Must supply an identifier!\n");
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or $self->throw("Must supply an identifier!\n") 0 0 0
155 0 my $ace = $self->_aceobj();
156 0 my ($seq,$dna,$out);
157  
158 0 $seq = $ace->fetch( 'Sequence' , $id);
159  
160 # get out the sequence somehow!
161  
162 0 $dna = $seq->asDNA();
163  
164 0 $dna =~ s/^>.*\n//;
165 0 $dna =~ s/\n//g;
166  
167 0 $out = Bio::Seq->new( -id => $id, -alphabet => 'Dna', -seq => $dna, -name => "Sequence from Bio::DB::Ace $id");
168 0 return $out;
169  
170 }
171  
172 =head2 get_Seq_by_acc
173  
174 Title : get_Seq_by_acc
175 Usage : $seq = $db->get_Seq_by_acc($acc);
176 Function: Gets a Bio::Seq object by its accession number
177 Returns : a Bio::Seq object
178 Args : $acc : the accession number of the desired sequence entry
179  
180  
181 =cut
182  
183 0 ▶sub get_Seq_by_acc {
Subroutine get_Seq_by_acc: not called CC=2 SCAR=17.9
Pod documented
184  
185 0 my $self = shift;
186 0 ▶ my $acc = shift or $self->throw("Must supply an accession number!\n");
Branch: 1 branch
BranchTrueFalseTotal
my $acc = shift() or $self->throw("Must supply an accession number!\n") 0 0 0
187  
188 0 return $self->get_Seq_by_id($acc);
189 }
190  
191 =head2 _aceobj
192  
193 Title : _aceobj
194 Usage : $ace = $db->_aceobj();
195 Function: Get/Set on the acedb object
196 Returns : Ace object
197 Args : New value of the ace object
198  
199 =cut
200  
201 0 ▶sub _aceobj {
Subroutine _aceobj: not called CC=2 SCAR=17.9
202 0 my ($self,$arg) = @_;
203  
204 0 ▶ if( $arg ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 0 0 0
205 0 $self->{'_aceobj'} = $arg;
206 }
207  
208 0 return $self->{'_aceobj'};
209 }
210  
211 1 1;
« lib/Bio/DB/GFF/Adaptor/dbi/oracleace.pm ↑ Summary lib/Bio/DB/GFF/Adaptor/ace.pm »