This file is indexed.

/usr/share/perl5/Bio/Tools/Run/EMBOSSApplication.pm is in libbio-perl-run-perl 1.6.9-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# $Id$
#
# BioPerl module for Bio::Tools::Run::EMBOSSApplication
#
# Copyright Heikki Lehvaslaiho
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::Tools::Run::EMBOSSApplication - class for EMBOSS Applications

=head1 SYNOPSIS

  use Bio::Factory::EMBOSS;
  # get an EMBOSS application object from the EMBOSS factory
  $factory = Bio::Factory::EMBOSS->new();
  $application = $factory->program('embossversion');
  # run the application with an optional hash containing parameters
  $result = $application->run(); # returns a string or creates a file
  print $result . "\n";

  $water = $factory->program('water');

  # here is an example of running the application
  # water can compare 1 seq against 1->many sequences
  # in a database using Smith-Waterman
  my $seq_to_test;     # this would have a seq here
  my @seqs_to_check; # this would be a list of seqs to compare 

  my $wateroutfile = 'out.water';
  $water->run({-sequencea => $seq_to_test,
               -seqall    => \@seqs_to_check,
               -gapopen   => '10.0',
               -gapextend => '0.5',
               -outfile   => $wateroutfile});
  # now you might want to get the alignment
  use Bio::AlignIO;
  my $alnin = Bio::AlignIO->new(-format => 'emboss',
			                      -file   => $wateroutfile);

  while ( my $aln = $alnin->next_aln ) {
      # process the alignment -- these will be Bio::SimpleAlign objects
  }

=head1 DESCRIPTION

The EMBOSSApplication class can represent EMBOSS any program. It is
created by a L<Bio::Factory::EMBOSS> object.

If you want to check command line options before sending them to the
program set $prog-E<gt>verbose to positive integer. The ADC
description of the available command line options is then parsed in
and compared to input.

See also L<Bio::Factory::EMBOSS> and L<Bio::Tools::Run::EMBOSSacd>.

=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to the
Bioperl mailing lists  Your participation is much appreciated.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

=head2 Support 

Please direct usage questions or support issues to the mailing list:

I<bioperl-l@bioperl.org>

rather than to the module maintainer directly. Many experienced and 
reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem 
with code and data examples if at all possible.

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution.  Bug reports can be submitted via the
web:

  http://redmine.open-bio.org/projects/bioperl/

=head1 AUTHOR - Heikki Lehvaslaiho

Email  heikki-at-bioperl-dot-org

=head2 CONTRIBUTORS

Email: jason-AT-bioperl_DOT_org

=head1 APPENDIX

The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _

=cut

# Let the code begin...

package Bio::Tools::Run::EMBOSSApplication;
use vars qw( $SEQIOLOADED $ALIGNIOLOADED );
use strict;
use Data::Dumper;
use Bio::Tools::Run::EMBOSSacd;
use base qw(Bio::Root::Root Bio::Tools::Run::WrapperBase);

sub new {
  my($class, $args) = @_;
  my $self = $class->SUPER::new();

  $self->name($args->{'name'});
  $self->verbose($args->{'verbose'});

  $self->acd if $self->verbose > 0;

  return $self;
}

=head2 run

 Title   : run
 Usage   : $embossapplication->run($attribute_hash)
 Function: Runs the EMBOSS program.
 Returns : string or creates files for now; will return objects!
 Args    : hash of input to the program

=cut

