]> git.donarmstrong.com Git - biopieces.git/commitdiff
ported length_seq to ruby
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 9 Sep 2010 11:41:03 +0000 (11:41 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 9 Sep 2010 11:41:03 +0000 (11:41 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1087 74ccb610-7750-0410-82ae-013aeee3265d

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

index 586409e6ff3e98a80d2666630cc878ab4fa10885..e3e6b094484db2fbb3a83f9344a35194f8fae2b1 100755 (executable)
@@ -1,6 +1,6 @@
-#!/usr/bin/env perl
+#!/usr/bin/env ruby
 
-# Copyright (C) 2007-2009 Martin A. Hansen.
+# 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
 
 # http://www.gnu.org/copyleft/gpl.html
 
-
-# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-
-# Determines the length of all sequences in the stream as well as a total length.
-
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
+# This program is part of the Biopieces framework (www.biopieces.org).
 
-use warnings;
-use strict;
-use Maasha::Biopieces;
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
+# Determines the length of each sequence in the stream.
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
-my ( $options, $in, $out, $record, $total );
-
-$options = Maasha::Biopieces::parse_options(
-    [
-        { long => 'no_stream', short => 'x', type => 'flag', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
-        { long => 'data_out',  short => 'o', type => 'file', mandatory => 'no', default => undef, allowed => undef, disallowed => undef },
-    ]   
-);
-
-$in  = Maasha::Biopieces::read_stream( $options->{ "stream_in" } );
-$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } );
-
-while ( $record = Maasha::Biopieces::get_record( $in ) ) {
-    $record->{ "SEQ_LEN" } = length $record->{ "SEQ" } if $record->{ "SEQ" }
-}
-
-Maasha::Biopieces::close_stream( $in );
-Maasha::Biopieces::close_stream( $out );
-
-
-# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+require 'biopieces'
 
+casts = []
 
-BEGIN
-{
-    Maasha::Biopieces::status_set();
-}
+bp = Biopieces.new
 
+options = bp.parse(ARGV, casts)
 
-END
-{
-    Maasha::Biopieces::status_log();
-}
+bp.each_record do |record|
+  record[:SEQ_LEN] = record[:SEQ].length if record.has_key? :SEQ
+  bp.puts record
+end
 
 
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
diff --git a/bp_test/in/length_seq.in b/bp_test/in/length_seq.in
new file mode 100644 (file)
index 0000000..8dd0ae6
--- /dev/null
@@ -0,0 +1,2 @@
+SEQ: ACGACGAGCATGCA
+---
diff --git a/bp_test/out/length_seq.out.1 b/bp_test/out/length_seq.out.1
new file mode 100644 (file)
index 0000000..7cad59f
--- /dev/null
@@ -0,0 +1,3 @@
+SEQ: ACGACGAGCATGCA
+SEQ_LEN: 14
+---
diff --git a/bp_test/test/test_length_seq b/bp_test/test/test_length_seq
new file mode 100755 (executable)
index 0000000..61c5709
--- /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
+clean