1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: phylip.t 14971 2008-10-28 16:08:52Z cjfields $
10 test_begin(-tests => 17);
12 use_ok('Bio::AlignIO::phylip');
15 my $DEBUG = test_debug();
17 my ($str,$aln,$strout,$status);
19 # PHYLIP sequential/non-interleaved
20 $strout = Bio::AlignIO->new('-file' => test_input_file('noninterleaved.phy'), '-interleaved' => 0,
21 '-format' => 'phylip');
22 $aln = $strout->next_aln($aln);
23 isa_ok($aln,'Bio::Align::AlignI');
24 is($aln->get_seq_by_pos(2)->seq(), 'CCTCAGATCACTCTTTGGCAACGACCCCTCGTCACAATAA'.
25 'AGGTAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGACATGAATT'.
26 'TGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGGTTTATCAAAGTAAGACAGTATGATCAGA'.
27 'TACCCATAGAGATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCCACACCTGTCAATATAATTG'.
28 'GAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTT' );
30 # PHYLIP interleaved with long Ids
32 $str = Bio::AlignIO->new(
33 '-file' => test_input_file("protpars_longid.phy"),
34 '-format' => 'phylip',
37 $aln = $str->next_aln();
38 #isa_ok($str,'Bio::AlignIO');
39 isa_ok($aln,'Bio::Align::AlignI');
40 is $aln->get_seq_by_pos(1)->get_nse, 'S I N F R U P 0 0 1 /1-84';
41 is $aln->get_seq_by_pos(2)->get_nse, 'SINFRUP002/1-84';
43 # PHYLIP interleaved, multiple segments
44 $str = Bio::AlignIO->new(
45 '-file' => test_input_file("protpars.phy"),
46 '-format' => 'phylip');
48 $aln = $str->next_aln();
49 #isa_ok($str,'Bio::AlignIO');
50 isa_ok($aln,'Bio::Align::AlignI');
51 is $aln->get_seq_by_pos(1)->get_nse, 'SINFRUP001/1-4940';
52 # is $aln->get_seq_by_pos(2)->get_nse, 'SINFRUP002/1-84';
57 $str = Bio::AlignIO->new(
58 '-file' => test_input_file("testaln.phylip"),
59 '-format' => 'phylip');
60 $aln = $str->next_aln();
61 #isa_ok($str,'Bio::AlignIO');
62 isa_ok($aln,'Bio::Align::AlignI');
63 is $aln->get_seq_by_pos(1)->get_nse, 'Homo_sapie/1-45';
65 $strout = Bio::AlignIO->new(
66 '-file' => ">".test_output_file(),
67 '-format' => 'phylip');
68 $status = $strout->write_aln($aln);
69 is $status, 1, "phylip output test";
71 # check the LocatableSeq start/end/strand etc
72 my $ls = $aln->get_seq_by_pos(2);
73 is($ls->display_id, 'Pan_panisc');
79 local $TODO = 'problems with default strand, length?';
80 # shouldn't this be 0?
85 # check to see that newlines between header and sequences are parsed correctly
86 $str = Bio::AlignIO->new('-file' => test_input_file("codeml45b.mlc"), '-format' => 'phylip', '-longid' => 1);
87 $aln = $str->next_aln();
88 $ls = $aln->get_seq_by_pos(9);
89 ok($ls->display_id eq "Pop_trich_ch", "newline between header and sequences is parsed correctly");