~ubuntu-branches/ubuntu/trusty/bioperl/trusty-proposed

« back to all changes in this revision

Viewing changes to Bio/SearchIO/hmmer.pm

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: hmmer.pm,v 1.34.4.1 2006/10/02 23:10:26 sendu Exp $
 
1
# $Id: hmmer.pm 15005 2008-11-19 20:32:50Z dave_messina $
2
2
#
3
3
# BioPerl module for Bio::SearchIO::hmmer
4
4
#
18
18
 
19
19
    # do not use this class directly it is available through Bio::SearchIO
20
20
    use Bio::SearchIO;
21
 
    my $in = new Bio::SearchIO(-format => 'hmmer',
 
21
    my $in = Bio::SearchIO->new(-format => 'hmmer',
22
22
                               -file   => 't/data/L77119.hmmer');
23
23
    while( my $result = $in->next_result ) {
24
24
        # this is a Bio::Search::Result::HMMERResult object
129
129
=head2 new
130
130
 
131
131
 Title   : new
132
 
 Usage   : my $obj = new Bio::SearchIO::hmmer();
 
132
 Usage   : my $obj = Bio::SearchIO::hmmer->new();
133
133
 Function: Builds a new Bio::SearchIO::hmmer object 
134
134
 Returns : Bio::SearchIO::hmmer
135
135
 Args    : -fh/-file => HMMER filename
481
481
                            $prelength = CORE::length($1);
482
482
                            $width     = 0;
483
483
 
484
 
                            # $width = CORE::length($2);
 
484
                            # deal with fact that start en stop is on same line
 
485
                            my $data = $2;
 
486
                            if ($data =~ s/\<\-?\*?\s*$//)
 
487
                            {
 
488
                                $width = CORE::length($data);
 
489
                            }
 
490
 
485
491
                            $self->element(
486
492
                                {
487
493
                                    'Name' => 'Hsp_qseq',
488
 
                                    'Data' => $2
 
494
                                    'Data' => $data
489
495
                                }
490
496
                            );
491
497
                            $count       = 0;
535
541
                                );
536
542
                            }
537
543
                            else {
538
 
                                $self->debug("midline is $_\n")
539
 
                                  if ( $verbose > 0
540
 
                                    && CORE::length($_) <= $prelength );
541
544
                                $self->element(
542
545
                                    {
543
546
                                        'Name' => 'Hsp_midline',
725
728
                        || ( $count != 1
726
729
                            && /^\s+RF\s+[x\s]+$/o )
727
730
                      );
728
 
                    $self->debug("$count $_") if $verbose > 0;
 
731
                    # fix for bug 2632
 
732
                    next if ($_ =~ m/^\s+CS\s+/o && $count == 0);
729
733
                    if ( /^Histogram/o || m!^//!o || /^Query sequence/o ) {
730
734
                        if ( $self->in_element('hsp') ) {
731
735
                            $self->end_element( { 'Name' => 'Hsp' } );
795
799
                                'Name' => 'Hsp_identity',
796
800
                                'Data' => 0
797
801
                            }
798
 
                        );
 
802
                        );                     
799
803
                        $self->element(
800
804
                            {
801
805
                                'Name' => 'Hsp_positive',
855
859
                            $prelength = CORE::length($1);
856
860
                            $width     = 0;
857
861
 
858
 
                            # $width = CORE::length($2);
 
862
                            # deal with fact that start en stop is on same line
 
863
                            my $data = $2;
 
864
                            if ($data =~ s/\<\-?\*?\s*$//)
 
865
                            {
 
866
                              $width = CORE::length($data);
 
867
                            }
 
868
 
859
869
                            $self->element(
860
870
                                {
861
871
                                    'Name' => 'Hsp_hseq',
862
 
                                    'Data' => $2
 
872
                                    'Data' => $data
863
873
                                }
864
874
                            );
865
875
                            $count       = 0;
978
988
                            'Name' => 'Hsp_query-from',
979
989
                            'Data' => shift @$HSPinfo
980
990
                        }
981
 
                    );
 
991
                    );                    
982
992
                    $self->element(
983
993
                        {
984
994
                            'Name' => 'Hsp_query-to',
1034
1044
                %hitinfo = ();
1035
1045
                last;
1036
1046
            }
1037
 
            else {
1038
 
                $self->debug($_) if $verbose > 0;
1039
 
            }
 
1047
            # uncomment to see missed lines with verbose on
 
1048
            #else {
 
1049
            #    $self->debug($_);
 
1050
            #}
1040
1051
        }
1041
1052
        $last = $_;
1042
1053
    }
1103
1114
    # object begins so have to detect this in end_element for now
1104
1115
    if ( $nm eq 'Hsp' ) {
1105
1116
        foreach (qw(Hsp_qseq Hsp_midline Hsp_hseq)) {
 
1117
            my $data = $self->{'_last_hspdata'}->{$_};
 
1118
            if ($data && $_ eq 'Hsp_hseq') {
 
1119
                # replace hmm '.' gap symbol by '-'
 
1120
                $data =~ s/\./-/g;
 
1121
            }
1106
1122
            $self->element(
1107
1123
                {
1108
1124
                    'Name' => $_,
1109
 
                    'Data' => $self->{'_last_hspdata'}->{$_}
 
1125
                    'Data' => $data
1110
1126
                }
1111
1127
            );
1112
1128
        }