0
|
1 # $Id: AlignFactory.pm,v 1.8 2001/11/20 02:09:40 lstein Exp $
|
|
2 #
|
|
3 # BioPerl module for Bio::Tools::AlignFactory
|
|
4 #
|
|
5 # Cared for by Ewan Birney <birney@sanger.ac.uk>
|
|
6 #
|
|
7 # Copyright Ewan Birney
|
|
8 #
|
|
9 # You may distribute this module under the same terms as perl itself
|
|
10
|
|
11 # POD documentation - main docs before the code
|
|
12
|
|
13 =head1 NAME
|
|
14
|
|
15 Bio::Tools::AlignFactory - Base object for alignment factories
|
|
16
|
|
17 =head1 SYNOPSIS
|
|
18
|
|
19 You wont be using this as an object, but using a dervied class
|
|
20 like Bio::Tools::pSW
|
|
21
|
|
22 =head1 DESCRIPTION
|
|
23
|
|
24 Holds common Alignment Factory attributes in place
|
|
25
|
|
26 =head1 CONTACT
|
|
27
|
|
28 http://bio.perl.org/ or birney@sanger.ac.uk
|
|
29
|
|
30 =head1 APPENDIX
|
|
31
|
|
32 The rest of the documentation details each of the object
|
|
33 methods. Internal methods are usually preceded with a _
|
|
34
|
|
35 =cut
|
|
36
|
|
37
|
|
38 # Let the code begin...
|
|
39
|
|
40 package Bio::Tools::AlignFactory;
|
|
41 use vars qw(@ISA);
|
|
42 use strict;
|
|
43
|
|
44 use Bio::Root::Root;
|
|
45 @ISA = qw(Bio::Root::Root);
|
|
46
|
|
47 BEGIN {
|
|
48 eval {
|
|
49 require Bio::Ext::Align;
|
|
50 };
|
|
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);
|
|
54 }
|
|
55 }
|
|
56
|
|
57 sub new {
|
|
58 my($class,@args) = @_;
|
|
59 my $self = $class->SUPER::new(@args);
|
|
60 $self->_initialize(@args);
|
|
61 # set up defaults
|
|
62
|
|
63 $self->{'kbyte'} = 20000;
|
|
64 $self->{'report'} = 0;
|
|
65 return $self;
|
|
66 }
|
|
67
|
|
68
|
|
69 =head2 kbyte
|
|
70
|
|
71 Title : kbyte()
|
|
72 Usage : set/gets the amount of memory able to be used
|
|
73 Function :
|
|
74 : $factory->kbyte(200);
|
|
75 :
|
|
76 Returns :
|
|
77 Argument : memory in kilobytes
|
|
78
|
|
79 =cut
|
|
80
|
|
81 sub kbyte {
|
|
82 my ($self,$value) = @_;
|
|
83
|
|
84 if( defined $value ) {
|
|
85 $self->{'kbyte'} = $value;
|
|
86 }
|
|
87 return $self->{'kbyte'};
|
|
88 }
|
|
89
|
|
90
|
|
91 =head2 report
|
|
92
|
|
93 Title : report()
|
|
94 Usage : set/gets the report boolean to issue reports or not
|
|
95 Function :
|
|
96 : $factory->report(1); # reporting goes on
|
|
97 :
|
|
98 Returns : n/a
|
|
99 Argument : 1 or 0
|
|
100
|
|
101 =cut
|
|
102
|
|
103 sub report {
|
|
104 my ($self,$value) = @_;
|
|
105
|
|
106
|
|
107 if( defined $value ) {
|
|
108 if( $value != 1 && $value != 0 ) {
|
|
109 $self->throw("Attempting to modify AlignFactory Report with no boolean value!");
|
|
110 }
|
|
111 $self->{'report'} = $value;
|
|
112 }
|
|
113
|
|
114 return $self->{'report'};
|
|
115 }
|
|
116
|
|
117 =head2 set_memory_and_report
|
|
118
|
|
119 Title : set_memory_and_report
|
|
120 Usage : Only used by subclasses.
|
|
121 Function:
|
|
122 Example :
|
|
123 Returns :
|
|
124 Args :
|
|
125
|
|
126
|
|
127 =cut
|
|
128
|
|
129 sub set_memory_and_report{
|
|
130 my ($self) = @_;
|
|
131
|
|
132 if( $self->{'kbyte'} < 5 ) {
|
|
133 $self->throw("You can suggest aligning things with less than 5kb");
|
|
134 }
|
|
135
|
|
136 &Bio::Ext::Align::change_max_BaseMatrix_kbytes($self->{'kbyte'});
|
|
137
|
|
138 if( $self->{'report'} == 0 ) {
|
|
139 &Bio::Ext::Align::error_off(16);
|
|
140 } else {
|
|
141 &Bio::Ext::Align::error_on(16);
|
|
142 }
|
|
143 }
|
|
144
|
|
145 1;
|