]> git.donarmstrong.com Git - biopieces.git/commitdiff
replacing read_fasta with ruby version
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 17 Aug 2010 13:48:11 +0000 (13:48 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 17 Aug 2010 13:48:11 +0000 (13:48 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1062 74ccb610-7750-0410-82ae-013aeee3265d

44 files changed:
code_ruby/Maasha/lib/biopieces.rb
code_ruby/Maasha/lib/doc/classes/Biopieces.src/M000001.html
code_ruby/Maasha/lib/doc/classes/Biopieces.src/M000002.html
code_ruby/Maasha/lib/doc/classes/Biopieces.src/M000003.html
code_ruby/Maasha/lib/doc/classes/Biopieces.src/M000005.html
code_ruby/Maasha/lib/doc/classes/Biopieces.src/M000006.html
code_ruby/Maasha/lib/doc/classes/Casts.src/M000007.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000008.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000009.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000010.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000011.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000012.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000013.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000014.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000015.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000016.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000017.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000018.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000019.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000020.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000021.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000022.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000023.html
code_ruby/Maasha/lib/doc/classes/OptionHandler.src/M000024.html
code_ruby/Maasha/lib/doc/classes/Seq.html
code_ruby/Maasha/lib/doc/classes/Seq.src/M000035.html
code_ruby/Maasha/lib/doc/classes/Status.html
code_ruby/Maasha/lib/doc/classes/Status.src/M000025.html
code_ruby/Maasha/lib/doc/classes/Status.src/M000026.html
code_ruby/Maasha/lib/doc/classes/Status.src/M000027.html
code_ruby/Maasha/lib/doc/classes/Status.src/M000028.html
code_ruby/Maasha/lib/doc/classes/Status.src/M000029.html
code_ruby/Maasha/lib/doc/classes/Stream.src/M000030.html
code_ruby/Maasha/lib/doc/created.rid
code_ruby/Maasha/lib/doc/files/biopieces_rb.html
code_ruby/Maasha/lib/doc/files/seq_rb.html
code_ruby/Maasha/lib/doc/fr_class_index.html
code_ruby/Maasha/lib/doc/fr_file_index.html
code_ruby/Maasha/lib/doc/fr_method_index.html
code_ruby/Maasha/lib/fasta.rb [new file with mode: 0644]
code_ruby/Maasha/lib/seq.rb
code_ruby/Maasha/test/test_biopieces.rb
code_ruby/Maasha/test/test_fasta.rb [new file with mode: 0755]
code_ruby/Maasha/test/test_seq.rb

index 3bc2cc23e746f7ef7e4dc52139d61c2c9e045372..05bc736fe7365b4b0235db053c5b12e9d7c0a9d5 100644 (file)
@@ -474,24 +474,31 @@ class Status
   def set
     time0  = Time.new.strftime("%Y-%m-%d %X")
 
-    File.open(path, mode="w") { |file| file.puts [time0, ARGV.join(" ")].join(";") }
+    File.open(path, mode="w") do |fh|
+      fh.puts [time0, ARGV.join(" ")].join(";")
+    end
   end
 
   # Append the a temporary directory path to the status file.
-  def set_tmpdir(tmp_path)
-    status = File.open(path, mode="r").read.chomp
+  def set_tmpdir(tmpdir_path)
+    File.open(path, mode="r") do |fh|
+      fh.read.chomp
+    end
 
     File.open(path, mode="w") do |fh|
-      fh << [status, tmp_path].join(";") + "\n"
+      fh << [status, tmpdir_path].join(";") + "\n"
     end
   end
 
   # Extract the temporary directory path from the status file,
   # and return this or nil if not found.
   def get_tmpdir
-    tmp_path = File.open(path, mode="r").read.chomp.split(";").last
+    File.open(path, mode="r") do |fh|
+      tmpdir_path = fh.read.chomp.split(";").last
+      return tmpdir_path if File.directory?(tmpdir_path)
+    end
 
-    File.directory?(tmp_path) ? tmp_path : nil
+    nil
   end
 
   # Write the Biopiece status to the log file.
index 5da85bc3decf0eac24ee5742a98b243db1154b52..7e9371a4eea28e57160b857654690b3a110a9174 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 19</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 43</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">test</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">input</span>=<span class="ruby-constant">STDIN</span>, <span class="ruby-identifier">output</span>=<span class="ruby-constant">STDOUT</span>)
     <span class="ruby-ivar">@test</span>   = <span class="ruby-identifier">test</span>
     <span class="ruby-ivar">@input</span>  = <span class="ruby-identifier">input</span>
index 38f8dcaf9f97c572d62740526191150c5c1b11a2..b69e1201abd32149f898bce7a4b3737c61553537 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 30</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 54</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-identifier">cast_list</span>=[], <span class="ruby-identifier">script_path</span>=<span class="ruby-identifier">$0</span>)
     <span class="ruby-identifier">casts</span>          = <span class="ruby-constant">Casts</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cast_list</span>)
     <span class="ruby-identifier">option_handler</span> = <span class="ruby-constant">OptionHandler</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-identifier">casts</span>, <span class="ruby-identifier">script_path</span>, <span class="ruby-ivar">@test</span>)
index c1a10dd0052e6d06e4d66fd34744706b643bd6fa..2675d141e1158c3bafc2b0dd054a0207a19e2a5b 100644 (file)
@@ -7,9 +7,10 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 38</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 62</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_record</span>
     <span class="ruby-ivar">@in</span> = <span class="ruby-constant">Stream</span><span class="ruby-operator">::</span><span class="ruby-identifier">open</span>(<span class="ruby-ivar">@options</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;r&quot;</span>, <span class="ruby-ivar">@input</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@in</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">IO</span>
+    <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@in</span>.<span class="ruby-identifier">nil?</span>
 
     <span class="ruby-identifier">record</span> = {}
 
index 441f0ea869723231910f71a8f73fc62fc389d73a..cb2274bc88a97ddae428d93ff2e5607103cdb8ac 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 63</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 88</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">puts</span>(<span class="ruby-identifier">record</span>)
     <span class="ruby-ivar">@out</span> = <span class="ruby-constant">Stream</span><span class="ruby-operator">::</span><span class="ruby-identifier">open</span>(<span class="ruby-ivar">@options</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;w&quot;</span>, <span class="ruby-ivar">@output</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">IO</span>
 
index 8c7cf6f5a6ce8fb1f0bc518c8de3deb1b67acabd..9e4ff5ea85cc1edcbd0ff5064bc1f748309cde4e 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 74</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 99</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mktmpdir</span>
     <span class="ruby-identifier">time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_i</span>
     <span class="ruby-identifier">user</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;USER&quot;</span>]
index 163a6aa5cfde10780e30256fed242d72285bbcda..8ae5d3fce00aec417673660349f669354c2dd809 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 100</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 125</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">cast_list</span>=[])
     <span class="ruby-ivar">@cast_list</span> = <span class="ruby-identifier">cast_list</span>
     <span class="ruby-identifier">ubiquitous</span>
index 5a62bc6f71b131c8d245298f676472eeb8405efd..5a296d0cf56757bc753099c4398ac98ff02433ab 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 225</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 250</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">argv</span>, <span class="ruby-identifier">casts</span>, <span class="ruby-identifier">script_path</span>, <span class="ruby-identifier">test</span>=<span class="ruby-keyword kw">nil</span>)
     <span class="ruby-ivar">@argv</span>        = <span class="ruby-identifier">argv</span>
     <span class="ruby-ivar">@casts</span>       = <span class="ruby-identifier">casts</span>
index 07ba63841f93bf94d6dc9ca6960b1f121bea39ee..97be195f78b06963f7cd09e5d19894e7be3fc685 100644 (file)
@@ -7,32 +7,33 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 235</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 260</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_parse</span>
     <span class="ruby-ivar">@options</span> = {}
 
     <span class="ruby-identifier">option_parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">option</span><span class="ruby-operator">|</span>
       <span class="ruby-ivar">@casts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cast</span><span class="ruby-operator">|</span>
-        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'flag'</span>
+        <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>]
+        <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'flag'</span>
           <span class="ruby-identifier">option</span>.<span class="ruby-identifier">on</span>(<span class="ruby-node">&quot;-#{cast[:short]}&quot;</span>, <span class="ruby-node">&quot;--#{cast[:long]}&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
             <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] = <span class="ruby-identifier">o</span>
           <span class="ruby-keyword kw">end</span>
-        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">=~</span> <span class="ruby-constant">REGEX_LIST</span>
+        <span class="ruby-keyword kw">when</span> <span class="ruby-value str">'float'</span>
+          <span class="ruby-identifier">option</span>.<span class="ruby-identifier">on</span>(<span class="ruby-node">&quot;-#{cast[:short]}&quot;</span>, <span class="ruby-node">&quot;--#{cast[:long]} F&quot;</span>, <span class="ruby-constant">Float</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
+            <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] = <span class="ruby-identifier">f</span>
+          <span class="ruby-keyword kw">end</span>
+        <span class="ruby-keyword kw">when</span> <span class="ruby-constant">REGEX_LIST</span>
           <span class="ruby-identifier">option</span>.<span class="ruby-identifier">on</span>( <span class="ruby-node">&quot;-#{cast[:short]}&quot;</span>, <span class="ruby-node">&quot;--#{cast[:long]} A&quot;</span>, <span class="ruby-constant">Array</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span>
             <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] = <span class="ruby-identifier">a</span>
           <span class="ruby-keyword kw">end</span>
