Bio-MUST-Core
view release on metacpan or search on metacpan
{
for my $stk ( qw(cbs upsk) ) {
my $infile = file('test', "$stk.stockholm");
my $ali = $class->load_stockholm($infile);
is $ali->filename, $infile, 'got expected filename from stockholm file';
my $flag = $ali->is_protein;
ok( $stk eq 'cbs' ? $flag : !$flag,
"rightly detected alignment type: $infile" );
cmp_store(
obj => $ali, method => 'store',
file => "$stk.ali",
test => 'wrote expected Ali from stockholm',
);
}
}
{
for my $ks (0, 1) {
my $infile = file('test', 'tinyseq.xml');
my $ali = $class->load_tinyseq($infile, { keep_strain => $ks } );
is $ali->filename, $infile, 'got expected filename from tinyseq file';
my $flag = not $ali->is_protein;
ok( $flag, "rightly detected alignment type: $infile" );
cmp_store(
obj => $ali, method => 'store',
file => "tinyseq_ks$ks.ali",
test => 'wrote expected Ali from tinyseq (keeping strains)',
);
}
}
{
my $infile = file('test', 'uniq.ali');
my $ali = $class->load($infile);
ok not($ali->has_uniq_ids), 'rightly detected duplicate ids';
cmp_store(
obj => $ali, method => 'store',
file => 'uniq.ali',
test => 'wrote expected Ali in spite of duplicate ids',
);
}
{
my $infile = file('test', 'unaligned.ali');
my $ali = $class->load($infile);
ok not($ali->is_aligned), 'rightly detected lack of alignment';
cmp_ok $ali->width, '==', 25, 'got expected unaligned Ali width';
cmp_store(
obj => $ali, method => 'store',
file => 'unaligned.ali',
test => 'wrote expected unaligned Ali',
);
}
my @exp_nomiss_lens = (56, 54, 48, 54, 44, 50, 48, 50, 52, 34);
{
my $infile = file('test', 'complete.ali');
my $ali = $class->load($infile);
$ali->dont_guess;
ok !$ali->is_aligned, 'rightly overrided guessing of alignment';
cmp_store(
obj => $ali, method => 'store_fasta',
file => 'complete.fasta',
test => 'wrote expected unaltered FASTA from non-guessing Ali',
);
$ali->guess;
ok $ali->is_aligned, 'rightly detected alignment';
cmp_ok $ali->width, '==', 56, 'got expected Ali width';
is_deeply [ map { $_->nomiss_seq_len } $ali->all_seqs ], \@exp_nomiss_lens,
'got expected seq lengths (excluding gaps and missing chars)';
}
{
my $infile = file('test', 'AhHMA4_clustalw.ali');
my $ali = $class->load($infile);
cmp_store(
obj => $ali, method => 'temp_fasta',
file => 'temp_degap.fasta',
test => 'wrote expected temp degapped .fasta file',
args => { degap => 1 },
);
is_deeply [ map { $_->full_id } $ali->all_seq_ids ], \@exp_full_ids,
'rightly restored original ids after temp file creation';
cmp_store(
obj => $ali, method => 'temp_fasta',
file => 'temp_degap_nowrap.fasta',
test => 'wrote expected temp degapped and unwrapped.fasta file',
args => { degap => 1, chunk => -1 },
);
cmp_store(
obj => $ali, method => 'temp_fasta',
file => 'temp.fasta',
test => 'wrote expected temp .fasta file (no degapping side-effect)',
);
cmp_store(
obj => $ali, method => 'temp_fasta',
file => 'temp_prefix.fasta',
test => 'wrote expected temp .fasta file (custom std_mapper prefix)',
args => { id_prefix => 'myseq' },
);
}
# TODO: check that mutators indeed return the Ali object?
# TODO: consider keeping empty seqs when parsing Ali (not that easy)
# {
# my $infile = file('test', 'empty_seqs.ali');
# my $ali = $class->load($infile);
# explain $ali;
# cmp_ok $ali->count_seqs, '==', 3;
# ok(List::AllUtils::all { $_->seq_len == 0 } $ali->all_seqs),
# 'rightly read an Ali full of empty seqs';
# }
# uc_seqs
{
my $infile = file('test', 'seqs4uc.ali');
my $ali = $class->load($infile);
my $ali_uc = $ali->uc_seqs;
( run in 0.722 second using v1.01-cache-2.11-cpan-39bf76dae61 )