Class: PluginSizeTrim

Inherits:
Plugin
  • Object
show all
Defined in:
lib/seqtrimnext/plugins/plugin_size_trim.rb

Overview

Author: Dario Guerrero

Defines the main methods that are necessary to execute PluginSizeTrim Inherit: Plugin Trims the output sequences to a fixed size

Instance Attribute Summary

Attributes inherited from Plugin

#stats

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

#add_plugin_stats, #add_stats, #add_text_stats, auto_setup, #can_execute?, check_param, #do_blasts, #execute, get_graph_filename, get_graph_title, graph_ignored?, ignored_graphs, #initialize, #merge_hits, #overlapX?, plot_setup, valid_graphs

Constructor Details

This class inherits a constructor from Plugin

Class Method Details

.check_params(params) ⇒ Object

Returns an array with the errors due to parameters are missing



48
49
50
51
52
53
54
55
# File 'lib/seqtrimnext/plugins/plugin_size_trim.rb', line 48

def self.check_params(params)
  errors=[]  
  
  self.check_param(errors,params,'trim_size_file_1','Integer',-1)
  self.check_param(errors,params,'trim_size_file_2','Integer',-1)
  
  return errors
end

Instance Method Details

#exec_seq(seq, blast_query) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/seqtrimnext/plugins/plugin_size_trim.rb', line 13

def exec_seq(seq,blast_query)
  #$LOG.debug "[#{self.class.to_s}, seq: #{seq.seq_name}]: checking if insert of sequence has enought size" 
  # puts "inserto #{seq.insert_start}, #{seq.insert_end} size #{seq.seq_fasta.size}" 
  

  tr_size = @params.get_param('trim_size_file_'+(seq.order_in_tuple+1).to_s)

  trim_size=-1

  if tr_size
    trim_size=tr_size.to_i
  end 

 # $WORKER_LOG.info "TRIM_SIZE=#{trim_size}, #{seq.order_in_tuple+1}"

  if trim_size>0

    if (seq.seq_fasta.size > trim_size)
    a_beg,a_end = trim_size, seq.seq_fasta.size  # position from an empty insert 
  
      actions=[]  
  
       type = "ActionTrim"
       
       a=seq.new_action(a_beg,a_end,type) 
       actions.push a                     
       add_stats('trim_sizes',a_end-a_beg+1)
       
      seq.add_actions(actions)  
    end  
  end
        
end