-        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">=~</span> <span class="ruby-constant">REGEX_INT</span>
+        <span class="ruby-keyword kw">when</span> <span class="ruby-constant">REGEX_INT</span>
           <span class="ruby-identifier">option</span>.<span class="ruby-identifier">on</span>(<span class="ruby-node">&quot;-#{cast[:short]}&quot;</span>, <span class="ruby-node">&quot;--#{cast[:long]} I&quot;</span>, <span class="ruby-constant">Integer</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
             <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] = <span class="ruby-identifier">i</span>
           <span class="ruby-keyword kw">end</span>
-        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">=~</span> <span class="ruby-constant">REGEX_STRING</span>
+        <span class="ruby-keyword kw">when</span> <span class="ruby-constant">REGEX_STRING</span>
           <span class="ruby-identifier">option</span>.<span class="ruby-identifier">on</span>(<span class="ruby-node">&quot;-#{cast[:short]}&quot;</span>, <span class="ruby-node">&quot;--#{cast[:long]} S&quot;</span>, <span class="ruby-constant">String</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
             <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] = <span class="ruby-identifier">s</span>
           <span class="ruby-keyword kw">end</span>
-        <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'float'</span>
-          <span class="ruby-identifier">option</span>.<span class="ruby-identifier">on</span>(<span class="ruby-node">&quot;-#{cast[:short]}&quot;</span>, <span class="ruby-node">&quot;--#{cast[:long]} F&quot;</span>, <span class="ruby-constant">Float</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
-            <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] = <span class="ruby-identifier">f</span>
-          <span class="ruby-keyword kw">end</span>
         <span class="ruby-keyword kw">else</span>
           <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Unknown option type: '#{cast[:type]}'&quot;</span>
         <span class="ruby-keyword kw">end</span>
index 92efe2990ff83719cbc6d7c6c6a588eede3b3b4b..f8f69912a8f6c575c4080d58676a56c5367565d7 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 282</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 308</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wiki_path</span>
     <span class="ruby-identifier">path</span> = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;BP_DIR&quot;</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;/bp_usage/&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-ivar">@script_path</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;.wiki&quot;</span>
     <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;No such wiki file: #{path}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span> <span class="ruby-identifier">path</span>
index 9ce7ab35cde5c8bdf9b5352ddb0f7a86ff7ca407..fc4110d6642acaac4c4ed84788102b984c747bd9 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 289</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 315</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_usage_full?</span>
     <span class="ruby-ivar">@options</span>[<span class="ruby-value str">&quot;help&quot;</span>]
   <span class="ruby-keyword kw">end</span></pre>
index f8d892ff5cf89e6cb3b86b2bcf60357cabbe2cc5..454bef7d3565e44089857cc92a3f17196ae8b17f 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 294</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 320</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_usage_short?</span>
     <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">tty?</span>
       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
index 9da1eed354f08975600a9aeeea56a04c6f27cc93..859c8a1c26e98285859e7a1efb502420f586c9a6 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 311</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 337</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">print_usage_and_exit</span>(<span class="ruby-identifier">full</span>=<span class="ruby-keyword kw">nil</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@test</span>
       <span class="ruby-keyword kw">return</span>
index e1c0dfbc80c264af721d220773b86544e8e4026c..6666325779c72e44ede8416149d2501d1718fac7 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 328</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 354</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_default</span>
     <span class="ruby-ivar">@casts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cast</span><span class="ruby-operator">|</span>
       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:default</span>]
index d7730e85aab83fc12c3a4ee570e2105bd0bc74b7..44dfb092812f065a45233ca17bcdf757a2ec0057 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 338</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 364</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_glob</span>
     <span class="ruby-ivar">@casts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cast</span><span class="ruby-operator">|</span>
       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'files'</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'files!'</span>
index b8bcc88af5e1482fc7a5194cc8252d926856fcd3..59771a25814083dee91eefdacc4e516805029e35 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 361</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 387</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check</span>
     <span class="ruby-ivar">@casts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">cast</span><span class="ruby-operator">|</span>
       <span class="ruby-identifier">options_check_mandatory</span>(<span class="ruby-identifier">cast</span>)
index 10fb109e7ec143f9faa36e0296d3658946597c56..f6c78dd492a23c613c98bb3b05794a7e50151758 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 375</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 401</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_mandatory</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:mandatory</span>]
       <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Mandatory argument: --#{cast[:long]}&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
index dfd342b46f756d1a3b9ac8fd79878185e4b3f796..91480ab3c1b38fcfe1947a8d71febbfe9b1e1ee2 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 382</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 408</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_int</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'int'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]].<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Integer</span>
index 601ea2c0e29d5e70b508ea5a6d145cb8120f1eeb..2bae2141ca2cac1d6855794d1d5b083bf131ace1 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 391</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 417</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_uint</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'uint'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]].<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Integer</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]] <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
index 76b9b832f6b26bdc6c802c64c6945f742c275d57..c4ad6f1dacd60223a0da1d6f730db471b2a5fe2f 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 400</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 426</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_file</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'file!'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;No such file: '#{@options[cast[:long]]}'&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]]
index 500f639c100389f5d967b88557c4defb0b591810..12c6e7b407a58a379ba6dd4dbca28332fdaca8d0 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 407</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 433</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_files</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'files!'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
index 7ffff36ceaba986c9804ea16b584ef3dba3580ff..b7399d74ec7bb939d401fa34dd8a2c3c9b62c01c 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 416</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 442</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_dir</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">'dir!'</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;No such directory: '#{@options[cast[:long]]}'&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]]
index 0ffe185429da27d5c721ad5c71e134737e4e39c8..de6439e8f13810899db68d21990e365f9f375b63 100644 (file)
@@ -7,13 +7,13 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 423</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 449</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_allowed</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:allowed</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-identifier">allowed_hash</span> = {}
-      <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:allowed</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">','</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">allowed_hash</span>[<span class="ruby-identifier">a</span>] = <span class="ruby-value">1</span> }
+      <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:allowed</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">','</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">allowed_hash</span>[<span class="ruby-identifier">a</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-value">1</span> }
   
-      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Argument '#{@options[cast[:long]]}' to --#{cast[:long]} not allowed&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">allowed_hash</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]]
+      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Argument '#{@options[cast[:long]]}' to --#{cast[:long]} not allowed&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">allowed_hash</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]].<span class="ruby-identifier">to_s</span>
     <span class="ruby-keyword kw">end</span>
   <span class="ruby-keyword kw">end</span></pre>
 </body>
index db4ee6bafa35b86a8b9d88392a6c504c4ba700d2..5bbf893441d62cf41b40719d5c48c8013f330142 100644 (file)
@@ -7,11 +7,11 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 433</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 459</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">options_check_disallowed</span>(<span class="ruby-identifier">cast</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:disallowed</span>] <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">has_key?</span> <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]
       <span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:disallowed</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">','</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
-        <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Argument '#{@options[cast[:long]]}' to --#{cast[:long]} is disallowed&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]]
+        <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Argument '#{@options[cast[:long]]}' to --#{cast[:long]} is disallowed&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">cast</span>[<span class="ruby-identifier">:long</span>]].<span class="ruby-identifier">to_s</span>
       <span class="ruby-keyword kw">end</span>
     <span class="ruby-keyword kw">end</span>
   <span class="ruby-keyword kw">end</span></pre>
index 3f9c2ae7fe30454f344d6036337d2a67c24db276..261716839efec5b1c03a5788751c194b2cbae679 100644 (file)
@@ -70,7 +70,7 @@
             <td><strong>Parent:</strong></td>
             <td>
 
-                String
+                Object
 
             </td>
         </tr>
 
   <div id="contextContent">
 
-    <div id="description">
-      <p>
-Class containing generic sequence methods and nucleic acid and amino acid
-subclasses.
-</p>
-
-    </div>
-
    </div>
 
 
@@ -99,15 +91,25 @@ subclasses.
 
       <div class="name-list">
 
-        <a href="#M000034">generate</a>&nbsp;&nbsp;
+        <a href="#M000043">complement</a>&nbsp;&nbsp;
+
+        <a href="#M000044">generate</a>&nbsp;&nbsp;
+
+        <a href="#M000037">is_dna</a>&nbsp;&nbsp;
+
+        <a href="#M000039">is_protein</a>&nbsp;&nbsp;
+
+        <a href="#M000038">is_rna</a>&nbsp;&nbsp;
 
-        <a href="#M000035">generate!</a>&nbsp;&nbsp;
+        <a href="#M000036">len</a>&nbsp;&nbsp;
 
-        <a href="#M000031">guess_type</a>&nbsp;&nbsp;
+        <a href="#M000035">length</a>&nbsp;&nbsp;
 
-        <a href="#M000032">wrap</a>&nbsp;&nbsp;
+        <a href="#M000042">to_bp</a>&nbsp;&nbsp;
 
-        <a href="#M000033">wrap!</a>&nbsp;&nbsp;
+        <a href="#M000041">to_dna</a>&nbsp;&nbsp;
+
+        <a href="#M000040">to_rna</a>&nbsp;&nbsp;
 
       </div>
     </div>
@@ -118,15 +120,49 @@ subclasses.
 
     <div id="section">
 
-    <div id="class-list">
-      <h3 class="section-bar">Classes and Modules</h3>
 
-      Class <a href="Seq/AA.html" class="link">Seq::AA</a><br />
-Class <a href="Seq/NA.html" class="link">Seq::NA</a><br />
 
-    </div>
+    <div id="attribute-list">
+      <h3 class="section-bar">Attributes</h3>
+
+      <div class="name-list">
+        <table>
 
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">qual</td>
+
+          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
+
+          <td class="context-item-desc"></td>
+        </tr>
 
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">seq</td>
+
+          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
+
+          <td class="context-item-desc"></td>
+        </tr>
+
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">seq_name</td>
+
+          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
+
+          <td class="context-item-desc"></td>
+        </tr>
+
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">type</td>
+
+          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
+
+          <td class="context-item-desc"></td>
+        </tr>
+
+        </table>
+      </div>
+    </div>
 
 
     <!-- if method_list -->
