]> git.donarmstrong.com Git - biopieces.git/commitdiff
added index_vals biopiece
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 11 Apr 2013 17:10:35 +0000 (17:10 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 11 Apr 2013 17:10:35 +0000 (17:10 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@2155 74ccb610-7750-0410-82ae-013aeee3265d

bp_bin/index_vals [new file with mode: 0755]
bp_test/in/index_vals.in [new file with mode: 0644]
bp_test/out/index_vals.out.1 [new file with mode: 0644]
bp_test/test/test_index_vals [new file with mode: 0755]

diff --git a/bp_bin/index_vals b/bp_bin/index_vals
new file mode 100755 (executable)
index 0000000..77b0ede
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/env ruby
+
+# Copyright (C) 2007-2013 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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+# Shred sequences in the stream into subsequences.
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+require 'maasha/biopieces'
+require 'pp'
+
+casts = []
+casts << {:long=>'key', :short=>'k', :type=>'string', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil}
+
+options = Biopieces.options_parse(ARGV, casts)
+
+key   = options[:key].to_sym
+index = Hash.new { |h, k| h[k] = 0 }
+
+Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
+  input.each_record do |record|
+    if val = record[key]
+      record["#{key}_INDEX".to_sym] = index[val]
+      index[val] += 1
+    end
+
+    puts record
+  end
+end
+
+
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+__END__
diff --git a/bp_test/in/index_vals.in b/bp_test/in/index_vals.in
new file mode 100644 (file)
index 0000000..aea8487
--- /dev/null
@@ -0,0 +1,50 @@
+BEG: 6099
+SCORE: 24
+MID: MID51
+END: 6408
+---
+BEG: 38849
+SCORE: 62
+MID: MID51
+END: 40451
+---
+BEG: 22258
+SCORE: 24
+MID: MID51
+END: 23567
+---
+BEG: 50054
+SCORE: 34
+MID: MID51
+END: 52161
+---
+BEG: 4267
+SCORE: 105
+MID: MID52
+END: 4442
+---
+BEG: 4400
+SCORE: 25
+MID: MID52
+END: 4658
+---
+BEG: 169970
+SCORE: 23
+MID: MID52
+END: 173847
+---
+BEG: 8273
+SCORE: 16
+MID: MID51
+END: 8981
+---
+BEG: 43015
+SCORE: 66
+MID: MID51
+END: 44202
+---
+BEG: 8109
+SCORE: 69
+MID: MID54
+END: 8393
+---
diff --git a/bp_test/out/index_vals.out.1 b/bp_test/out/index_vals.out.1
new file mode 100644 (file)
index 0000000..30333d4
--- /dev/null
@@ -0,0 +1,60 @@
+BEG: 6099
+SCORE: 24
+MID: MID51
+END: 6408
+MID_INDEX: 0
+---
+BEG: 38849
+SCORE: 62
+MID: MID51
+END: 40451
+MID_INDEX: 1
+---
+BEG: 22258
+SCORE: 24
+MID: MID51
+END: 23567
+MID_INDEX: 2
+---
+BEG: 50054
+SCORE: 34
+MID: MID51
+END: 52161
+MID_INDEX: 3
+---
+BEG: 4267
+SCORE: 105
+MID: MID52
+END: 4442
+MID_INDEX: 0
+---
+BEG: 4400
+SCORE: 25
+MID: MID52
+END: 4658
+MID_INDEX: 1
+---
+BEG: 169970
+SCORE: 23
+MID: MID52
+END: 173847
+MID_INDEX: 2
+---
+BEG: 8273
+SCORE: 16
+MID: MID51
+END: 8981
+MID_INDEX: 4
+---
+BEG: 43015
+SCORE: 66
+MID: MID51
+END: 44202
+MID_INDEX: 5
+---
+BEG: 8109
+SCORE: 69
+MID: MID54
+END: 8393
+MID_INDEX: 0
+---
diff --git a/bp_test/test/test_index_vals b/bp_test/test/test_index_vals
new file mode 100755 (executable)
index 0000000..b4e475f
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+source "$BP_DIR/bp_test/lib/test.sh"
+
+run "$bp -I $in -k MID -O $tmp"
+assert_no_diff $tmp $out.1
+clean