Class: PluginLowComplexity

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

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



86
87
88
89
90
91
92
93
94
95
# File 'lib/seqtrimnext/plugins/plugin_low_complexity.rb', line 86

def self.check_params(params)
  errors=[]

  # 
  # comment='Minimum percent of T bases in poly_a to be accepted'
  # default_value = 80
  # params.check_param(errors,'poly_t_percent','Integer',default_value,comment)
  # 
  return errors
end

Instance Method Details

#do_dust(seqs) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/seqtrimnext/plugins/plugin_low_complexity.rb', line 26

def do_dust(seqs)
   # find MIDS  with less results than max_target_seqs value 
   dust_masker=DustMasker.new()

   fastas=[]
   
   seqs.each do |seq|
    fastas.push ">"+seq.seq_name
    fastas.push seq.seq_fasta
   end
   
   # fastas=fastas.join("\n")
   
   found_dust = dust_masker.do_dust(fastas)
   # puts found_dust
   # puts blast_table_results.inspect
  
   return found_dust
end

#exec_seq(seq, dust_query) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/seqtrimnext/plugins/plugin_low_complexity.rb', line 47

def exec_seq(seq,dust_query)
  if dust_query.query_id != seq.seq_name
    raise "Blast and seq names does not match, blast:#{blast_query.query_id} sn:#{seq.seq_name}"
  end
  actions=[]

    # puts "Checking for dust: #{seq.seq_fasta}"
    # puts found_dust.to_json
    total_dust=0
    if !dust_query.nil?
      dust_query.dust.each do |dust|
        start=dust[0]
        stop=dust[1]
        dust_size=dust[1]-dust[0]+1
        total_dust+=dust_size

        if (dust_size)>=MIN_DUST_SIZE
        
          a = seq.new_action(start,stop,'ActionLowComplexity')
          # a.left_action=true
          actions.push a
          # break
        end
      end
    end
    
    if !actions.empty?
      add_stats('low_complexity',total_dust)
      seq.add_actions(actions)
    end

end

#execute(seqs) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/seqtrimnext/plugins/plugin_low_complexity.rb', line 18

def execute(seqs)
  dust= do_dust(seqs)
  
  seqs.each_with_index do |s,i|
    exec_seq(s,dust[i])
  end
end