bio-gemma-wrapper 0.99.5 → 0.99.6

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/gemma-wrapper +41 -31
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ec477c7560ae55b6d7c8a74b5e46cd95586a87f02ac698c540b2d6cc40c4392
4
- data.tar.gz: bf79dc493baa99efd2e20a298d702ece9973c3fd377773cc80f0867c0a132ae5
3
+ metadata.gz: 69d74ac5f1a705132d7ddc86bd1182c11fc37cf32062dbb28909f16684a827cb
4
+ data.tar.gz: 6f912b3c03474c1334a105d6c9471c02d39c205e94b0d07e5281718beec65ee7
5
5
  SHA512:
6
- metadata.gz: 0ca0c04ef86c22d332c10f21b66ef24aab7fd3dbfd1f2db67f78309ba8a5af47a9263bf94aaf2afeda021cdace3ed042af6f3a5ebf6628714a78ad18b494284f
7
- data.tar.gz: b3692f74bb4437f70d2671fe48e1ec9f7c44c64b4553c93b511cc648e157e6a9f5b0f66acce2f07721a74a7ce20a1993c7eb2d2a74eb362c786cd7ee42eeab16
6
+ metadata.gz: 35fbdf4ccfc482f6898e35b1e46e840db87f34efb35a096206ffef4a131ac8b21a4e6b7893be6ee053a59837eadba6547258d2360d796794c71a60670458943f
7
+ data.tar.gz: 43f7a7438f475583930e6cf1f50d34206fba7674b3df836791cf7064bd7ca55dddc2cc101f7c5a89d8042645b6dd06245b84d3b38501bc1eab7d18774703a01a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.99.5
1
+ 0.99.6
data/bin/gemma-wrapper CHANGED
@@ -4,7 +4,7 @@
4
4
  # Author:: Pjotr Prins
5
5
  # License:: GPL3
6
6
  #
7
- # Copyright (C) 2017-2021 Pjotr Prins <pjotr.prins@thebird.nl>
7
+ # Copyright (C) 2017-2022 Pjotr Prins <pjotr.prins@thebird.nl>
8
8
 
9
9
  USAGE = "
10
10
  GEMMA wrapper example:
@@ -64,6 +64,7 @@ if not gemma_command
64
64
  end
65
65
  end
66
66
 
67
+ hashme = nil
67
68
 
68
69
  require 'digest/sha1'
69
70
  require 'fileutils'
@@ -214,13 +215,13 @@ end
214
215
  # ---- Start banner
215
216
 
216
217
  GEMMA_K_VERSION=version
217
- GEMMA_K_BANNER = "gemma-wrapper #{version} (Ruby #{RUBY_VERSION}) by Pjotr Prins 2017-2021\n"
218
+ GEMMA_K_BANNER = "gemma-wrapper #{version} (Ruby #{RUBY_VERSION}) by Pjotr Prins 2017-2022\n"
218
219
  info.call GEMMA_K_BANNER
219
220
 
220
221
  # Check gemma version
221
222
  begin
222
223
  gemma_command2 = options[:gemma_command]
223
- info.call "NOTE: gemma-wrapper is soon to be replaced by gemma2/lib"
224
+ info.call "NOTE: gemma-wrapper is soon to be replaced"
224
225
 
225
226
  GEMMA_INFO = `#{gemma_command2}`
226
227
  rescue Errno::ENOENT
@@ -279,7 +280,6 @@ raise "Expected GEMMA -a genotype file switch" if anno_idx == nil
279
280
  CHROMOSOMES = get_chromosomes(gemma_args[anno_idx+1])
280
281
 
281
282
  # ---- Compute HASH on inputs
282
- hashme = []
283
283
  geno_idx = gemma_args.index '-g'
284
284
  raise "Expected GEMMA -g genotype file switch" if geno_idx == nil
285
285
  pheno_idx = gemma_args.index '-p'
