my
$NUMTESTS
;
my
$error
;
BEGIN {
if
( $@ ) {
}
$error
= 0;
if
($@) {
print
STDERR
"XML::Writer not found, skipping game test\n"
;
$error
= 1;
}
$NUMTESTS
= (
$error
== 1) ? 44 : 46;
plan
tests
=>
$NUMTESTS
;
}
my
@seqformats
=
qw{ ace embl fasta gcg genbank mase
pfam pir raw swiss tab }
;
push
@seqformats
,
"game"
if
(
$error
== 0);
ok 1;
my
$format
;
my
$verbose
=1;
my
%no_seqio_module
=
map
{
$_
=>1}
qw {gcgblast
gcgfasta mase pfam};
my
$guessed_format
= new Bio::Tools::GuessSeqFormat
(
-file
=> Bio::Root::IO->catfile(
"t"
,
"data"
,
"test.waba"
))->guess;
ok
$guessed_format
,
undef
;
eval
{
my
$input
= Bio::SeqIO->new
(
-file
=>Bio::Root::IO->catfile(
"t"
,
"data"
,
"test.waba"
));
ok
my
$seq
=
$input
->next_seq();
};
$@ ? ok 1 : ok 0;
foreach
$format
(
@seqformats
) {
my
$guessed_format
= new Bio::Tools::GuessSeqFormat
(
-file
=> Bio::Root::IO->catfile(
"t"
,
"data"
,
"test.$format"
),
)->guess;
$format
=~ s/\..*$//;
ok
$guessed_format
,
$format
;
next
if
$no_seqio_module
{
$format
};
eval
{
my
$input
= Bio::SeqIO->new
(
-file
=>Bio::Root::IO->catfile(
"t"
,
"data"
,
"test.$format"
));
ok
my
$seq
=
$input
->next_seq();
};
ok 0, 1, $@
if
$@;
}
@seqformats
=
qw{ aln:clustalw fasta mase msf nexus pfam phylip
prodom stockholm}
;
my
%no_alignio_module
=
map
{
$_
=>1}
qw {};
foreach
my
$ext
(
@seqformats
) {
my
$format
;
(
$ext
,
$format
) =
split
/:/,
$ext
;
my
$guesser
= new Bio::Tools::GuessSeqFormat
(
-file
=> Bio::Root::IO->catfile(
"t"
,
"data"
,
"testaln.$ext"
));
$format
||=
$ext
;
ok
$guesser
->guess(),
$format
;
next
if
$no_alignio_module
{
$format
};
eval
{
my
$input
= Bio::AlignIO->new
(
-file
=>Bio::Root::IO->catfile(
"t"
,
"data"
,
"testaln.$ext"
));
ok
my
$seq
=
$input
->next_aln();
};
ok 0, 1, $@
if
$@;
}
if
(
eval
'require IO::String; 1'
) {
my
$string
= ">test1
no
comment
agtgctagctagctagctagct
>test2
no
comment
gtagttatgc
";
my
$stringfh
= new IO::String(
$string
);
my
$seqio
= new Bio::SeqIO(
-fh
=>
$stringfh
);
while
(
my
$seq
=
$seqio
->next_seq ) {
ok
$seq
->id =~ /test/;
}
ok new Bio::Tools::GuessSeqFormat(
-text
=>
$string
)->guess,
'fasta'
;
}
else
{
for
(1..3) {
skip(
"skipping guessing format from string, IO::String not installed"
,1);
}
}