# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-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