sync w/ main trunk
[bioperl-live.git] / Bio / Tools / AlignFactory.pm
blob9f02343f017f3958824ce11795d400e0ddfd2ae5
1 # $Id$
3 # BioPerl module for Bio::Tools::AlignFactory
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Ewan Birney <birney@sanger.ac.uk>
9 # Copyright Ewan Birney
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
15 =head1 NAME
17 Bio::Tools::AlignFactory - Base object for alignment factories
19 =head1 SYNOPSIS
21 You wont be using this as an object, but using a dervied class
22 like Bio::Tools::pSW
24 =head1 DESCRIPTION
26 Holds common Alignment Factory attributes in place
28 =head1 CONTACT
30 http://bio.perl.org/ or birney@sanger.ac.uk
32 =head1 APPENDIX
34 The rest of the documentation details each of the object
35 methods. Internal methods are usually preceded with a _
37 =cut
40 # Let the code begin...
42 package Bio::Tools::AlignFactory;
43 use strict;
45 use base qw(Bio::Root::Root);
47 BEGIN {
48 eval {
49 require Bio::Ext::Align;
51 if ( $@ ) {
52 print STDERR ("\nThe C-compiled engine for Smith Waterman alignments (Bio::Ext::Align) has not been installed.\n Please install the bioperl-ext package\n\n");
53 exit(1);
57 sub new {
58 my($class,@args) = @_;
59 my $self = $class->SUPER::new(@args);
60 $self->_initialize(@args);
61 # set up defaults
63 $self->{'kbyte'} = 20000;
64 $self->{'report'} = 0;
65 return $self;
69 =head2 kbyte
71 Title : kbyte()
72 Usage : set/gets the amount of memory able to be used
73 Function :
74 : $factory->kbyte(200);
76 Returns :
77 Argument : memory in kilobytes
79 =cut
81 sub kbyte {
82 my ($self,$value) = @_;
84 if( defined $value ) {
85 $self->{'kbyte'} = $value;
87 return $self->{'kbyte'};
91 =head2 report
93 Title : report()
94 Usage : set/gets the report boolean to issue reports or not
95 Function :
96 : $factory->report(1); # reporting goes on
98 Returns : n/a
99 Argument : 1 or 0
101 =cut
103 sub report {
104 my ($self,$value) = @_;
107 if( defined $value ) {
108 if( $value != 1 && $value != 0 ) {
109 $self->throw("Attempting to modify AlignFactory Report with no boolean value!");
111 $self->{'report'} = $value;
114 return $self->{'report'};
117 =head2 set_memory_and_report
119 Title : set_memory_and_report
120 Usage : Only used by subclasses.
121 Function:
122 Example :
123 Returns :
124 Args :
127 =cut
129 sub set_memory_and_report{
130 my ($self) = @_;
132 if( $self->{'kbyte'} < 5 ) {
133 $self->throw("You can suggest aligning things with less than 5kb");
136 &Bio::Ext::Align::change_max_BaseMatrix_kbytes($self->{'kbyte'});
138 if( $self->{'report'} == 0 ) {
139 &Bio::Ext::Align::error_off(16);
140 } else {
141 &Bio::Ext::Align::error_on(16);