X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fclip_seq;h=45a96c74cd094f1141b9c40443af27ea9a7e106a;hb=7c0fcb47dbf02882b86fa507b7888495b0878e6f;hp=f26e10b9dea90023b800b3127e6cca9cacb290cf;hpb=494dc53ebd515b1e3e9b91bbebf43059899ca4ce;p=biopieces.git diff --git a/bp_bin/clip_seq b/bp_bin/clip_seq index f26e10b..45a96c7 100755 --- a/bp_bin/clip_seq +++ b/bp_bin/clip_seq @@ -33,31 +33,31 @@ 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.has_key? :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 - if record[:SEQ] =~ /[a-z]+$/ - trim_end = $`.length - else - trim_end = record[:SEQ].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.has_key? :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