neurohmmer 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64bfcd138dcaa9161c75b0f3432be1fb086f9b0e
4
- data.tar.gz: 0c48aaea036d17b839b62d751313590224dce84c
3
+ metadata.gz: db09d40ef755f21f24d634b0ccbc99b931451284
4
+ data.tar.gz: 0c5206d2a6e780321087cbb08b372eedd360a432
5
5
  SHA512:
6
- metadata.gz: ca2b38036ba66bb3856c24553dfe4785e3427858e8609fc00db26d4491f0fb70486c0a31508a0ef9462d02d5d56e84f31b3312e4911ce693ca71f53003782f6c
7
- data.tar.gz: 6620ff16a2c77edad30b5bdd604178a33045ceb6d33ae9c7b4104919e3342d37ea0fcf0249c4e5a777308d828b4f86ce70d6a8d4a44c6cb319a2718e0265b654
6
+ metadata.gz: 622d211f245980ea29f0ea95db2d3d0be0a6fae190829201887d2f311abf24ad1d9ba149a24a8dc9a452ac335e4d244f82e1af564fd8cdc5c946aaf092000fdc
7
+ data.tar.gz: 8a910895b19c9cc131a4ec477875076a356b8f205a49734552b12d0bc866e9ea6285c3500abfa67bbcb1cb0520891bbc653e0af2b7905f510e4aabd81c71ef13
data/bin/neurohmmer CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'optparse'
3
+ require 'English'
3
4
 
4
5
  require 'neurohmmer'
5
6
  require 'neurohmmer/version'
@@ -36,7 +37,7 @@ BANNER
36
37
  opt[:signalp_path] = s
37
38
  end
38
39
 
39
- opts.on('-b', '--hmmer_bin_path path',
40
+ opts.on('-H', '--hmmer_bin_path path',
40
41
  'The full path to hmmer binaries directory') do |h|
41
42
  opt[:hmmer_path] = h
42
43
  end
@@ -70,7 +71,7 @@ begin
70
71
  exit 1
71
72
  end
72
73
  rescue OptionParser::ParseError
73
- $stderr.print 'Error: ' + $ERROR_INFO.to_s + '\n'
74
+ $stderr.print 'Error: ' + $ERROR_INFO.to_s + "\n"
74
75
  exit 1
75
76
  end
76
77
 
data/lib/neurohmmer.rb CHANGED
@@ -19,7 +19,8 @@ module Neurohmmer
19
19
  raw_alignments: File.expand_path('../../data/raw_data/alignments',
20
20
  __FILE__),
21
21
  hmm_output: File.join(@opt[:temp_dir], 'input.hmm_search.out'),
22
- html_output: "#{@opt[:input_file]}.neurohmmer.html"
22
+ html_output: "#{@opt[:input_file]}.neurohmmer.html",
23
+ fasta_output: "#{@opt[:input_file]}.neurohmmer.fa"
23
24
  }
24
25
  init_input
25
26
  end
@@ -27,6 +28,7 @@ module Neurohmmer
27
28
  def run
28
29
  Hmmer.search
29
30
  hmm_analysis = Hmmer.analyse_output
31
+ Output.to_fasta(hmm_analysis)
30
32
  Output.to_html(hmm_analysis)
31
33
  remove_temp_dir
32
34
  end
@@ -11,7 +11,7 @@ module Neurohmmer
11
11
  assert_input_file_probably_fasta(opt[:input_file])
12
12
  opt[:type] = assert_input_sequence(opt[:input_file])
13
13
  export_bin_dirs(opt[:hmmer_bin]) if opt[:hmmer_bin]
14
- # TODO: Assert hmm & mafft binaries
14
+ # TODO: Assert mafft binaries
15
15
  opt
16
16
  end
17
17
 
@@ -69,9 +69,9 @@ module Neurohmmer
69
69
  end
70
70
 
71
71
  def export_bin_dirs(hmmer_bin)
72
- bin = File.expand_path(bin)
72
+ bin = File.expand_path(hmmer_bin)
73
73
  if File.exist?(bin) && File.directory?(bin)
74
- add_to_path(bin)
74
+ add_to_path(bin)
75
75
  else
76
76
  $stderr.puts '*** The following bin directory does not exist:'
77
77
  $stderr.puts " #{bin}"
@@ -13,7 +13,8 @@ module Neurohmmer
13
13
  Dir.foreach(conf[:hmm_dir]) do |h|