@@ -136,15 +172,39 @@ Class <a href="Seq/NA.html" class="link">Seq::NA</a><br />
       <h3 class="section-bar">Public Instance methods</h3>
 
 
-      <div id="method-M000034" class="method-detail">
-        <a name="M000034"></a>
+      <div id="method-M000043" class="method-detail">
+        <a name="M000043"></a>
+
+        <div class="method-heading">
+
+          <a href="Seq.src/M000043.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000043.html');return false;">
+
+          <span class="method-name">complement</span><span class="method-args">()</span>
+
+          </a>
+
+        </div>
+
+        <div class="method-description">
+
+          <p>
+Method that complements sequence including ambiguity codes.
+</p>
+
+        </div>
+      </div>
+
+
+      <div id="method-M000044" class="method-detail">
+        <a name="M000044"></a>
 
         <div class="method-heading">
 
-          <a href="Seq.src/M000034.html" target="Code" class="method-signature"
-            onclick="popupCode('Seq.src/M000034.html');return false;">
+          <a href="Seq.src/M000044.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000044.html');return false;">
 
-          <span class="method-name">generate</span><span class="method-args">( length )</span>
+          <span class="method-name">generate</span><span class="method-args">(length,type)</span>
 
           </a>
 
@@ -160,6 +220,89 @@ Method that generates a random sequence of a given length.
       </div>
 
 
+      <div id="method-M000037" class="method-detail">
+        <a name="M000037"></a>
+
+        <div class="method-heading">
+
+          <a href="Seq.src/M000037.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000037.html');return false;">
+
+          <span class="method-name">is_dna</span><span class="method-args">()</span>
+
+          </a>
+
+        </div>
+
+        <div class="method-description">
+
+          <p>
+Method that returns true is a given sequence type is DNA.
+</p>
+
+        </div>
+      </div>
+
+
+      <div id="method-M000039" class="method-detail">
+        <a name="M000039"></a>
+
+        <div class="method-heading">
+
+          <a href="Seq.src/M000039.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000039.html');return false;">
+
+          <span class="method-name">is_protein</span><span class="method-args">()</span>
+
+          </a>
+
+        </div>
+
+        <div class="method-description">
+
+        </div>
+      </div>
+
+
+      <div id="method-M000038" class="method-detail">
+        <a name="M000038"></a>
+
+        <div class="method-heading">
+
+          <a href="Seq.src/M000038.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000038.html');return false;">
+
+          <span class="method-name">is_rna</span><span class="method-args">()</span>
+
+          </a>
+
+        </div>
+
+        <div class="method-description">
+
+        </div>
+      </div>
+
+
+      <div id="method-M000036" class="method-detail">
+        <a name="M000036"></a>
+
+        <div class="method-heading">
+
+          <span class="method-name">len</span><span class="method-args">()</span>
+
+        </div>
+
+        <div class="method-description">
+
+          <p>
+Alias for <a href="Seq.html#M000035">length</a>
+</p>
+
+        </div>
+      </div>
+
+
       <div id="method-M000035" class="method-detail">
         <a name="M000035"></a>
 
@@ -168,7 +311,7 @@ Method that generates a random sequence of a given length.
           <a href="Seq.src/M000035.html" target="Code" class="method-signature"
             onclick="popupCode('Seq.src/M000035.html');return false;">
 
-          <span class="method-name">generate!</span><span class="method-args">( length )</span>
+          <span class="method-name">length</span><span class="method-args">()</span>
 
           </a>
 
@@ -176,24 +319,19 @@ Method that generates a random sequence of a given length.
 
         <div class="method-description">
 
-          <p>
-Method that replaces sequence with a randomly generated sequence of a given
-length.
-</p>
-
         </div>
       </div>
 
 
-      <div id="method-M000031" class="method-detail">
-        <a name="M000031"></a>
+      <div id="method-M000042" class="method-detail">
+        <a name="M000042"></a>
 
         <div class="method-heading">
 
-          <a href="Seq.src/M000031.html" target="Code" class="method-signature"
-            onclick="popupCode('Seq.src/M000031.html');return false;">
+          <a href="Seq.src/M000042.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000042.html');return false;">
 
-          <span class="method-name">guess_type</span><span class="method-args">()</span>
+          <span class="method-name">to_bp</span><span class="method-args">()</span>
 
           </a>
 
@@ -202,23 +340,23 @@ length.
         <div class="method-description">
 
           <p>
-Guess the sequence type by analyzing the first 100 residues allowing for
-ambiguity codes.
+Method that given a <a href="Seq.html">Seq</a> entry returns a <a
+href="Biopieces.html">Biopieces</a> record (a hash).
 </p>
 
         </div>
       </div>
 
 
-      <div id="method-M000032" class="method-detail">
-        <a name="M000032"></a>
+      <div id="method-M000041" class="method-detail">
+        <a name="M000041"></a>
 
         <div class="method-heading">
 
-          <a href="Seq.src/M000032.html" target="Code" class="method-signature"
-            onclick="popupCode('Seq.src/M000032.html');return false;">
+          <a href="Seq.src/M000041.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000041.html');return false;">
 
-          <span class="method-name">wrap</span><span class="method-args">( width = 80, delimit = &quot;\n&quot; )</span>
+          <span class="method-name">to_dna</span><span class="method-args">()</span>
 
           </a>
 
@@ -227,22 +365,22 @@ ambiguity codes.
         <div class="method-description">
 
           <p>
-Method to wrap a sequence to a given width using a given delimiter.
+Method to reverse-transcribe RNA to DNA.
 </p>
 
         </div>
       </div>
 
 
-      <div id="method-M000033" class="method-detail">
-        <a name="M000033"></a>
+      <div id="method-M000040" class="method-detail">
+        <a name="M000040"></a>
 
         <div class="method-heading">
 
-          <a href="Seq.src/M000033.html" target="Code" class="method-signature"
-            onclick="popupCode('Seq.src/M000033.html');return false;">
+          <a href="Seq.src/M000040.html" target="Code" class="method-signature"
+            onclick="popupCode('Seq.src/M000040.html');return false;">
 
-          <span class="method-name">wrap!</span><span class="method-args">( width = 80, delimit = &quot;\n&quot; )</span>
+          <span class="method-name">to_rna</span><span class="method-args">()</span>
 
           </a>
 
@@ -251,8 +389,7 @@ Method to wrap a sequence to a given width using a given delimiter.
         <div class="method-description">
 
           <p>
-Method to wrap and replace a sequence to a given width using a given
-delimiter.
+Method to transcribe DNA to RNA.
 </p>
 
         </div>
index 8340c9a176f0a05f08f9677354de6b27a1900564..9817e7f5f8d02ad11a2c7bbec14b5f42fec3bd61 100644 (file)
@@ -2,14 +2,14 @@
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
-  <title>generate! (Seq)</title>
+  <title>length (Seq)</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File seq.rb, line 40</span>
-        <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">generate!</span>( <span class="ruby-identifier">length</span> )
-                <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">replace</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">generate</span>( <span class="ruby-identifier">length</span> ) )
-        <span class="ruby-keyword kw">end</span></pre>
+  <pre><span class="ruby-comment cmt"># File seq.rb, line 11</span>
+  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">length</span>
+    <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">seq</span>.<span class="ruby-identifier">length</span>
+  <span class="ruby-keyword kw">end</span></pre>
 </body>
 </html>
index 2ca780f51e54da8f5e4a70a0171a9845bf01ece1..d6681d4346842e7e8618905b4d9452a15589e81e 100644 (file)
@@ -236,7 +236,7 @@ Write the status to a status file.
           <a href="Status.src/M000026.html" target="Code" class="method-signature"
             onclick="popupCode('Status.src/M000026.html');return false;">
 
-          <span class="method-name">set_tmpdir</span><span class="method-args">(tmp_path)</span>
+          <span class="method-name">set_tmpdir</span><span class="method-args">(tmpdir_path)</span>
 
           </a>
 
index 5b625be6e13a3d02aba4335da72129f70d21c56a..84e53d7619ec4e8453864cac2f45ab67ed59c6aa 100644 (file)
@@ -7,11 +7,13 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 448</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 474</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>
     <span class="ruby-identifier">time0</span>  = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%Y-%m-%d %X&quot;</span>)
 
-    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;w&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-identifier">file</span>.<span class="ruby-identifier">puts</span> [<span class="ruby-identifier">time0</span>, <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; &quot;</span>)].<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;;&quot;</span>) }
+    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;w&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fh</span><span class="ruby-operator">|</span>
+      <span class="ruby-identifier">fh</span>.<span class="ruby-identifier">puts</span> [<span class="ruby-identifier">time0</span>, <span class="ruby-constant">ARGV</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; &quot;</span>)].<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;;&quot;</span>)
+    <span class="ruby-keyword kw">end</span>
   <span class="ruby-keyword kw">end</span></pre>
 </body>
 </html>
index 2951cbb3509c391c65c906e985c21f44dbd3dac0..3a81609070ef95f045b1ca5fe7f944bab76d0b41 100644 (file)
@@ -7,12 +7,14 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 455</span>
-  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_tmpdir</span>(<span class="ruby-identifier">tmp_path</span>)
-    <span class="ruby-identifier">status</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;r&quot;</span>).<span class="ruby-identifier">read</span>.<span class="ruby-identifier">chomp</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 483</span>
+  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_tmpdir</span>(<span class="ruby-identifier">tmpdir_path</span>)
+    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;r&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fh</span><span class="ruby-operator">|</span>
+      <span class="ruby-identifier">fh</span>.<span class="ruby-identifier">read</span>.<span class="ruby-identifier">chomp</span>
+    <span class="ruby-keyword kw">end</span>
 
     <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;w&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fh</span><span class="ruby-operator">|</span>
