# test functions
package main;
use Test::More tests => 8;
{
BEGIN {
use_ok('Seq2');
}
can_ok('Seq2', qw/new read concatenate count dna2rna print_dna
read_file reverse_complement/);
my $seq = Seq2->new("GCAT");
isa_ok($seq, 'Seq2');
# set up data
my $seqfile = "throwaway.data";
my $data = '
AGCTAGCTCATCATCATCATTAGBAGDADTATGAGCGCAAAAAAAA
BADBADGGGGCCCCATATATATATATATATAAAAAAAAAAAAAAAA
';
open(FILE, "> $seqfile") or die("Unable to write: $sequence: $!");
print FILE $data;
close(FILE);
# run tests
my @seqinfo = $seq->read_file($seqfile);
$data =~ s/\s//g;
my $seqinfo = join('', @seqinfo);
$seqinfo =~ s/\s//g;
is($data, $seqinfo, 'test of $seq->read_file()');
my $text = $seq->count();
# note the use of tab as \t and newline as \n
# These are hard to spot in testing
# I let the test tell me the answers:
# is($text,"tell me", "Test of counts and output");
is($text,"throwaway.data:\tA=45 C=12 G=11 T=17 errors=7\n",
'Test of $seq->count() and output');
my $seq1 = new Seq2("AGCT");
is($seq1->concatenate("GATC")->{seq},"AGCTGATC",
'Test $seq->concatenate()');
is($seq1->reverse_complement()->{seq},"AGCT",
'Test $seq->reverse_complement()');
is($seq1->dna2rna()->{seq},"AGCU",'Test $seq->dna2rna()');
# Clean up any test files
unlink($seqfile) or die("Unable to delete $seqfile: $!");
# successful exit
exit (0);
}