14
14
  hmm_file = File.join(conf[:hmm_dir], h)
15
15
  next if hmm_file !~ /hmm$/
16
- hmm_search(opt[:input_file], hmm_file, conf[:hmm_output])
16
+ hmm_search(opt[:input_file], hmm_file, conf[:hmm_output],
17
+ opt[:num_threads])
17
18
  end
18
19
  end
19
20
 
@@ -36,7 +37,7 @@ module Neurohmmer
36
37
  "#{file.gsub(/fa(sta)?$/, '')}.aligned")
37
38
  hmm_model_file = File.join(conf[:hmm_dir],
38
39
  "#{file.gsub(/fa(sta)?$/, '')}.hmm")
39
- mafft(np_fasta_file, aligned_file, conf[:num_threads])
40
+ mafft(np_fasta_file, aligned_file, opt[:num_threads])
40
41
  hmm_build(aligned_file, hmm_model_file)
41
42
  end
42
43
  end
@@ -63,8 +64,9 @@ module Neurohmmer
63
64
  `hmmbuild '#{hmm_model_file}' '#{aligned_file}'`
64
65
  end
65
66
 
66
- def hmm_search(input_file, hmm_file, hmm_output)
67
- `hmmsearch '#{hmm_file}' '#{input_file}' >> '#{hmm_output}'`
67
+ def hmm_search(input_file, hmm_file, hmm_output, num_threads)
68
+ `hmmsearch --cpu #{num_threads} '#{hmm_file}' '#{input_file}' >> \
69
+ '#{hmm_output}'`
68
70
  end
69
71
  end
70
72
  end
@@ -11,6 +11,20 @@ module Neurohmmer
11
11
  extend Forwardable
12
12
  def_delegators Neurohmmer, :opt, :conf
13
13
 
14
+ def to_fasta(hmm_results)
15
+ File.open(conf[:fasta_output], 'w') do |file|
16
+ hmm_results.each do |query, hits|
17
+ next if hits.length == 0
18
+ file.puts # a blank line
19
+ file.puts '# ' + query
20
+ hits.each do |hit|
21
+ file.puts '>' + hit[:id]
22
+ file.puts hit[:seq]
23
+ end
24
+ end
25
+ end
26
+ end
27
+
14
28
  def to_html(hmm_results)
15
29
  @html_results = format_seqs_for_html(hmm_results)
16
30
  template_path = File.expand_path('../../../template/contents.slim',
@@ -64,12 +78,12 @@ module Neurohmmer
64
78
  s = s1.gsub(/<span class=hsp>/, '</span><span class=sp_hsp>') +
65
79
  seq[sp_cut_off..-1]
66
80
  return s.insert(0, '<span class=sp>')
67
- .insert(sp_cut_off + 41, '</span><span class=hsp>')
81
+ .insert(sp_cut_off + 41, '</span><span class=hsp>')
68
82
  elsif s1 =~ /</
69
- s = s1.gsub(/<.+$/, '</span><span class=sp_hsp>') +
70
- seq[sp_cut_off..-1].gsub(/^\w+?>/,'')
83
+ s = s1.gsub(/<.*?$/, '</span><span class=sp_hsp>') +
84
+ seq[sp_cut_off..-1].gsub(/^.*?>/, '')
71
85
  return s.insert(0, '<span class=sp>')
72
- .insert(sp_cut_off + 41, '</span><span class=hsp>')
86
+ .insert(sp_cut_off + 41, '</span><span class=hsp>')
73
87
  else
74
88
  return seq.insert(0, '<span class=sp>').insert(sp_cut_off + 15,
75
89
  '</span>')
@@ -1,4 +1,4 @@
1
1
  # Top level module / namespace.
2
2
  module Neurohmmer
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
@@ -53,5 +53,5 @@ html lang="en"
53
53
  a href="http://www.sbcs.qmul.ac.uk" target="_blank" QMUL
54
54
  br
55
55
  | This page was created by
56
- a href="https://github.com/wurmlab/NpSearch" target="_blank" NpSearch
56
+ a href="https://github.com/wurmlab/neurohmmer" target="_blank" NeuroHMMer
57
57
  | v#{Neurohmmer::VERSION}
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.1
4
+ version: 0.1.2
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-18 00:00:00.000000000 Z
13
+ date: 2015-11-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler