Length is correct, should not be part of TO DO
[bioperl-live.git] / t / AlignIO / phylip.t
blob0d20ee82e171283a3755af60997d7a42e177da52
1 # -*-Perl-*- Test Harness script for Bioperl
3 use strict;
5 BEGIN {
6         use lib '.';
7     use Bio::Root::Test;
9     test_begin(-tests => 20);
11         use_ok('Bio::AlignIO::phylip');
14 my $DEBUG = test_debug();
16 my ($str,$aln,$strout,$status);
18 # PHYLIP sequential/non-interleaved
19 $strout = Bio::AlignIO->new('-file'  => test_input_file('noninterleaved.phy'), '-interleaved' => 0,
20                             '-format' => 'phylip');
21 $aln = $strout->next_aln($aln);
22 isa_ok($aln,'Bio::Align::AlignI');
23 is($aln->get_seq_by_pos(2)->seq(), 'CCTCAGATCACTCTTTGGCAACGACCCCTCGTCACAATAA'.
24    'AGGTAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGACATGAATT'.
25    'TGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGGTTTATCAAAGTAAGACAGTATGATCAGA'.
26    'TACCCATAGAGATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCCACACCTGTCAATATAATTG'.
27    'GAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTT' );
29 # PHYLIP interleaved with long Ids
30 $str = Bio::AlignIO->new(
31     '-file' => test_input_file("protpars_longid.phy"),
32     '-format' => 'phylip',
33     'longid' => 1);
35 $aln = $str->next_aln();
36 #isa_ok($str,'Bio::AlignIO');
37 isa_ok($aln,'Bio::Align::AlignI');
38 is $aln->get_seq_by_pos(1)->get_nse, 'S I N F R U  P 0 0 1 /1-84';
39 is $aln->get_seq_by_pos(2)->get_nse, 'SINFRUP002/1-84';
41 # PHYLIP interleaved, multiple segments
42 $str = Bio::AlignIO->new(
43     '-file' => test_input_file("protpars.phy"),
44     '-format' => 'phylip');
46 $aln = $str->next_aln();
47 #isa_ok($str,'Bio::AlignIO');
48 isa_ok($aln,'Bio::Align::AlignI');
49 is $aln->get_seq_by_pos(1)->get_nse, 'SINFRUP001/1-4940';
50 # is $aln->get_seq_by_pos(2)->get_nse, 'SINFRUP002/1-84';
52 # PHYLIP interleaved
53 $str = Bio::AlignIO->new(
54     '-file' => test_input_file("testaln.phylip"),
55     '-format' => 'phylip');
56 $aln = $str->next_aln();
57 #isa_ok($str,'Bio::AlignIO');
58 isa_ok($aln,'Bio::Align::AlignI');
59 is $aln->get_seq_by_pos(1)->get_nse, 'Homo_sapie/1-45';
61 $strout = Bio::AlignIO->new(
62     '-file'  => ">".test_output_file(),
63     '-format' => 'phylip');
64 $status = $strout->write_aln($aln);
65 is $status, 1, "phylip output test";
67 # check the LocatableSeq start/end/strand etc
68 my $ls = $aln->get_seq_by_pos(2);
69 is($ls->display_id, 'Pan_panisc');
70 is($ls->start, 1);
71 is($ls->end,47);
72 is($ls->length,50);
74 # bug 2984
75 TODO: {
76     local $TODO = 'problems with default strand';
77     # shouldn't this be 0?
78     is($ls->strand,0);
81 # check to see that newlines between header and sequences are parsed correctly
82 $str = Bio::AlignIO->new('-file' => test_input_file("codeml45b.mlc"), -format => 'phylip', '-longid' => 1);
83 $aln = $str->next_aln();
84 $ls = $aln->get_seq_by_pos(9);
85 ok($ls->display_id eq "Pop_trich_ch", "newline between header and sequences is parsed correctly");
87 # bug 123 "Problem with newer versions of AlignIO to write alignment data #123"
88 my $io = Bio::AlignIO->new(
89     -file => test_input_file("ORTHOMCL2345.cluster.aa.fa.aln.aa.phy.txt"),
90     -format => 'phylip');
91 $aln = $io->next_aln();
92 isa_ok($aln,'Bio::SimpleAlign');
94 # Alignment file where an id has spaces in it
95 $io = Bio::AlignIO->new(
96     -file => test_input_file("ids-with-spaces.phy"),
97     -format => 'phylip');
98 $aln = $io->next_aln();
99 isa_ok($aln,'Bio::SimpleAlign');
100 is($aln->get_seq_by_pos(1)->display_id, 'A_BAD_ID');