-      <span class="ruby-identifier">fh</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">tmp_path</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;;&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n&quot;</span>
+      <span class="ruby-identifier">fh</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">tmpdir_path</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;;&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n&quot;</span>
     <span class="ruby-keyword kw">end</span>
   <span class="ruby-keyword kw">end</span></pre>
 </body>
index cf79dfc81d8154886d7f042fca7a5912f34e9037..a78ea57189f544105cc61effadda10fe5afa583c 100644 (file)
@@ -7,11 +7,14 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 465</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 495</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_tmpdir</span>
-    <span class="ruby-identifier">tmp_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;r&quot;</span>).<span class="ruby-identifier">read</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;;&quot;</span>).<span class="ruby-identifier">last</span>
+    <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>=<span class="ruby-value str">&quot;r&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fh</span><span class="ruby-operator">|</span>
+      <span class="ruby-identifier">tmpdir_path</span> = <span class="ruby-identifier">fh</span>.<span class="ruby-identifier">read</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;;&quot;</span>).<span class="ruby-identifier">last</span>
+      <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">tmpdir_path</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">tmpdir_path</span>)
+    <span class="ruby-keyword kw">end</span>
 
-    <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">tmp_path</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">tmp_path</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
+    <span class="ruby-keyword kw">nil</span>
   <span class="ruby-keyword kw">end</span></pre>
 </body>
 </html>
index fea2bcbbc4c421967ac85f818cb485c0e119dff4..4f73b4e5159b1a8897a822607b71beed8333f16d 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 472</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 505</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">log</span>(<span class="ruby-identifier">exit_status</span>)
     <span class="ruby-identifier">time1</span>   = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%Y-%m-%d %X&quot;</span>)
     <span class="ruby-identifier">user</span>    = <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;USER&quot;</span>]
index 397c4bd01e1c3852ba742eb94a377bf3d2feab49..2e74133e53d61a73067d5966f3e48e557f3e1161 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 489</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 522</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>
     <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">path</span>)
   <span class="ruby-keyword kw">end</span></pre>
index 55b2a87cfe6f24a5b5ebdbd186d171759bff56da..9a8cbd8e22c5d42473503297779e6cc1be8a9644 100644 (file)
@@ -7,7 +7,7 @@
   <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
 </head>
 <body class="standalone-code">
-  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 514</span>
+  <pre><span class="ruby-comment cmt"># File biopieces.rb, line 547</span>
   <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">mode</span>, <span class="ruby-identifier">stdio</span>)
     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mode</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;r&quot;</span>
       <span class="ruby-identifier">$stdin</span>.<span class="ruby-identifier">tty?</span> <span class="ruby-value">? </span><span class="ruby-identifier">read</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;stream_in&quot;</span>]) <span class="ruby-operator">:</span> <span class="ruby-identifier">stdio</span>
index b6664bf397c382c4e242978f14cafe2dcbff3a34..90dc268f57c2eb1da2980d72dafa5b1f83fcbfc7 100644 (file)
@@ -1 +1 @@
-Fri, 06 Aug 2010 15:47:42 +0200
+Tue, 17 Aug 2010 15:43:49 +0200
index e396f11e681ee82660e8ea54a3b42dc9746d841e..0efeadc0db2ae66d7b67db17584bf0d528e10c5c 100644 (file)
@@ -53,7 +53,7 @@
     </tr>
     <tr class="top-aligned-row">
       <td><strong>Last Update:</strong></td>
-      <td>2010-08-06 13:58:09 +0200</td>
+      <td>2010-08-17 14:23:28 +0200</td>
     </tr>
     </table>
   </div>
 
   <div id="contextContent">
 
+    <div id="description">
+      <p>
+Copyright (C) 2007-2010 Martin A. Hansen.
+</p>
+
+    </div>
+
     <div id="requires-list">
       <h3 class="section-bar">Required files</h3>
 
index 2d6aa8749490b7a85e86dd19b4710aeeced90665..e080b995b6275c819919537825289a73b8a919c4 100644 (file)
@@ -53,7 +53,7 @@
     </tr>
     <tr class="top-aligned-row">
       <td><strong>Last Update:</strong></td>
-      <td>2009-08-10 09:00:55 +0200</td>
+      <td>2010-08-17 08:33:38 +0200</td>
     </tr>
     </table>
   </div>
 
   <div id="contextContent">
 
-    <div id="description">
-      <p>
-Class containing generic sequence methods and nucleic acid and amino acid
-subclasses.
-</p>
-
-    </div>
-
    </div>
 
 
@@ -80,6 +72,37 @@ subclasses.
 
     <div id="section">
 
+    <div id="constants-list">
+      <h3 class="section-bar">Constants</h3>
+
+      <div class="name-list">
+        <table summary="Constants">
+
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">DNA</td>
+          <td>=</td>
+          <td class="context-item-value">%w[a t c g]</td>
+
+        </tr>
+
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">RNA</td>
+          <td>=</td>
+          <td class="context-item-value">%w[a u c g]</td>
+
+        </tr>
+
+        <tr class="top-aligned-row context-row">
+          <td class="context-item-name">PROTEIN</td>
+          <td>=</td>
+          <td class="context-item-value">%w[f l s y c w p h q r i m t n k v a d e g]</td>
+
+        </tr>
+
+        </table>
+      </div>
+    </div>
+
 
 
 
index 6cdfd54292188e92ba5d5601d100adc15750bca3..7fc7d713f3ff98a3dead97e6bcb2c7ab1f08a4b0 100644 (file)
 
     <a href="classes/Casts.html">Casts</a><br />
 
-    <a href="classes/OptionHandler.html">OptionHandler</a><br />
-
-    <a href="classes/Seq.html">Seq</a><br />
+    <a href="classes/Fasta.html">Fasta</a><br />
 
-    <a href="classes/Seq/AA.html">Seq::AA</a><br />
+    <a href="classes/FastaError.html">FastaError</a><br />
 
-    <a href="classes/Seq/NA.html">Seq::NA</a><br />
+    <a href="classes/OptionHandler.html">OptionHandler</a><br />
 
-    <a href="classes/Seq/NA/DNA.html">Seq::NA::DNA</a><br />
+    <a href="classes/Seq.html">Seq</a><br />
 
-    <a href="classes/Seq/NA/RNA.html">Seq::NA::RNA</a><br />
+    <a href="classes/SeqError.html">SeqError</a><br />
 
     <a href="classes/Status.html">Status</a><br />
 
index e78e9bed4a46f1c424198f7c3707491071f0514a..fd47302cbb529791512ea06d20eb6a09f02e74d0 100644 (file)
@@ -19,6 +19,8 @@
 
     <a href="files/biopieces_rb.html">biopieces.rb</a><br />
 
+    <a href="files/fasta_rb.html">fasta.rb</a><br />
+
     <a href="files/seq_rb.html">seq.rb</a><br />
 
   </div>
index 3834175bbc2f974193bb527a3a79e277b6c0bf8b..5a0e1e97a28d71e6f6ddfa462db2654bad6ebab7 100644 (file)
   <h1 class="section-bar">Methods</h1>
   <div id="index-entries">
 
-    <a href="classes/Seq/NA/RNA.html#M000043">complement (Seq::NA::RNA)</a><br />
-
-    <a href="classes/Seq/NA/DNA.html#M000040">complement (Seq::NA::DNA)</a><br />
+    <a href="classes/Seq.html#M000043">complement (Seq)</a><br />
 
     <a href="classes/Status.html#M000029">delete (Status)</a><br />
 
+    <a href="classes/Fasta.html#M000033">each (Fasta)</a><br />
+
     <a href="classes/Biopieces.html#M000004">each (Biopieces)</a><br />
 
     <a href="classes/Biopieces.html#M000003">each_record (Biopieces)</a><br />
 
-    <a href="classes/Seq.html#M000034">generate (Seq)</a><br />
+    <a href="classes/Seq.html#M000044">generate (Seq)</a><br />
 
-    <a href="classes/Seq.html#M000035">generate! (Seq)</a><br />
+    <a href="classes/Fasta.html#M000034">get_entry (Fasta)</a><br />
 
     <a href="classes/Status.html#M000027">get_tmpdir (Status)</a><br />
 
-    <a href="classes/Seq.html#M000031">guess_type (Seq)</a><br />
+    <a href="classes/Seq.html#M000037">is_dna (Seq)</a><br />
+
+    <a href="classes/Seq.html#M000039">is_protein (Seq)</a><br />
+
+    <a href="classes/Seq.html#M000038">is_rna (Seq)</a><br />
+
+    <a href="classes/Seq.html#M000036">len (Seq)</a><br />
+
+    <a href="classes/Seq.html#M000035">length (Seq)</a><br />
 
     <a href="classes/Status.html#M000028">log (Status)</a><br />
 
     <a href="classes/Biopieces.html#M000006">mktmpdir (Biopieces)</a><br />
 
-    <a href="classes/Seq/AA.html#M000037">mol_weight (Seq::AA)</a><br />
+    <a href="classes/OptionHandler.html#M000008">new (OptionHandler)</a><br />
 
     <a href="classes/Casts.html#M000007">new (Casts)</a><br />
 
