61
61
ok($NGmat->[0]->[1]->{'omega'}, 0.2507);
62
62
ok($NGmat->[0]->[1]->{'dN'}, 0.0863);
63
63
ok($NGmat->[0]->[1]->{'dS'}, 0.3443);
64
65
ok($NGmat->[2]->[3]->{'omega'}, 0.2178);
65
66
ok($NGmat->[2]->[3]->{'dN'}, 0.1348);
66
67
ok($NGmat->[2]->[3]->{'dS'}, 0.6187);
68
ok($MLmat->[0]->[1]->{'omega'}, 0.1948);
69
ok($MLmat->[0]->[1]->{'omega'}, 0.19479);
69
70
ok($MLmat->[0]->[1]->{'dN'}, 0.0839);
70
71
ok($MLmat->[0]->[1]->{'dS'}, 0.4309);
71
72
ok($MLmat->[0]->[1]->{'lnL'}, -1508.607268);
72
ok($MLmat->[2]->[3]->{'omega'}, 0.1611);
73
ok($MLmat->[0]->[1]->{'t'}, 0.47825);
74
ok($MLmat->[0]->[1]->{'kappa'}, 2.29137);
76
ok($MLmat->[2]->[3]->{'omega'}, 0.16114);
73
77
ok($MLmat->[2]->[3]->{'dN'}, 0.1306);
74
78
ok($MLmat->[2]->[3]->{'dS'}, 0.8105);
75
79
ok($MLmat->[2]->[3]->{'lnL'},-1666.440696);
80
ok($MLmat->[2]->[3]->{'t'}, 0.85281);
81
ok($MLmat->[2]->[3]->{'kappa'}, 2.21652);
77
83
my @codonposfreq = $result->get_codon_pos_basefreq();
78
84
ok($codonposfreq[0]->{'A'}, 0.23579);
244
250
ok($firstsite->[1], 'L');
245
251
ok($firstsite->[2], 0.6588);
253
# codeml NSSites parsing
256
my $codeml_m0 = new Bio::Tools::Phylo::PAML
257
(-file => Bio::Root::IO->catfile(qw/t data M0.mlc/));
259
my $result_m0 = $codeml_m0->next_result;
260
my ($nssite_m0,$nssite_m1) = $result_m0->get_NSSite_results;
261
ok($nssite_m0->num_site_classes,1);
262
my $class_m0 = $nssite_m0->dnds_site_classes;
263
ok($class_m0->{q/p/}->[0],q/1.00000/);
264
ok($class_m0->{q/w/}->[0],0.09213);
266
ok($nssite_m0->model_num, "0");
267
@trees= $nssite_m0->get_trees;
270
ok($trees[0]->score, -30.819156);
271
ok($nssite_m1->model_num, "1");
272
@trees= $nssite_m1->get_trees;
273
ok($trees[0]->score, -30.819157);
278
my $baseml_p = Bio::Tools::Phylo::PAML->new
279
(-file => Bio::Root::IO->catfile(qw(t data baseml.pairwise)));
281
my $baseml = $baseml_p->next_result;
282
my @b_seqs = $baseml->get_seqs;
283
ok($b_seqs[0]->seq, 'GTAGAGTACTTT');
284
ok($b_seqs[1]->seq, 'GTAAGAGACGAT');
286
my @otus = map { $_->display_id } @b_seqs;
288
my $ntfreq = $baseml->get_NTFreqs;
290
ok($ntfreq->{$otus[0]}->{'A'}, '0.3333');
291
ok($ntfreq->{$otus[1]}->{'G'}, '0.2105');
292
my $kappaM = $baseml->get_KappaMatrix;
294
ok($kappaM->get_entry($otus[1],$otus[0]), '0.3240');
295
ok($kappaM->get_entry($otus[0],$otus[1]),
296
$kappaM->get_entry($otus[1],$otus[0]));
297
ok($kappaM->get_entry($otus[1],$otus[2]), '0.1343');
298
my $alphaM = $baseml->get_AlphaMatrix;
300
ok($alphaM->get_entry($otus[1],$otus[0]), '9.3595');
301
ok($alphaM->get_entry($otus[0],$otus[1]),
302
$alphaM->get_entry($otus[1],$otus[0]));
303
ok($alphaM->get_entry($otus[1],$otus[2]), '1.1101');
304
ok($alphaM->get_entry($otus[0],$otus[2]), '33.1197');
306
# codeml NSSites parsing
309
my $codeml_single = new Bio::Tools::Phylo::PAML
310
(-file => Bio::Root::IO->catfile(qw/t data singleNSsite.mlc/));
312
my $result_single = $codeml_single->next_result;
313
my ($nssite_single) = $result_single->get_NSSite_results;
314
ok($nssite_single->num_site_classes,q/3/);
315
ok($nssite_single->kappa, q/5.28487/);
316
ok($nssite_single->likelihood,q/-30.819156/);
318
ok($baseml->get_stat('loglikelihood'),-110.532715);
319
ok($baseml->get_stat('constant_sites'),46);
320
ok($baseml->get_stat('constant_sites_percentage'),'80.70');
321
ok($baseml->model,'HKY85 dGamma (ncatG=5)');
324
$baseml_p = Bio::Tools::Phylo::PAML->new
325
(-file => Bio::Root::IO->catfile(qw(t data baseml.usertree)));
326
$baseml = $baseml_p->next_result;
328
@trees = $baseml->get_trees;
330
ok($trees[0]->score, -129.328757);
332
# codeml NSSites parsing
333
# for branch site model/clade model
335
my $codeml_bs = new Bio::Tools::Phylo::PAML
336
(-file => Bio::Root::IO->catfile(qw/t data branchSite.mlc/));
338
my $result_bs = $codeml_bs->next_result;
339
my ($nssite_bs) = $result_bs->get_NSSite_results;
340
ok($nssite_bs->num_site_classes,q/4/);
341
my $class_bs = $nssite_bs->dnds_site_classes;
342
ok($class_bs->{q/p/}->[1],q/0.65968/);
343
ok($class_bs->{q/w/}->[1]->{q/background/},q/0.00000/);
344
ok($class_bs->{q/w/}->[2]->{q/foreground/},q/999.00000/);
346
# Let's parse the RST file
348
my $paml = Bio::Tools::Phylo::PAML->new
349
(-file => Bio::Root::IO->catfile(qw(t data codeml_lysozyme mlc)),
350
-dir => Bio::Root::IO->catfile(qw(t data codeml_lysozyme)));
352
$result = $paml->next_result;
354
my ($rst) = grep {$_->id eq 'node#8'} $result->get_rst_seqs;
356
ok($rst->seq, join('',qw(
357
AAGGTCTTTGAAAGGTGTGAGTTGGCCAGAACTCTGAAAAGATTGGGACTGGATGGCTAC
358
AGGGGAATCAGCCTAGCAAACTGGATGTGTTTGGCCAAATGGGAGAGTGATTATAACACA
359
CGAGCTACAAACTACAATCCTGGAGACCAAAGCACTGATTATGGGATATTTCAGATCAAT
360
AGCCACTACTGGTGTAATAATGGCAAAACCCCAGGAGCAGTTAATGCCTGTCATATATCC
361
TGCAATGCTTTGCTGCAAGATAACATCGCTGATGCTGTAGCTTGTGCAAAGAGGGTTGTC
362
CGTGATCCACAAGGCATTAGAGCATGGGTGGCATGGAGAAATCATTGTCAAAACAGAGAT
363
GTCAGTCAGTATGTTCAAGGTTGTGGAGTG)),
364
'node#8 reconstructed seq');
366
my ($first_tree) = $result->get_rst_trees;
367
my ($node) = $first_tree->find_node(-id => '5_Mmu_rhesus');
368
my @changes = $node->get_tag_values('changes');
369
my ($site) = grep { $_->{'site'} == 94 } @changes;
370
ok($site->{'anc_aa'}, 'A','ancestral AA');
371
ok($site->{'anc_prob'}, '0.947','ancestral AA prob');
372
ok($site->{'derived_aa'}, 'T','derived AA');
374
($node) = $first_tree->find_node(-id => '12');
375
@changes = $node->get_tag_values('changes');
376
($site) = grep { $_->{'site'} == 88 } @changes;
377
ok($site->{'anc_aa'}, 'N','ancestral AA');
378
ok($site->{'anc_prob'}, '0.993','ancestral AA prob');
379
ok($site->{'derived_aa'}, 'D','derived AA');
380
ok($site->{'derived_prob'}, '0.998','derived AA prob');
382
my $persite = $result->get_rst_persite;
383
# minus 1 because we have shifted so that array index matches site number
384
# there are 130 sites in this seq file
385
ok(scalar @$persite -1, $result->patterns->{'-ls'});
387
$site = $persite->[2];
388
# so site 2, node 2 (extant)
389
ok($site->[2]->{'codon'}, 'GTC');
390
ok($site->[2]->{'aa'}, 'V');
392
ok($site->[3]->{'codon'}, 'ATC');
393
ok($site->[3]->{'aa'}, 'I');
396
ok($site->[9]->{'codon'}, 'GTC');
397
ok($site->[9]->{'aa'}, 'V');
398
ok($site->[9]->{'prob'}, '1.000');
399
ok($site->[9]->{'Yang95_aa'},'V');
400
ok($site->[9]->{'Yang95_aa_prob'},'1.000');
403
ok($site->[10]->{'codon'}, 'ATC');
404
ok($site->[10]->{'aa'}, 'I');
405
ok($site->[10]->{'prob'}, '0.992');
406
ok($site->[10]->{'Yang95_aa'},'I');
407
ok($site->[10]->{'Yang95_aa_prob'},'0.992');
411
$paml = Bio::Tools::Phylo::PAML->new(-file => Bio::Root::IO->catfile(qw(t data codeml315.mlc)) );
412
$result = $paml->next_result;
414
ok($result->model, 'One dN/dS ratio');
415
ok($result->version, qr'3\.15');
416
$MLmat = $result->get_MLmatrix;
417
$NGmat = $result->get_NGmatrix;
419
ok($NGmat->[0]->[1]->{'omega'}, 0.2264);
420
ok($NGmat->[0]->[1]->{'dN'}, 0.0186);
421
ok($NGmat->[0]->[1]->{'dS'}, 0.0821);
423
ok($MLmat->[0]->[1]->{'omega'}, 0.32693);
424
ok($MLmat->[0]->[1]->{'dN'}, '0.0210');
425
ok($MLmat->[0]->[1]->{'dS'}, 0.0644);