Class: SeqtrimAction

Inherits:
Object
  • Object
show all
Defined in:
lib/seqtrimnext/actions/seqtrim_action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_pos, end_pos) ⇒ SeqtrimAction

Creates the nexts values from an action: start_position, end_position, type



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 16

def initialize(start_pos,end_pos)
  # puts " #{start_pos} #{end_pos} #{self.class.to_s}"   
  
  @start_pos = start_pos.to_i
  @end_pos = end_pos.to_i        
  
  #@notes = '' 
  @left_action = false
  @right_action = false
  @message = ''
  @found_definition=[] #array when contaminant or vectors definitions are saved, each  separately
  @cut = false 
  @informative = false
  @reversed = false
  # puts " #{@start_pos} #{@end_pos} #{self.class.to_s}"  
  @tag_id =''
  
end

Instance Attribute Details

#cutObject

Returns the value of attribute cut.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def cut
  @cut
end

#end_posObject

Returns the value of attribute end_pos.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def end_pos
  @end_pos
end

#found_definitionObject

Returns the value of attribute found_definition.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def found_definition
  @found_definition
end

#informativeObject

Returns the value of attribute informative.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def informative
  @informative
end

#left_actionObject

Returns the value of attribute left_action.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def left_action
  @left_action
end

#messageObject

Returns the value of attribute message.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def message
  @message
end

#reversedObject

Returns the value of attribute reversed.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def reversed
  @reversed
end

#right_actionObject

Returns the value of attribute right_action.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def right_action
  @right_action
end

#start_posObject

Returns the value of attribute start_pos.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def start_pos
  @start_pos
end

#tag_idObject

Returns the value of attribute tag_id.



13
14
15
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 13

def tag_id
  @tag_id
end

Instance Method Details

#action_typeObject



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 78

def action_type
  
  a_type='INFO'
  if !@informative
    a_type = 'LEFT'
    if right_action
      a_type = 'RIGHT'
    end
  end
  return a_type
  
end

#apply_decoration(char) ⇒ Object



61
62
63
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 61

def apply_decoration(char)
  return char
end

#apply_to(seq) ⇒ Object



35
36
37
38
39
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 35

def apply_to(seq)   
     
  $LOG.debug " Applying #{self.class} to seq #{seq.seq_name} . BEGIN: #{@start_pos}   END: #{@end_pos}  " 
  
end

#contains?(pos) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 51

def contains?(pos)
  return ((pos>=@start_pos) && (pos<=@end_pos))
end

#contains_action?(start_pos, end_pos, margin = 10) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 56

def contains_action?(start_pos,end_pos,margin=10)
  #puts "#{start_pos}>=#{@start_pos-margin} && #{end_pos}<=#{@end_pos+margin} "
return ((start_pos>=@start_pos-margin) && (end_pos<=@end_pos+margin))
end

#decorate(char, pos) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 67

def decorate(char,pos)
  if contains?(pos)
    return apply_decoration(char)
  else
    return char
  end
end

#descriptionObject



41
42
43
44
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 41

def description
  
  return "Action Type: #{self.class} Begin: #{start_pos} End: #{end_pos}"
end

#inspectObject



46
47
48
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 46

def inspect
  description
end

#left_action?(seq_fasta_size) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
115
116
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 111

def left_action?(seq_fasta_size)
  res = (@left_action || (!@right_action && near_left?(seq_fasta_size)))
  # @left_action = res
    
  return res
end

#near_left?(seq_fasta_size) ⇒ Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 106

def near_left?(seq_fasta_size)
  return ((@start_pos - 0 ) < (seq_fasta_size - @end_pos))
end

#right_action?(seq_fasta_size) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
121
122
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 118

def right_action?(seq_fasta_size)
   res= (@right_action || !left_action?(seq_fasta_size))
   # @right_action = res
   return res
end

#titleObject



102
103
104
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 102

def title
 return to_human(type.gsub('Action',''))
end

#to_hashObject



124
125
126
127
128
129
130
131
132
133
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 124

def to_hash
   a = {}
   
   a[:type]=type
   a[:start_pos]=@start_pos
   a[:end_pos]=@end_pos
   a[:message]=@message
   
   return a
end

#to_human(camel_cased_word) ⇒ Object



91
92
93
94
95
96
97
98
99
100
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 91

def to_human(camel_cased_word)
  word = camel_cased_word.to_s.dup
  word.gsub!(/::/, '/')
  word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1 \2')
  word.gsub!(/([a-z\d])([A-Z])/,'\1 \2')
  word.tr!("-", " ")
  word.downcase!
  word.capitalize!
  word
end

#typeObject



75
76
77
# File 'lib/seqtrimnext/actions/seqtrim_action.rb', line 75

def type
  return self.class.to_s
end