[BioRuby] alignment.rb

GOTO Naohisa ngoto at gen-info.osaka-u.ac.jp
Thu Sep 22 12:19:14 EDT 2005


Hi,
I'm one of authors of alignment.rb.

On Wed, 21 Sep 2005 13:13:02 -0700
Conan K Woods <email at woodsc.ca> wrote:

> I noticed that their was a file bio/alignment.rb.  This sounded 
> interesting(and might be of use for me on another project) and I was 
> wondering what its for and how its used?  It looked like it could be used 
> to interface with an alignment program, but I'm not sure how it is used 
> that way.

Bio::Alignment class in bio/alignment.rb is a container class
like Ruby's Hash, Array and BioPerl's Bio::SimpleAlign.
A very simple example is:

  require 'bio'

  seqs = [ 'atgca', 'aagca', 'acgca', 'acgcg' ]
  seqs = seqs.collect{ |x| Bio::Sequence::NA.new(x) }

  # creates alignment object
  a = Bio::Alignment.new(seqs)

  # shows consensus sequence
  p a.consensus             # ==> "a?gc?"

  # shows IUPAC consensus
  p a.consensus_iupac       # ==> "ahgcr"

  # iterates over each seq
  a.each { |x| p x }
    # ==>
    #    "atgca"
    #    "aagca"
    #    "acgca"
    #    "acgcg"

  # iterates over each site
  a.each_site { |x| p x }
    # ==>
    #    ["a", "a", "a", "a"]
    #    ["t", "a", "c", "c"]
    #    ["g", "g", "g", "g"]
    #    ["c", "c", "c", "c"]
    #    ["a", "a", "a", "g"]

  # doing alignment by using CLUSTAL W.
  # clustalw command must be installed.
  factory = Bio::ClustalW.new
  a2 = a.do_align(factory)

Note that Bio::Alignment has more methods.
Becase it has too many methods and it is very complicated,
I'm planning to do refactoring and splitting its functions into
some modules. So, specs and usages of methods might be
changed in the near future.

-- 
Naohisa GOTO
ngoto at gen-info.osaka-u.ac.jp
Department of Genome Informatics, Genome Information Research Center,
Research Institute for Microbial Diseases, Osaka University, Japan


More information about the BioRuby mailing list