]> git.donarmstrong.com Git - biopieces.git/commitdiff
added swapcase_seq written in RUBY
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 6 Aug 2010 12:05:43 +0000 (12:05 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 6 Aug 2010 12:05:43 +0000 (12:05 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1042 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/swapcase_seq [new file with mode: 0755]
bp_test/in/swapcase_seq.in [new file with mode: 0644]
bp_test/out/swapcase_seq.out.1 [new file with mode: 0644]
bp_test/test/test_swapcase_seq [new file with mode: 0755]
code_ruby/Maasha/lib/biopieces.rb

diff --git a/bp_bin/swapcase_seq b/bp_bin/swapcase_seq
new file mode 100755 (executable)
index 0000000..b36d21d
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/env ruby
+
+# 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 program is part of the Biopieces framework (www.biopieces.org).
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Test mock-up of a Biopiece written in Ruby.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+require 'biopieces'
+
+casts = []
+
+bp = Biopieces.new
+
+options = bp.parse(ARGV,casts)
+
+bp.each_record do |record|
+  record["SEQ"].swapcase! if record.has_key? "SEQ"
+  bp.puts record
+end
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+__END__
diff --git a/bp_test/in/swapcase_seq.in b/bp_test/in/swapcase_seq.in
new file mode 100644 (file)
index 0000000..59ead5a
--- /dev/null
@@ -0,0 +1,2 @@
+SEQ: ACGACGCATNNNNNNactgatcga
+---
diff --git a/bp_test/out/swapcase_seq.out.1 b/bp_test/out/swapcase_seq.out.1
new file mode 100644 (file)
index 0000000..2214628
--- /dev/null
@@ -0,0 +1,2 @@
+SEQ: acgacgcatnnnnnnACTGATCGA
+---
diff --git a/bp_test/test/test_swapcase_seq b/bp_test/test/test_swapcase_seq
new file mode 100755 (executable)
index 0000000..4266db8
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+source "$BP_DIR/bp_test/lib/test.sh"
+
+run "$bp -I $in -O $tmp"
+assert_no_diff $tmp $out.1
+rm $tmp
index 222e53b3b8772fe36f1482cd0371c8c79cd6e236..42eeb76296b37ce9b5f9bfe5da1ac55aa935442c 100644 (file)
@@ -584,48 +584,27 @@ class Stream < IO
 end
 
 
-# Stuff to be done at begin such as setting the exit status
-# and signal handlers
-def do_at_begin
-  status = Status.new
-  status.set
-  exit_status = "OK"
-
-  # Install signal handlers
-  %w( INT TERM QUIT ).each do |signal| 
-    Signal.trap(signal) do
-      exit_status = signal
-      exit
-    end
-  end
-
-  exit_status
-end
-
-exit_status = do_at_begin
+Status.new.set
 
-# Make sure that file streams are closed, tmpdir removed, and
-# exit status is written to log file.
 at_exit do
-  begin
-    @in.close  if @in.respond_to?  :close  # FIXME: This can never work
-    @out.close if @out.respond_to? :close  # FIXME: Same
-  rescue Exception => exception
-    $stderr.puts "Exception caught!"   # DEBUG
-    case exit_status
-    when 'INT'  then exit_status = 'INTERRUPTED'
-    when 'TERM' then exit_status = 'TERMINATED'
-    end
-    exit_status = "DIED" unless exit_status =~ /INT|TERM|QUIT/
-    $stderr.puts exit_status
-    $stderr.puts exception.backtrace
-  ensure
-    status = Status.new
-    FileUtils.remove_entry_secure(status.get_tmpdir)
-    status.log(exit_status)
-    status.delete
-    puts "DEBUG EXIT STATUS: #{exit_status}" # DEBUG
+  exit_status = $! ? $!.inspect : "OK"
+
+  case exit_status
+  when /error/i
+    exit_status = "ERROR"
+  when "Interrupt"
+    exit_status = "INTERRUPTED"
+  when /SIGTERM/
+    exit_status = "TERMINATED"
+  when /SIGQUIT/
+    exit_status = "QUIT"
   end
+
+  status = Status.new
+  tmpdir = status.get_tmpdir
+  FileUtils.remove_entry_secure(tmpdir) unless tmpdir.nil?
+  status.log(exit_status)
+  status.delete
 end