[BioRuby] Is it possible to read sequences in the format of phylip with bioruby?

Naohisa Goto ngoto at gen-info.osaka-u.ac.jp
Fri Jul 18 17:13:48 UTC 2014


Hi, Cacau

A very short example:

  require "bio"
  str = File.read("sample.phylip")
  ph = Bio::Phylip::PhylipFormat.new(str)
  a = ph.alignment
  a.keys.each do |k|
    print k, "\t", a[k], "\n"
  end

Alternatively, Bio::FlatFile can also be used to read a file
with explicitly specifying data class.

  ph = Bio::FlatFile.open(Bio::Phylip::PhylipFormat, "sample.phylip")  { |ff|
    ff.next_entry
  }

See reference manual for details.
http://bioruby.org/rdoc/Bio/Phylip/PhylipFormat.html

Naohisa Goto
ng at bioruby.org

> There is Phylip support in BioRuby - you can probably take a hint from
> my PAML modules in how to use those. There is also support in the bigbio
> gem - which is the route I would take. Read the examples, tests and source code.
> 
> Not sure there is interleaved support in the bigbio though. Phylip is
> really several formats. But it would be easy to incorporate your own
> based on those examples.
> 
> Pj.
> 
> On Thu, Jul 17, 2014 at 03:40:32PM -0800, Cacau Centurion wrote:
> > Hi biorubyers,
> > 
> > I want to read phylip-formatted sequences with bioruby. However,
> > Bio::FlatFile failed to work. Is there other ways to do it?
> > 
> > Yours,
> > Cacau




More information about the BioRuby mailing list