[BioRuby-cvs] bioruby/doc Tutorial.rd,1.16,1.17

Pjotr Prins pjotr at dev.open-bio.org
Sun Feb 3 17:17:59 UTC 2008


Update of /home/repository/bioruby/bioruby/doc
In directory dev.open-bio.org:/tmp/cvs-serv15881/doc

Modified Files:
	Tutorial.rd 
Log Message:
More doctests in Tutorial.rd

Index: Tutorial.rd
===================================================================
RCS file: /home/repository/bioruby/bioruby/doc/Tutorial.rd,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Tutorial.rd	2 Feb 2008 14:15:08 -0000	1.16
--- Tutorial.rd	3 Feb 2008 17:17:48 -0000	1.17
***************
*** 13,16 ****
--- 13,17 ----
  
  =begin
+ #doctest Testing bioruby
  
  = BioRuby Tutorial
***************
*** 64,68 ****
  following command
  
!   ./bin/bioruby
  
  and you should see a prompt
--- 65,70 ----
  following command
  
!   ./bin/bioruby  or
!   ruby -I lib bin/bioruby
  
  and you should see a prompt
***************
*** 73,80 ****
  
    bioruby> seq = Bio::Sequence::NA.new("atgcatgcaaaa")
!   bioruby> puts seq
!   atgcatgcaaaa
!   bioruby> puts seq.complement
!   ttttgcatgcat
  
  == Working with nucleic / amino acid sequences (Bio::Sequence class)
--- 75,82 ----
  
    bioruby> seq = Bio::Sequence::NA.new("atgcatgcaaaa")
!   ==> "atgcatgcaaaa"
! 
!   bioruby> seq.complement
!   ==> "ttttgcatgcat"
  
  == Working with nucleic / amino acid sequences (Bio::Sequence class)
***************
*** 89,122 ****
  defined in codontable.rb).
  
  
!     #!/usr/bin/env ruby
! 
!     require 'bio'
! 
!     seq = Bio::Sequence::NA.new("atgcatgcaaaa")
! 
!     puts seq                            # original sequence
!     puts seq.complement                 # complemental sequence (Bio::Sequence::NA object)
!     puts seq.subseq(3,8)                # gets subsequence of positions 3 to 8
  
!     p seq.gc_percent                    # GC percent (BioRuby 0.6.X: Float, BioRuby 0.7 or later: Integer)
!     p seq.composition                   # nucleic acid compositions (Hash)
  
!     puts seq.translate                  # translation (Bio::Sequence::AA object)
!     puts seq.translate(2)               # translation from frame 2 (default is frame 1)
!     puts seq.translate(1,11)            # using codon table No.11 
!                                         # (see http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi)
  
!     p seq.translate.codes               # shows three-letter codes (Array)
!     p seq.translate.names               # shows amino acid names (Array)
!     p seq.translate.composition         # amino acid compositions (Hash)
!     p seq.translate.molecular_weight    # calculating molecular weight (Float)
  
!     puts seq.complement.translate       # translation of complemental strand
  
-     # reshuffle sequence with same frequencies:
-     counts = {'a'=>seq.count('a'),'c'=>seq.count('c'),
-               'g'=>seq.count('g'),'t'=>seq.count('t')}
-     p randomseq = Bio::Sequence::NA.randomize(counts)  
  
  The p, print and puts methods are standard Ruby ways of outputting to
--- 91,136 ----
  defined in codontable.rb).
  
+   bioruby> seq = Bio::Sequence::NA.new("atgcatgcaaaa")
+   ==> "atgcatgcaaaa"
  
!   # complemental sequence (Bio::Sequence::NA object)
!   bioruby> seq.complement
!   ==> "ttttgcatgcat"
  
!   bioruby> seq.subseq(3,8) # gets subsequence of positions 3 to 8
!   ==> "gcatgc"
!   bioruby> seq.gc_percent 
!   ==> 33
!   bioruby> seq.composition 
!   ==> {"a"=>6, "c"=>2, "g"=>2, "t"=>2}
!   bioruby> seq.translate 
!   ==> "MHAK"
!   bioruby> seq.translate(2)        # translate from frame 2
!   ==> "CMQ"
!   bioruby> seq.translate(1,11)     # codon table 11
!   ==> "MHAK"
!   bioruby> seq.translate.codes
!   ==> ["Met", "His", "Ala", "Lys"]
!   bioruby> seq.translate.names
!   ==> ["methionine", "histidine", "alanine", "lysine"]
!   bioruby>  seq.translate.composition
!   ==> {"K"=>1, "A"=>1, "M"=>1, "H"=>1}
!   bioruby> seq.translate.molecular_weight
!   ==> 485.605
!   bioruby> seq.complement.translate
!   ==> "FCMH"
  
! get a random sequence with the same NA count:
  
!   bioruby> counts = {'a'=>seq.count('a'),'c'=>seq.count('c'),'g'=>seq.count('g'),'t'=>seq.count('t')}
!   ==> {"a"=>6, "c"=>2, "g"=>2, "t"=>2}
!   bioruby!> randomseq = Bio::Sequence::NA.randomize(counts) 
!   ==!> "aaacatgaagtc"
  
!   bioruby!> print counts
! a6c2g2t2  
!   bioruby!> p counts
! {"a"=>6, "c"=>2, "g"=>2, "t"=>2}
  
  
  The p, print and puts methods are standard Ruby ways of outputting to
***************
*** 140,152 ****
  has index 0, for example:
  
!   s = 'abc'
!   puts s[0].chr
! 
!   >a
! 
!   puts s[0..1]
! 
!   >ab
! 
  
  So when using String methods, you should subtract 1 from positions
--- 154,163 ----
  has index 0, for example:
  
!   bioruby> s = 'abc'
!   ==> "abc"
!   bioruby> s[0].chr
!   ==> "a"
!   bioruby> s[0..1]
!   ==> "ab"
  
  So when using String methods, you should subtract 1 from positions
***************
*** 160,169 ****
  through a variable named +s+.
  
! * Shows average percentage of GC content for 100 bases (stepping
! the default one base at a time)
  
!     seq.window_search(100) do |s|
!       puts s.gc_percent
!     end
  
  Since the class of each subsequence is the same as original sequence
--- 171,182 ----
  through a variable named +s+.
  
! * Shows average percentage of GC content for 20 bases (stepping the default one base at a time)
  
! bioruby> seq = Bio::Sequence::NA.new("atgcatgcaattaagctaatcccaattagatcatcccgatcatcaaaaaaaaaa")
!   ==> "atgcatgcaattaagctaatcccaattagatcatcccgatcatcaaaaaaaaaa"
! 
!   bioruby>  seq.window_search(20) { |s| print s.gc_percent,',' } 
! 30,35,40,40,35,35,35,30,25,30,30,30,35,35,35,35,35,40,45,45,45,45,40,35,40,40,40,40,40,35,35,35,30,30,30,  ==> ""
!  
  
  Since the class of each subsequence is the same as original sequence
***************
*** 1165,1168 ****
--- 1178,1192 ----
  included - with output)
  
+ == Unit testing and doctests
+ 
+ BioRuby comes with an extensive testing framework with over 1300 tests and 2700
+ assertions. To run the unit tests:
+ 
+   cd test
+   ruby runner.rb
+ 
+ We have also started with doctest for Ruby. We are porting the examples
+ in this tutorial to doctest - more info upcoming.
+ 
  == Further reading
  




More information about the bioruby-cvs mailing list