Bio::EnsEMBL::Analysis::Runnable BestPmatch
Included librariesPackage variablesGeneral documentationMethods
Toolbar
WebCvsRaw content
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Analysis::Runnable
Bio::EnsEMBL::Analysis::Tools::GeneBuildUtils qw ( id coord_string )
Bio::EnsEMBL::Utils::Argument qw ( rearrange )
Bio::EnsEMBL::Utils::Exception qw ( throw warning )
Inherit
Bio::EnsEMBL::Analysis::Runnable
Synopsis
No synopsis!
Description
No description!
Methods
min_coverage
No description
Code
new
No description
Code
protein_hash
No description
Code
protein_hits
No description
Code
prune_hits
No description
Code
run
No description
Code
Methods description
None available.
Methods code
min_coveragedescriptionprevnextTop
sub min_coverage {
  my ($self, $arg) = @_;
  if($arg){
    $self->{'min_coverage'} = $arg;
  }
  return $self->{'min_coverage'};
}
newdescriptionprevnextTop
sub new {
  my ($class,@args) = @_;
  my $self = $class->SUPER::new(@args);

  my ($pafs, $min_coverage) = rearrange(['PROTEIN_HITS', 'MIN_COVERAGE'], @args);
  
  ###SETTING DEFAULTS###
$self->min_coverage(25); #######################
$self->protein_hits($pafs); $self->min_coverage($min_coverage); return $self;
}
protein_hashdescriptionprevnextTop
sub protein_hash {
  my ($self, $hash) = @_;
  if(!$self->{'_proteins'}){
    $self->{'_proteins'} = {};
  }
  if($hash){
    throw("Must pass protein_hash a hashref not ".$hash) 
      if(ref($hash) ne 'HASH');
    $self->{'_proteins'} = $hash;
  }
  return $self->{'_proteins'};
}
protein_hitsdescriptionprevnextTop
sub protein_hits {
  my ($self, $ref) = @_;
  if($ref){
    if(ref($ref) ne "ARRAY"){
      throw("Runnable::BestPmatch Must pass protein hits an array ref not ".$ref);
    }
    $self->{protein_hits} = $ref;
  }
  return $self->{protein_hits};
}
prune_hitsdescriptionprevnextTop
sub prune_hits {
  my ($self, $hits) = @_;

  $hits = $self->protein_hits if(!$hits);
  my @chosen;
  my %prots = %{$self->protein_hash};
 PROTEIN:foreach my $p(keys(%{$self->protein_hash})){
    my $allhits = $prots{$p};
    my @sorted = sort {$b->score <=> $a->score} @$allhits;

    my $first = shift(@sorted);
    my $score_boundary = $first->score() - 2; 
    my $lower_threshold = $self->min_coverage;
    next PROTEIN if $first->score < $lower_threshold;
    push(@chosen, $first);
  PRUNE:foreach my $hit(@sorted){
      last PRUNE if($hit->score < $score_boundary);
      last PRUNE if($hit->score < $lower_threshold);
      push(@chosen, $hit);
    }
  }
  return\@ chosen;
}

1;
}
rundescriptionprevnextTop
sub run {
  my ($self) = @_;
  my %prots;
  foreach my $hit(@{$self->protein_hits}){
    push (@{$prots{$hit->hseqname}}, $hit);
  }
  $self->protein_hash(\%prots);
  my $hits = $self->prune_hits;
  my %unique;
  foreach my $hit(@$hits){
    my $string = id($hit)."-".coord_string($hit);
    if(!$unique{$string}){
      $hit->analysis($self->analysis);
      $unique{$string} = $hit;
    }
  }
  my @output = values(%unique);
  $self->output(\@output);
}
General documentation
No general documentation available.