X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fanalyze_seq;h=2c38a274beeb593394ec5d33663d4dec1129de23;hb=48bea5c28b89dc5586d0bddb338ccd6ba23aa1f9;hp=b6f7d8c50ca78c4c054a7f68936fcc2c75a8e8ff;hpb=9bf550c4335d8860c5f6f9c4db0f385f1b36c1dd;p=biopieces.git diff --git a/bp_bin/analyze_seq b/bp_bin/analyze_seq index b6f7d8c..2c38a27 100755 --- a/bp_bin/analyze_seq +++ b/bp_bin/analyze_seq @@ -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 @@ -18,60 +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 warnings; -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_bp(record) + 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 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<