lib/seqtrimnext/classes/params.rb in seqtrimnext-2.0.51 vs lib/seqtrimnext/classes/params.rb in seqtrimnext-2.0.52

- old
+ new

@@ -125,11 +125,11 @@ #if (line[0]!=62) && (line[0]!=48) # if (line[0]!='>'[0]) && (line[0]!='0'[0]) # line doesn't finish in * if (line[0]!='>'[0]) && (!(line =~ /\*$/)) - + #puts line # puts line,line[0] if line =~ />([^\.]+)\.\.\.\s/ #puts 'ok' # puts $1 @@ -187,16 +187,16 @@ return @params[param] end def get_fasta(list,name,type) res = list[name] - + if res.nil? $LOG.error("Error. The #{type}: #{name} was not correctly loaded") raise "Error. The #{type}: #{name} was not found in loaded #{name}s: #{list.map{|k,v| k}}." end - + return res end # Return the mid's size of param def get_mid(mid) @@ -229,168 +229,154 @@ if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at file = Regexp.last_match[1] line = Regexp.last_match[2].to_i method = Regexp.last_match[3] plugin=File.basename(file,File.extname(file)) - - # puts "CALLER: #{plugin}" - # puts [file, line, method] end end - def set_param(param,value,comment=nil) - plugin=get_plugin + def set_param(param,value,comment = nil) + plugin=get_plugin - @params[param] = value + @params[param] = value - if get_comment(plugin,param).nil? - set_comment(plugin,param,comment) - end + if get_comment(plugin,param).nil? + set_comment(plugin,param,comment) + end - end + end - # def set_order(plugin,param) - # - # if @param_order[plugin].nil? - # @param_order[plugin]=[] - # end - # - # if !@param_order[plugin].index(param) - # @param_order[plugin].push param - # end - # end - - def get_comment(plugin,param) - res = nil - if @plugin_comments[plugin] - res =@plugin_comments[plugin][param] - end - return res - end + res = nil + if @plugin_comments[plugin] + res =@plugin_comments[plugin][param] + end + return res + end def set_comment(plugin,param,comment) - if !comment.is_a?(Array) && !comment.nil? - comment=comment.split("\n").compact.map{|l| l.strip} - end + if !comment.is_a?(Array) && !comment.nil? + comment=comment.split("\n").compact.map{|l| l.strip} + end - if @plugin_comments[plugin].nil? - @plugin_comments[plugin]={} - end + if @plugin_comments[plugin].nil? + @plugin_comments[plugin]={} + end - old_comment='' - # remove from other plugins - @plugin_comments.each do |plugin_name,comments| - if comments.keys.include?(param) && plugin_name!=plugin - old_comment=comments[param] - comments.delete(param) - end - end + old_comment='' + # remove from other plugins + @plugin_comments.each do |plugin_name,comments| + if comments.keys.include?(param) && plugin_name!=plugin + old_comment=comments[param] + comments.delete(param) + end + end - if comment.nil? - comment=old_comment - end + if comment.nil? + comment=old_comment + end - # @comments[param]=(comment || ['']) - @plugin_comments[plugin][param]=(comment || ['']) - # puts @plugin_comments.keys.to_json + # @comments[param]=(comment || ['']) + @plugin_comments[plugin][param]=(comment || ['']) + # puts @plugin_comments.keys.to_json - # remove empty comments + # remove empty comments - @plugin_comments.reverse_each do |plugin_name,comments| - if comments.empty? - @plugin_comments.delete(plugin_name) - end - end + @plugin_comments.reverse_each do |plugin_name,comments| + if comments.empty? + @plugin_comments.delete(plugin_name) + end + end - end - + end + def set_mid(param,value) - @mids[param] = value - end - #attr_accessor :h # to accede to the atribute 'h' from out of this class + @mids[param] = value + end # Returns true if exists the parameter and nil if don't def exists?(param_name) - return !@params[param_name].nil? - end - + return !@params[param_name].nil? + end + def check_plugin_list_param(errors,param_name) - # get plugin list - pl_list=get_param(param_name) + # get plugin list + pl_list=get_param(param_name) - # puts pl_list,param_name - list=pl_list.split(',') + # puts pl_list,param_name + list=pl_list.split(',') - list.map!{|e| e.strip} + list.map!{|e| e.strip} - # puts "Lista:",list.join(',') + # puts "Lista:",list.join(',') - # always the pluginExtractInserts at the end - list.delete('PluginExtractInserts') - list << 'PluginExtractInserts' + # always the pluginExtractInserts at the end + list.delete('PluginExtractInserts') + list << 'PluginExtractInserts' - set_param(param_name,list.join(',')) - # if !list.include?('PluginExtractInserts') - # raise "PluginExtractInserts do not exists" - # - # end + set_param(param_name,list.join(',')) + # if !list.include?('PluginExtractInserts') + # raise "PluginExtractInserts do not exists" + # + # end - end + end # def split_databases(db_param_name) def check_db_param(errors,db_param_name) - # expand database paths - dbs= get_param(db_param_name).gsub('"','').split(/\s+/) - # puts "ALGO"*20 - # puts "INPUT DATABASES:\n"+dbs.join(',') + if !get_param(db_param_name).empty? + # expand database paths + dbs= get_param(db_param_name).gsub('"','').split(/\s+/) + # puts "ALGO"*20 + # puts "INPUT DATABASES:\n"+dbs.join(',') - procesed_dbs=[] - # - # TODO - chequear aqui que la db no esta vacia y que esta formateada. - dbs.reverse_each {|db_p| - db=File.expand_path(db_p) + procesed_dbs=[] + # + # TODO - chequear aqui que la db no esta vacia y que esta formateada. + dbs.reverse_each {|db_p| + db=File.expand_path(db_p) - if !File.exists?(db) - path=File.join($FORMATTED_DB_PATH,db_p) - else - path=db - end + if !File.exists?(db) + path=File.join($FORMATTED_DB_PATH,db_p) + else + path=db + end - if Dir.glob(path+'*.n*').entries.empty? - puts "DB file #{path} not formatted" + if Dir.glob(path+'*.n*').entries.empty? + puts "DB file #{path} not formatted" - if File.writable_real?(path) - cmd = "makeblastdb -in #{path} -parse_seqids -dbtype nucl" - system(cmd) - else - raise "Can't format database. We don't have write permissions in: #{path}" - end - end + if File.writable_real?(path) + cmd = "makeblastdb -in #{path} -parse_seqids -dbtype nucl" + system(cmd) + else + raise "Can't format database. We don't have write permissions in: #{path}" + end + end - procesed_dbs << path + procesed_dbs << path - if !File.exists?(path) - raise "DB File #{path} does not exists" - # exit - end - } + if !File.exists?(path) + raise "DB File #{path} does not exists" + # exit + end + } - db_paths = '"'+procesed_dbs.join(' ')+'"' + db_paths = '"'+procesed_dbs.join(' ')+'"' - set_param(db_param_name,db_paths) + set_param(db_param_name,db_paths) - puts "USED DATABASES\n"+db_paths - end + puts "USED DATABASES\n"+db_paths + end + end def self.generate_sample_params filename = 'sample_params.txt'