neurohmmer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4482fb1f357fa6979328e0962b4d78fc3e976c2
4
- data.tar.gz: f8261599fb51877933c4f9aa275dee98409f602b
3
+ metadata.gz: 64bfcd138dcaa9161c75b0f3432be1fb086f9b0e
4
+ data.tar.gz: 0c48aaea036d17b839b62d751313590224dce84c
5
5
  SHA512:
6
- metadata.gz: 67613f69fbbf1118e6ced3ca3d7f08a3ee615926947dd82b98e49a793804900ca5dfca8858fb137793452e628101ab538e6298586de7ab9acfb73096f44aca88
7
- data.tar.gz: c95c9fea86dd0ba0ce28d6f69fd74f703db570aec6eab7823c220af0d95bf760ada5dd65aaf0dcfcad1ec7c7ac29b1a1b078d70bd1687ddc3aafd24ecee78f3a
6
+ metadata.gz: ca2b38036ba66bb3856c24553dfe4785e3427858e8609fc00db26d4491f0fb70486c0a31508a0ef9462d02d5d56e84f31b3312e4911ce693ca71f53003782f6c
7
+ data.tar.gz: 6620ff16a2c77edad30b5bdd604178a33045ceb6d33ae9c7b4104919e3342d37ea0fcf0249c4e5a777308d828b4f86ce70d6a8d4a44c6cb319a2718e0265b654
data/bin/neurohmmer CHANGED
@@ -30,6 +30,17 @@ BANNER
30
30
  opt[:temp_dir] = p
31
31
  end
32
32
 
33
+ opt[:signalp_path] = 'signalp'
34
+ opts.on('-s', '--signalp_path path',
35
+ 'The full path to signalp executable') do |s|
36
+ opt[:signalp_path] = s
37
+ end
38
+
39
+ opts.on('-b', '--hmmer_bin_path path',
40
+ 'The full path to hmmer binaries directory') do |h|
41
+ opt[:hmmer_path] = h
42
+ end
43
+
33
44
  opt[:num_threads] = 1
34
45
  opts.on('-n', '--num_threads num_of_threads', Integer,
35
46
  'The number of threads to use when analysing the input file') do |n|
@@ -10,6 +10,7 @@ module Neurohmmer
10
10
  assert_input_file_not_empty(opt[:input_file])
11
11
  assert_input_file_probably_fasta(opt[:input_file])
12
12
  opt[:type] = assert_input_sequence(opt[:input_file])
13
+ export_bin_dirs(opt[:hmmer_bin]) if opt[:hmmer_bin]
13
14
  # TODO: Assert hmm & mafft binaries
14
15
  opt
15
16
  end
@@ -66,6 +67,23 @@ module Neurohmmer
66
67
  type = Bio::Sequence.new(cleaned_sequence).guess(0.9)
67
68
  (type == Bio::Sequence::NA) ? :genetic : :protein
68
69
  end
70
+
71
+ def export_bin_dirs(hmmer_bin)
72
+ bin = File.expand_path(bin)
73
+ if File.exist?(bin) && File.directory?(bin)
74
+ add_to_path(bin)
75
+ else
76
+ $stderr.puts '*** The following bin directory does not exist:'
77
+ $stderr.puts " #{bin}"
78
+ end
79
+ end
80
+
81
+ ## Checks if dir is in $PATH and if not, it adds the dir to the $PATH.
82
+ def add_to_path(bin_dir)
83
+ return unless bin_dir
84
+ return if ENV['PATH'].split(':').include?(bin_dir)
85
+ ENV['PATH'] = "#{bin_dir}:#{ENV['PATH']}"
86
+ end
69
87
  end
70
88
  end
71
89
  end
@@ -1,5 +1,7 @@
1
- require 'slim'
2
1
  require 'forwardable'
2
+ require 'slim'
3
+
4
+ require 'neurohmmer/signalp'
3
5
 
4
6
  # Top level module / namespace.
5
7
  module Neurohmmer
@@ -7,12 +9,12 @@ module Neurohmmer
7
9
  class Output
8
10
  class <<self
9
11
  extend Forwardable
10
- def_delegators Neurohmmer, :conf
12
+ def_delegators Neurohmmer, :opt, :conf
11
13
 
12
14
  def to_html(hmm_results)
13
15
  @html_results = format_seqs_for_html(hmm_results)
14
- template_path = File.expand_path(File.join(__FILE__, '../../../',
15
- 'template/contents.slim'))
16
+ template_path = File.expand_path('../../../template/contents.slim',
17
+ __FILE__)
16
18
  contents_temp = File.read(template_path)
17
19
  html_content = Slim::Template.new { contents_temp }.render(self)
18
20
  File.open(conf[:html_output], 'w') { |f| f.puts html_content }
@@ -35,9 +37,11 @@ module Neurohmmer
35
37
 
36
38
  def format_html_seq(seq, flatseq)
