Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/AlignIO/mase.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 # $Id: mase.pm,v 1.9 2002/10/22 07:38:25 lapp Exp $ | |
2 # | |
3 # BioPerl module for Bio::AlignIO::mase | |
4 | |
5 # based on the Bio::SeqIO::mase module | |
6 # by Ewan Birney <birney@sanger.ac.uk> | |
7 # and Lincoln Stein <lstein@cshl.org> | |
8 # | |
9 # and the SimpleAlign.pm module of Ewan Birney | |
10 # | |
11 # Copyright Peter Schattner | |
12 # | |
13 # You may distribute this module under the same terms as perl itself | |
14 # _history | |
15 # September 5, 2000 | |
16 # POD documentation - main docs before the code | |
17 | |
18 =head1 NAME | |
19 | |
20 Bio::AlignIO::mase - mase sequence input/output stream | |
21 | |
22 =head1 SYNOPSIS | |
23 | |
24 Do not use this module directly. Use it via the L<Bio::AlignIO> class. | |
25 | |
26 =head1 DESCRIPTION | |
27 | |
28 This object can transform L<Bio::Align::AlignI> objects to and from mase flat | |
29 file databases. | |
30 | |
31 =head1 FEEDBACK | |
32 | |
33 =head2 Reporting Bugs | |
34 | |
35 Report bugs to the Bioperl bug tracking system to help us keep track | |
36 the bugs and their resolution. | |
37 Bug reports can be submitted via email or the web: | |
38 | |
39 bioperl-bugs@bio.perl.org | |
40 http://bugzilla.bioperl.org/ | |
41 | |
42 =head1 AUTHORS - Peter Schattner | |
43 | |
44 Email: schattner@alum.mit.edu | |
45 | |
46 | |
47 =head1 APPENDIX | |
48 | |
49 The rest of the documentation details each of the object | |
50 methods. Internal methods are usually preceded with a _ | |
51 | |
52 =cut | |
53 | |
54 # Let the code begin... | |
55 | |
56 package Bio::AlignIO::mase; | |
57 use vars qw(@ISA); | |
58 use strict; | |
59 | |
60 use Bio::AlignIO; | |
61 | |
62 @ISA = qw(Bio::AlignIO); | |
63 | |
64 | |
65 =head2 next_aln | |
66 | |
67 Title : next_aln | |
68 Usage : $aln = $stream->next_aln() | |
69 Function: returns the next alignment in the stream. | |
70 Returns : L<Bio::Align::AlignI> object | |
71 Args : NONE | |
72 | |
73 =cut | |
74 | |
75 sub next_aln { | |
76 my $self = shift; | |
77 my $entry; | |
78 my $name; | |
79 my $start; | |
80 my $end; | |
81 my $seq; | |
82 my $add; | |
83 my $count = 0; | |
84 my $seq_residues; | |
85 | |
86 my $aln = Bio::SimpleAlign->new(-source => 'mase'); | |
87 | |
88 | |
89 while( $entry = $self->_readline) { | |
90 $entry =~ /^;/ && next; | |
91 if( $entry =~ /^(\S+)\/(\d+)-(\d+)/ ) { | |
92 $name = $1; | |
93 $start = $2; | |
94 $end = $3; | |
95 } else { | |
96 $entry =~ s/\s//g; | |
97 $name = $entry; | |
98 $end = -1; | |
99 } | |
100 | |
101 $seq = ""; | |
102 | |
103 while( $entry = $self->_readline) { | |
104 $entry =~ /^;/ && last; | |
105 $entry =~ s/[^A-Za-z\.\-]//g; | |
106 $seq .= $entry; | |
107 } | |
108 if( $end == -1) { | |
109 $start = 1; | |
110 | |
111 $seq_residues = $seq; | |
112 $seq_residues =~ s/\W//g; | |
113 $end = length($seq_residues); | |
114 } | |
115 | |
116 $add = new Bio::LocatableSeq('-seq'=>$seq, | |
117 '-id'=>$name, | |
118 '-start'=>$start, | |
119 '-end'=>$end, | |
120 ); | |
121 | |
122 | |
123 $aln->add_seq($add); | |
124 | |
125 | |
126 # If $end <= 0, we have either reached the end of | |
127 # file in <> or we have encountered some other error | |
128 # | |
129 if ($end <= 0) { undef $aln;} | |
130 | |
131 } | |
132 | |
133 return $aln; | |
134 } | |
135 | |
136 | |
137 | |
138 =head2 write_aln | |
139 | |
140 Title : write_aln | |
141 Usage : $stream->write_aln(@aln) | |
142 Function: writes the $aln object into the stream in mase format ###Not yet implemented!### | |
143 Returns : 1 for success and 0 for error | |
144 Args : L<Bio::Align::AlignI> object | |
145 | |
146 | |
147 =cut | |
148 | |
149 sub write_aln { | |
150 my ($self,@aln) = @_; | |
151 | |
152 $self->throw("Sorry: mase-format output, not yet implemented! /n"); | |
153 } | |
154 | |
155 1; |