bio-velvet 0.4.2 → 0.5.0

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: 2d61f788902dd64e947b0a072fe7ea4928d0090e
4
- data.tar.gz: c74bf34034fed56504e7db21df832117747db1d6
3
+ metadata.gz: 9aabe701dacbf7cda8d1d87ed8fc183c655f808c
4
+ data.tar.gz: 84bcad61582984031f5e34471a84a964c8564485
5
5
  SHA512:
6
- metadata.gz: 771d1e978e005c88e90e1c0f6740491f292d6296f7c32bb353ceab4c32b8d268beac7d81d74aa85d09d373ce1be09e53060ba7f41ff8d5203c0f2042cd13f855
7
- data.tar.gz: 7630ace0116ba247f7982779874e5a1c0d94db026afcb07792094a64195e09bdbeaee14f4e27c292434c69a47e27481e95665dab41a043415e7fb415b7ebc797
6
+ metadata.gz: 1958b34c29aa4c69e3f8282af61f630e809c19b42a95ada248fda72e85e4e0ca49fd8976e65bf168dc96775afe10ddb1006f99ec5af34f1aa82f2d9bf3d4f997
7
+ data.tar.gz: e30e66ded35e8d22a663c942420caa5dd7a87c0adce6c076d18a8b66295b732b439675de976a72b87b6c0582d454d20b0c91f5de0dd2f7176d8c745c2a6e0862
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem 'systemu', '~>2.6'
5
5
  gem 'files', '~>0.3'
6
6
  gem 'hopcsv', '~> 0.4'
7
7
  gem 'bio-commandeer', '~>0.1'
8
+ gem 'parallel', '~>1.3', '>=1.3.3'
8
9
 
9
10
  # Add dependencies to develop your gem here.
10
11
  # Include everything needed to run rake, tests, features, etc.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
@@ -447,7 +447,7 @@ module Bio
447
447
  fwd = @ends_of_kmers_of_node[0...10]+'..'
448
448
  rev = @ends_of_kmers_of_twin_node[0...10]+'..'
449
449
  end
450
- "Node #{@node_id}: #{fwd} / #{rev}"
450
+ "Node from #{@parent_graph.class}: #{@node_id}: #{fwd} / #{rev}"
451
451
  end
452
452
 
453
453
  def inspect
@@ -1,10 +1,12 @@
1
1
  require 'files'
2
2
  require 'systemu'
3
+ require 'parallel'
3
4
 
4
5
  module Bio
5
6
  module Velvet
6
7
  class Runner
7
8
  include Bio::Velvet::Logging
9
+ include Parallel::ProcessorCount
8
10
 
9
11
  # Run velveth and then velvetg, with the given kmer size. Returned
10
12
  # is a Bio::Velvet::Result class, stored in a temporary directory.
@@ -14,13 +16,21 @@ module Bio
14
16
  # to velveth and velvetg, respectively.
15
17
  #
16
18
  # The final options argument is used to specify bio-velvet wrapper options. Currently:
17
- # :output_assembly_path: a directory where the assembly takes place (by default, a temporary directory)
19
+ # :output_assembly_path: a directory where the assembly takes place [default: a temporary directory]
20
+ # :velveth_path: path to the velveth binary [default: 'velveth']
21
+ # :velvetg_path: path to the velvetg binary [default: 'velvetg']
22
+ # :threads: number of threads to use [default: all threads on the machine]
18
23
  def velvet(kmer_length, velveth_options_string, velvetg_options_string='', options={})
19
24
  res = velveth kmer_length, velveth_options_string, options
20
- velvetg res, velvetg_options_string
25
+ velvetg res, velvetg_options_string, options
21
26
  end
22
27
 
28
+ # Run velveth with the given kmer and return a Bio::Velvet::Result object
29
+ #
30
+ # Options:
31
+ # :velveth_path: path to the velveth binary [default: 'velveth']
23
32
  def velveth(kmer_length, velveth_arguments, options={})
33
+ set_num_cpus(options[:threads])
24
34
  result = Result.new
25
35
  outdir = nil
26
36
  if options[:output_assembly_path]
@@ -31,8 +41,11 @@ module Bio
31
41
  end
32
42
  result.result_directory = outdir
33
43
 
44
+ binary = options[:velveth_path]
45
+ binary ||= 'velveth'
46
+
34
47
  # Run velveth
35
- cmd = "velveth #{result.result_directory} #{kmer_length} #{velveth_arguments}"
48
+ cmd = "#{binary} #{result.result_directory} #{kmer_length} #{velveth_arguments}"
36
49
  log.info "Running velveth: #{cmd}" if log.info?
37
50
  status, stdout, stderr = systemu cmd
38
51
  if status.exitstatus != 0
@@ -47,8 +60,15 @@ module Bio
47
60
  # Run velvetg, with a Bio::Velvet::Result object
48
61
  # generated with velveth, and velvetg arguments as a String (no need to specify the velvet directory, just the extra
49
62
  # arguments).
50
- def velvetg(velveth_result_object, velvetg_arguments)
51
- cmd = "velvetg #{velveth_result_object.result_directory} #{velvetg_arguments}"
63
+ #
64
+ # Further options (the third argument):
65
+ # :velvetg_path: path to the velvetg binary [default: 'velvetg']
66
+ def velvetg(velveth_result_object, velvetg_arguments, options={})
67
+ binary = options[:velvetg_path]
68
+ binary ||= 'velvetg'
69
+
70
+ cmd = "#{binary} #{velveth_result_object.result_directory} #{velvetg_arguments}"
71
+
52
72
  log.info "Running velvetg: #{cmd}" if log.info?
53
73
  status, stdout, stderr = systemu cmd
54
74
  if status.exitstatus != 0
@@ -62,8 +82,8 @@ module Bio
62
82
 
63
83
  # Detect the binary version currently in use and return
64
84
  # as a String
65
- def binary_version
66
- cmd = 'velveth'
85
+ def binary_version(velveth_path='velveth')
86
+ cmd = velveth_path
67
87
  log.info "Running velveth: #{cmd}" if log.info?
68
88
  status, stdout, stderr = systemu cmd
69
89
  if status.exitstatus != 0
@@ -76,6 +96,18 @@ module Bio
76
96
  raise "Unable to parse the version number from running `#{cmd}', the output was: #{stdout}"
77
97
  end
78
98
  end
99
+
100
+ # According to the manual,
101
+ #"Velvet will the use up to OMP_NUM_THREADS+1 or OMP_THREAD_LIMIT threads."
102
+ #
103
+ # Argument is the number of CPUs, or nil if all CPUs on the machine are
104
+ # to be used
105
+ def set_num_cpus(num_cpus=nil)
106
+ num_cpus ||= processor_count #from the parallel gem
107
+ log.debug "Setting number of CPUs to run velvet with to #{num_cpus}."
108
+ ENV['OMP_NUM_THREADS'] = (num_cpus - 1).to_s
109
+ ENV['OMP_THREAD_LIMIT'] = num_cpus.to_s
110
+ end
79
111
  end
80
112
 
81
113
  class VelvetRunnerException < Exception; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-velvet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben J Woodcroft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-15 00:00:00.000000000 Z
11
+ date: 2015-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bio-logger
@@ -80,6 +80,26 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: parallel
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.3
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '1.3'
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.3.3
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.3'
83
103
  - !ruby/object:Gem::Dependency
84
104
  name: rspec
85
105
  requirement: !ruby/object:Gem::Requirement