aai 0.4.0 → 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: b2cbffaec2af6b021831515c48b227eeb9115b95
4
- data.tar.gz: 537374f723948c2b42d118e3bd2cfc702b0f39ad
3
+ metadata.gz: 26efeea51af3369c265b1bda2c7ea1540884ebfb
4
+ data.tar.gz: fed2bdcddcfe2fb67540515494aae9ec260a1c59
5
5
  SHA512:
6
- metadata.gz: 9bc4dcd6f1ad1401d96734d7e97f6bf8a614dd474e9d61eb6973f8f148c948cbbfe47fd4671a30d80eb26345b56315912a7b94f26e1b4a2dad4f2afbbead313e
7
- data.tar.gz: 6ab74991df2c29db77f8b0ddfd3c72b69428c01cfd3c2f9952f4d6687503d33caa8dcc472d1349938f41cd849639afbd4d5f4d855799d2759605529a45edef14
6
+ metadata.gz: 76389d1e54a82b008b1c4920460bb4d450375bb5f72a03d599d3950c926da7ff17defbea97695edac8f467401a203b8d17abda2a17c1e74e337ae06d814b4743
7
+ data.tar.gz: f39b404ae3a7a5c494a99a1fc505b9894375c63878fe9d40bcb09e7701b610d80c6501297ea7fc9d42e1fdc5bf5809d4fb28dfb8b888152415a7d30ab9a29003
@@ -2,5 +2,6 @@
2
2
 
3
3
  Only key changes are listed here.
4
4
 
5
+ - 0.5.0: Fail immediately on failed DIAMOND jobs. Use parallel gem.
5
6
  - 0.4.0: Switch to using DIAMOND instead of BLAST
6
7
  - 0.3.0: Last version that uses blast.
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "yard", "~> 0.9.9"
29
29
 
30
30
  spec.add_runtime_dependency "abort_if", "~> 0.2.0"
31
- # spec.add_runtime_dependency "parallel", "~> 1.6", ">= 1.6.1"
31
+ spec.add_runtime_dependency "parallel", "~> 1.6", ">= 1.6.1"
32
32
  spec.add_runtime_dependency "parse_fasta", "~> 2.2"
33
33
  spec.add_runtime_dependency "systemu", "~> 2.6", ">= 2.6.5"
34
34
  spec.add_runtime_dependency "trollop", "~> 2.1", ">= 2.1.2"
data/lib/aai.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "abort_if"
2
2
  require "systemu"
3
+ require "parallel"
3
4
  require "parse_fasta"
4
5
 
5
6
  require "aai/core_extensions"
@@ -20,17 +21,12 @@ module Aai
20
21
  EVALUE_CUTOFF = 1e-3
21
22
  LENGTH_CUTOFF = 70 # actually is 70 percent
22
23
 
23
- # If a blast job fails, it will retry once. If it fails again, it
24
- # will be ignored by the rest of the pipeline.
25
24
  def blast_permutations! fastas, blast_dbs, cpus=4
26
25
  file_permutations = one_way_combinations fastas, blast_dbs, true
27
26
  file_permutations = file_permutations.select do |f1, f2|
28
27
  genome_from_fname(f1) != genome_from_fname(f2)
29
28
  end
30
29
 
31
- completed_outf_names = []
32
- failed_jobs = []
33
-
34
30
  first_files = file_permutations.map(&:first)
35
31
  second_files = file_permutations.map(&:last)
36
32
 
@@ -58,56 +54,58 @@ module Aai
58
54
  end
59
55
 
60
56
  Time.time_it "Running blast jobs" do
61
- args.each_with_index do |infiles, idx|
57
+ Parallel.each(args, in_processes: cpus) do |infiles|
62
58
  query = infiles[0]
63
59
  db = infiles[1]
64
60
  out = infiles[2]
65
61
 
66
- cmd = "diamond blastp --threads #{cpus} --outfmt 6 " +
62
+ cmd = "diamond blastp --threads 1 --outfmt 6 " +
67
63
  "--query #{query} --db #{db} --out #{out} " +
68
64
  "--evalue #{EVALUE_CUTOFF}"
69
65
 
