Mercurial > repos > mahtabm > ensemb_rep_gvl
comparison variant_effect_predictor/Bio/AlignIO/bl2seq.pm @ 0:2bc9b66ada89 draft default tip
Uploaded
author | mahtabm |
---|---|
date | Thu, 11 Apr 2013 06:29:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2bc9b66ada89 |
---|---|
1 # $Id: bl2seq.pm,v 1.13.2.1 2003/06/18 12:19:52 jason Exp $ | |
2 # | |
3 # BioPerl module for Bio::AlignIO::bl2seq | |
4 | |
5 # based on the Bio::SeqIO modules | |
6 # by Ewan Birney <birney@sanger.ac.uk> | |
7 # and Lincoln Stein <lstein@cshl.org> | |
8 # | |
9 # the Bio::Tools::BPlite modules by | |
10 # Ian Korf (ikorf@sapiens.wustl.edu, http://sapiens.wustl.edu/~ikorf), | |
11 # Lorenz Pollak (lorenz@ist.org, bioperl port) | |
12 # | |
13 # and the SimpleAlign.pm module of Ewan Birney | |
14 # | |
15 # Copyright Peter Schattner | |
16 # | |
17 # You may distribute this module under the same terms as perl itself | |
18 # _history | |
19 # September 5, 2000 | |
20 # POD documentation - main docs before the code | |
21 | |
22 =head1 NAME | |
23 | |
24 Bio::AlignIO::bl2seq - bl2seq sequence input/output stream | |
25 | |
26 =head1 SYNOPSIS | |
27 | |
28 Do not use this module directly. Use it via the L<Bio::AlignIO> class, as in: | |
29 | |
30 use Bio::AlignIO; | |
31 | |
32 $in = Bio::AlignIO->new(-file => "inputfilename" , '-format' => 'bl2seq'); | |
33 $aln = $in->next_aln(); | |
34 | |
35 | |
36 =head1 DESCRIPTION | |
37 | |
38 This object can create L<Bio::SimpleAlign> sequence alignment objects (of | |
39 2 sequences) from bl2seq BLAST reports. | |
40 | |
41 A nice feature of this module is that- in combination with | |
42 StandAloneBlast.pm or remote blasting - it can be used to align 2 | |
43 sequences and make a SimpleAlign object from them which can then be | |
44 manipulated using any SimpleAlign.pm methods, eg: | |
45 | |
46 #Get 2 sequences | |
47 $str = Bio::SeqIO->new(-file=>'t/amino.fa' , '-format' => 'Fasta', ); | |
48 my $seq3 = $str->next_seq(); | |
49 my $seq4 = $str->next_seq(); | |
50 | |
51 # Run bl2seq on them | |
52 $factory = Bio::Tools::StandAloneBlast->new('program' => 'blastp', | |
53 'outfile' => 'bl2seq.out'); | |
54 my $bl2seq_report = $factory->bl2seq($seq3, $seq4); | |
55 | |
56 # Use AlignIO.pm to create a SimpleAlign object from the bl2seq report | |
57 $str = Bio::AlignIO->new(-file=> 'bl2seq.out','-format' => 'bl2seq'); | |
58 $aln = $str->next_aln(); | |
59 | |
60 Pass in -report_type flag when initializing the object to have this | |
61 pass through to the Bio::Tools::BPbl2seq object. See that object. | |
62 | |
63 =head1 FEEDBACK | |
64 | |
65 =head2 Mailing Lists | |
66 | |
67 User feedback is an integral part of the evolution of this and other | |
68 Bioperl modules. Send your comments and suggestions preferably to one | |
69 of the Bioperl mailing lists. Your participation is much appreciated. | |
70 | |
71 bioperl-l@bioperl.org - General discussion | |
72 http://bio.perl.org/MailList.html - About the mailing lists | |
73 | |
74 =head2 Reporting Bugs | |
75 | |
76 Report bugs to the Bioperl bug tracking system to help us keep track | |
77 the bugs and their resolution. | |
78 Bug reports can be submitted via email or the web: | |
79 | |
80 bioperl-bugs@bio.perl.org | |
81 http://bugzilla.bioperl.org/ | |
82 | |
83 =head1 AUTHOR - Peter Schattner | |
84 | |
85 Email: schattner@alum.mit.edu | |
86 | |
87 | |
88 =head1 APPENDIX | |
89 | |
90 The rest of the documentation details each of the object | |
91 methods. Internal methods are usually preceded with a _ | |
92 | |
93 =cut | |
94 | |
95 # Let the code begin... | |
96 | |
97 package Bio::AlignIO::bl2seq; | |
98 use vars qw(@ISA); | |
99 use strict; | |
100 # Object preamble - inherits from Bio::Root::Object | |
101 | |
102 use Bio::AlignIO; | |
103 use Bio::Tools::BPbl2seq; | |
104 | |
105 @ISA = qw(Bio::AlignIO); | |
106 | |
107 | |
108 | |
109 sub _initialize { | |
110 my ($self,@args) = @_; | |
111 $self->SUPER::_initialize(@args); | |
112 ($self->{'report_type'}) = $self->_rearrange([qw(REPORT_TYPE)], | |
113 @args); | |
114 return 1; | |
115 } | |
116 | |
117 =head2 next_aln | |
118 | |
119 Title : next_aln | |
120 Usage : $aln = $stream->next_aln() | |
121 Function: returns the next alignment in the stream. | |
122 Returns : L<Bio::Align::AlignI> object - returns 0 on end of file | |
123 or on error | |
124 Args : NONE | |
125 | |
126 =cut | |
127 | |
128 sub next_aln { | |
129 my $self = shift; | |
130 my ($start,$end,$name,$seqname,$seq,$seqchar); | |
131 my $aln = Bio::SimpleAlign->new(-source => 'bl2seq'); | |
132 $self->{'bl2seqobj'} = | |
133 $self->{'bl2seqobj'} || Bio::Tools::BPbl2seq->new(-fh => $self->_fh, | |
134 -report_type => $self->{'report_type'}); | |
135 my $bl2seqobj = $self->{'bl2seqobj'}; | |
136 my $hsp = $bl2seqobj->next_feature; | |
137 $seqchar = $hsp->querySeq; | |
138 $start = $hsp->query->start; | |
139 $end = $hsp->query->end; | |
140 $seqname = 'Query-sequence'; # Query name not present in bl2seq report | |
141 | |
142 # unless ($seqchar && $start && $end && $seqname) {return 0} ; | |
143 unless ($seqchar && $start && $end ) {return 0} ; | |
144 | |
145 $seq = new Bio::LocatableSeq('-seq'=>$seqchar, | |
146 '-id'=>$seqname, | |
147 '-start'=>$start, | |
148 '-end'=>$end, | |
149 ); | |
150 | |
151 $aln->add_seq($seq); | |
152 | |
153 $seqchar = $hsp->sbjctSeq; | |
154 $start = $hsp->hit->start; | |
155 $end = $hsp->hit->end; | |
156 $seqname = $bl2seqobj->sbjctName; | |
157 | |
158 unless ($seqchar && $start && $end && $seqname) {return 0} ; | |
159 | |
160 $seq = new Bio::LocatableSeq('-seq'=>$seqchar, | |
161 '-id'=>$seqname, | |
162 '-start'=>$start, | |
163 '-end'=>$end, | |
164 ); | |
165 | |
166 $aln->add_seq($seq); | |
167 | |
168 return $aln; | |
169 | |
170 } | |
171 | |
172 | |
173 =head2 write_aln | |
174 | |
175 Title : write_aln | |
176 Usage : $stream->write_aln(@aln) | |
177 Function: writes the $aln object into the stream in bl2seq format | |
178 Returns : 1 for success and 0 for error | |
179 Args : L<Bio::Align::AlignI> object | |
180 | |
181 | |
182 =cut | |
183 | |
184 sub write_aln { | |
185 my ($self,@aln) = @_; | |
186 | |
187 $self->throw("Sorry: writing bl2seq output is not available! /n"); | |
188 } | |
189 | |
190 1; |