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



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

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_blasts(seqs) ⇒ Object

do the dust masker instead of blast



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/seqtrimnext/plugins/plugin_low_complexity.rb', line 17

def do_blasts(seqs)

   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, blast_query) ⇒ Object



38
39
40
41
42
43
44
45
46
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
79
80
# File 'lib/seqtrimnext/plugins/plugin_low_complexity.rb', line 38

def exec_seq(seq,blast_query)
  dust_query=blast_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?
      # low_quals=seq.get_actions(ActionLowQuality)
      
      dust_query.dust.each do |dust|
        start=dust[0]
        stop=dust[1]
        dust_size=dust[1]-dust[0]+1
        

        if (dust_size)>=MIN_DUST_SIZE
        
          # check if low complexity is inside a lowqual region
          if !seq.range_inside_action_type?(start,stop,ActionLowQuality)
            
            total_dust+=dust_size    
            a = seq.new_action(start,stop,'ActionLowComplexity')
            # a.left_action=true
            actions.push a
            
          end
          # break
        end
      end
    end
    
    if !actions.empty?
      add_stats('low_complexity',total_dust)
      seq.add_file_tag(0, 'low_complexity', :both, 100)
      seq.add_actions(actions)
    end

end