]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_bin/patscan_seq
added missing files
[biopieces.git] / bp_bin / patscan_seq
index ef217c559298293d0fdec522e77b9d46c1af535e..089954ddb6de2893d15e604fbf12ef073cc3099b 100755 (executable)
@@ -46,11 +46,11 @@ class Patscan
   end
 
   # Method to run Patscan
-  def run(comp = nil, type = nil, max_mis = nil, max_hit = nil, verbose = nil)
+  def run(comp = nil, type = nil, max_hit = nil, max_mis = nil, verbose = nil)
     args = []
     args << "scan_for_matches"
     args << "-c"            if comp
-    args << "-p"            if type == 'protein'
+    args << "-p"            if type == :protein
     args << "-n #{max_mis}" if max_mis
     args << "-m #{max_hit}" if max_hit
     args << @pat_file
@@ -68,7 +68,7 @@ class Patscan
   def results_parse
     results = Hash.new { |h, k| h[k] = [] }
 
-    Fasta.open(@out_file, mode='r') do |ios|
+    Fasta.open(@out_file, 'r') do |ios|
       ios.each do |entry|
         if entry.seq_name =~ /([^:]+):\[(\d+),(\d+)\]/
           id    = $1.to_i
@@ -141,19 +141,21 @@ seq_type       = nil
 Biopieces.open(options[:stream_in], tmp_file) do |input, output|
   Fasta.open(in_file, mode="w") do |fasta_io|
     input.each_record do |record|
-      if record.has_key? :SEQ_NAME
+      if record[:SEQ_NAME]
         seq_name_hash[seq_name_count] = record[:SEQ_NAME]
         record[:SEQ_NAME] = seq_name_count
         seq_name_count += 1
 
+        seq = Seq.new_bp(record)
+
         if seq_type.nil?
-          seq      = Seq.new("", record[:SEQ])
           seq_type = seq.type_guess
         end
+
+        fasta_io.puts seq.to_fasta
       end
 
       output.puts record
-      fasta_io.puts record
     end
   end
 end
@@ -164,12 +166,12 @@ results = patscan.results_parse
 
 Biopieces.open(tmp_file, options[:stream_out]) do |input, output|
   input.each_record do |record|
-    if record.has_key? :SEQ_NAME
+    if record[:SEQ_NAME]
       key = record[:SEQ_NAME].to_i
       record[:SEQ_NAME] = seq_name_hash[key]
 
       if options[:inline]
-        if results.has_key? key
+        if results[key]
           results[key].each do |result|
             record[:PATTERN]   = options[:pattern]
             record[:MATCH]     = result.match
@@ -180,6 +182,8 @@ Biopieces.open(tmp_file, options[:stream_out]) do |input, output|
 
             output.puts record
           end
+        else
+          output.puts record
         end
       else
         output.puts record