Skip to content

Commit

Permalink
reverse compliment
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjpage committed Aug 1, 2012
1 parent e82bc56 commit 8de6801
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions modules/MLST/Blast/BlastN.pm
Expand Up @@ -60,6 +60,7 @@ sub _build_top_hit
$top_hit{allele_name} = $blast_raw_results[0];
$top_hit{percentage_identity} = int($blast_raw_results[2]);
$top_hit{source_name} = $blast_raw_results[1];
$top_hit{reverse} = 0;

my $start = $blast_raw_results[8];
my $end = $blast_raw_results[9];
Expand All @@ -68,6 +69,7 @@ sub _build_top_hit
my $tmp = $start;
$start = $end;
$end = $tmp;
$top_hit{reverse} = 1;
}

$top_hit{source_start} = $start;
Expand Down
14 changes: 10 additions & 4 deletions modules/MLST/CompareAlleles.pm
Expand Up @@ -19,6 +19,7 @@ package MLST::CompareAlleles;
use Moose;
use File::Basename;
use Bio::SeqIO;
use Bio::Perl;
use MLST::Blast::Database;
use MLST::Blast::BlastN;
use MLST::Types;
Expand Down Expand Up @@ -117,11 +118,11 @@ sub _build_matching_sequences

if($top_blast_hit{percentage_identity} == 100 )
{
$matching_sequence_names{$top_blast_hit{allele_name}} = $self->_get_blast_hit_sequence($top_blast_hit{source_name}, $top_blast_hit{source_start},$top_blast_hit{source_end},$word_size);
$matching_sequence_names{$top_blast_hit{allele_name}} = $self->_get_blast_hit_sequence($top_blast_hit{source_name}, $top_blast_hit{source_start},$top_blast_hit{source_end},$word_size,$top_blast_hit{reverse});
}
else
{
$non_matching_sequence_names{$top_blast_hit{allele_name}} = $self->_get_blast_hit_sequence($top_blast_hit{source_name}, $top_blast_hit{source_start},$top_blast_hit{source_end},$word_size);
$non_matching_sequence_names{$top_blast_hit{allele_name}} = $self->_get_blast_hit_sequence($top_blast_hit{source_name}, $top_blast_hit{source_start},$top_blast_hit{source_end},$word_size,$top_blast_hit{reverse});
$self->new_st(1);
}
}
Expand All @@ -132,13 +133,18 @@ sub _build_matching_sequences

sub _get_blast_hit_sequence
{
my ($self, $contig_name, $start, $end, $word_size) = @_;
my ($self, $contig_name, $start, $end, $word_size, $reverse_complement) = @_;
seek($self->_sequence_handle->_fh, 0,0);
while( my $input_sequence_obj = $self->_sequence_handle->next_seq() )
{

next if( $input_sequence_obj->id ne $contig_name);
my $sequence = $input_sequence_obj->subseq($start, $end);
if($reverse_complement)
{
my $reverse_sequence = revcom( $sequence );
$sequence = $reverse_sequence->{seq};
}

$sequence = $self->_pad_out_sequence($sequence, $word_size);
return $sequence;
}
Expand Down

0 comments on commit 8de6801

Please sign in to comment.