X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Flength_seq;h=04384db3660c7762ccb1b99f9500d8a2e4bd3dc5;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=2ca4b0f950ae56029513bb090cf8c9d2ecf75a11;hpb=0309c14a327e5dc44d6216f7d94721e563502d7b;p=biopieces.git diff --git a/bp_bin/length_seq b/bp_bin/length_seq index 2ca4b0f..04384db 100755 --- a/bp_bin/length_seq +++ b/bp_bin/length_seq @@ -1,6 +1,6 @@ -#!/usr/bin/env perl -w +#!/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 @@ -18,71 +18,32 @@ # http://www.gnu.org/copyleft/gpl.html - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - -# Determines the length of all sequences in the stream as well as a total length. - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - -use strict; -use Maasha::Biopieces; - - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# This program is part of the Biopieces framework (www.biopieces.org). -my ( $run_time_beg, $run_time_end, $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 ) ) -{ - if ( $record->{ "SEQ" } ) - { - $record->{ "SEQ_LEN" } = length $record->{ "SEQ" }; - $total += $record->{ "SEQ_LEN" }; - } - - Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" }; -} - -Maasha::Biopieces::put_record( { TOTAL_SEQ_LEN => $total }, $out ); +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# Determines the length of each sequence in the stream. # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -BEGIN -{ - $run_time_beg = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::log_biopiece(); -} +require 'maasha/biopieces' +casts = [] -END -{ - Maasha::Biopieces::close_stream( $in ); - Maasha::Biopieces::close_stream( $out ); +options = Biopieces.options_parse(ARGV, casts) - $run_time_end = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options ); -} +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + input.each_record do |record| + record[:SEQ_LEN] = record[:SEQ].length if record[:SEQ] + output.puts record + end +end # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< __END__ -