Used quoted strings in Bio::Species to avoid a 'Invalid [] range in regex' error...
[bioperl-live.git] / t / AlignIO / phylip.t
blob1b6e68f22513aa3405af12552db39622458fe361
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: phylip.t 14971 2008-10-28 16:08:52Z cjfields $
4 use strict;
6 BEGIN {
7         use lib '.';
8     use Bio::Root::Test;
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',
35     'longid' => 1);
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';
55 # PHYLIP interleaved
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');
74 is($ls->start, 1);
75 is($ls->end,47);
77 # bug 2984
78 TODO: {
79     local $TODO = 'problems with default strand, length?';
80     # shouldn't this be 0?
81     is($ls->strand,0);
82     is($ls->length,47);
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");