Skip to content

Commit

Permalink
Consistent indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fangly committed Oct 18, 2012
1 parent a09f77f commit 6a001cd
Showing 1 changed file with 52 additions and 33 deletions.
85 changes: 52 additions & 33 deletions lib/Bio/Tools/Run/Alignment/Blat.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ methods. Internal methods are usually preceded with a _
=cut


package Bio::Tools::Run::Alignment::Blat;

use strict;
Expand Down Expand Up @@ -138,6 +139,7 @@ sub new {
return $self;
}


=head2 program_name
Title : program_name
Expand All @@ -149,9 +151,10 @@ sub new {
=cut

sub program_name {
return 'blat';
return 'blat';
}


=head2 program_dir
Title : program_dir
Expand All @@ -163,9 +166,10 @@ sub program_name {
=cut

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


=head2 run
Title : run()
Expand All @@ -177,20 +181,21 @@ sub program_dir {
=cut

sub run {
my ($self,$query) = @_;
my @feats;

if (ref($query) ) { # it is an object
if (ref($query) =~ /GLOB/) {
$self->throw("Cannot use filehandle as argument to run()");
}
my $infile = $self->_writeSeqFile($query);
my ($self,$query) = @_;
my @feats;

if (ref($query) ) { # it is an object
if (ref($query) =~ /GLOB/) {
$self->throw("Cannot use filehandle as argument to run()");
}
my $infile = $self->_writeSeqFile($query);
return $self->_run($infile);
} else {
return $self->_run($query);
}
} else {
return $self->_run($query);
}
}


=head2 align
Title : align
Expand All @@ -200,13 +205,15 @@ sub run {
=cut

sub align {
return shift->run(@_);
return shift->run(@_);
}


=head2 db
=cut


sub db {
my $self = shift;
return $self->{blat_db} = shift if @_;
Expand All @@ -218,6 +225,7 @@ sub db {

*DB = \&db;


=head2 qsegment
Title : qsegment
Expand All @@ -242,6 +250,7 @@ sub qsegment {
return $self->{blat_qsegment};
}


=head2 tsegment
Title : tsegment
Expand All @@ -266,13 +275,15 @@ sub tsegment {
return $self->{blat_tsegment};
}


# override this, otherwise one gets a default of 'mlc'
sub outfile_name {
my $self = shift;
return $self->{blat_outfile} = shift if @_;
return $self->{blat_outfile};
}


=head2 searchio
Title : searchio
Expand All @@ -298,12 +309,11 @@ sub searchio {
return $self->{blat_searchio} || {};
}


=head1 Bio::ParameterBaseI-specific methods
These methods are part of the Bio::ParameterBaseI interface
=cut

=head2 set_parameters
Title : set_parameters
Expand All @@ -313,6 +323,7 @@ These methods are part of the Bio::ParameterBaseI interface
Args : [optional] hash or array of parameter/values. These can optionally
be hash or array references
Note : This only sets parameters; to set methods use the method name
=cut

sub set_parameters {
Expand All @@ -338,6 +349,7 @@ sub set_parameters {
}
}


=head2 reset_parameters
Title : reset_parameters
Expand All @@ -356,6 +368,7 @@ sub reset_parameters {
}
}


=head2 validate_parameters
Title : validate_parameters
Expand All @@ -370,6 +383,7 @@ sub reset_parameters {

sub validate_parameters { 0 }


=head2 parameters_changed
Title : parameters_changed
Expand All @@ -383,6 +397,7 @@ sub validate_parameters { 0 }

sub parameters_changed { 1 }


=head2 available_parameters
Title : available_parameters
Expand All @@ -400,6 +415,7 @@ sub available_parameters {
return @params;
}


=head2 get_parameters
Title : get_parameters
Expand All @@ -422,12 +438,11 @@ sub get_parameters {
return %params;
}


=head1 to_* methods
All to_* methods are implementation-specific
=cut

=head2 to_exe_string
Title : to_exe_string
Expand Down Expand Up @@ -484,6 +499,7 @@ sub to_exe_string {
$string;
}


#=head2 _input
#
# Title : _input
Expand All @@ -496,12 +512,13 @@ sub to_exe_string {

sub _input() {
my ($self,$infile1) = @_;
if(defined $infile1){
$self->{'input'}=$infile1;
}
return $self->{'input'};
if (defined $infile1) {
$self->{'input'} = $infile1;
}
return $self->{'input'};
}


#=head2 _database
#
# Title : _database
Expand Down Expand Up @@ -530,31 +547,31 @@ sub _database() {
#=cut

sub _run {
my ($self)= shift;
my $str = $self->to_exe_string(-seq_file => shift);
my ($self)= shift;
my $str = $self->to_exe_string(-seq_file => shift);

my $out = $self->outfile_name || $self->_tempfile;

$str .= " $out".$self->_quiet;
$self->debug($str."\n") if( $self->verbose > 0 );
$self->debug($str."\n") if( $self->verbose > 0 );

my %params = $self->get_parameters;

my $status = system($str);
$self->throw( "Blat call ($str) crashed: $? \n") unless $status==0;
my $status = system($str);
$self->throw( "Blat call ($str) crashed: $? \n") unless $status==0;

my $format = exists($params{out}) ?
$searchio_map{$params{out}} : 'psl';

my @io = ref ($out) !~ /GLOB/ ? (-file => $out,) : (-fh => $out,);
my $blat_obj = Bio::SearchIO->new(%{$self->searchio},
my @io = ref ($out) !~ /GLOB/ ? (-file => $out,) : (-fh => $out,);
my $blat_obj = Bio::SearchIO->new(%{$self->searchio},
@io,
-query_type => $params{prot} ? 'protein' :
$params{q} || 'dna',
-hit_type => $params{prot} ? 'protein' :
$params{t} || 'dna',
-format => $format);
return $blat_obj;
return $blat_obj;
}


Expand All @@ -577,14 +594,16 @@ sub _writeSeqFile {
return $inputfile;
}


sub _tempfile {
my $self = shift;
my ($tfh,$outfile) = $self->io->tempfile(-dir=>$Bio::Root::IO::TEMPDIR);
# this is because we only want a unique filename
close($tfh);
# this is because we only want a unique filename
close($tfh);
return $outfile;
}


sub _quiet {
my $self = shift;
my $q = '';
Expand Down

0 comments on commit 6a001cd

Please sign in to comment.