biodiversity19 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use ruby-1.9.2-p290@biodiversity--create
1
+ rvm use ruby-1.9.2-p290@biodiversity --create
data/Gemfile CHANGED
@@ -1,10 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "jeweler"
4
3
  gem "treetop"
5
- gem "facter"
6
4
  gem "parallel"
7
5
 
6
+ group :development do
7
+ gem "jeweler"
8
+ end
9
+
8
10
  group :test do
9
11
  gem "ruby-debug19", :require => "ruby-debug"
10
12
  gem "rspec"
data/Gemfile.lock CHANGED
@@ -4,7 +4,6 @@ GEM
4
4
  archive-tar-minitar (0.5.2)
5
5
  columnize (0.3.4)
6
6
  diff-lcs (1.1.3)
7
- facter (1.6.3)
8
7
  git (1.2.5)
9
8
  jeweler (1.6.4)
10
9
  bundler (~> 1.0)
@@ -41,7 +40,6 @@ PLATFORMS
41
40
  ruby
42
41
 
43
42
  DEPENDENCIES
44
- facter
45
43
  jeweler
46
44
  parallel
47
45
  rspec
data/README.rdoc CHANGED
@@ -85,6 +85,11 @@ You can use it as a library
85
85
  # to get detailed information about elements of the name
86
86
  parser.parse("Pseudocercospora dendrobii (H.C. Burnett 1883) U. Braun & Crous 2003")[:scientificName][:details]
87
87
 
88
+ # to parse using several CPUs (4 seem to be optimal)
89
+ parser = ParallelParser.new # ParallelParser.new(4) will try to run 4 processes if hardware allows
90
+ array_of_names = ["Betula alba", "Homo sapiens"....]
91
+ parser.parse(array_of_names) # -> {"Betula alba" => "{scientificName...}", "Homo sapiens" => "{scientificName...}", ...}
92
+
88
93
  # to resolve lsid and get back RDF file
89
94
  LsidResolver.resolve("urn:lsid:ubio.org:classificationbank:2232671")
90
95
 
data/Rakefile CHANGED
@@ -30,6 +30,7 @@ begin
30
30
  gem.bindir = 'bin'
31
31
  gem.executables = ['nnparse', 'parserver']
32
32
  gem.add_dependency('treetop')
33
+ gem.add_dependency('parallel')
33
34
  gem.add_dependency('json') if ruby_version < 19
34
35
  gem.add_development_dependency "rspec"
35
36
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.7
@@ -25,11 +25,14 @@ end
25
25
 
26
26
  class ParallelParser
27
27
 
28
- def initialize
29
- require 'facter'
28
+ def initialize(processes_num = nil)
30
29
  require 'parallel'
31
30
  cpu_num
32
- @processes_num = cpu_num > 1 ? cpu_num - 1 : 1
31
+ if processes_num.to_i > 0
32
+ @processes_num = [processes_num, cpu_num - 1].min
33
+ else
34
+ @processes_num = cpu_num > 3 ? cpu_num - 2 : 1
35
+ end
33
36
  end
34
37
 
35
38
  def parse(names_list)
@@ -38,7 +41,7 @@ class ParallelParser
38
41
  end
39
42
 
40
43
  def cpu_num
41
- @cpu_num ||= Facter.processorcount.to_i
44
+ @cpu_num ||= Parallel.processor_count
42
45
  end
43
46
 
44
47
  private
@@ -61,4 +61,13 @@ describe ParallelParser do
61
61
  res.keys.size.should == names.size
62
62
  end
63
63
 
64
+ it "should parse several names in parallel with given num of processes" do
65
+ names = []
66
+ read_test_file { |n| names << (n[:name]) if n[:name] }
67
+ names.uniq!
68
+ pparser = ParallelParser.new(4)
69
+ res = pparser.parse(names)
70
+ names.size.should > 100
71
+ res.keys.size.should == names.size
72
+ end
64
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biodiversity19
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,8 +12,8 @@ cert_chain: []
12
12
  date: 2011-11-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: jeweler
16
- requirement: &70228377889480 !ruby/object:Gem::Requirement
15
+ name: treetop
16
+ requirement: &70293221558620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70228377889480
24
+ version_requirements: *70293221558620
25
25
  - !ruby/object:Gem::Dependency
26
- name: treetop
27
- requirement: &70228377827560 !ruby/object:Gem::Requirement
26
+ name: parallel
27
+ requirement: &70293221558140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,21 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70228377827560
35
+ version_requirements: *70293221558140
36
36
  - !ruby/object:Gem::Dependency
37
- name: facter
38
- requirement: &70228377827080 !ruby/object:Gem::Requirement
37
+ name: jeweler
38
+ requirement: &70293221557660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
- type: :runtime
44
+ type: :development
45
45
  prerelease: false
46
- version_requirements: *70228377827080
46
+ version_requirements: *70293221557660
47
47
  - !ruby/object:Gem::Dependency
48
- name: parallel
49
- requirement: &70228377826600 !ruby/object:Gem::Requirement
48
+ name: treetop
49
+ requirement: &70293221557180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70228377826600
57
+ version_requirements: *70293221557180
58
58
  - !ruby/object:Gem::Dependency
59
- name: treetop
60
- requirement: &70228377826120 !ruby/object:Gem::Requirement
59
+ name: parallel
60
+ requirement: &70293221556700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70228377826120
68
+ version_requirements: *70293221556700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70228377825640 !ruby/object:Gem::Requirement
71
+ requirement: &70293221556220 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70228377825640
79
+ version_requirements: *70293221556220
80
80
  description: Tools for biodiversity informatics
81
81
  email: dmozzherin@gmail.com
82
82
  executables: