Skip to content

Commit

Permalink
Merging postreleasefix/89 to release/89
Browse files Browse the repository at this point in the history
* postreleasefix/89:
  extend FASTA synonym search to add/remove chr
  • Loading branch information
William McLaren committed Jun 15, 2017
2 parents c387308 + 1cb6932 commit 0afbd49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 13 additions & 3 deletions modules/Bio/EnsEMBL/Variation/Utils/FastaSequence.pm
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,17 @@ sub _new_slice_seq {
my $fasta_db = $Bio::EnsEMBL::Slice::fasta_db;
my $fa_length = $fasta_db->length($sr_name);
unless($fa_length && $fa_length > 0) {

foreach my $alt(keys %{$Bio::EnsEMBL::Slice::_fasta_synonyms->{$sr_name} || {}}) {
foreach my $alt(
$sr_name =~ /^chr/i ?
(substr($sr_name, 3), keys %{$Bio::EnsEMBL::Slice::_fasta_synonyms->{substr($sr_name, 3)} || {}}) :
(
'chr'.$sr_name,
'CHR'.$sr_name,
keys %{$Bio::EnsEMBL::Slice::_fasta_synonyms->{'chr'.$sr_name} || {}},
keys %{$Bio::EnsEMBL::Slice::_fasta_synonyms->{'CHR'.$sr_name} || {}}
),
keys %{$Bio::EnsEMBL::Slice::_fasta_synonyms->{$sr_name} || {}}
) {
$fa_length = $fasta_db->length($alt);

if($fa_length && $fa_length > 0) {
Expand Down Expand Up @@ -608,9 +617,10 @@ sub _raw_seq {
if($fasta_db->isa('Bio::DB::HTS::Faidx')) {
my $location_string = $sr_name.":".$start."-".$end ;
($seq, $length) = $fasta_db->get_sequence($location_string);
$seq = uc($seq);
}
elsif($fasta_db->isa('Bio::DB::Fasta')) {
$seq = $fasta_db->seq($sr_name, $start => $end);
$seq = uc($fasta_db->seq($sr_name, $start => $end));
}
else {
throw("ERROR: Don't know how to fetch sequence from a ".ref($fasta_db)."\n");
Expand Down
9 changes: 9 additions & 0 deletions modules/t/fastaSequence.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ $slice1 = Bio::EnsEMBL::Slice->new(
);
is($slice1->seq, 'G', "synonym");

$slice2 = Bio::EnsEMBL::Slice->new(
-COORD_SYSTEM => Bio::EnsEMBL::CoordSystem->new(-NAME => 'chromosome', -RANK => 1),
-START => 25606454,
-END => 25606454,
-SEQ_REGION_NAME => 'chrfoo',
-SEQ_REGION_LENGTH => $slice1->length
);
is($slice2->seq, 'G', "implied chr synonym");

# remember to revert!!!
revert_fasta();

Expand Down

0 comments on commit 0afbd49

Please sign in to comment.