added bio::ext support
[bioperl-live.git] / Bio / Tools / AlignFactory.pm
blobe3368099dad24d8f902b174bb82d52cd9098f768
3 # BioPerl module for Bio::Tools::AlignFactory
5 # Cared for by Ewan Birney <birney@sanger.ac.uk>
7 # Copyright Ewan Birney
9 # You may distribute this module under the same terms as perl itself
11 # POD documentation - main docs before the code
13 =head1 NAME
15 Bio::Tools::AlignFactory - Base object for alignment factories
17 =head1 SYNOPSIS
19 You wont be using this as an object, but using a dervied class
20 like Bio::Tools::pSW
22 =head1 DESCRIPTION
24 Holds common Alignment Factory attributes in place
26 =head1 CONTACT
28 http://bio.perl.org/ or birney@sanger.ac.uk
30 =head1 APPENDIX
32 The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
34 =cut
37 # Let the code begin...
40 package Bio::Tools::AlignFactory;
41 use vars qw($AUTOLOAD @ISA);
42 use strict;
44 # Object preamble - inheriets from Bio::Root::Object
46 use Bio::Root::Object;
48 BEGIN {
49 eval {
50 require Bio::Ext::Align;
52 if ( $@ ) {
53 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");
54 exit(1);
59 @ISA = qw(Bio::Root::Object Exporter);
60 # new() is inherited from Bio::Root::Object
62 # _initialize is where the heavy stuff will happen when new is called
64 sub _initialize {
65 my($self,@p) = @_;
66 my $make = $self->SUPER::_initialize(@p);
68 # set up defaults
70 $self->{'kbyte'} = 20000;
71 $self->{'report'} = 0;
72 # set stuff in self from @args
73 return $make; # success - we hope!
77 =head2 kbyte
79 Title : kbyte()
80 Usage : set/gets the amount of memory able to be used
81 Function :
82 : $factory->kbyte(200);
84 Returns :
85 Argument : memory in kilobytes
87 =cut
89 sub kbyte {
90 my ($self,$value) = @_;
92 if( defined $value ) {
93 $self->{'kbyte'} = $value;
96 return $self->{'kbyte'};
100 =head2 report
102 Title : report()
103 Usage : set/gets the report boolean to issue reports or not
104 Function :
105 : $factory->report(1); # reporting goes on
107 Returns : n/a
108 Argument : 1 or 0
110 =cut
112 sub report {
113 my ($self,$value) = @_;
116 if( defined $value ) {
117 if( $value != 1 && $value != 0 ) {
118 $self->throw("Attempting to modify AlignFactory Report with no boolean value!");
120 $self->{'report'} = $value;
123 return $self->{'report'};
126 =head2 set_memory_and_report
128 Title : set_memory_and_report
129 Usage : Only used by subclasses.
130 Function:
131 Example :
132 Returns :
133 Args :
136 =cut
138 sub set_memory_and_report{
139 my ($self) = @_;
141 if( $self->{'kbyte'} < 5 ) {
142 $self->throw("You can suggest aligning things with less than 5kb");
145 &Bio::Ext::Align::change_max_BaseMatrix_kbytes($self->{'kbyte'});
147 if( $self->{'report'} == 0 ) {
148 &bp_sw::error_off(16);
149 } else {
150 &bp_sw::error_on(16);