| 1 | # | ||||||||||
| 2 | # BioPerl module for Bio::AlignIO::mase | ||||||||||
| 3 | |||||||||||
| 4 | # based on the Bio::SeqIO::mase module | ||||||||||
| 5 | # by Ewan Birney <birney@ebi.ac.uk> | ||||||||||
| 6 | # and Lincoln Stein <lstein@cshl.org> | ||||||||||
| 7 | # | ||||||||||
| 8 | # and the SimpleAlign.pm module of Ewan Birney | ||||||||||
| 9 | # | ||||||||||
| 10 | # Copyright Peter Schattner | ||||||||||
| 11 | # | ||||||||||
| 12 | # You may distribute this module under the same terms as perl itself | ||||||||||
| 13 | # _history | ||||||||||
| 14 | # September 5, 2000 | ||||||||||
| 15 | # POD documentation - main docs before the code | ||||||||||
| 16 | |||||||||||
| 17 | =head1 NAME | ||||||||||
| 18 | |||||||||||
| 19 | Bio::AlignIO::mase - mase sequence input/output stream | ||||||||||
| 20 | |||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||
| 22 | |||||||||||
| 23 | Do not use this module directly. Use it via the L<Bio::AlignIO> class. | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | This object can transform L<Bio::Align::AlignI> objects to and from mase flat | ||||||||||
| 28 | file databases. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 FEEDBACK | ||||||||||
| 31 | |||||||||||
| 32 | =head2 Support | ||||||||||
| 33 | |||||||||||
| 34 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 35 | |||||||||||
| 36 | I<bioperl-l@bioperl.org> | ||||||||||
| 37 | |||||||||||
| 38 | rather than to the module maintainer directly. Many experienced and | ||||||||||
| 39 | reponsive experts will be able look at the problem and quickly | ||||||||||
| 40 | address it. Please include a thorough description of the problem | ||||||||||
| 41 | with code and data examples if at all possible. | ||||||||||
| 42 | |||||||||||
| 43 | =head2 Reporting Bugs | ||||||||||
| 44 | |||||||||||
| 45 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||
| 46 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||
| 47 | web: | ||||||||||
| 48 | |||||||||||
| 49 | https://github.com/bioperl/bioperl-live/issues | ||||||||||
| 50 | |||||||||||
| 51 | =head1 AUTHORS - Peter Schattner | ||||||||||
| 52 | |||||||||||
| 53 | Email: schattner@alum.mit.edu | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | =head1 APPENDIX | ||||||||||
| 57 | |||||||||||
| 58 | The rest of the documentation details each of the object | ||||||||||
| 59 | methods. Internal methods are usually preceded with a _ | ||||||||||
| 60 | |||||||||||
| 61 | =cut | ||||||||||
| 62 | |||||||||||
| 63 | # Let the code begin... | ||||||||||
| 64 | |||||||||||
| 65 | package Bio::AlignIO::mase; | ||||||||||
| 66 | 3 | $Bio::AlignIO::mase::VERSION = '1.7.8'; | |||||||||
| 67 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | 3 | ▶ | use base qw(Bio::AlignIO); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 71 | |||||||||||
| 72 | |||||||||||
| 73 | =head2 next_aln | ||||||||||
| 74 | |||||||||||
| 75 | Title : next_aln | ||||||||||
| 76 | Usage : $aln = $stream->next_aln() | ||||||||||
| 77 | Function: returns the next alignment in the stream. | ||||||||||
| 78 | Returns : L<Bio::Align::AlignI> object | ||||||||||
| 79 | Args : NONE | ||||||||||
| 80 | |||||||||||
| 81 | =cut | ||||||||||
| 82 | |||||||||||
| 83 | 11 | ▶ | sub next_aln { | ||||||||
|
Subroutine
next_aln: called CC=9 SCAR=22.5
Pod
documented
| |||||||||||
| 84 | 11 | my $self = shift; | |||||||||
| 85 | 11 | my $entry; | |||||||||
| 86 | my $name; | ||||||||||
| 87 | 11 | my $start; | |||||||||
| 88 | 11 | my $end; | |||||||||
| 89 | 11 | my $seq; | |||||||||
| 90 | 11 | my $add; | |||||||||
| 91 | 11 | my $count = 0; | |||||||||
| 92 | 11 | my $seq_residues; | |||||||||
| 93 | |||||||||||
| 94 | 11 | my $aln = Bio::SimpleAlign->new(-source => 'mase'); | |||||||||
| 95 | |||||||||||
| 96 | |||||||||||
| 97 | 11 | ▶ | while( $entry = $self->_readline) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | 77 | ▶ | $entry =~ /^;/ && next; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 22 | ▶ | if( $entry =~ /^(\S+)\/(\d+)-(\d+)/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 0 | $name = $1; | |||||||||
| 101 | 0 | $start = $2; | |||||||||
| 102 | 0 | $end = $3; | |||||||||
| 103 | } else { | ||||||||||
| 104 | 22 | $entry =~ s/\s//g; | |||||||||
| 105 | 22 | $name = $entry; | |||||||||
| 106 | 22 | $end = -1; | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | 22 | $seq = ""; | |||||||||
| 110 | |||||||||||
| 111 | 22 | ▶ | while( $entry = $self->_readline) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 112 | 165 | ▶ | $entry =~ /^;/ && last; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | 154 | $entry =~ s/[^A-Za-z\.\-]//g; | |||||||||
| 114 | 154 | $seq .= $entry; | |||||||||
| 115 | } | ||||||||||
| 116 | 22 | ▶ | if( $end == -1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 117 | 22 | $start = 1; | |||||||||
| 118 | |||||||||||
| 119 | 22 | $seq_residues = $seq; | |||||||||
| 120 | 22 | $seq_residues =~ s/\W//g; | |||||||||
| 121 | 22 | $end = length($seq_residues); | |||||||||
| 122 | } | ||||||||||
| 123 | |||||||||||
| 124 | 22 | $add = Bio::LocatableSeq->new('-seq' => $seq, | |||||||||
| 125 | '-display_id' => $name, | ||||||||||
| 126 | '-start' => $start, | ||||||||||
| 127 | '-end' => $end, | ||||||||||
| 128 | '-alphabet' => $self->alphabet, | ||||||||||
| 129 | ); | ||||||||||
| 130 | |||||||||||
| 131 | |||||||||||
| 132 | 22 | $aln->add_seq($add); | |||||||||
| 133 | |||||||||||
| 134 | |||||||||||
| 135 | # If $end <= 0, we have either reached the end of | ||||||||||
| 136 | # file in <> or we have encountered some other error | ||||||||||
| 137 | # | ||||||||||
| 138 | 0 | ▶ | if ($end <= 0) { undef $aln;} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 139 | |||||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | 11 | ▶ | return $aln if $aln->num_sequences; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 143 | 0 | return; | |||||||||
| 144 | } | ||||||||||
| 145 | |||||||||||
| 146 | |||||||||||
| 147 | |||||||||||
| 148 | =head2 write_aln | ||||||||||
| 149 | |||||||||||
| 150 | Title : write_aln | ||||||||||
| 151 | Usage : $stream->write_aln(@aln) | ||||||||||
| 152 | Function: writes the $aln object into the stream in mase format ###Not yet implemented!### | ||||||||||
| 153 | Returns : 1 for success and 0 for error | ||||||||||
| 154 | Args : L<Bio::Align::AlignI> object | ||||||||||
| 155 | |||||||||||
| 156 | |||||||||||
| 157 | =cut | ||||||||||
| 158 | |||||||||||
| 159 | 0 | ▶ | sub write_aln { | ||||||||
|
Subroutine
write_aln: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 160 | 0 | my ($self,@aln) = @_; | |||||||||
| 161 | 0 | $self->throw_not_implemented(); | |||||||||
| 162 | } | ||||||||||
| 163 | |||||||||||
| 164 | 3 | 1; | |||||||||