-    <a href="classes/OptionHandler.html#M000008">new (OptionHandler)</a><br />
+    <a href="classes/Fasta.html#M000032">new (Fasta)</a><br />
 
     <a href="classes/Biopieces.html#M000001">new (Biopieces)</a><br />
 
     <a href="classes/Stream.html#M000030">open (Stream)</a><br />
 
+    <a href="classes/Fasta.html#M000031">open (Fasta)</a><br />
+
     <a href="classes/OptionHandler.html#M000016">options_check (OptionHandler)</a><br />
 
     <a href="classes/OptionHandler.html#M000023">options_check_allowed (OptionHandler)</a><br />
 
     <a href="classes/Biopieces.html#M000005">puts (Biopieces)</a><br />
 
-    <a href="classes/Seq/NA/RNA.html#M000041">residues (Seq::NA::RNA)</a><br />
-
-    <a href="classes/Seq/NA/DNA.html#M000038">residues (Seq::NA::DNA)</a><br />
-
-    <a href="classes/Seq/AA.html#M000036">residues (Seq::AA)</a><br />
-
     <a href="classes/Status.html#M000025">set (Status)</a><br />
 
     <a href="classes/Status.html#M000026">set_tmpdir (Status)</a><br />
 
-    <a href="classes/Seq/NA/RNA.html#M000042">to_DNA (Seq::NA::RNA)</a><br />
+    <a href="classes/Seq.html#M000042">to_bp (Seq)</a><br />
 
-    <a href="classes/Seq/NA/DNA.html#M000039">to_RNA (Seq::NA::DNA)</a><br />
+    <a href="classes/Seq.html#M000041">to_dna (Seq)</a><br />
 
-    <a href="classes/OptionHandler.html#M000010">wiki_path (OptionHandler)</a><br />
-
-    <a href="classes/Seq.html#M000032">wrap (Seq)</a><br />
+    <a href="classes/Seq.html#M000040">to_rna (Seq)</a><br />
 
-    <a href="classes/Seq.html#M000033">wrap! (Seq)</a><br />
+    <a href="classes/OptionHandler.html#M000010">wiki_path (OptionHandler)</a><br />
 
   </div>
 </div>
