t/AlignIO/AlignIO.t: fix number of tests in plan (fixup c523e6bed866)
[bioperl-live.git] / Bio / Search / HSP / PSLHSP.pm
blob738da3472df5290d1bb426ae8ae757e207363d81
2 # BioPerl module for Bio::Search::HSP::PSLHSP
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason-at-bioperl-dot-org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
14 =head1 NAME
16 Bio::Search::HSP::PSLHSP - A HSP for PSL output
18 =head1 SYNOPSIS
20 # get a PSLHSP somehow (SearchIO::psl)
22 =head1 DESCRIPTION
24 This is a HSP for PSL output so we can handle seq_inds differently.
26 =head1 FEEDBACK
28 =head2 Mailing Lists
30 User feedback is an integral part of the evolution of this and other
31 Bioperl modules. Send your comments and suggestions preferably to
32 the Bioperl mailing list. Your participation is much appreciated.
34 bioperl-l@bioperl.org - General discussion
35 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
37 =head2 Support
39 Please direct usage questions or support issues to the mailing list:
41 I<bioperl-l@bioperl.org>
43 rather than to the module maintainer directly. Many experienced and
44 reponsive experts will be able look at the problem and quickly
45 address it. Please include a thorough description of the problem
46 with code and data examples if at all possible.
48 =head2 Reporting Bugs
50 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 the web:
54 https://github.com/bioperl/bioperl-live/issues
56 =head1 AUTHOR - Jason Stajich
58 Email jason-at-bioperl-dot-org
60 =head1 APPENDIX
62 The rest of the documentation details each of the object methods.
63 Internal methods are usually preceded with a _
65 =cut
68 # Let the code begin...
71 package Bio::Search::HSP::PSLHSP;
72 use strict;
74 # Object preamble - inherits from Bio::Root::Root
77 use base qw(Bio::Search::HSP::GenericHSP);
79 =head2 new
81 Title : new
82 Usage : my $obj = Bio::Search::HSP::PSLHSP->new();
83 Function: Builds a new Bio::Search::HSP::PSLHSP object
84 Returns : an instance of Bio::Search::HSP::PSLHSP
85 Args : -gapblocks => arrayref of gap locations which are [start,length]
86 of gaps
89 =cut
91 sub new {
92 my ($class,@args) = @_;
93 my $self = $class->SUPER::new(@args);
94 my ($qgaplocs,
95 $hgaplocs,
96 $mismatches) = $self->_rearrange([qw(QUERY_GAPBLOCKS
97 HIT_GAPBLOCKS
98 MISMATCHES)],
99 @args);
100 $self->gap_blocks('query',$qgaplocs) if defined $qgaplocs;
101 $self->gap_blocks('hit', $hgaplocs) if defined $hgaplocs;
102 $self->mismatches($mismatches) if defined $mismatches;
103 return $self;
106 =head2 gap_blocks
108 Title : gap_blocks
109 Usage : $obj->gap_blocks($seqtype,$blocks)
110 Function: Get/Set the gap blocks
111 Returns : value of gap_blocks (a scalar)
112 Args : sequence type - 'query' or 'hit'
113 blocks - arrayref of block start,length
116 =cut
118 sub gap_blocks {
119 my ($self,$seqtype,$blocks) = @_;
120 if( ! defined $seqtype ) { $seqtype = 'query' }
121 $seqtype = lc($seqtype);
122 $seqtype = 'hit' if $seqtype eq 'sbjct';
123 if( $seqtype !~ /query|hit/i ) {
124 $self->warn("Expect either 'query' or 'hit' as argument 1 for gap_blocks");
127 unless( defined $blocks ) {
128 return $self->{'_gap_blocks'}->{$seqtype};
129 } else {
130 return $self->{'_gap_blocks'}->{$seqtype} = $blocks;
134 =head2 mismatches
136 Title : mismatches
137 Usage : $obj->mismatches($newval)
138 Function: Get/Set the number of mismatches
139 Returns : value of mismatches (a scalar)
140 Args : on set, new value (a scalar or undef, optional)
143 =cut
145 sub mismatches{
146 my $self = shift;
147 return $self->{'mismatches'} = shift if @_;
148 return $self->{'mismatches'};