X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fanalyze_seq;h=c2b96a5070b252bbe89f9e2e1c1fbd63055432a0;hb=2f0fd91b461033529a4a72e161bd133252a22eb6;hp=952fc4a8e3cec256b68e99ca967ed20e47c23263;hpb=66938be910a5642b50ddf28991649858b5c36580;p=biopieces.git diff --git a/bp_bin/analyze_seq b/bp_bin/analyze_seq index 952fc4a..c2b96a5 100755 --- a/bp_bin/analyze_seq +++ b/bp_bin/analyze_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,59 +18,42 @@ # http://www.gnu.org/copyleft/gpl.html - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - -# Analyze BED entries in the stream. - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# This program is part of the Biopieces framework (www.biopieces.org). -use strict; -use Maasha::Biopieces; -use Maasha::Seq; +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +# Analyze sequences in the stream. # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -my ( $options, $in, $out, $record, $analysis ); - -$options = Maasha::Biopieces::parse_options(); +require 'maasha/biopieces' +require 'maasha/seq' -$in = Maasha::Biopieces::read_stream( $options->{ "stream_in" } ); -$out = Maasha::Biopieces::write_stream( $options->{ "stream_out" } ); +casts = [] -while ( $record = Maasha::Biopieces::get_record( $in ) ) -{ - if ( $record->{ "SEQ" } ) - { - $analysis = Maasha::Seq::seq_analyze( $record->{ "SEQ" } ); - - map { $record->{ $_ } = $analysis->{ $_ } } keys %{ $analysis }; - } - - Maasha::Biopieces::put_record( $record, $out ); -} - -Maasha::Biopieces::close_stream( $in ); -Maasha::Biopieces::close_stream( $out ); - - -# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +options = Biopieces.options_parse(ARGV, casts) +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + input.each_record do |record| + if record[:SEQ] + seq = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SEQ_TYPE], record[:SCORE]) + comp = seq.composition -BEGIN -{ - Maasha::Biopieces::status_set(); -} + comp.each_pair do |key,val| + record["RES[#{key}]"] = val + end + record["SOFT_MASK%"] = seq.soft_mask + record["HARD_MASK%"] = (comp["N"].to_f / (seq.len - seq.indels).to_f * 100.0).round(2) + record["GC%"] = ((comp["G"] + comp["C"]).to_f / (seq.len - seq.indels).to_f * 100.0).round(2) + end -END -{ - Maasha::Biopieces::status_log(); -} + output.puts record + end +end # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<