2014-06-03 19:22:39 -07:00
#!/usr/bin/env perl
use strict ;
use warnings ;
use Test::More ;
2016-05-16 06:07:57 -07:00
use Test::Deep ;
2014-06-03 19:22:39 -07:00
use DDG::Test::Goodie ;
2014-10-06 05:06:42 -07:00
zci answer_type = > 'reverse_complement' ;
zci is_cached = > 1 ;
2016-05-18 14:20:30 -07:00
my @ aaaacccggt = ( "ACCGGGTTTT" , 'AAAACCCGGT' ) ;
sub build_test {
my ( $ answer , $ input ) = @ _ ;
return test_zci ( $ answer , structured_answer = > {
data = > {
title = > $ answer ,
subtitle = > "Nucleotide reverse complement: $input"
} ,
templates = > {
group = > 'text'
}
2016-05-18 14:21:20 -07:00
} ) ;
2016-05-18 14:20:30 -07:00
}
2014-06-03 19:22:39 -07:00
ddg_goodie_test (
2014-10-06 05:06:42 -07:00
[ qw( DDG::Goodie::ReverseComplement ) ] ,
#Basic DNA reverse complements, various trigger combinations
2016-05-18 14:21:20 -07:00
'AAAACCCGGT reverse complement' = > build_test ( @ aaaacccggt ) ,
2016-05-18 14:20:30 -07:00
'AAAACCCGGT revcomp' = > build_test ( @ aaaacccggt ) ,
'revcomp AAAACCCGGT' = > build_test ( @ aaaacccggt ) ,
'revcomp of AAAACCCGGT' = > build_test ( @ aaaacccggt ) ,
'DNA revcomp of sequence AAAACCCGGT' = > build_test ( @ aaaacccggt ) ,
'reverse complement of RNA sequence AAAACCCGGU' = > build_test ( "ACCGGGTTTT" , 'AAAACCCGGU' ) ,
2016-05-18 14:21:20 -07:00
'reverse complement of TTTGATCATGGCTCAGGACGAACGCTGGCGGCGT' = > build_test ( "ACGCCGCCAGCGTTCGTCCTGAGCCATGATCAAA" , 'TTTGATCATGGCTCAGGACGAACGCTGGCGGCGT' ) ,
2014-10-06 05:06:42 -07:00
#RNA reverse complement with acceptable spacing characters
2016-05-18 14:20:30 -07:00
'reverse complement uca gac gga' = > build_test ( "TCCGTCTGA" , 'UCAGACGGA' ) ,
'reverse complement of nucleotide sequence uca-gac-gga' = > build_test ( "TCCGTCTGA" , 'UCAGACGGA' ) ,
2014-10-06 05:06:42 -07:00
#With ambiguous bases (both DNA and RNA)
'reverse complement TCAAAWWDGGATTAMATACCCTGGTAGTCCACRCCATAAACGATGTATGCTTGGTGRGVGTGAGTAATCACTCAGTMCGAAGGCAACCTGATAAGCATACCKCCTVGAGTACGATCSCAAGGTTGAAACTCA DNA sequence'
2016-05-18 14:20:30 -07:00
= > build_test (
"TGAGTTTCAACCTTGSGATCGTACTCBAGGMGGTATGCTTATCAGGTTGCCTTCGKACTGAGTGATTACTCACBCYCACCAAGCATACATCGTTTATGGYGTGGACTACCAGGGTATKTAATCCHWWTTTGA" ,
'TCAAAWWDGGATTAMATACCCTGGTAGTCCACRCCATAAACGATGTATGCTTGGTGRGVGTGAGTAATCACTCAGTMCGAAGGCAACCTGATAAGCATACCKCCTVGAGTACGATCSCAAGGTTGAAACTCA'
) ,
2014-10-06 05:06:42 -07:00
'reverse complement CUAKCCAAGCCGACGASUCGGUAGCUGGUCUGAGAGKGACGAACAGCCACACUGGAACUGAGACAYCGGUCCAGACUCCUACGGGAGGCAGCAGUGAGGAAUAUUGGUCAAKUGGACRGCAAGUCUGAACCAYGCGACGRCGCGUGCGGGAUGAAGGGGCUUAGCCUCGUAAACDCGCURGUCAAGAGGGACGAGAGGHGCGAUUUUGUMCGUCCGGGWWACGV'
2016-05-18 14:21:20 -07:00
= > build_test (
2016-05-18 14:20:30 -07:00
"BCGTWWCCCGGACGKACAAAATCGCDCCTCTCGTCCCTCTTGACYAGCGHGTTTACGAGGCTAAGCCCCTTCATCCCGCACGCGYCGTCGCRTGGTTCAGACTTGCYGTCCAMTTGACCAATATTCCTCACTGCTGCCTCCCGTAGGAGTCTGGACCGRTGTCTCAGTTCCAGTGTGGCTGTTCGTCMCTCTCAGACCAGCTACCGASTCGTCGGCTTGGMTAG" ,
'CUAKCCAAGCCGACGASUCGGUAGCUGGUCUGAGAGKGACGAACAGCCACACUGGAACUGAGACAYCGGUCCAGACUCCUACGGGAGGCAGCAGUGAGGAAUAUUGGUCAAKUGGACRGCAAGUCUGAACCAYGCGACGRCGCGUGCGGGAUGAAGGGGCUUAGCCUCGUAAACDCGCURGUCAAGAGGGACGAGAGGHGCGAUUUUGUMCGUCCGGGWWACGV' ,
2014-10-06 05:06:42 -07:00
) ,
#Mix of DNA and RNA bases (should return empty, as it is more likely that this
# is an error than one of the edge cases of uracil-containing DNA)
'reverse complement AAATTTCCCGGGUUU' = > undef ,
#Non-nucleic acid query strings (should return empty, no idea what they wanted)
'reverse complement hello-this-is-DNA' = > undef ,
'DNA reverse complement' = > undef ,
2014-06-03 19:22:39 -07:00
) ;
done_testing ;