Class: NpSearch::Sequence

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

Overview

A class to hold sequence data

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, seq, signalp_output, frame = nil) ⇒ Sequence

Returns a new instance of Sequence.



16
17
18
19
20
21
22
23
24
25
# File 'lib/npsearch/sequence.rb', line 16

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

Instance Attribute Details

#html_seqObject (readonly)

Returns the value of attribute html_seq.



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

def html_seq
  @html_seq
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/npsearch/sequence.rb', line 7

def id
  @id
end

#potential_cleaved_npsObject

Returns the value of attribute potential_cleaved_nps.



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

def potential_cleaved_nps
  @potential_cleaved_nps
end

#scoreObject

Returns the value of attribute score.



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

def score
  @score
end

#seqObject (readonly)

Returns the value of attribute seq.



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

def seq
  @seq
end

#signalpObject (readonly)

Returns the value of attribute signalp.



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

def signalp
  @signalp
end

#signalp_outputObject (readonly)

Returns the value of attribute signalp_output.



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

def signalp_output
  @signalp_output
end

#translated_frameObject (readonly)

Returns the value of attribute translated_frame.



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

def translated_frame
  @translated_frame
end

Instance Method Details

#format_seq_for_htmlObject



27
28
29
30
31
32
33
34
35
# File 'lib/npsearch/sequence.rb', line 27

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