#!perl -w
use strict;
package main;
use Test::More tests => 30;
{
BEGIN {
use_ok("TwoBio");
}
my $seq = Sequence->new;
isa_ok($seq, 'Sequence');
can_ok('Sequence',qw/revcom transpose/);
$seq->seq("catcatcat");
$seq->type("dna");
is($seq->seq,"catcatcat", "Test sequence");
is($seq->type,"dna", "Test sequence type");
is($seq->revcom,"atgatgatg","Test reverse complement");
is($seq->transpose("at","cg"),"ccgccgccg","Test transpose");
# test read and save of Sequence from file
open(FILE, "> temp.data") or die "Unable to open test file";
print FILE <<"EOF";
catcatcat
EOF
close FILE;
$seq = Sequence->new(file => "temp.data", form => "raw", type => "dna");
isa_ok($seq, 'Sequence');
is($seq->raw, "catcatcat\n", "Test of reading raw dna data");
$seq->seq($seq->raw);
is($seq->revcom, "\natgatgatg", "Test of revcom dna data");
unlink "temp.data";
$seq->save();
$seq = Sequence->new(file => "temp.data", form => "raw", type => "dna");
is($seq->raw, "catcatcat\n", "Test of saved seq data");
$seq = FASTA->new( );
isa_ok($seq, 'Sequence');
can_ok('FASTA',qw/revcom transpose extract/);
isa_ok($seq, 'FASTA');
$seq->type("dna");
is($seq->type,"dna", "Test sequence type");
$seq->form("FASTA");
is($seq->form,"FASTA", "Test file format");
$seq->raw("> solo flight of a bumblebee\ncatcatcat");
is($seq->raw,"> solo flight of a bumblebee\ncatcatcat",
"Test raw sequence");
is($seq->extract, qw/catcatcat/, "Test FASTA extract");
is($seq->anot,"> solo flight of a bumblebee", "Test annotation");
is($seq->seq,"catcatcat", "Test sequence");
is($seq->revcom,"atgatgatg","Test reverse complement");
is($seq->transpose("at","cg"),"ccgccgccg","Test transpose");
# test read of FASTA from file plus extract
open(FILE, "> temp.data") or die "Unable to open test file";
print FILE '> simple FASTA file
# dna follows
catcatcat
';
close FILE;
$seq = FASTA->new(file => "temp.data", form => "raw", type => "dna",
source => "NIH database");
isa_ok($seq, 'Sequence');
isa_ok($seq, 'FASTA');
is($seq->source, "NIH database", 'Test of FASTA source data');
my @lines = $seq->extract( );
my @check = ( "catcatcat" );
is_deeply(\@lines, \@check, 'Test array return of $seq->extract();');
is($seq->raw, "> simple FASTA file\n# dna follows\ncatcatcat\n",
"Test of raw FASTA dna data");
is($seq->anot, "> simple FASTA file\n# dna follows",
"Test of annot FASTA dna data");
is($seq->seq, "catcatcat", 'Test of extracted seq');
is($seq->revcom, "atgatgatg", "Test of revcom dna data");
}