37
39
  seq.gsub!("\n", '')
40
+ signalp_output = Signalp.analyse_sequence(seq) if opt[:type] == :protein
38
41
  flatseq.each do |hsp|
39
42
  seq.gsub!(/#{hsp.gsub('-', '')}/i, '<span class=hsp>\0</span>')
40
43
  end
44
+ seq = format_signal_peptide(seq, signalp_output)
41
45
  seq.gsub(/KR|KK|RR/i, '<span class=clv>\0</span>')
42
46
  .gsub(/(K|R)<span class=hsp>(K|R)/i, '<span class=clv>\1</span>' \
43
47
  '<span class=clv_i>\2</span><span class=hsp>')
@@ -45,6 +49,32 @@ module Neurohmmer
45
49
  ' class=hsp>', 'R<span class=hsp>K')
46
50
  .gsub(/G<span class=clv>/, '<span class=gly>G</span><span class=clv>')
47
51
  end
52
+
53
+ def format_signal_peptide(seq, sp)
54
+ return seq if opt[:type] == :genetic || sp[:sp] == 'N'
55
+ add_signalp_formatting(seq, sp[:ymax_pos].to_i - 1)
56
+ end
57
+
58
+ def add_signalp_formatting(seq, sp_cut_off)
59
+ s1 = seq[0, sp_cut_off]
60
+ if s1 =~ /^</
61
+ s = seq.gsub(/^<span class=hsp>/, '<span class=sp_hsp>')
62
+ return s.insert(sp_cut_off + 19, '</span><span class=hsp>')
63
+ elsif s1 =~ /<span class=hsp>/
64
+ s = s1.gsub(/<span class=hsp>/, '</span><span class=sp_hsp>') +
65
+ seq[sp_cut_off..-1]
66
+ return s.insert(0, '<span class=sp>')
67
+ .insert(sp_cut_off + 41, '</span><span class=hsp>')
68
+ elsif s1 =~ /</
69
+ s = s1.gsub(/<.+$/, '</span><span class=sp_hsp>') +
70
+ seq[sp_cut_off..-1].gsub(/^\w+?>/,'')
71
+ return s.insert(0, '<span class=sp>')
72
+ .insert(sp_cut_off + 41, '</span><span class=hsp>')
73
+ else
74
+ return seq.insert(0, '<span class=sp>').insert(sp_cut_off + 15,
75
+ '</span>')
76
+ end
77
+ end
48
78
  end
49
79
  end
50
80
  end
@@ -0,0 +1,20 @@
1
+ require 'forwardable'
2
+
3
+ # Top level module / namespace.
4
+ module Neurohmmer
5
+ # A class to hold sequence data
6
+ class Signalp
7
+ class << self
8
+ extend Forwardable
9
+ def_delegators Neurohmmer, :opt
10
+
11
+ def analyse_sequence(seq)
12
+ sp_headers = %w(name cmax cmax_pos ymax ymax_pos smax smax_pos smean d
13
+ sp dmaxcut networks)
14
+ s = `echo ">seq\n#{seq}\n" | #{opt[:signalp_path]} -t euk -f short \
15
+ -U 0.3 -u 0.3`
16
+ Hash[sp_headers.map(&:to_sym).zip(s.gsub(/^#.*\n/, '').split)]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,4 +1,4 @@
1
1
  # Top level module / namespace.
2
2
  module Neurohmmer
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
@@ -15,6 +15,8 @@ html lang="en"
15
15
  a{color:#18bc9c; text-decoration:none}a:hover,a:focus{color:#18bc9c; text-decoration:underline}
16
16
  p {margin:0 0 10.5px}
17
17
  .id {font-weight:bold;}
18
+ .sp {color:#007AC0; font-weight:bold;}
19
+ .sp_hsp {color:#007AC0; font-weight:bold; background-color:#FFE4B5;}
18
20
  .sequence {word-break:break-all; font-family:Courier New, Courier, Mono;}
19
21
  .clv {color:#00B050; font-weight:bold;}
20
22
  .clv_i {color:#00B050; font-weight: bold; background-color:#FFE4B5;}
@@ -30,7 +32,7 @@ html lang="en"
30
32
  - hits.each do |hit|
31
33
  p.sequence
32
34
  span.id
33
- = hit[:id]
35
+ = '>' + hit[:id]
34
36
  br
35
37
  span.seq
36
38
  == hit[:seq]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neurohmmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismail Moghul
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-11-17 00:00:00.000000000 Z
13
+ date: 2015-11-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -233,6 +233,7 @@ files:
233
233
  - lib/neurohmmer/arg_validators.rb
234
234
  - lib/neurohmmer/hmmer.rb
235
235
  - lib/neurohmmer/output.rb
236
+ - lib/neurohmmer/signalp.rb
236
237
  - lib/neurohmmer/version.rb
237
238
  - neurohmmer.gemspec
238
239
  - spec/neurohmmer_spec.rb