X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fclip_seq;h=44d1e508e1b007a0a8ae50b4ba67f37bc88bb20c;hb=8d375c58a048400bc06ce223bbb3315060b3b471;hp=4af564c9b487467f65f441f54864f5ccad06509f;hpb=a66f9359480be4e44b608c682c355e6a725b051c;p=biopieces.git diff --git a/bp_bin/clip_seq b/bp_bin/clip_seq index 4af564c..44d1e50 100755 --- a/bp_bin/clip_seq +++ b/bp_bin/clip_seq @@ -29,32 +29,35 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -require 'biopieces' +require 'maasha/biopieces' casts = [] -bp = Biopieces.new +options = Biopieces.options_parse(ARGV, casts) -options = bp.parse(ARGV, casts) +Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| + input.each_record do |record| + if record[:SEQ] + trim_beg = 0 + trim_end = record[:SEQ].length -bp.each_record do |record| - if record.has_key? :SEQ - trim_beg = 0 - trim_end = record[:SEQ].length + record[:SEQ] =~ /[^a-z]/ - record[:SEQ] =~ /[^a-z]/ + trim_beg = $`.length - trim_beg = $`.length + if record[:SEQ] =~ /[a-z]+$/ + trim_end = $`.length + else + trim_end = record[:SEQ].length + end - record[:SEQ] =~ /[a-z]+$/ - trim_end = $`.length + record[:SEQ] = record[:SEQ][trim_beg ... trim_end] + record[:SEQ_LEN] = record[:SEQ].length + record[:SCORES] = record[:SCORES][trim_beg ... trim_end] if record[:SCORES] + end - record[:SEQ] = record[:SEQ][trim_beg ... trim_end] - record[:SEQ_LEN] = record[:SEQ].length - record[:SCORES] = record[:SCORES][trim_beg ... trim_end] if record.has_key? :SCORES + output.puts record end - - bp.puts record end