[BioRuby] alignment.rb

Pjotr Prins pjotr at pckassa.com
Fri Sep 23 04:40:21 EDT 2005


I added this to the Tutorial.

Again, can I ask everyone - how do we plan to maintain unit tests and
make sure the code in the documentation is *not* broken? The code
should be only *once* in the source repository for a dual purpose -
and I would like to be sure it is correct.

If I were to write something I would like to have these code snippets
in the unit tests and parse them into the rd documentation when
generating documents with rdoc. Is there already something for this in
Ruby space? I know you can do an include in rd, but would need to do
some preparsing to lift only the interesting code out of the unit
test.


Anyway if I were to experiment with this would you welcome it - or
reject it?

Pj.

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
> _______________________________________________
> BioRuby mailing list
> BioRuby at open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioruby


More information about the BioRuby mailing list