Class: PluginKey

Inherits:
Plugin show all
Defined in:
lib/seqtrimnext/plugins/plugin_key.rb

Overview

Author: Almudena Bocinos Rioboo

Defines the main methods that are necessary to execute PluginKey

Inherit: Plugin

Instance Attribute Summary

Attributes inherited from Plugin

#stats

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Plugin

#add_stats, #add_text_stats, auto_setup, check_param, 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



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/seqtrimnext/plugins/plugin_key.rb', line 56

def self.check_params(params)
  errors=[]
  
  # self.check_param(errors,params,'blast_evalue_mids','Float')
  # self.check_param(errors,params,'blast_percent_mids','Integer')
  comment='sequences containing with diferent keys (barcodes) are saved to separate folders'
 default_value='false'
 params.check_param(errors,'use_independent_folder_for_each_key','String',default_value,comment)
  
  
  return errors
end

Instance Method Details

#exec_seq(seq) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/seqtrimnext/plugins/plugin_key.rb', line 23

def exec_seq(seq)
  $LOG.info "[#{self.class.to_s}, seq: #{seq.seq_name}]: marking key into the sequence" 
  # blast_table_results.inspect        
  
  actions=[]
  
  key_size=0
  # mid_size=0
  key_beg,key_end=[0,3]
  key_size=4
  key=seq.seq_fasta[0..3].upcase
  
  a = seq.new_action(key_beg,key_end,'ActionKey') # adds the actionKey to the sequence
  actions.push a       
  
  #Add actions  
  seq.add_actions(actions)
  
  
  if @group_by_key
    
    seq.add_file_tag(0,'key_' + key, :dir)
    add_stats('key_tag',key)
  end
  
  add_stats('key_size',key_size)
  # add_stats('mid_size',mid_size)
        

  
end

#execute(seqs) ⇒ Object

Begins the pluginKey’s execution to warn where is a key in the sequence “seq”



14
15
16
17
18
19
20
# File 'lib/seqtrimnext/plugins/plugin_key.rb', line 14

def execute(seqs)
  @group_by_key=(@params.get_param('use_independent_folder_for_each_key')=='true')
  
  seqs.each do |s|
      exec_seq(s)
  end
end