Skip to content

Home

ktym edited this page May 3, 2011 · 7 revisions
Clone this wiki locally

Welcome to the bioruby-hello wiki!

Install

% gem install bio-hello

Usage

% biohello.rb -x -c 'Hello world!'  
catgaattattatagtaatggtagagattagat

     cg
    a--t
   t---a
  g----c
 a----t
a---t
t--a
 ta
 ta
a--t
a---t
 t----a
  a----t
   t---a
    c--g
     at
     at
    a--t
   t---a
  g----c
 g----c
t---a
a--t
 gc
 ta
c--g
t---a
 a----t
  a----t
   t---a
    c--g
     ta

% ruby -rubygems -r bio -e 'p Bio::Sequence::NA.new("catgaattattatagtaatggtagagattagat").translate'
 ==> "HELLO*WORLD"

Options

Please see https://github.com/ktym/bioruby-hello/blob/master/lib/bio-hello.rb and try

% biohello.rb --help

for more details. I hope you enjoy!

Usage:
    % biohello.rb [options...] string
    % biohello.rb [options...] file

Options:
    -e or --encode
       Encode the given string or file contents as a DNA sequence. (default)
    -d or --decode
       Decode a DNA encoded string.
    -x or --helix
       Show a DNA double strand helix in ASCII art.
    -c or --code
       Show the BioRuby code snippet.
    -h or --help
       Print this help message.

Examples:
    % biohello.rb file
    % biohello.rb -e file
    % biohello.rb -d file

    % biohello.rb "BioRuby is fun"
    % biohello.rb -e "BIORUBY*IS*FUN"
    % biohello.rb -d "nacatatagagatganactattaaataagttaattttgaaat"

    % biohello.rb -x "I love you"
    % biohello.rb -x -e "I*LOVE*YOU"
    % biohello.rb -x -d "atataattataggtagaataatattagtga"

    % biohello.rb -c "A happy new year"
    % biohello.rb -c -e "A*HAPPY*NEW*YEAR"
    % biohello.rb -c -d "gcataacatgcacctccttattaaaatgaatggtaatatgaagcaaga"

Examples in action

By default, biohello.rb encodes a string (supposed to be an amino acid sequence) into a DNA sequence.

% biohello.rb "BioRuby is fun"
nacatatagagatganactattaaatattttaattttgaaat

Encoding:

% biohello.rb -e "BIORUBY*IS*FUN"
nacatatagagatganactattaaataagttaattttgaaat

Decoding:

% biohello.rb -d "nacatatagagatganactattaaataagttaattttgaaat"
BIORUBY*IS*FUN

Encoding with a DNA double helix:

% biohello.rb -x -e "I love you"                            
atataattataggtagaataatattagtga

     at
    t--a
   a---t
  t----a
 a----t
a---t
t--a
 ta
 ta
a--t
t---a
 c----g
  c----g
   a---t
    t--a
     cg

Decoding with a double helix:

% biohello.rb -x -d "atataattataggtagaataatattagtga"
I*LOVE*YOU

     at
    t--a
   a---t
  t----a
 a----t
a---t
t--a
 ta
 ta
a--t
t---a
 c----g
  c----g
   a---t
    t--a
     cg

Encoding with a code (showing how to decode a DNA sequence with the BioRuby w/o this bio-hello plugin):

% biohello.rb -c -e "HELLO*WORLD"     
catgaattattatagtaatggtagagattagat

  % ruby -rubygems -r bio -e 'p Bio::Sequence::NA.new("catgaattattatagtaatggtagagattagat").translate'
   ==> "HELLO*WORLD"

Decoding with a code:

% biohello.rb -c -d "catgaattattatagtaatggtagagattagat"
HELLO*WORLD

  % ruby -rubygems -r bio -e 'p Bio::Sequence::NA.new("catgaattattatagtaatggtagagattagat").translate'
   ==> "HELLO*WORLD"

Original ideas behind

# BioRuby shell's equivalent for Bio::Sequence::AA.new("HAPPY*NEW*YEAR")
bioruby> aa = getseq("HAPPY*NEW*YEAR")
  ==> #<Bio::Sequence:0x1016bb1e0 @moltype=Bio::Sequence::AA, @seq="HAPPY*NEW*YEAR">