diff --git a/code_ruby/Maasha/lib/fasta.rb b/code_ruby/Maasha/lib/fasta.rb
new file mode 100644 (file)
index 0000000..23bad26
--- /dev/null
@@ -0,0 +1,87 @@
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# This software is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+require 'seq'
+
+# Error class for all exceptions to do with FASTA.
+class FastaError < StandardError; end
+
+class Fasta
+  include Enumerable
+
+  # Class method allowing open to be used on files.
+  # See File.open.
+  def self.open(*args)
+    ios   = File.open(*args)
+    fasta = self.new(ios)
+
+    if block_given?
+      begin
+        yield fasta
+      ensure
+        ios.close
+      end
+
+      return true
+    else
+      return fasta
+    end
+  end
+
+  def initialize(io, type=nil)
+    @io   = io
+    @type = type
+  end
+
+  # Iterator method for parsing FASTA enries.
+  def each
+    while entry = get_entry do
+      yield entry
+    end
+  end
+
+  # Method to get the next FASTA entry form an ios and return this
+  # as a Seq object. If no entry is found or eof then nil is returned.
+  def get_entry
+    block = @io.gets($/ + '>')
+    return nil if block.nil?
+
+    block.chomp!($/ + '>')
+
+    (seq_name, seq) = block.split($/, 2)
+
+    raise FastaError, "Bad FASTA format" if seq_name.nil? or seq.nil?
+
+    entry          = Seq.new
+    entry.type     = @type.nil? ? nil : @type.downcase
+    entry.seq      = seq.gsub(/\s/, '')
+    entry.seq_name = seq_name.sub(/^>/, '').rstrip
+
+    raise FastaError, "Bad FASTA format" if entry.seq_name.empty?
+    raise FastaError, "Bad FASTA format" if entry.seq.empty?
+
+    entry
+  end
+end
+
+
+__END__
index 4ce1e019ab79ebb75841b779f3b0ba5d4d92a317..e55a383e6a26a16d2d2033418975df6c79c55b53 100644 (file)
+DNA     = %w[a t c g]
+RNA     = %w[a u c g]
+PROTEIN = %w[f l s y c w p h q r i m t n k v a d e g]
+
+# Error class for all exceptions to do with Seq.
+class SeqError < StandardError; end
+
+class Seq
+  attr_accessor :seq_name, :seq, :type, :qual
+
+  def length
+    self.seq.nil? ? 0 : self.seq.length
+  end
+
+  alias len length
+
+  # Method that returns true is a given sequence type is DNA.
+  def is_dna
+    self.type == 'dna'
+  end
+
+  def is_rna
+    self.type == 'rna'
+  end
+
+  def is_protein
+    self.type == 'protein'
+  end
+
+  # Method to transcribe DNA to RNA.
+  def to_rna
+    raise SeqError, "Cannot transcribe 0 length sequence" if self.length == 0
+    raise SeqError, "Cannot transcribe sequence type: #{self.type}" unless self.is_dna
+    self.type = 'rna'
+    self.seq.tr!('Tt','Uu')
+  end
+
+  # Method to reverse-transcribe RNA to DNA.
+  def to_dna
+    raise SeqError, "Cannot reverse-transcribe 0 length sequence" if self.length == 0
+    raise SeqError, "Cannot reverse-transcribe sequence type: #{self.type}" unless self.is_rna
+    self.type = 'dna'
+    self.seq.tr!('Uu','Tt')
+  end
+
+  # Method that given a Seq entry returns a Biopieces record (a hash).
+  def to_bp
+    raise SeqError, "Missing seq_name" if self.seq_name.nil?
+    raise SeqError, "Missing seq"      if self.seq.nil?
+    record             = {}
+    record['SEQ_NAME'] = self.seq_name
+    record['SEQ']      = self.seq
+    record['SEQ_LEN']  = self.length
+    record
+  end
+
+  # Method that complements sequence including ambiguity codes.
+  def complement
+    raise SeqError, "Cannot complement 0 length sequence" if self.length == 0
+
+    if self.is_dna
+      self.seq.tr!( 'AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'TCGAAYRWSKMDHBVNtcgaayrwskmdhbvn' )
+    elsif self.is_rna
+      self.seq.tr!( 'AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'UCGAAYRWSKMDHBVNucgaayrwskmdhbvn' )
+    else
+      raise SeqError, "Cannot complement sequence type: #{self.type}"
+    end
+  end
+
+  # Method that generates a random sequence of a given length.
+  def generate(length,type)
+    raise SeqError, "Cannot generate negative sequence length: #{length}" if length <= 0
+
+    case type.downcase
+    when "dna"
+      alph = DNA
+    when "rna"
+      alph = RNA
+    when "protein"
+      alph = PROTEIN
+    else
+      raise SeqError, "Unknown sequence type: #{type}"
+    end
+
+    seq_new   = Array.new(length) { alph[rand(alph.size)] }.join("")
+    self.seq  = seq_new
+    self.type = type.downcase
+    seq_new
+  end
+end
+
+__END__
+
+
+
+
+
 # Class containing generic sequence methods and nucleic acid and amino acid subclasses.
 class Seq < String
-       # Guess the sequence type by analyzing the first 100 residues allowing for ambiguity codes.
-       def guess_type
-               raise ArgumentError, "No sequence." if self.empty?
-
-               seq_beg = self[0, 100].upcase
-
-               if seq_beg.count( "FLPQIE" ) > 0
-                       Seq::AA.new(self)
-               elsif seq_beg.count("U") > 0
-                       Seq::NA::RNA.new(self)
-               else
-                       Seq::NA::DNA.new(self)
-               end
-       end
-
-       # Method to wrap a sequence to a given width using a given delimiter.
-       def wrap(width = 80, delimit = $/)
-               raise ArgumentError, "Cannot wrap sequence to negative width: #{width}." if width <= 0
-
-               self.delete!(" \t\n\r")
-               self.gsub(/.{#{width}}(?!$)/, "\\0#{delimit}")
-       end
-
-       # Method to wrap and replace a sequence to a given width using a given delimiter.
-       def wrap!(width = 80, delimit = $/)
-               self.replace(self.wrap(width, delimit))
-       end
-
-       # Method that generates a random sequence of a given length.
-       def generate(length)
-               raise ArgumentError, "Cannot generate negative sequence length: #{length}." if length <= 0
-
-               alph = self.residues
-               Array.new(length) { alph[rand(alph.size)] }.join("")
-       end
-
-       # Method that replaces sequence with a randomly generated sequence of a given length.
-       def generate!(length)
-               self.replace(self.generate(length))
-       end
-
-       # Class containing methods specific for amino acid (AA) sequences.
-       class AA < Seq
-               # Method that returns an array of amino acid residues.
-               def residues
-                       %w{ F L S Y C W P H Q R I M T N K V A D E G }
-               end
-
-               # Calculate the molecular weight of an amino acid seuqunce.
-               # The caluculation is only approximate since there is no correction
-               # for amino bond formation and the MW used are somewhat imprecise:
-               # http://www.expasy.ch/tools/pscale/Molecularweight.html
-               def mol_weight
-                       raise ArgumentError, "invalid residues found: #{self.delete("#{residues.join( "" )}")}" if self.upcase =~ /[^#{residues.join( "" )}]/
-
-                       mol_weight_aa = {
-                               "A" => 89.000,    # Ala
-                               "R" => 174.000,   # Arg
-                               "N" => 132.000,   # Asn
-                               "D" => 133.000,   # Asp
-                               "C" => 121.000,   # Cys
-                               "Q" => 146.000,   # Gln
-                               "E" => 147.000,   # Glu
-                               "G" => 75.000,    # Gly
-                               "H" => 155.000,   # His
-                               "I" => 131.000,   # Ile
-                               "L" => 131.000,   # Leu
-                               "K" => 146.000,   # Lys
-                               "M" => 149.000,   # Met
-                               "F" => 165.000,   # Phe
-                               "P" => 115.000,   # Pro
-                               "S" => 105.000,   # Ser
-                               "T" => 119.000,   # Thr
-                               "W" => 204.000,   # Trp
-                               "Y" => 181.000,   # Tyr
-                               "V" => 117.000,   # Val
-                       }
-
-                       mw = 0.0
-
-                       self.upcase.each_char { |c| mw += mol_weight_aa[ c ] }
-
-                       mw
-               end
-       end
-
-       # Class containing methods specific for nucleic acid (NA) sequences.
-       class NA < Seq
-               # Class containing methods specific for DNA sequences.
-               class DNA < NA
-                       # Method that returns an array of DNA residues.
-                       def residues
-                               %w{ A T C G }
-                       end
-
-                       # Method to transcribe DNA to RNA.
-                       def to_RNA
-                               Seq::NA::RNA.new( self.tr( 'Tt', 'Uu' ) )
-                       end
-
-                       # Method that complements DNA sequence including ambiguity codes.
-                       def complement
-                               self.tr!( 'AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'TCGAAYRWSKMDHBVNtcgaayrwskmdhbvn' )
-                       end
-               end                     
-
-               # Class containing methods specific for RNA sequences.
-               class RNA < NA
-                       # Method that returns an array of RNA residues.
-                       def residues
-                               %w{ A U C G }
-                       end
-
-                       # Method to reverse transcribe RNA to DNA.
-                       def to_DNA
-                               Seq::NA::DNA.new( self.tr( 'Uu', 'Tt' ) )
-                       end
-
-                       # Method that complements RNA sequence including ambiguity codes.
-                       def complement
-                               self.tr!( 'AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'UCGAAYRWSKMDHBVNucgaayrwskmdhbvn' )
-                       end
-               end
-       end
-end
+  # Guess the sequence type by analyzing the first 100 residues allowing for ambiguity codes.
+  def guess_type
+    raise ArgumentError, "No sequence." if self.empty?
+
+    seq_beg = self[0, 100].upcase
+
+    if seq_beg.count( "FLPQIE" ) > 0
+      Seq::AA.new(self)
+    elsif seq_beg.count("U") > 0
+      Seq::NA::RNA.new(self)
+    else
+      Seq::NA::DNA.new(self)
+    end
+  end
+
+  # Method to wrap a sequence to a given width using a given delimiter.
+  def wrap(width = 80, delimit = $/)
+    raise ArgumentError, "Cannot wrap sequence to negative width: #{width}." if width <= 0
+
+    self.delete!(" \t\n\r")
+    self.gsub(/.{#{width}}(?!$)/, "\\0#{delimit}")
+  end
+
+  # Method to wrap and replace a sequence to a given width using a given delimiter.
+  def wrap!(width = 80, delimit = $/)
+    self.replace(self.wrap(width, delimit))
+  end
+
+  # Method that generates a random sequence of a given length.
+  def generate(length)
+    raise ArgumentError, "Cannot generate negative sequence length: #{length}." if length <= 0
+
+    alph = self.residues
+    Array.new(length) { alph[rand(alph.size)] }.join("")
+  end
+
+  # Method that replaces sequence with a randomly generated sequence of a given length.
+  def generate!(length)
+    self.replace(self.generate(length))
+  end
+
+  # Class containing methods specific for amino acid (AA) sequences.
+  class AA < Seq
+    # Method that returns an array of amino acid residues.
+    def residues
+      %w{ F L S Y C W P H Q R I M T N K V A D E G }
+    end
+
+    # Calculate the molecular weight of an amino acid seuqunce.
+    # The caluculation is only approximate since there is no correction
+    # for amino bond formation and the MW used are somewhat imprecise:
+    # http://www.expasy.ch/tools/pscale/Molecularweight.html
+    def mol_weight
+      raise ArgumentError, "invalid residues found: #{self.delete("#{residues.join( "" )}")}" if self.upcase =~ /[^#{residues.join( "" )}]/
+
+      mol_weight_aa = {
+        "A" => 89.000,    # Ala
+        "R" => 174.000,   # Arg
+        "N" => 132.000,   # Asn
+        "D" => 133.000,   # Asp
+        "C" => 121.000,   # Cys
+        "Q" => 146.000,   # Gln
+        "E" => 147.000,   # Glu
+        "G" => 75.000,    # Gly
+        "H" => 155.000,   # His
+        "I" => 131.000,   # Ile
+        "L" => 131.000,   # Leu
+        "K" => 146.000,   # Lys
+        "M" => 149.000,   # Met
+        "F" => 165.000,   # Phe
+        "P" => 115.000,   # Pro
+        "S" => 105.000,   # Ser
+        "T" => 119.000,   # Thr
+        "W" => 204.000,   # Trp
+        "Y" => 181.000,   # Tyr
+        "V" => 117.000,   # Val
+      }
+
+      mw = 0.0
+
+      self.upcase.each_char { |c| mw += mol_weight_aa[ c ] }
+
+      mw
+    end
+  end
index 9770bc3966ede80aa979c5f8e09ee35b0a0ff244..123b866f372f410d3d50131984a40a3d8ef16f52 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-$:.unshift File.join(File.dirname(__FILE__),'..','lib')
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
 
 # Copyright (C) 2007-2010 Martin A. Hansen.
 
@@ -34,7 +34,7 @@ TYPES       = %w[flag string list int uint float file file! files files! dir dir
 DUMMY_FILE  = __FILE__
 SCRIPT_PATH = "write_fasta"
 
-class OptionTest < Test::Unit::TestCase
+class BiopiecesTest < Test::Unit::TestCase
 
   def setup
     @input  = StringIO.new
diff --git a/code_ruby/Maasha/test/test_fasta.rb b/code_ruby/Maasha/test/test_fasta.rb
new file mode 100755 (executable)
index 0000000..dc59f58
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/env ruby
+$:.unshift File.join(File.dirname(__FILE__),'..','lib')
+
+# Copyright (C) 2007-2010 Martin A. Hansen.
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# http://www.gnu.org/copyleft/gpl.html
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# This software is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+require 'test/unit'
+require 'fasta'
+require 'stringio'
+require 'pp'
+
+class FastaTest < Test::Unit::TestCase
+  test "Fasta#get_entry obtains the correct seq_name" do
+    fasta = Fasta.new(StringIO.new(">test\nATCG\n"))
+    assert_equal(fasta.get_entry.seq_name, "test")
+  end
+
+  test "Fasta#get_entry obtains the correct seq without trailing newlines" do
+    fasta = Fasta.new(StringIO.new(">test\nATCG"))
+    assert_equal(fasta.get_entry.seq, "ATCG")
+  end
+
+  test "Fasta#get_entry obtains the correct seq with trailing newlines" do
+    fasta = Fasta.new(StringIO.new(">test\nATCG\n\n\n"))
+    assert_equal(fasta.get_entry.seq, "ATCG")
+  end
+
+  test "Fasta#get_entry obtains the correct type" do
+    fasta = Fasta.new(StringIO.new(">test\nATCG\n"), 'DNA')
+    assert_equal(fasta.get_entry.type, "dna")
+  end
+
+  test "Fasta#get_entry rstrips whitespace from seq_name" do
+    fasta = Fasta.new(StringIO.new(">test\n\r\t ATCG\n"))
+    assert_equal(fasta.get_entry.seq_name, "test")
+  end
+
+  test "Fasta#get_entry strips whitespace from seq" do
+    fasta = Fasta.new(StringIO.new(">test\n\r\t AT\n\r\t CG\n\r\t "))
+    assert_equal(fasta.get_entry.seq, "ATCG")
+  end
+
+  test "Fasta#get_entry with two entries obtain correct" do
+    fasta = Fasta.new(StringIO.new(">test1\n\r\t AT\n\r\t CG\n\r\t \n>test2\n\r\t atcg\n"))
+    assert_equal(fasta.get_entry.seq, "ATCG")
+    assert_equal(fasta.get_entry.seq, "atcg")
+  end
+
+  test "Fasta#get_entry without seq_name raises" do
+    fasta = Fasta.new(StringIO.new("ATCG\n"))
+    assert_raise( FastaError ) { fasta.get_entry }
+  end
+
+  test "Fasta#get_entry without seq raises" do
+    fasta = Fasta.new(StringIO.new(">test\n\n"))
+    assert_raise( FastaError ) { fasta.get_entry }
+  end
+
+  test "Fasta#get_entry with leading newline raises" do
+    fasta = Fasta.new(StringIO.new("\n>test\nATCG\n"))
+    assert_raise( FastaError ) { fasta.get_entry }
+  end
+
+# FIXME
+#  test "Fasta#get_entry raises on missing > in seq_name" do
+#    fasta = Fasta.new(StringIO.new("test\nATCG\n"))
+#    assert_raise( FastaError ) { fasta.get_entry }
+#  end
+end
index c080665aec31583aaf0b9d071448721c99afa400..b8841ac22df9693bd9210a562c5d671163c2f717 100755 (executable)
@@ -5,260 +5,389 @@ require 'test/unit'
 require 'pp'
 
 class TestSeq < Test::Unit::TestCase 
-       # Testing Seq#initialize
+  def setup
+    @entry = Seq.new
+  end
+
+  #  test "Seq# autoremoves whitespace, newlines, and carriage returns" do
+  #    dna = Seq.new
+  #    dna.seq = "A\tT\r\tC\nG  "
+  #    assert_equal(dna.seq, "ATCG")
+  #  end
+
+  test "Seq#is_dna with no sequence type returns false" do
+    assert_false(@entry.is_dna)
+  end
+
+  test "Seq#is_dna with dna sequence type returns true" do
+    @entry.type = 'dna'
+    assert_true(@entry.is_dna)
+  end
+
+  test "Seq#is_rna with no sequence type returns false" do
+    assert_false(@entry.is_rna)
+  end
+
+  test "Seq#is_rna with rna sequence type returns true" do
+    @entry.type = 'rna'
+    assert_true(@entry.is_rna)
+  end
+
+  test "Seq#is_protein with no sequence type returns false" do
+    assert_false(@entry.is_protein)
+  end
+
+  test "Seq#is_protein with protein sequence type returns true" do
+    @entry.type = 'protein'
+    assert_true(@entry.is_protein)
+  end
+
+  test "Sequence length is correct" do
+    @entry.seq = 'ATCG'
+    assert_equal(@entry.length, 4)
+  end
+
+  test "Seq#to_rna raises if no sequence" do
+    @entry.type = 'dna'
+    assert_raise(SeqError) { @entry.to_rna }
+  end
+
+  test "Seq#to_rna raises on bad type" do
+    @entry.seq  = 'ATCG'
+    @entry.type = 'rna'
+    assert_raise(SeqError) { @entry.to_rna }
+  end
+
+  test "Seq#to_rna transcribes correctly" do
+    @entry.seq  = 'ATCGatcg'
+    @entry.type = 'dna'
+    assert_equal(@entry.to_rna, "AUCGaucg")
+  end
+
+  test "Seq#to_rna changes entry type to rna" do
+    @entry.seq  = 'ATCGatcg'
+    @entry.type = 'dna'
+    @entry.to_rna
+    assert_equal(@entry.type, "rna")
+  end
+
+  test "Seq#to_dna raises if no sequence" do
+    @entry.type = 'rna'
+    assert_raise(SeqError) { @entry.to_dna }
+  end
+
+  test "Seq#to_dna raises on bad type" do
+    @entry.seq  = 'AUCG'
+    @entry.type = 'dna'
+    assert_raise(SeqError) { @entry.to_dna }
+  end
+
+  test "Seq#to_dna transcribes correctly" do
+    @entry.seq  = 'AUCGaucg'
+    @entry.type = 'rna'
+    assert_equal(@entry.to_dna, "ATCGatcg")
+  end
+
+  test "Seq#to_dna changes entry type to dna" do
+    @entry.seq  = 'AUCGaucg'
+    @entry.type = 'rna'
+    @entry.to_dna
+    assert_equal(@entry.type, "dna")
+  end
+
+  test "Seq#to_bp returns correct record" do
+    @entry.seq_name = 'test'
+    @entry.seq = 'ATCG'
+    assert_equal(@entry.to_bp, {"SEQ_NAME"=>"test", "SEQ"=>"ATCG", "SEQ_LEN"=>4})
+  end
+
+  test "Seq#to_bp raises on missing seq_name" do
+    @entry.seq = 'ATCG'
+    assert_raise(SeqError) { @entry.to_bp }
+  end
+
+  test "Seq#to_bp raises on missing sequence" do
+    @entry.seq_name = 'test'
+    assert_raise(SeqError) { @entry.to_bp }
+  end
+
+  test "Seq#complement raises if no sequence" do
+    @entry.type = 'dna'
+    assert_raise(SeqError) { @entry.complement }
+  end
+
+  test "Seq#complement raises on bad type" do
+    @entry.seq  = 'ATCG'
+    @entry.type = 'protein'
+    assert_raise(SeqError) { @entry.complement }
+  end
+
+  test "Seq#complement for DNA is correct" do
+    @entry.seq  = 'ATCGatcg'
+    @entry.type = 'dna'
+    assert_equal(@entry.complement, "TAGCtagc")
+  end
+
+  test "Seq#complement for RNA is correct" do
+    @entry.seq  = 'AUCGaucg'
+    @entry.type = 'rna'
+    assert_equal(@entry.complement, "UAGCuagc")
+  end
+
+  test "Seq#generate raises if length <= 0" do
+    assert_raise(SeqError) { @entry.generate(-10, "dna") }
+    assert_raise(SeqError) { @entry.generate(0, "dna") }
+  end
+
+  test "Seq#generate raises on bad type" do 
+    assert_raise(SeqError) { @entry.generate(10, "foo") }
+  end
+
+  test "Seq#generate don't raise on ok type" do
+    %w[ dna DNA rna RNA protein Protein ].each do |type|
+      assert_nothing_raised { @entry.generate(10, type) }
+    end
+  end
+end
+
 
-       # test marked for deletion - too simple and not informative
-       def test_Seq_initialize_with_0_args
-               s = Seq.new
-               assert_equal( "", s.to_s ) 
-       end
+__END__
+
+class TestSeq < Test::Unit::TestCase 
+  # Testing Seq#guess_type
 
-       # test marked for deletion - too simple and not informative
-       def test_Seq_initialize_with_1_args
-               s = Seq.new( "ATCG" )
-               assert_equal( "ATCG", s.to_s ) 
-       end
+  def test_guess_type_raise_if_no_sequence
+    s = Seq.new
 
-       # Testing Seq#to_s
-       def test_to_s
-               s = Seq.new( "ATCG" )
-               assert_equal( "ATCG", s.to_s )
-       end
+    assert_raise( ArgumentError ) { s.guess_type }
+  end
 
-       # Testing Seq#guess_type
+  def test_guess_type_AA_uppercase
+    s1 = Seq.new( "SEQ" )
+    s2 = Seq::AA.new( "SEQ" )
+    assert_equal( s1.guess_type.class, s2.class )
+  end
 
-       def test_guess_type_raise_if_no_sequence
-               s = Seq.new
+  def test_guess_type_AA_lowercase
+    s1 = Seq.new( "seq" )
+    s2 = Seq::AA.new( "seq" )
 
-               assert_raise( ArgumentError ) { s.guess_type }
-       end
+    assert_equal( s1.guess_type.class, s2.class )
+  end
 
-       def test_guess_type_AA_uppercase
-               s1 = Seq.new( "SEQ" )
-               s2 = Seq::AA.new( "SEQ" )
-               assert_equal( s1.guess_type.class, s2.class )
-       end
+  def test_guess_type_DNA_uppercase
+    s1 = Seq.new( "ATCG" )
+    s2 = Seq::NA::DNA.new( "ATCG" )
 
-       def test_guess_type_AA_lowercase
-               s1 = Seq.new( "seq" )
-               s2 = Seq::AA.new( "seq" )
+    assert_equal( s1.guess_type.class, s2.class )
+  end
 
-               assert_equal( s1.guess_type.class, s2.class )
-       end
+  def test_guess_type_DNA_lowercase
+    s1 = Seq.new( "atcg" )
+    s2 = Seq::NA::DNA.new( "atcg" )
 
-       def test_guess_type_DNA_uppercase
-               s1 = Seq.new( "ATCG" )
-               s2 = Seq::NA::DNA.new( "ATCG" )
+    assert_equal( s1.guess_type.class, s2.class )
+  end
 
-               assert_equal( s1.guess_type.class, s2.class )
-       end
+  def test_guess_type_RNA_uppercase
+    s1 = Seq.new( "AUCG" )
+    s2 = Seq::NA::RNA.new( "AUCG" )
 
-       def test_guess_type_DNA_lowercase
-               s1 = Seq.new( "atcg" )
-               s2 = Seq::NA::DNA.new( "atcg" )
+    assert_equal( s1.guess_type.class, s2.class )
+  end
 
-               assert_equal( s1.guess_type.class, s2.class )
-       end
+  def test_guess_type_RNA_lowercase
+    s1 = Seq.new( "aucg" )
+    s2 = Seq::NA::RNA.new( "aucg" )
 
-       def test_guess_type_RNA_uppercase
-               s1 = Seq.new( "AUCG" )
-               s2 = Seq::NA::RNA.new( "AUCG" )
+    assert_equal( s1.guess_type.class, s2.class )
+  end
 
-               assert_equal( s1.guess_type.class, s2.class )
-       end
+  # Testing Seq#wrap
 
-       def test_guess_type_RNA_lowercase
-               s1 = Seq.new( "aucg" )
-               s2 = Seq::NA::RNA.new( "aucg" )
+  def test_wrap_arg_is_a_positive_number
+    s = Seq.new
 
-               assert_equal( s1.guess_type.class, s2.class )
-       end
+    assert_raise( ArgumentError ) { s.wrap( 0 ) }
+    assert_raise( ArgumentError ) { s.wrap( -10 ) }
+  end
 
-       # Testing Seq#wrap
+  def test_wrap_with_0_args
+    s = Seq.new( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACGACTACGACT" )
 
-       def test_wrap_arg_is_a_positive_number
-               s = Seq.new
+    assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.wrap.to_s )
+  end
 
-               assert_raise( ArgumentError ) { s.wrap( 0 ) }
-               assert_raise( ArgumentError ) { s.wrap( -10 ) }
-       end
+  def test_wrap_with_1_args
+    s = Seq.new( "ATCG" )
 
-       def test_wrap_with_0_args
-               s = Seq.new( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACGACTACGACT" )
+    assert_equal( "AT\nCG", s.wrap( 2 ).to_s )
+  end
 
-               assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.wrap.to_s )
-       end
+  def test_wrap_with_2_args
+    s = Seq.new( "ATCG" )
 
-       def test_wrap_with_1_args
-               s = Seq.new( "ATCG" )
+    assert_equal( "AT\rCG", s.wrap( 2, "\r" ).to_s )
+  end
 
-               assert_equal( "AT\nCG", s.wrap( 2 ).to_s )
-       end
+  def test_wrap_dont_change_instance_var
+    s = Seq.new( "ATCG" )
 
-       def test_wrap_with_2_args
-               s = Seq.new( "ATCG" )
+    s.wrap( 2 )
 
-               assert_equal( "AT\rCG", s.wrap( 2, "\r" ).to_s )
-       end
+    assert_equal( "ATCG", s.to_s )
+  end
 
-       def test_wrap_dont_change_instance_var
-               s = Seq.new( "ATCG" )
+  # Testing Seq#wrap!
 
-               s.wrap( 2 )
+  def test_wrap_with_0_args!
+    s = Seq.new( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACGACTACGACT" )
 
-               assert_equal( "ATCG", s.to_s )
-       end
+    s.wrap!
 
-       # Testing Seq#wrap!
+    assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.to_s )
+  end
 
-       def test_wrap_with_0_args!
-               s = Seq.new( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACGACTACGACT" )
+  def test_wrap_with_1_args!
+    s = Seq.new( "ATCG" )
 
-               s.wrap!
+    s.wrap!( 2 )
 
-               assert_equal( "ACTGACTAGCATCGACTACGACTGACACGACGACGACGACCGAACGATCGATCGCAGACGACGCAGCATGACGACGTACG\nACTACGACT", s.to_s )
-       end
+    assert_equal( "AT\nCG", s.to_s )
+  end
 
-       def test_wrap_with_1_args!
-               s = Seq.new( "ATCG" )
+  def test_wrap_with_2_args!
+    s = Seq.new( "ATCG" )
 
-               s.wrap!( 2 )
+    s.wrap!( 2, "\r" )
 
-               assert_equal( "AT\nCG", s.to_s )
-       end
+    assert_equal( "AT\rCG", s.to_s )
+  end
 
-       def test_wrap_with_2_args!
-               s = Seq.new( "ATCG" )
+  # Testing Seq#generate
 
-               s.wrap!( 2, "\r" )
+  def test_generate_arg_is_a_positive_number
+    s = Seq.new
 
-               assert_equal( "AT\rCG", s.to_s )
-       end
+    assert_raise( ArgumentError ) { s.generate( 0 ) }
+    assert_raise( ArgumentError ) { s.generate( -10 ) }
+  end
 
-       # Testing Seq#generate
+  def test_generate
+    s = Seq::AA.new
 
-       def test_generate_arg_is_a_positive_number
-               s = Seq.new
+    seq = s.generate( 40 )
 
-               assert_raise( ArgumentError ) { s.generate( 0 ) }
-               assert_raise( ArgumentError ) { s.generate( -10 ) }
-       end
+    assert_equal( 40, seq.length )
+  end
 
-       def test_generate
-               s = Seq::AA.new
+  def test_generate_dont_change_instance_var
+    s = Seq::AA.new
 
-               seq = s.generate( 40 )
+    seq = s.generate( 40 )
 
-               assert_equal( 40, seq.length )
-       end
+    assert_equal( "", s.to_s )
+  end
 
-       def test_generate_dont_change_instance_var
-               s = Seq::AA.new
+  # Testing Seq#generate!
 
-               seq = s.generate( 40 )
+  def test_generate!
+    s = Seq::AA.new
 
-               assert_equal( "", s.to_s )
-       end
+    s.generate!( 40 )
 
-       # Testing Seq#generate!
+    assert_equal( 40, s.length )
+  end
 
-       def test_generate!
-               s = Seq::AA.new
+  # Testing Seq::AA#residues
 
-               s.generate!( 40 )
-       
-               assert_equal( 40, s.length )
-       end
+  def test_Seq_AA_residues
+    s = Seq::AA.new
 
-       # Testing Seq::AA#residues
+    assert_equal( %w{ F L S Y C W P H Q R I M T N K V A D E G }, s.residues )
+  end
 
-       def test_Seq_AA_residues
-               s = Seq::AA.new
+  # Testing Seq::AA#mol_weight
 
-               assert_equal( %w{ F L S Y C W P H Q R I M T N K V A D E G }, s.residues )
-       end
+  def test_Seq_aa_mol_weight_bad_residue
+    s = Seq::AA.new( "7" )
+    assert_raise( ArgumentError ) { s.mol_weight }
+  end
 
-       # Testing Seq::AA#mol_weight
+  def test_Seq_aa_mol_wight_return_correct_uppercase
+    s = Seq::AA.new( "SEQ" )
+    assert_equal( 398.0, s.mol_weight )
+  end
 
-       def test_Seq_aa_mol_weight_bad_residue
-               s = Seq::AA.new( "7" )
-               assert_raise( ArgumentError ) { s.mol_weight }
-       end
+  def test_Seq_aa_mol_wight_return_correct_lowercase
+    s = Seq::AA.new( "seq" )
+    assert_equal( 398.0, s.mol_weight )
+  end
 
-       def test_Seq_aa_mol_wight_return_correct_uppercase
-               s = Seq::AA.new( "SEQ" )
-               assert_equal( 398.0, s.mol_weight )
-       end
+  # Testing Seq::NA::DNA#residues
 
-       def test_Seq_aa_mol_wight_return_correct_lowercase
-               s = Seq::AA.new( "seq" )
-               assert_equal( 398.0, s.mol_weight )
-       end
+  def test_Seq_NA_DNA_residues
+    s = Seq::NA::DNA.new
 
-       # Testing Seq::NA::DNA#residues
+    assert_equal( %w{ A T C G }, s.residues )
+  end
 
-       def test_Seq_NA_DNA_residues
-               s = Seq::NA::DNA.new
+  # Testing Seq::NA::DNA#complement
 
-               assert_equal( %w{ A T C G }, s.residues )
-       end
+  def test_Seq_NA_DNA_complement_correct
+    s = Seq::NA::DNA.new( "ATCGatcg" )
+    assert_equal( "TAGCtagc", s.complement.to_s )
+  end
 
-       # Testing Seq::NA::DNA#complement
+  # Testing Seq::NA::DNA#to_RNA
 
-       def test_Seq_NA_DNA_complement_correct
-               s = Seq::NA::DNA.new( "ATCGatcg" )
-               assert_equal( "TAGCtagc", s.complement.to_s )
-       end
+  def test_Seq_NA_DNA_to_RNA_returns_RNA_object
+    dna = Seq::NA::DNA.new( "ATCGatcg" )
+    rna = Seq::NA::RNA.new
 
-       # Testing Seq::NA::DNA#to_RNA
+    new_rna = dna.to_RNA
 
-       def test_Seq_NA_DNA_to_RNA_returns_RNA_object
-               dna = Seq::NA::DNA.new( "ATCGatcg" )
-               rna = Seq::NA::RNA.new
-               
-               new_rna = dna.to_RNA
+    assert_equal( rna.class, new_rna.class )
+  end
 
-               assert_equal( rna.class, new_rna.class )
-       end
+  def test_Seq_NA_DNA_to_RNA_is_correct
+    dna = Seq::NA::DNA.new( "ATCGatcg" )
+    rna = dna.to_RNA
 
-       def test_Seq_NA_DNA_to_RNA_is_correct
-               dna = Seq::NA::DNA.new( "ATCGatcg" )
-               rna = dna.to_RNA
+    assert_equal( "AUCGaucg", rna.to_s )
+  end
 
-               assert_equal( "AUCGaucg", rna.to_s )
-       end
+  # Testing Seq::NA::RNA#residues
 
-       # Testing Seq::NA::RNA#residues
+  def test_Seq_NA_RNA_residues
+    s = Seq::NA::RNA.new
 
-       def test_Seq_NA_RNA_residues
-               s = Seq::NA::RNA.new
+    assert_equal( %w{ A U C G }, s.residues )
+  end
 
-               assert_equal( %w{ A U C G }, s.residues )
-       end
+  # Testing Seq::NA::RNA#complement
 
-       # Testing Seq::NA::RNA#complement
+  def test_Seq_NA_RNA_complement_correct
+    s = Seq::NA::RNA.new( "AUCGaucg" )
+    assert_equal( "UAGCuagc", s.complement.to_s )
+  end
 
-       def test_Seq_NA_RNA_complement_correct
-               s = Seq::NA::RNA.new( "AUCGaucg" )
-               assert_equal( "UAGCuagc", s.complement.to_s )
-       end
+  # Testing Seq::NA::RNA#to_DNA
 
-       # Testing Seq::NA::RNA#to_DNA
+  def test_Seq_NA_RNA_to_DNA_returns_DNA_object
+    rna = Seq::NA::RNA.new( "AUCGaucg" )
+    dna = Seq::NA::DNA.new
 
-       def test_Seq_NA_RNA_to_DNA_returns_DNA_object
-               rna = Seq::NA::RNA.new( "AUCGaucg" )
-               dna = Seq::NA::DNA.new
-               
-               new_dna = rna.to_DNA
+    new_dna = rna.to_DNA
 
-               assert_equal( dna.class, new_dna.class )
-       end
+    assert_equal( dna.class, new_dna.class )
+  end
 
-       def test_Seq_NA_RNA_to_DNA_is_correct
-               rna = Seq::NA::RNA.new( "AUCGaucg" )
-               dna = rna.to_DNA
+  def test_Seq_NA_RNA_to_DNA_is_correct
+    rna = Seq::NA::RNA.new( "AUCGaucg" )
+    dna = rna.to_DNA
 
-               assert_equal( "ATCGatcg", dna.to_s )
-       end
+    assert_equal( "ATCGatcg", dna.to_s )
+  end
 end