X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fdigest_seq;h=2aa9ff9837fded6ad832d44fffacf99b08f96742;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=9fe81e9b83ad60162abc7711b95a3465182a865e;hpb=6b206a970406acb806365b5524c506d1fbfaedc2;p=biopieces.git diff --git a/bp_bin/digest_seq b/bp_bin/digest_seq index 9fe81e9..2aa9ff9 100755 --- a/bp_bin/digest_seq +++ b/bp_bin/digest_seq @@ -28,43 +28,40 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - -require 'biopieces' -require 'fasta' -require 'seq' +require 'maasha/biopieces' +require 'maasha/seq' casts = [] casts << {:long=>'pattern', :short=>'p', :type=>'string', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil} casts << {:long=>'cut_pos', :short=>'c', :type=>'int', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil} -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_NAME] and record[:SEQ] + seq = Seq.new_bp(record) -bp.each_record do |record| - if record.has_key? :SEQ_NAME and record.has_key? :SEQ - seq = Seq.new(record[:SEQ_NAME], record[:SEQ]) - digest = Digest.new(seq, options[:pattern].to_s, options[:cut_pos]) + seq.each_digest(options[:pattern].to_s, options[:cut_pos]) do |digest| + new_record = digest.to_bp - digest.each do |subseq| - new_record = subseq.to_bp + if new_record[:SEQ_NAME] =~ /\[(\d+)-(\d+)\]$/ + s_beg = $1 + s_end = $2 + end - if new_record[:SEQ_NAME] =~ /\[(\d+)-(\d+)\]$/ - s_beg = $1 - s_end = $2 - end + new_record[:S_BEG] = s_beg + new_record[:S_END] = s_end + new_record[:REC_TYPE] = "DIGEST" - new_record[:S_BEG] = s_beg - new_record[:S_END] = s_end - new_record[:REC_TYPE] = "DIGEST" - bp.puts new_record + output.puts new_record + end + else + output.puts record end - else - bp.puts record end end - # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<