[Bioperl-l] Phylip format error

24 views
Skip to first unread message

Bernard Cohen

unread,
May 20, 2013, 2:49:50 PM5/20/13
to biop...@bioperl.org
Hello!

I happen to have checked to see what the PERL webpage says about Phylip format for DNA alignment files and see that it is erroneous. 

I am not a PERL user and do not want to be bothered to register or otherwise learn how to make an official comment, so forward this for someone to pick up.

Phylip format allows up to 10 spaces for taxon names; the data must start in the 11th space. This can be checked on Jo Felsenstein's site.

The PERL page accessed by searching for "Phylip format PERL" allows only 8 spaces for the name. 

B. L. Cohen
_______________________________________________
Bioperl-l mailing list
Biop...@lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/bioperl-l

Alexey Morozov

unread,
May 23, 2013, 3:22:13 AM5/23/13
to biop...@bioperl.org
Which is also worsened by the fact that there is relaxed phylip format,
which allows up to 250 chars for taxon name. They are separated from a
sequence by single space, which creates problems if names were extended to
10 chars in strict Felsenstein's format by whitespaces. On the whole,
phylip is as messily defined format as one can make from a plain textfile
with information content of fasta.
Bioperl documentation says nothing about whether Bio::SeqIO accepts relaxed
phylip and how does it tell dialects from one another. Even if code support
is OK, it may be worthwile to explain it somewhere at bioperl.org


2013/5/21 Bernard Cohen <b.l.coh...@btinternet.com>
--
Alexey Morozov,
LIN SB RAS, bioinformatics group.
Irkutsk, Russia.

Peter Cock

unread,
May 23, 2013, 4:30:21 AM5/23/13
to Alexey Morozov, biop...@bioperl.org
On Thu, May 23, 2013 at 8:22 AM, Alexey Morozov
<alexeymo...@gmail.com> wrote:
> Which is also worsened by the fact that there is relaxed phylip format,
> which allows up to 250 chars for taxon name. They are separated from a
> sequence by single space, which creates problems if names were extended to
> 10 chars in strict Felsenstein's format by whitespaces. On the whole,
> phylip is as messily defined format as one can make from a plain textfile
> with information content of fasta.
> Bioperl documentation says nothing about whether Bio::SeqIO accepts relaxed
> phylip and how does it tell dialects from one another. Even if code support
> is OK, it may be worthwile to explain it somewhere at bioperl.org

Biopython's AlignIO defines both a (strict) "phylip" and "relaxed-phylip"
as two separate formats (or variants, like the "fastq" variants). Doing
the same in BioPerl would seem sensible since auto-detection is not
easy.

http://biopython.org/wiki/AlignIO#File_Formats

Peter

P.S. Where does that 250 characters for the taxon name limit come from?
The trouble with relaxed phylip is that some tools are more relaxed than
others ;)

Adam Witney

unread,
May 23, 2013, 4:43:15 AM5/23/13
to biop...@lists.open-bio.org

Not sure if there is an actual question in these messages, but BioPerl
can be used to generate valid Phylip format and run, like this:

## Build Align object
my $aln = Bio::SimpleAlign->new(-seqs=>$seqs);

## swap the taxa names with 8 characters long unique IDs
my ($aln_safe, $ref_name) = $aln->set_displayname_safe(8);

## Write out phylip format infile
Bio::AlignIO->new(-file=>'>infile.out', -format=>'phylip', -interleaved
=> 0)->write_aln($aln);

## run PHYLIP's pars program
my @params = (idlength=>10); #, jumble=>"17,10");
my $tree_factory = Bio::Tools::Run::Phylo::Phylip::Pars->new(@params);
$tree_factory->quiet(1); # Suppress pars messages to terminal
my $tree = $tree_factory->create_tree($aln_safe);

## fix the node labels back
my @nodes = sort { defined $a->id && defined $b->id && $a->id cmp $b->id
} $tree->get_nodes();
foreach my $nd (@nodes) {
if ( $nd->is_Leaf ) {
$nd->id($ref_name->{$nd->id_output})
}
}

HTH

Adam

Fields, Christopher J

unread,
May 23, 2013, 9:48:31 AM5/23/13
to Alexey Morozov, biop...@bioperl.org
Alexey,

Just want to point out that 'relaxed phylip' format was introduced long after this parser was created; in fact (as Adam points out) there was an alternative workaround to deal with the lossy names.

The content of that page is on a wiki, which anyone is free to edit (just need an OpenID to set up an account).

chris

Fields, Christopher J

unread,
May 23, 2013, 10:05:32 AM5/23/13
to Peter Cock, Alexey Morozov, biop...@bioperl.org
On May 23, 2013, at 3:30 AM, Peter Cock <p.j.a...@googlemail.com> wrote:

> On Thu, May 23, 2013 at 8:22 AM, Alexey Morozov
> <alexeymo...@gmail.com> wrote:
>> Which is also worsened by the fact that there is relaxed phylip format,
>> which allows up to 250 chars for taxon name. They are separated from a
>> sequence by single space, which creates problems if names were extended to
>> 10 chars in strict Felsenstein's format by whitespaces. On the whole,
>> phylip is as messily defined format as one can make from a plain textfile
>> with information content of fasta.
>> Bioperl documentation says nothing about whether Bio::SeqIO accepts relaxed
>> phylip and how does it tell dialects from one another. Even if code support
>> is OK, it may be worthwile to explain it somewhere at bioperl.org
>
> Biopython's AlignIO defines both a (strict) "phylip" and "relaxed-phylip"
> as two separate formats (or variants, like the "fastq" variants). Doing
> the same in BioPerl would seem sensible since auto-detection is not
> easy.
>
> http://biopython.org/wiki/AlignIO#File_Formats
>
> Peter
>
> P.S. Where does that 250 characters for the taxon name limit come from?
> The trouble with relaxed phylip is that some tools are more relaxed than
> others ;)

As Adam pointed out, prior to the introduction of 'relaxed phylip' we had an alternative solution that didn't require a modified format but still allowed one to use PHYLIP and other tools requesting the format. I think 'relaxed phylip' was introduced by CIPRES a few years back. Frankly, this is the first time I have seen this mentioned on the list; yay, yet another format variation :)

The variant format parsing (as implemented for SeqIO::fastq, as you know) deals with variant names like 'fastq-sanger', where the main format name is first, the variant of the format second. The order in this case is reversed (relaxed-phylip), which I'm pretty sure will not work. Not impossible to allow, but we would probably allow support like this initially:

my $in = Bio::AlignIO->new(-format => 'phylip',
-variant => 'relaxed',
…);

chris

Peter Cock

unread,
May 23, 2013, 10:53:09 AM5/23/13
to Fields, Christopher J, Alexey Morozov, biop...@bioperl.org
On Thu, May 23, 2013 at 3:05 PM, Fields, Christopher J
<cjfi...@illinois.edu> wrote:
>
> I think 'relaxed phylip' was introduced by CIPRES a few years back.
> Frankly, this is the first time I have seen this mentioned on the list; yay,
> yet another format variation :)

The relaxed phylip 'format' goes back further than that, e.g.
http://lists.open-bio.org/pipermail/biopython-dev/2008-June/003899.html

RAxML and PHYML support relaxed phylip - but with their own ID limits.

Peter
Reply all
Reply to author
Forward
0 new messages