[BioRuby] alignment.rb

Conan K Woods email at woodsc.ca
Thu Sep 22 14:27:13 EDT 2005


Ah, I see.  That helps quite a bit.

On Fri, Sep 23, 2005 at 01:19:14AM +0900, GOTO Naohisa wrote:
> 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