70
- exit_status = Process.run_it cmd
71
-
72
- if exit_status.zero?
73
- completed_outf_names << out
74
- else
75
- failed_jobs << idx
76
- AbortIf.logger.warn { "Blast job failed. Non-zero exit status " +
77
- "(#{exit_status}) " +
78
- "when running '#{cmd}'. " +
79
- "Will retry at end." }
80
- end
81
- end
82
- end
83
-
84
- if failed_jobs.count > 0
85
- Time.time_it "Retrying failed blast jobs" do
86
- # retry failed jobs once
87
- failed_jobs.each do |idx|
88
- query = args[idx][0]
89
- db = args[idx][1]
90
- out = args[idx][2]
91
-
92
- cmd = "diamond blastp --threads #{cpus} --outfmt 6 " +
93
- "--query #{query} --db #{db} --out #{out} " +
94
- "--evalue #{EVALUE_CUTOFF}"
95
-
96
- exit_status = Process.run_it cmd
66
+ Process.run_it! cmd
97
67
 
98
- if exit_status.zero?
99
- completed_outf_names << out
100
- else
101
- AbortIf.logger.error { "Retrying blast job failed. " +
102
- "Non-zero exit status " +
103
- "(#{exit_status}) " +
104
- "when running '#{cmd}'." }
105
- end
106
- end
68
+ # if exit_status.zero?
69
+ # completed_outf_names << out
70
+ # else
71
+ # failed_jobs << idx
72
+ # AbortIf.logger.warn { "Blast job failed. Non-zero exit status " +
73
+ # "(#{exit_status}) " +
74
+ # "when running '#{cmd}'. " +
75
+ # "Will retry at end." }
76
+ # end
77
+
78
+ # [completed_outf_names, failed_jobs]
107
79
  end
108
80
  end
109
81
 
110
- completed_outf_names
82
+ # if failed_jobs.count > 0
83
+ # Time.time_it "Retrying failed blast jobs" do
84
+ # # retry failed jobs once
85
+ # Parallel.each(failed_jobs, in_processes: cpus) do |idx|
86
+ # query = args[idx][0]
87
+ # db = args[idx][1]
88
+ # out = args[idx][2]
89
+
90
+ # cmd = "diamond blastp --threads #{cpus} --outfmt 6 " +
91
+ # "--query #{query} --db #{db} --out #{out} " +
92
+ # "--evalue #{EVALUE_CUTOFF}"
93
+
94
+ # exit_status = Process.run_it cmd
95
+
96
+ # if exit_status.zero?
97
+ # completed_outf_names << out
98
+ # else
99
+ # AbortIf.logger.error { "Retrying blast job failed. " +
100
+ # "Non-zero exit status " +
101
+ # "(#{exit_status}) " +
102
+ # "when running '#{cmd}'." }
103
+ # end
104
+ # end
105
+ # end
106
+ # end
107
+
108
+ outf_names
111
109
  end
112
110
 
113
111
  # Make blast dbs given an array of filenames.
@@ -121,8 +119,8 @@ module Aai
121
119
  outfiles = fnames.map { |fname| fname + suffix }
122
120
 
123
121
  Time.time_it "Making blast databases" do
124
- fnames.each do |fname|
125
- cmd = "diamond makedb --threads #{cpus} --in #{fname} " +
122
+ Parallel.each(fnames, in_processes: cpus) do |fname|
123
+ cmd = "diamond makedb --threads 1 --in #{fname} " +
126
124
  "--db #{fname}#{BLAST_DB_SUFFIX}"
127
125
 
128
126
  Process.run_it! cmd
@@ -1,5 +1,5 @@
1
1
  module Aai
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  COPYRIGHT = "2017 Ryan Moore"
4
4
  CONTACT = "moorer@udel.edu"
5
5
  WEBSITE = "https://github.com/mooreryan/aai"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moore
@@ -94,6 +94,26 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.2.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: parallel
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.6'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 1.6.1
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '1.6'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 1.6.1
97
117
  - !ruby/object:Gem::Dependency
98
118
  name: parse_fasta
99
119
  requirement: !ruby/object:Gem::Requirement