sub run {
	my ($self, $input) = @_;
	$self->io->_io_cleanup();
	# test input
	$self->debug( Dumper($input) );

	# parse ACD information
	$self->acd if $self->verbose > 0;

	# collect the options into a string
	my $option_string = '';
	foreach my $attr (keys %{$input}) {
		my $attr_name = substr($attr, 1) if substr($attr, 0, 1) =~ /\W/;

		my $array = 0;

		if( defined $input->{$attr} && ref($input->{$attr}) ) {

			my (@pieces);

			if( $array = (ref($input->{$attr}) =~ /array/i) ) {
				foreach my $s ( @{$input->{$attr}} ) {
					@pieces = @{$input->{$attr}};
				}
			} else {
				@pieces = ($input->{$attr});
			}
			if( ! defined $pieces[0] ) {
				# we ignore for now
				$self->warn("specified a parameter $attr with no value");
				$input->{$attr} = undef;
				return;
			} elsif( $pieces[0]->isa('Bio::PrimarySeqI') ) {
				unless(  $SEQIOLOADED ) { 
					require Bio::SeqIO;
					$SEQIOLOADED = 1;
				}
				my ($tfh,$tempfile) = $self->io->tempfile(-dir => $self->tempdir);
				my $out = Bio::SeqIO->new(-format => 'fasta',
												 -fh     => $tfh);
				foreach my $seq ( @pieces ) {
					$out->write_seq($seq);
				}
				$out->close();
				$input->{$attr} = $tempfile;
				close($tfh);
				undef $tfh;
			} elsif( $pieces[0]->isa('Bio::Align::AlignI') ) {
				unless(  $ALIGNIOLOADED ) { 
					require Bio::AlignIO;
					$ALIGNIOLOADED = 1;
				}
				my ($tfh,$tempfile) = $self->io->tempfile();
				my $out = Bio::AlignIO->new(-format => 'msf',
													-fh     => $tfh);
				foreach my $p ( @pieces ) {
					$out->write_aln($p);
				}
				$input->{$attr} = $tempfile;
				close($tfh);
				undef $tfh;
			}
		}

		# check each argument against ACD
		if ($self->verbose > 0) {

			last unless defined $self->acd; # might not have the parser

			$self->throw("Attribute [$attr] not recognized!\n")
			  unless $self->acd->qualifier($attr);
		}

		# print out debugging info
		$self->debug("Input attr: ". $attr_name. " => ".
						 $input->{$attr}. "\n");
		$option_string .= " " . $attr;
		$option_string .= " ". $input->{$attr}
		  if defined $input->{$attr};
	}

	# check mandatory attributes against given ones
	if ($self->verbose > 0) {
		last unless defined $self->acd; # might not have the parser
		#	$self->acd->mandatory->print;
		#	if ($self->name eq 'water') {
		#	    print Dumper($self->acd->mandatory);
		#	}
		foreach my $attr (keys %{$self->acd->mandatory} ) {
			last unless defined $self->acd; # might not have the parser
			unless (defined $input->{$attr}) {
				print "-" x 38, "\n", "MISSING MANDATORY ATTRIBUTE: $attr\n", 
				  "-" x 38, "\n";
				$self->acd->print($attr) and
				  $self->throw("Program ". $self->name.
									" needs attribute [$attr]!\n")
			  }
		}
	}
	my $runstring = join (' ', $self->name, $option_string, '-auto');
	$self->debug( "Command line: ", $runstring, "\n"); 
	return `$runstring`;
}

=head2 acd

 Title   : acd
 Usage   : $embossprogram->acd
 Function: finds out all the possible qualifiers for this
           EMBOSS application. They can be used to debug the
           options given.
 Throws  : 
 Returns : boolean
 Args    : 

=cut

sub acd {
    my ($self) = @_;
    unless ( $self->{'_acd'} ) {
	$self->{'_acd'} =
	    Bio::Tools::Run::EMBOSSacd->new($self->name);
    }
    return $self->{'_acd'};
}

=head2 name

 Title   : name
 Usage   : $embossprogram->name
 Function: sets/gets the name of the EMBOSS program
           Setting is done by the EMBOSSFactory object,
           you should only get it.
 Throws  : 
 Returns : name string
 Args    : None

=cut

sub name {
    my ($self,$value) = @_;
    if (defined $value) {
	$self->{'_name'} = $value;
    }
    return $self->{'_name'};
}


=head2 descr

 Title   : descr
 Usage   : $embossprogram->descr
 Function: sets/gets the descr of the EMBOSS program
           Setting is done by the EMBOSSFactory object,
           you should only get it.
 Throws  : 
 Returns : description string
 Args    : None

=cut

sub descr {
    my ($self,$value) = @_;
    if (defined $value) {
	$self->{'_descr'} = $value;
    }
    return $self->{'_descr'};
}


=head2 group

 Title   : group
 Usage   : $embossprogram->group
 Function: sets/gets the group of the EMBOSS program
           Setting is done by the EMBOSSFactory object,
           you should only get it.

           If the application is assigned into a subgroup
           use l<subgroup> to get it.
 Throws  : 
 Returns : string, group name
 Args    : group string

=cut

sub group {
    my ($self,$value) = @_;
    if (defined $value) {
	my ($group, $subgroup) = split ':', $value;
	$self->{'_group'} = $group;
	$self->{'_subgroup'} = $subgroup;
    }
    return $self->{'_group'};
}


=head2 subgroup

 Title   : subgroup
 Usage   : $embossprogram->subgroup
 Function: sets/gets the subgroup of the EMBOSS program
           Setting is done by the EMBOSSFactory object,
           you should only get it.
 Throws  : 
 Returns : string, subgroup name; undef if not defined
 Args    : None

=cut

sub subgroup {
    my ($self) = @_;
    return $self->{'_subgroup'};
}

=head2 program_dir

 Title   : program_dir
 Usage   :
 Function: Required by WrapperBase
 Throws  :
 Returns : Name of directory with EMBOSS programs
 Args    :

=cut

sub program_dir {
	return Bio::Root::IO->catfile($ENV{EMBOSS_ACDROOT});
}

=head2 program_path

 Title   : program_path
 Usage   :
 Function: Required by WrapperBase
 Throws  :
 Returns : Full path of program
 Args    :

=cut

sub program_path {
	my $self = shift;
	my $name = $self->{_name};
	my $dir = Bio::Root::IO->catfile($ENV{EMBOSS_ACDROOT});
	return "$dir/$name";
}

=head2 executable

 Title   : executable
 Usage   :
 Function: Required by WrapperBase
 Throws  :
 Returns : Name of program
 Args    :

=cut

sub executable {
	my $self = shift;
	$self->{_name};
}

1;