@@ -309,14 +309,15 @@ execute = lambda { |cmd|
309
309
 
310
310
  compute_hash = lambda do | phenofn = nil |
311
311
  # Compute a HASH on the inputs
312
- debug.call "Hashing on ",hashme,"\n"
312
+ error.call "Hash is empty" if hashme == nil or hashme == []
313
+ debug.call "Hashing on ",hashme," before phenofn inject"
313
314
  hashes = []
314
315
  hm = if phenofn
315
316
  hashme + ["-p", phenofn]
316
317
  else
317
318
  hashme
318
319
  end
319
- debug.call(hm)
320
+ debug.call("Hashing on ",hm)
320
321
  hm.each do | item |
321
322
  if File.file?(item)
322
323
  hashes << Digest::SHA1.hexdigest(File.read(item))
@@ -329,6 +330,18 @@ compute_hash = lambda do | phenofn = nil |
329
330
  Digest::SHA1.hexdigest hashes.join(' ')
330
331
  end
331
332
 
333
+ error.call "Do not use the GEMMA -o switch!" if gemma_args.include? '-o'
334
+ error.call "Do not use the GEMMA -outdir switch!" if gemma_args.include? '-outdir'
335
+ GEMMA_ARGS_HASH = gemma_args.dup # do not include outdir
336
+
337
+ hashme =
338
+ if DO_COMPUTE_KINSHIP and pheno_idx != nil
339
+ # Remove the phenotype file from the hash for GRM computation
340
+ GEMMA_ARGS_HASH[0..pheno_idx-1] + GEMMA_ARGS_HASH[pheno_idx+2..-1]
341
+ else
342
+ GEMMA_ARGS_HASH
343
+ end
344
+
332
345
  HASH = compute_hash.call()
333
346
  options[:hash] = HASH
334
347
 
@@ -345,21 +358,10 @@ FileUtils::mkdir_p options[:cache_dir]
345
358
 
346
359
  Dir.mktmpdir do |tmpdir| # tmpdir for GEMMA output
347
360
 
348
- error.call "Do not use the GEMMA -o switch!" if gemma_args.include? '-o'
349
- error.call "Do not use the GEMMA -outdir switch!" if gemma_args.include? '-outdir'
350
- GEMMA_ARGS_HASH = gemma_args.dup # do not include outdir
351
361
  gemma_args << '-outdir'
352
362
  gemma_args << tmpdir
353
363
  GEMMA_ARGS = gemma_args
354
364
 
355
- hashme =
356
- if DO_COMPUTE_KINSHIP and pheno_idx != nil
357
- # Remove the phenotype file from the hash for GRM computation
358
- GEMMA_ARGS_HASH[0..pheno_idx-1] + GEMMA_ARGS_HASH[pheno_idx+2..-1]
359
- else
360
- GEMMA_ARGS_HASH
361
- end
362
-
363
365
  debug.call "Options: ",options,"\n" if !options[:quiet]
364
366
 
365
367
  invoke_gemma = lambda do |extra_args, cache_hit = false, chr = "full", permutation = 1|
@@ -560,22 +562,30 @@ end
560
562
  # ---- Invoke parallel
561
563
  if options[:parallel]
562
564
  # parallel_cmds = ["echo 1","sleep 1 && echo 2", "false", "echo 3"]
563
- cmd = parallel_cmds.join("\\n")
564
-
565
- cmd = "echo -e \"#{cmd}\""
566
- err = execute.call(cmd+"|parallel --joblog #{joblog}") # first try optimistically to run all jobs in parallel
567
- if err != 0
568
- [16,8,4,1].each do |jobs|
569
- info.call("Failed to complete parallel run -- retrying with smaller RAM footprint!")
570
- err = execute.call(cmd+"|parallel -j #{jobs} --resume --joblog #{joblog}")
571
- break if err == 0
565
+
566
+ Tempfile.open("commands.txt") do |f|
567
+ cmdfn = f.path
568
+ File.open(cmdfn,"w") do |f|
569
+ parallel_cmds.each do |c|
570
+ f.puts(c)
571
+ end
572
572
  end
573
+ cmd = "cat \"#{cmdfn}\""
574
+ err = execute.call(cmd+"|parallel --joblog #{joblog}") # first try optimistically to run all jobs in parallel
573
575
  if err != 0
574
- info.call("Run failed!")
575
- # Remove remaining files
576
- FileUtils.rm_rf("#{tmpdir}/*", secure: true)
577
- FileUtils.mv joblog, joblog+".bak", verbose: false, force: true
578
- exit err
576
+ [16,8,4,1].each do |jobs|
577
+ info.call("Failed to complete parallel run -- retrying with smaller RAM footprint!")
578
+ err = execute.call(cmd+"|parallel -j #{jobs} --resume --joblog #{joblog}")
579
+ break if err == 0
580
+ end
581
+ if err != 0
582
+ info.call("Parallel run failed!")
583
+ debug.call("Job log is: ",File.read(joblog))
584
+ # Remove remaining files
585
+ FileUtils.mv joblog, joblog+".bak", verbose: false, force: true
586
+ FileUtils.rm_rf("#{tmpdir}/*", secure: true)
587
+ exit err
588
+ end
579
589
  end
580
590
  end
581
591
  info.call("Run successful!")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-gemma-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.5
4
+ version: 0.99.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pjotr Prins
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-26 00:00:00.000000000 Z
11
+ date: 2022-01-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: GEMMA wrapper adds LOCO and permutation support. Also runs in parallel
14
14
  and caches K between runs with LOCO support
@@ -29,7 +29,7 @@ homepage: https://github.com/genetics-statistics/gemma-wrapper
29
29
  licenses:
30
30
  - GPL3
31
31
  metadata: {}
32
- post_install_message:
32
+ post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
@@ -44,8 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 3.1.4
48
- signing_key:
47
+ rubygems_version: 3.2.22
48
+ signing_key:
49
49
  specification_version: 4
50
50
  summary: GEMMA with LOCO and permutations
51
51
  test_files: []