3 # BioPerl module for Bio::Tools::Run::EMBOSSacd
6 # Please direct questions and support issues to <bioperl-l@bioperl.org>
8 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
10 # Copyright Heikki Lehvaslaiho
12 # You may distribute this module under the same terms as perl itself
14 # POD documentation - main docs before the code
18 Bio::Tools::Run::EMBOSSacd - class for EMBOSS Application qualifiers
22 use Bio::Factory::EMBOSS;
23 # get an EMBOSS application object from the EMBOSS factory
24 $factory = Bio::Factory::EMBOSS->new();
25 $application = $factory->program('embossversion');
26 # run the application with an optional hash containing parameters
27 $result = $application->run(); # returns a string or creates a file
30 $water = $factory->program('water');
32 # here is an example of running the application
33 # water can compare 1 seq against 1->many sequences
34 # in a database using Smith-Waterman
35 my $seq_to_test; # this would have a seq here
36 my @seqs_to_check; # this would be a list of seqs to compare
38 my $wateroutfile = 'out.water';
39 $water->run({ -sequencea => $seq_to_test,
40 -seqall => \@seqs_to_check,
43 -outfile => $wateroutfile});
44 # now you might want to get the alignment
46 my $alnin = Bio::AlignIO->new(-format => 'emboss',
47 -file => $wateroutfile);
49 while( my $aln = $alnin->next_aln ) {
50 # process the alignment -- these will be Bio::SimpleAlign objects
55 The EMBOSSacd represents all the possible command line arguments that
56 can be given to an EMBOSS application.
58 Do not create this object directly. It will be created and attached to
59 its corresponding Bio::Tools::Run::EMBOSSApplication if you set
61 $application->verbose > 0
67 to retrive the Bio::Tools::Run::EMBOSSApplication::EMBOSSacd object.
69 See also L<Bio::Tools::Run::EMBOSSApplication> and L<Bio::Factory::EMBOSS>.
75 User feedback is an integral part of the evolution of this and other
76 Bioperl modules. Send your comments and suggestions preferably to the
77 Bioperl mailing lists Your participation is much appreciated.
79 bioperl-l@bioperl.org - General discussion
80 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
84 Please direct usage questions or support issues to the mailing list:
86 I<bioperl-l@bioperl.org>
88 rather than to the module maintainer directly. Many experienced and
89 reponsive experts will be able look at the problem and quickly
90 address it. Please include a thorough description of the problem
91 with code and data examples if at all possible.
95 report bugs to the Bioperl bug tracking system to help us keep track
96 the bugs and their resolution. Bug reports can be submitted via the
99 http://redmine.open-bio.org/projects/bioperl/
101 =head1 AUTHOR - Heikki Lehvaslaiho
103 Email: heikki-at-bioperl-dot-org
106 EMBL Outstation, European Bioinformatics Institute
107 Wellcome Trust Genome Campus, Hinxton
108 Cambs. CB10 1SD, United Kingdom
112 The rest of the documentation details each of the object
113 methods. Internal methods are usually preceded with a _
117 # Let the code begin...
119 package Bio
::Tools
::Run
::EMBOSSacd
;
120 use vars
qw(@ISA %QUALIFIER_CATEGORIES $QUAL %OPT);
126 @ISA = qw(Bio::Root::Root);
130 %QUALIFIER_CATEGORIES =
132 'Mandatory qualifiers' => 'mandatory',
133 'Standard (Mandatory) qualifiers' => 'mandatory',
134 'Optional qualifiers' => 'optional',
135 'Additional (Optional) qualifiers'=> 'optional',
136 'Advanced qualifiers' => 'advanced',
137 'Advanced (Unprompted) qualifiers'=> 'advanced',
138 'Associated qualifiers' => 'associated',
139 'General qualifiers' => 'general',
141 $QUAL; # qualifier category
149 Usage : $emboss_prog->acd($prog_name);
150 Function: Constructor for the class.
151 Calls EMBOSS program 'acdc', converts the
152 HTML output into XML and uses XML::Twig XML
153 parser to write out a hash of qualifiers which is
155 Throws : without program name
157 Args : EMBOSS program name
163 my($class, $prog) = @_;
165 eval {require XML
::Twig
;};
166 Bio
::Root
::Root
->warn("You need XML::Twig for EMBOSS ACD parsing")
167 and return undef if $@
;
169 Bio
::Root
::Root
->throw("Need EMBOSSprogram name as an argument")
174 my $version = `embossversion -auto`;
176 if ($version lt "2.8.0") {
177 # reading from EMBOSS program acdc stdout (prior to version 2.8.0)
178 $file = `acdc $prog -help -verbose -acdtable 2>&1`;
180 # reading from EMBOSS program acdtable stdout (version 2.8.0 or greater)
181 $file = `acdtable $prog -help -verbose 2>&1`;
184 # converting HTML -> XHTML for XML parsing
185 $file =~ s/border/border="1"/;
186 $file =~ s/=(\d+)/="$1"/g;
187 $file =~ s/<br>/<br><\/br
>/g
;
188 $file =~ s/ //g;
190 my $t = XML
::Twig
->new( TwigHandlers
=>
192 '/table/tr' => \
&_row
}
195 $t->safe_parse( $file);
197 #Bio::Root::Root->throw("XML parsing error: $@");
199 my %acd = %OPT; # copy to a private hash
200 $acd{'_name'} = $prog;
207 return if $row->text eq "(none)"; # no qualifiers in this category
209 my $name = $row->first_child; # qualifier name
211 my $namet = $name->text;
212 if ($namet =~ /qualifiers$/) { # set category
213 $QUAL = $QUALIFIER_CATEGORIES{$namet};
214 if( ! defined $QUAL ) {
215 warn("-- namet is $namet\n");
220 if ($namet =~ /\(Parameter (\d+)\)/) { # unnamed parameter
222 $namet =~ s/\(Parameter (\d+)\)//;
223 $namet =~ s/[\[\]]//g ; # name is in brackets
226 my $desc = $name->next_sibling;
227 my $values = $desc->next_sibling;
228 my $default = $values->next_sibling;
230 $OPT{$namet}{'unnamed'} = $unnamed;
231 $OPT{$namet}{'category'} = $QUAL;
232 $OPT{$namet}{'descr'} = $desc->text;
233 $OPT{$namet}{'values'} = $values->text;
234 $OPT{$namet}{'default'} = $default->text;
236 $t->purge; # to reduce memory requirements
242 Usage : $embossacd->name
243 Function: sets/gets the name of the EMBOSS program
244 Setting is done by the EMBOSSApplication object,
245 you should only get it.
247 Returns : name string
253 my ($self,$value) = @_;
254 if (defined $value) {
255 $self->{'_name'} = $value;
257 return $self->{'_name'};
264 Usage : $embossacd->print; $embossacd->print('-word');
265 Function: Print out the qualifiers.
266 Uses Data::Dumper to print the qualifiers into STDOUT.
267 A valid qualifier name given as an argment limits the output.
269 Returns : print string
270 Args : optional qualifier name
275 my ($self, $value) = @_;
276 if ($value and $self->{$value}) {
277 print Dumper
$self->{$value};
286 Usage : $acd->mandatory
287 Function: gets a mandatory subset of qualifiers
289 Returns : Bio::Tools::Run::EMBOSSacd object
297 foreach my $key (keys %{$self}) {
298 next unless $key =~ /^-/; #ignore other attributes
300 $mand{$key} = $self->{$key}
301 if $self->{$key}{category
} eq 'mandatory';
306 =head2 Qualifier queries
308 These methods can be used test qualifier names and read values.
315 Usage : $acd->qualifier($string)
316 Function: tests for the existence of the qualifier
319 Args : string, name of the qualifier
324 my ($self, $value) = @_;
326 $self->throw("Qualifier has to start with '-'")
327 unless $value =~ /^-/;
328 $self->{$value} ?
1 : 0
334 Usage : $acd->category($qual_name)
335 Function: Return the category of the qualifier
337 Returns : 'mandatory' or 'optional' or 'advanced' or
338 'associated' or 'general'
339 Args : string, name of the qualifier
344 my ($self, $value) = @_;
346 $self->throw("Not a valid qualifier name [$value]")
347 unless $self->qualifier($value);
348 $self->{$value}->{'category'};
354 Usage : $acd->values($qual_name)
355 Function: Return the possible values for the qualifier
358 Args : string, name of the qualifier
363 my ($self, $value) = @_;
365 $self->throw("Not a valid qualifier name [$value]")
366 unless $self->qualifier($value);
367 $self->{$value}->{'values'};
374 Usage : $acd->descr($qual_name)
375 Function: Return the description of the qualifier
378 Args : string, name of the qualifier
383 my ($self, $value) = @_;
385 $self->throw("Not a valid qualifier name [$value]")
386 unless $self->qualifier($value);
387 $self->{$value}->{'descr'};
394 Usage : $acd->unnamed($qual_name)
395 Function: Find if the qualifier can be left unnamed
397 Returns : 0 if needs to be named, order number otherwise
398 Args : string, name of the qualifier
403 my ($self, $value) = @_;
405 $self->throw("Not a valid qualifier name [$value]")
406 unless $self->qualifier($value);
407 $self->{$value}->{'unnamed'};
414 Usage : $acd->default($qual_name)
415 Function: Return the default value for the qualifier
418 Args : string, name of the qualifier
423 my ($self, $value) = @_;
425 $self->throw("Not a valid qualifier name [$value]")
426 unless $self->qualifier($value);
427 $self->{$value}->{'default'};