]> git.donarmstrong.com Git - biopieces.git/commitdiff
beautifying fasta.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 13 Oct 2011 09:56:15 +0000 (09:56 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 13 Oct 2011 09:56:15 +0000 (09:56 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1560 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/write_fasta_files
code_ruby/lib/maasha/biopieces.rb
code_ruby/lib/maasha/fasta.rb
code_ruby/lib/maasha/filesys.rb

index da4a1c6d347cb22210c1d504327429a7813791fb..debea31cb5c073f3ed6cbbacdb22a3096c7cd201 100755 (executable)
@@ -46,6 +46,8 @@ fh_hash = {}
 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
   input.each_record do |record|
     if record[:SEQ_NAME] and record[:SEQ] and record[key]
+      seq = Seq.new_bp(record)
+
       if fh_hash.has_key? record[key].to_sym
         fasta_io = fh_hash[record[key].to_sym]
       else
@@ -54,7 +56,7 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
         fh_hash[record[key].to_sym] = fasta_io
       end
 
-      fasta_io.puts record
+      fasta_io.puts seq.to_fasta
     end
 
     output.puts record unless options[:no_stream]
index 5fd6edf4a505154bb929976a86c58246ac5d3f85..1d1deb55e1daf4a05f798e51071eca68ea441641 100644 (file)
@@ -171,7 +171,7 @@ class Biopieces
   end
 
   # Class method for opening data stream for writing Biopiece records.
-  # Records are written to STDOU (default) or file.
+  # Records are written to STDOUT (default) or file.
   def self.open_output(output)
     if output.nil?
       output = self.new(STDOUT, stdio = true)
@@ -209,10 +209,10 @@ class Casts < Array
 
   # Add ubiquitous options casts.
   def ubiquitous
-    @cast_list << {:long=>'help',       :short=>'?', :type=>'flag',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-    @cast_list << {:long=>'stream_in',  :short=>'I', :type=>'file!',  :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-    @cast_list << {:long=>'stream_out', :short=>'O', :type=>'file',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
-    @cast_list << {:long=>'verbose',    :short=>'v', :type=>'flag',   :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+    @cast_list << {:long=>'help',       :short=>'?', :type=>'flag',  :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+    @cast_list << {:long=>'stream_in',  :short=>'I', :type=>'file!', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+    @cast_list << {:long=>'stream_out', :short=>'O', :type=>'file',  :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
+    @cast_list << {:long=>'verbose',    :short=>'v', :type=>'flag',  :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
   end
 
   # Check integrity of the casts.
index f57a6222f981589dd5728b819bb9888be50dc6aa..05655f67c86d609e8e4ab666347df228ad246c50 100644 (file)
@@ -51,14 +51,6 @@ class Fasta < Filesys
 
     entry
   end
-
-  # TODO - this should be some custom to_s method instead.
-  def puts(record)
-    if record.has_key? :SEQ_NAME and record.has_key? :SEQ
-      @io.print ">#{record[:SEQ_NAME]}\n"
-      @io.print "#{record[:SEQ]}\n"
-    end
-  end
 end
 
 
index 9024a580db80a4d1c16738ee7444aa0cee81e382..b3b450a9aefd653a53f8d80a9647a2e231f372c5 100644 (file)
@@ -65,6 +65,7 @@ class Filesys
     end
   end
 
+  # TODO figure out what type is for.
   def initialize(io, type=nil)
     @io   = io
     @type = type
@@ -82,6 +83,11 @@ class Filesys
     end
   end
 
+  # Method to puts directoy on Filesys objects.
+  def puts *args
+    @io.puts *args
+  end
+
   private
 
   # Helper method to return an ios to a file that may be zipped in which case
@@ -98,3 +104,4 @@ class Filesys
     self.new(ios)
   end
 end
+