~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to Bio/SearchIO/sim4.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id $
 
1
# $Id: sim4.pm,v 1.13.4.1 2006/10/02 23:10:26 sendu Exp $
2
2
#
3
3
# BioPerl module for Bio::SearchIO::sim4
4
4
#
34
34
This is a driver for the SearchIO system for parsing Sim4.
35
35
http://globin.cse.psu.edu/html/docs/sim4.html
36
36
 
 
37
Cannot parse LAV or 'exon file' formats (A=2 or A=5)
 
38
 
37
39
=head1 FEEDBACK
38
40
 
39
41
=head2 Mailing Lists
42
44
Bioperl modules. Send your comments and suggestions preferably to
43
45
the Bioperl mailing list.  Your participation is much appreciated.
44
46
 
45
 
  bioperl-l@bioperl.org              - General discussion
46
 
  http://bioperl.org/MailList.shtml  - About the mailing lists
 
47
  bioperl-l@bioperl.org                  - General discussion
 
48
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
47
49
 
48
50
=head2 Reporting Bugs
49
51
 
50
52
Report bugs to the Bioperl bug tracking system to help us keep track
51
 
of the bugs and their resolution. Bug reports can be submitted via
52
 
email or the web:
 
53
of the bugs and their resolution. Bug reports can be submitted via the
 
54
web:
53
55
 
54
 
  bioperl-bugs@bioperl.org
55
 
  http://bioperl.org/bioperl-bugs/
 
56
  http://bugzilla.open-bio.org/
56
57
 
57
58
=head1 AUTHOR - Jason Stajich
58
59
 
76
77
package Bio::SearchIO::sim4;
77
78
 
78
79
use strict;
79
 
use vars qw(@ISA $DEFAULTFORMAT %ALIGN_TYPES
 
80
use vars qw($DEFAULTFORMAT %ALIGN_TYPES
80
81
            %MAPPING %MODEMAP $DEFAULT_WRITER_CLASS);
81
82
 
82
83
use POSIX;
83
 
use Bio::SearchIO;
84
84
use Bio::SearchIO::SearchResultEventBuilder;
85
85
 
86
 
@ISA = qw(Bio::SearchIO );
 
86
use base qw(Bio::SearchIO);
87
87
 
88
88
$DEFAULTFORMAT = 'SIM4';
89
89
$DEFAULT_WRITER_CLASS = 'Bio::Search::Writer::HitTableWriter';
153
153
 
154
154
sub next_result {
155
155
    my ($self) = @_;
 
156
    local $/ = "\n";
 
157
    local $_;
156
158
 
157
159
    # Declare/adjust needed variables
158
160
    $self->{'_last_data'} = '';
162
164
    # Start document and main element
163
165
    $self->start_document();
164
166
    $self->start_element({'Name' => 'Sim4Output'});
165
 
 
 
167
    my $lastquery = '';
166
168
    # Read output report until EOF
167
169
    while( defined($_ = $self->_readline) ) {       
168
170
        # Skip empty lines, chomp filled ones
170
172
 
171
173
        # Make sure sim4 output format is not 2 or 5
172
174
        if (!$seentop) {
173
 
            if ( /^#:lav/ ) { $format = 2; }
 
175
            if ( /^\#:lav/ ) { $format = 2; }
174
176
            elsif ( /^<|>/ ) { $format = 5; }
175
177
            $self->throw("Bio::SearchIO::sim4 module cannot parse 'type $format' outputs.") if $format;
176
178
        }
177
179
 
178
180
        # This line indicates the start of a new hit
179
181
        if( /^seq1\s*=\s*(\S+),\s+(\d+)/ ) {
 
182
            my ($nm,$desc) = ($1,$2);
180
183
            # First hit? Adjust some parameters if so
181
 
            if ( !$seentop ) {
 
184
            if ( ! $seentop ) {
182
185
                $self->element( {'Name' => 'Sim4Output_query-def', 
183
 
                                 'Data' => $1} );
 
186
                                 'Data' => $nm} );
184
187
                $self->element( {'Name' => 'Sim4Output_query-len', 
185
 
                                 'Data' => $2} );
 
188
                                 'Data' => $desc} );
186
189
                $seentop = 1;
 
190
            } elsif( $nm ne $lastquery ) {
 
191
                $self->_pushback($_);
 
192
                last;
187
193
            }
 
194
            $lastquery = $nm;
188
195
            # A previous HSP may need to be ended
189
196
            $self->end_element({'Name' => 'Hsp'}) if ( $self->in_element('hsp') );
190
197
            # A previous hit exists? End it and reset needed variables
312
319
                }
313
320
            }
314
321
            # Current alignment block does not contain HSPs boundary
315
 
            # We only need to adjust details of the current HSP
316
322
            else {
 
323
                # Start a new HSP if none is currently open
 
324
                # (Happens if last boundary finished at the very end of previous block)
 
325
                if ( !$self->in_element('hsp') ) {
 
326
                    $self->start_element({'Name' => 'Hsp'});
 
327
                    $self->{'_currentHSP'} = @hsps ? shift @hsps : {
 
328
                        'Hsp_query-from' => $alignment{Query}{start},
 
329
                        'Hsp_hit-from' => $alignment{Sbjct}{start},
 
330
                    }
 
331
                }
 
332
                # Adjust details of the current HSP
317
333
                $self->{'_currentHSP'}{'Hsp_query-from'} ||= 
318
334
                    $alignment{Query}{start} - 
319
335
                    length($self->{'_currentHSP'}{'Hsp_qseq'} || '');
353
369
        $self->end_element({'Name' => 'Sim4Output'});
354
370
        return $self->end_document();
355
371
    } 
356
 
    return undef;
 
372
    return;
357
373
}
358
374
 
359
375
=head2 start_element