comparison variant_effect_predictor/Bio/DB/XEMBL.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 #
2 # $Id: XEMBL.pm,v 1.3 2002/10/22 07:38:29 lapp Exp $
3 #
4 # BioPerl module for Bio::DB::XEMBL
5 #
6 # Cared for by Lincoln Stein
7 #
8 # Copyright Lincoln Stein
9 #
10 # You may distribute this module under the same terms as perl itself
11
12 # POD documentation - main docs before the code
13
14 =head1 NAME
15
16 Bio::DB::XEMBL - Database object interface for XEMBL entry retrieval
17
18 =head1 SYNOPSIS
19
20 use Bio::DB::XEMBL;
21
22 $embl = new Bio::DB::XEMBL;
23
24 # remember that XEMBL_ID does not equal GenBank_ID!
25 $seq = $embl->get_Seq_by_id('BUM'); # EMBL ID
26 print "cloneid is ", $seq->id, "\n";
27
28 # or changeing to accession number and Fasta format ...
29 $seq = $embl->get_Seq_by_acc('J02231'); # XEMBL ACC
30 print "cloneid is ", $seq->id, "\n";
31
32 # especially when using versions, you better be prepared
33 # in not getting what what want
34 eval {
35 $seq = $embl->get_Seq_by_version('J02231.1'); # XEMBL VERSION
36 }
37 print "cloneid is ", $seq->id, "\n" unless $@;
38
39 my $seqio = $embl->get_Stream_by_batch(['U83300','U83301','U83302']);
40 while( my $clone = $seqio->next_seq ) {
41 print "cloneid is ", $clone->id, "\n";
42 }
43
44 =head1 DESCRIPTION
45
46 Allows the dynamic retrieval of Bio::Seq objects from the XEMBL
47 database. See L<Bio::Seq> for details.
48
49 =head1 FEEDBACK
50
51 =head2 Mailing Lists
52
53 User feedback is an integral part of the evolution of this and other
54 Bioperl modules. Send your comments and suggestions preferably to one
55 of the Bioperl mailing lists. Your participation is much appreciated.
56
57 bioperl-l@bioperl.org - General discussion
58 http://bio.perl.org/MailList.html - About the mailing lists
59
60 =head2 Reporting Bugs
61
62 Report bugs to the Bioperl bug tracking system to help us keep track
63 the bugs and their resolution.
64 Bug reports can be submitted via email or the web:
65
66 bioperl-bugs@bio.perl.org
67 http://bugzilla.bioperl.org/
68
69 =head1 AUTHOR - Lincoln Stein
70
71 Email Lincoln Stein E<lt>lstein@cshl.orgE<gt>
72
73 =head1 APPENDIX
74
75 The rest of the documentation details each of the object
76 methods. Internal methods are usually preceded with a _
77
78 =cut
79
80 # Let the code begin...
81
82 package Bio::DB::XEMBL;
83 use strict;
84 use Bio::DB::RandomAccessI;
85 use Bio::DB::XEMBLService 'getNucSeq';
86 # bsml parser appears broken...
87 use Bio::SeqIO::bsml;
88 use File::Temp 'tempfile';
89 use vars qw(@ISA $MODVERSION);
90
91 @ISA = qw(Bio::DB::RandomAccessI);
92 $MODVERSION = '0.1';
93
94 sub new {
95 my ($class, @args ) = @_;
96 my $self = $class->SUPER::new(@args);
97 return $self;
98 }
99
100 =head2 get_Seq_by_id
101
102 Title : get_Seq_by_id
103 Usage : $seq = $db->get_Seq_by_id('ROA1_HUMAN')
104 Function: Gets a Bio::Seq object by its name
105 Returns : a Bio::Seq object
106 Args : the id (as a string) of a sequence
107 Throws : "id does not exist" exception
108
109
110 =cut
111
112 sub get_Seq_by_id {
113 my ($self,@args) = @_;
114 my $seqio = $self->get_Stream_by_batch([@args]);
115 return $seqio->next_seq;
116 }
117
118 =head2 get_Stream_by_batch
119
120 Title : get_Stream_by_batch
121 Usage : $seq = $db->get_Stream_by_batch($ref);
122 Function: Retrieves Seq objects from XEMBL 'en masse', rather than one
123 at a time. Currently this is not particularly efficient, as
124 it loads the entire result into memory and parses it.
125 Example :
126 Returns : a Bio::SeqIO stream object
127 Args : $ref : an array reference containing a list of unique
128 ids/accession numbers.
129
130 =cut
131
132 sub get_Stream_by_batch {
133 my ($self, $ids) = @_;
134 $self->throw("expected an array ref, but got $ids")
135 unless ref($ids) eq 'ARRAY';
136 my @args = @$ids;
137 my $result = getNucSeq(SOAP::Data->name(format=>'bsml'),
138 SOAP::Data->name(ids=>"@args"))
139 or $self->throw('id does not exist');
140 my($fh,$filename) = tempfile(File::Spec->tmpdir . '/bsmlXXXXXX',SUFFIX=>'.bsml');
141 print $fh $result;
142 close $fh;
143 my $seqio = Bio::SeqIO->new(-file=>$filename,-format=>'bsml');
144 unlink $filename;
145 $seqio;
146 }
147
148 *get_Stream_by_id = \&get_Stream_by_batch;
149
150 =head2 get_Seq_by_acc
151
152 Title : get_Seq_by_acc
153 Usage : $seq = $db->get_Seq_by_acc('X77802');
154 Function: Gets a Bio::Seq object by accession number
155 Returns : A Bio::Seq object
156 Args : accession number (as a string)
157 Throws : "acc does not exist" exception
158
159
160 =cut
161
162 sub get_Seq_by_acc{
163 my ($self,@args) = @_;
164 return $self->get_Seq_by_id(@args);
165 }
166
167 =head2 get_Seq_by_version
168
169 Title : get_Seq_by_version
170 Usage : $seq = $db->get_Seq_by_version('X77802.1');
171 Function: Gets a Bio::Seq object by sequence version
172 Returns : A Bio::Seq object
173 Args : accession.version (as a string)
174 Throws : "acc.version does not exist" exception
175
176 =cut
177
178 sub get_Seq_by_version{
179 my ($self,@args) = @_;
180 return $self->get_Seq_by_id(@args);
181 }
182
183
184 1;