# BioRuby shell's shortcut for Bio::CodonTable.copy(1)
bioruby> ct = codontable(1)

 = Codon table 1 : Standard (Eukaryote)

   hydrophilic: H K R (basic), S T Y Q N S (polar), D E (acidic)
   hydrophobic: F L I M V P A C W G (nonpolar)

 *---------------------------------------------*
 |       |              2nd              |     |
 |  1st  |-------------------------------| 3rd |
 |       |  U    |  C    |  A    |  G    |     |
 |-------+-------+-------+-------+-------+-----|
 | U   U | Phe F | Ser S | Tyr Y | Cys C |  u  |
 | U   U | Phe F | Ser S | Tyr Y | Cys C |  c  |
 | U   U | Leu L | Ser S | STOP  | STOP  |  a  |
 |  UUU  | Leu L | Ser S | STOP  | Trp W |  g  |
 |-------+-------+-------+-------+-------+-----|
 |  CCCC | Leu L | Pro P | His H | Arg R |  u  |
 | C     | Leu L | Pro P | His H | Arg R |  c  |
 | C     | Leu L | Pro P | Gln Q | Arg R |  a  |
 |  CCCC | Leu L | Pro P | Gln Q | Arg R |  g  |
 |-------+-------+-------+-------+-------+-----|
 |   A   | Ile I | Thr T | Asn N | Ser S |  u  |
 |  A A  | Ile I | Thr T | Asn N | Ser S |  c  |
 | AAAAA | Ile I | Thr T | Lys K | Arg R |  a  |
 | A   A | Met M | Thr T | Lys K | Arg R |  g  |
 |-------+-------+-------+-------+-------+-----|
 |  GGGG | Val V | Ala A | Asp D | Gly G |  u  |
 | G     | Val V | Ala A | Asp D | Gly G |  c  |
 | G GGG | Val V | Ala A | Glu E | Gly G |  a  |
 |  GG G | Val V | Ala A | Glu E | Gly G |  g  |
 *---------------------------------------------*

  ==> #<Bio::CodonTable:0x10171e5b0 @stop=["taa", "tag", "tga"], @table={"gcg"=>"A", "gtc"=>"V", "ctg"=>"L", "cat"=>"H", "tac"=>"Y", "gga"=>"G", "agg"=>"R", "aaa"=>"K", "acc"=>"T", "att"=>"I", "cca"=>"P", "tta"=>"L", "tgt"=>"C", "gag"=>"E", "gct"=>"A", "tcg"=>"S", "ggc"=>"G", "ata"=>"I", "aac"=>"N", "agt"=>"S", "cgg"=>"R", "caa"=>"Q", "ccc"=>"P", "ctt"=>"L", "tga"=>"*", "ttc"=>"F", "gtg"=>"V", "gat"=>"D", "tag"=>"*", "gca"=>"A", "acg"=>"T", "aga"=>"R", "atc"=>"I", "cta"=>"L", "cac"=>"H", "cgt"=>"R", "tgc"=>"C", "tct"=>"S", "ggg"=>"G", "gaa"=>"E", "gcc"=>"A", "gtt"=>"V", "aag"=>"K", "agc"=>"S", "act"=>"T", "ccg"=>"P", "cga"=>"R", "ctc"=>"L", "ttg"=>"L", "tca"=>"S", "tat"=>"Y", "gta"=>"V", "gac"=>"D", "ggt"=>"G", "atg"=>"M", "aca"=>"T", "aat"=>"N", "cag"=>"Q", "cgc"=>"R", "cct"=>"P", "tgg"=>"W", "taa"=>"*", "tcc"=>"S", "ttt"=>"F"}, @start=["ttg", "ctg", "atg", "gtg"], @definition="Standard (Eukaryote)">

# Actually, there can be several candidate codons but we take the first one here...
bioruby> na = aa.split(//).map{|a| ct.revtrans(a).first}.join
  ==> "catgctcctccttattaaaatgaatggtaatatgaagctcgt"

# Properly translated?
bioruby> getseq(na).translate
  ==> "HAPPY*NEW*YEAR"
Something went wrong with that request. Please try again.