#!perl -w use strict; # test functions package main; use Test::More tests => 22; { BEGIN { use_ok('Seq'); } can_ok('Seq', qw/new read concatenate motif print read_file/); can_ok('RNA', qw/new/); can_ok('DNA', qw/new count dna2rna revcom/); # Test Seq my $seq = Seq->new("GCAT"); isa_ok($seq, 'Seq'); isa_ok($seq, 'GetterSetter'); is($seq->seq, "GCAT", 'test $seq->seq( )'); # Test DNA my $dna = DNA->new("GCAT"); isa_ok($dna, 'DNA'); isa_ok($dna, 'Seq'); isa_ok($dna, 'GetterSetter'); is($dna->seq, "GCAT", 'test $dna->seq( )'); # Test RNA my $rna = RNA->new("GCAU"); isa_ok($rna, 'RNA'); isa_ok($rna, 'Seq'); isa_ok($rna, 'GetterSetter'); is($rna->seq, "GCAU", 'test $rna->seq( )'); # set up data my $seqfile = "throwaway.data"; my $data = ' AGCTAGCTCATCATCATCATTAGBAGDADTATGAGCGCAAAAAAAA BADBADGGGGCCCCATATATATATATATATAAAAAAAAAAAAAAAA '; open(FILE, "> $seqfile") or die("Unable to write: $seqfile: $!"); print FILE $data; close(FILE); # run tests is($seq->read_file($seqfile), 0, 'Test valid open of $seq->read_file'); $data =~ s/\s//g; is($seq->seq, $data, 'Test valid data from $seq->read_file'); # DNA testing my $text = $seq->dna->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 $dna->count() and output'); my $dna1 = new DNA("AGCT"); is($dna1->revcom()->seq,"AGCT", 'Test $dna->revcom()'); # DNA 2 RNA transcription is($dna1->dna2rna()->seq,"AGCU",'Test $dna->dna2rna()'); my $rna1 = $dna1->dna2rna; isa_ok($rna1, 'RNA'); # Seq testing my $seq1 = new Seq("AGCT"); is($seq1->concatenate("GATC")->seq,"AGCTGATC", 'Test $seq->concatenate()'); # Clean up any test files unlink($seqfile) or die("Unable to delete $seqfile: $!"); # successful exit exit (0); }