1 # -*-Perl-*- Test Harness script for Bioperl
8 test_begin(-tests => 20);
10 use_ok('Bio::AlignIO::phylip');
13 my $DEBUG = test_debug();
15 my ($str,$aln,$strout,$status);
17 # PHYLIP sequential/non-interleaved
18 $strout = Bio::AlignIO->new('-file' => test_input_file('noninterleaved.phy'), '-interleaved' => 0,
19 '-format' => 'phylip');
20 $aln = $strout->next_aln($aln);
21 isa_ok($aln,'Bio::Align::AlignI');
22 is($aln->get_seq_by_pos(2)->seq(), 'CCTCAGATCACTCTTTGGCAACGACCCCTCGTCACAATAA'.
23 'AGGTAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGACATGAATT'.
24 'TGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGGTTTATCAAAGTAAGACAGTATGATCAGA'.
25 'TACCCATAGAGATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCCACACCTGTCAATATAATTG'.
26 'GAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTT' );
28 # PHYLIP interleaved with long Ids
29 $str = Bio::AlignIO->new(
30 '-file' => test_input_file("protpars_longid.phy"),
31 '-format' => 'phylip',
34 $aln = $str->next_aln();
35 #isa_ok($str,'Bio::AlignIO');
36 isa_ok($aln,'Bio::Align::AlignI');
37 is $aln->get_seq_by_pos(1)->get_nse, 'S I N F R U P 0 0 1 /1-84';
38 is $aln->get_seq_by_pos(2)->get_nse, 'SINFRUP002/1-84';
40 # PHYLIP interleaved, multiple segments
41 $str = Bio::AlignIO->new(
42 '-file' => test_input_file("protpars.phy"),
43 '-format' => 'phylip');
45 $aln = $str->next_aln();
46 #isa_ok($str,'Bio::AlignIO');
47 isa_ok($aln,'Bio::Align::AlignI');
48 is $aln->get_seq_by_pos(1)->get_nse, 'SINFRUP001/1-4940';
49 # is $aln->get_seq_by_pos(2)->get_nse, 'SINFRUP002/1-84';
52 $str = Bio::AlignIO->new(
53 '-file' => test_input_file("testaln.phylip"),
54 '-format' => 'phylip');
55 $aln = $str->next_aln();
56 #isa_ok($str,'Bio::AlignIO');
57 isa_ok($aln,'Bio::Align::AlignI');
58 is $aln->get_seq_by_pos(1)->get_nse, 'Homo_sapie/1-45';
60 $strout = Bio::AlignIO->new(
61 '-file' => ">".test_output_file(),
62 '-format' => 'phylip');
63 $status = $strout->write_aln($aln);
64 is $status, 1, "phylip output test";
66 # check the LocatableSeq start/end/strand etc
67 my $ls = $aln->get_seq_by_pos(2);
68 is($ls->display_id, 'Pan_panisc');
75 local $TODO = 'problems with default strand';
76 # shouldn't this be 0?
80 # check to see that newlines between header and sequences are parsed correctly
81 $str = Bio::AlignIO->new('-file' => test_input_file("codeml45b.mlc"), -format => 'phylip', '-longid' => 1);
82 $aln = $str->next_aln();
83 $ls = $aln->get_seq_by_pos(9);
84 ok($ls->display_id eq "Pop_trich_ch", "newline between header and sequences is parsed correctly");
86 # bug 123 "Problem with newer versions of AlignIO to write alignment data #123"
87 my $io = Bio::AlignIO->new(
88 -file => test_input_file("ORTHOMCL2345.cluster.aa.fa.aln.aa.phy.txt"),
90 $aln = $io->next_aln();
91 isa_ok($aln,'Bio::SimpleAlign');
93 # Alignment file where an id has spaces in it
94 $io = Bio::AlignIO->new(
95 -file => test_input_file("ids-with-spaces.phy"),
97 $aln = $io->next_aln();
98 isa_ok($aln,'Bio::SimpleAlign');
99 is($aln->get_seq_by_pos(1)->display_id, 'A_BAD_ID');