Class: NpSearch::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/npsearch/sequence.rb

Overview

Adapted from GeneValidator’s Query Class.. A class to hold sequence data

Constant Summary collapse

DI_NP_CLV =
'KR|KK|RR'.freeze
MONO_NP_CLV =
'[KRH]..R|[KRH]....R|[KRH]......R'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, sp, frame = nil) ⇒ Sequence

Returns a new instance of Sequence.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/npsearch/sequence.rb', line 18

def initialize(entry, sp, frame = nil)
  @id                    = entry.entry_id
  @defline               = entry.definition
  sp_cleavage_site_idx   = sp[:ymax_pos].to_i - 1
  @signalp               = sp[:orf][0..(sp_cleavage_site_idx - 1)]
  @seq                   = sp[:orf][sp_cleavage_site_idx..-1]
  @html_seq              = format_seq_for_html
  @translated_frame      = frame
  @score                 = 0
  @potential_cleaved_nps = nil
end

Instance Attribute Details

#deflineObject (readonly)

Returns the value of attribute defline.



10
11
12
# File 'lib/npsearch/sequence.rb', line 10

def defline
  @defline
end

#html_seqObject (readonly)

Returns the value of attribute html_seq.



13
14
15
# File 'lib/npsearch/sequence.rb', line 13

def html_seq
  @html_seq
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/npsearch/sequence.rb', line 9

def id
  @id
end

#potential_cleaved_npsObject

Returns the value of attribute potential_cleaved_nps.



16
17
18
# File 'lib/npsearch/sequence.rb', line 16

def potential_cleaved_nps
  @potential_cleaved_nps
end

#scoreObject

Returns the value of attribute score.



15
16
17
# File 'lib/npsearch/sequence.rb', line 15

def score
  @score
end

#seqObject (readonly)

Returns the value of attribute seq.



12
13
14
# File 'lib/npsearch/sequence.rb', line 12

def seq
  @seq
end

#signalpObject (readonly)

Returns the value of attribute signalp.



11
12
13
# File 'lib/npsearch/sequence.rb', line 11

def signalp
  @signalp
end

#translated_frameObject (readonly)

Returns the value of attribute translated_frame.



14
15
16
# File 'lib/npsearch/sequence.rb', line 14

def translated_frame
  @translated_frame
end

Instance Method Details

#format_seq_for_htmlObject



30
31
32
33
34
35
36
37
38
# File 'lib/npsearch/sequence.rb', line 30

def format_seq_for_html
  seq = @seq.gsub(/C/, '<span class=cysteine>C</span>')
  seq.gsub!(/#{DI_NP_CLV}/i, '<span class=np_clv>\0</span>')
  seq.gsub!(/#{MONO_NP_CLV}/i, '\0::NP_CLV::') # so that we can target 'R'
  seq.gsub!('R::NP_CLV::', '<span class=mono_np_clv>R</span>')
  seq.gsub!('G<span class=np_clv>',
            '<span class=glycine>G</span><span class=np_clv>')
  "<span class=signalp>#{@signalp}</span><span class=seq>#{seq}</span>"
end