3 # Copyright (C) 2007-2012 Martin A. Hansen.
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.
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.
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.
19 # http://www.gnu.org/copyleft/gpl.html
21 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
23 # This program is part of the Biopieces framework (www.biopieces.org).
25 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
27 # Find similar sequences between query sequences from the stream and a database.
29 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
32 require 'maasha/biopieces'
33 require 'maasha/fasta'
34 require 'maasha/findsim'
37 casts << {:long=>'database', :short=>'d', :type=>'file!', :mandatory=>true, :default=>nil, :allowed=>nil, :disallowed=>nil}
38 casts << {:long=>'kmer', :short=>'k', :type=>'uint', :mandatory=>false, :default=>8, :allowed=>"4,5,6,7,8,9", :disallowed=>nil}
39 casts << {:long=>'step', :short=>'s', :type=>'uint', :mandatory=>false, :default=>1, :allowed=>nil, :disallowed=>"0"}
40 casts << {:long=>'min_score', :short=>'m', :type=>'float', :mandatory=>false, :default=>0.5, :allowed=>nil, :disallowed=>nil}
41 casts << {:long=>'max_hits', :short=>'h', :type=>'uint', :mandatory=>false, :default=>7, :allowed=>nil, :disallowed=>"0"}
42 casts << {:long=>'query_ids', :short=>'Q', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
43 casts << {:long=>'subject_ids', :short=>'S', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
44 casts << {:long=>'precise', :short=>'p', :type=>'flag', :mandatory=>false, :default=>nil, :allowed=>nil, :disallowed=>nil}
46 options = Biopieces.options_parse(ARGV, casts)
47 tmpdir = Biopieces.mktmpdir
48 query_file = File.join(tmpdir, "query.fna")
50 Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output|
51 Fasta.open(query_file, "w") do |fasta_io|
52 input.each_record do |record|
53 if record[:SEQ_NAME] and record[:SEQ]
54 entry = Seq.new_bp(record)
56 fasta_io.puts entry.to_fasta
63 fs = FindSim.new(options)
64 fs.load_query(query_file)
65 fs.search_db(options[:database])
72 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<