]> git.donarmstrong.com Git - biopieces.git/blob - bp_bin/find_orfs
fixed seq qual length check
[biopieces.git] / bp_bin / find_orfs
1 #!/usr/bin/env ruby
2
3 # Copyright (C) 2007-2012 Martin A. Hansen.
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 # http://www.gnu.org/copyleft/gpl.html
20
21 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
22
23 # This program is part of the Biopieces framework (www.biopieces.org).
24
25 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
26
27 # Determine the frequencies for k-mers in sequences in the stream.
28
29 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
30
31
32 require 'maasha/biopieces'
33 require 'maasha/seq'
34
35 codons_start = "ATG,GTG,AUG,GUG"
36 codons_stop  = "TAA,TGA,TAG,UAA,UGA,UAG"
37
38 casts = []
39 casts << {:long=>'start_codons',  :short=>'s', :type=>'list', :mandatory=>true,  :default=>codons_start, :allowed=>nil, :disallowed=>nil}
40 casts << {:long=>'stop_codons',   :short=>'S', :type=>'list', :mandatory=>true,  :default=>codons_stop,  :allowed=>nil, :disallowed=>nil}
41 casts << {:long=>'min_size',      :short=>'m', :type=>'uint', :mandatory=>true,  :default=>50,           :allowed=>nil, :disallowed=>'0'}
42 casts << {:long=>'max_size',      :short=>'M', :type=>'uint', :mandatory=>true,  :default=>10_000,       :allowed=>nil, :disallowed=>'0'}
43 casts << {:long=>'non_redundant', :short=>'n', :type=>'flag', :mandatory=>false, :default=>nil,          :allowed=>nil, :disallowed=>'0'}
44
45 options = Biopieces.options_parse(ARGV, casts)
46
47 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
48   input.each_record do |record|
49     output.puts record
50
51     if record[:SEQ]
52       entry = Seq.new_bp(record)
53
54       entry.each_orf(options[:min_size], options[:max_size], options[:start_codons], options[:stop_codons], options[:non_redundant]) do |orf, orf_beg, orf_end|
55         new_record = {}
56         new_record[:REC_TYPE] = "ORF"
57         new_record.merge!(orf.to_bp)
58         new_record[:S_BEG] = orf_beg
59         new_record[:S_END] = orf_end
60
61         output.puts new_record
62       end
63     end
64   end
65 end
66
67
68 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
69
70
71 __END__