Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #551 from killerfish/revcomp
Browse files Browse the repository at this point in the history
Reverse complement fix for issue #548
  • Loading branch information
mintsoft committed Jul 13, 2014
2 parents ee621a7 + 0b1923d commit b4ed184
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 3 additions & 6 deletions lib/DDG/Goodie/ReverseComplement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ handle remainder => sub {
$sequence =~ s/\bsequence\b//gi;
$sequence =~ s/\b[DR]NA\b//gi;
$sequence =~ s/\bnucleotide\b//gi;

#Remove whitespace and dashes and make uppercase
$sequence =~ s/\s|-//g;
$sequence = uc($sequence);

#Return nothing if sequence contains characters
#Return nothing if sequence does not contains characters or contains characters
# other than DNA/RNA bases or standard IUPAC ambiguity codes
return if $sequence =~ /[^ATCGURYKMSWBVDHN]/;

return unless ($sequence =~ /^[ATCGURYKMSWBVDHN]+$/);
#DNA contains thymine (T) but not uracil (U);
# RNA contains U but not T (with some extremely
# rare exceptions). Hence, if the sequence
Expand All @@ -45,7 +42,7 @@ handle remainder => sub {

#Reverse
$sequence = reverse($sequence);

return $sequence, html => wrap_html('DNA reverse complement:', $sequence);
};

Expand Down
3 changes: 2 additions & 1 deletion t/ReverseComplement.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ ddg_goodie_test(
# is an error than one of the edge cases of uracil-containing DNA)
'reverse complement AAATTTCCCGGGUUU' => undef,

#Non-nucleic acid query string (should return empty, no idea what they wanted)
#Non-nucleic acid query strings (should return empty, no idea what they wanted)
'reverse complement hello-this-is-DNA' => undef,
'DNA reverse complement' => undef,

);

Expand Down

0 comments on commit b4ed184

Please sign in to comment.