cagnut_picard 0.3.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cagnut_picard.gemspec +27 -0
- data/lib/cagnut_picard/base.rb +59 -0
- data/lib/cagnut_picard/check_tools.rb +36 -0
- data/lib/cagnut_picard/configuration.rb +70 -0
- data/lib/cagnut_picard/functions/add_or_replace_readgroups.rb +93 -0
- data/lib/cagnut_picard/functions/build_bam_index.rb +74 -0
- data/lib/cagnut_picard/functions/collect_gc_bias_metrics.rb +82 -0
- data/lib/cagnut_picard/functions/collect_insert_size_metrics.rb +81 -0
- data/lib/cagnut_picard/functions/collect_multiple_metrics.rb +79 -0
- data/lib/cagnut_picard/functions/markdup.rb +92 -0
- data/lib/cagnut_picard/functions/mean_quality_by_cycle.rb +79 -0
- data/lib/cagnut_picard/functions/quality_score_distribution.rb +79 -0
- data/lib/cagnut_picard/functions/sort_sam.rb +89 -0
- data/lib/cagnut_picard/util.rb +62 -0
- data/lib/cagnut_picard/version.rb +3 -0
- data/lib/cagnut_picard.rb +16 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b1a0e031d3539d0901778f55ecc65ce135909878
|
4
|
+
data.tar.gz: 8f2eb71e9cef1eb0f9ee98a7012d3ae965ec6c1d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8bc7f21dccd1ae4b091d0cc7ab6a8bcf6d02d7e0548f1b4c1f3d4dcb3a704b6afd091d99dd282c4a102729c25f7d688694c3b252dc8b9e3d3abb184960e5296
|
7
|
+
data.tar.gz: 969806a9eed0e46ae04c8a8bd206e1f6170f9c4ffdd11527e202eaad65fa0dcb8acf2e8c4fcb1cf19649079d8a78650175f0a88ad690d580187916f88a9c9438
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Goldenio Technology
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# CagnutPicard
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'cagnut_picard'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install cagnut_picard
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cagnut_picard.
|
30
|
+
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
35
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cagnut_picard"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cagnut_picard/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cagnut_picard"
|
8
|
+
spec.version = CagnutPicard::VERSION
|
9
|
+
spec.authors = ['Shi-Gang Wang', 'Tse-Ching Ho']
|
10
|
+
spec.email = ['seanwang@goldenio.com', 'tsechingho@goldenio.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Cagnut Picard tools}
|
13
|
+
spec.description = %q{Cagnut Picard tools}
|
14
|
+
spec.homepage = "https://github.com/CAGNUT/cagnut_picard"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'cagnut_core'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'cagnut_picard/functions/add_or_replace_readgroups'
|
2
|
+
require 'cagnut_picard/functions/markdup'
|
3
|
+
require 'cagnut_picard/functions/build_bam_index'
|
4
|
+
require 'cagnut_picard/functions/mean_quality_by_cycle'
|
5
|
+
require 'cagnut_picard/functions/quality_score_distribution'
|
6
|
+
require 'cagnut_picard/functions/collect_gc_bias_metrics'
|
7
|
+
require 'cagnut_picard/functions/collect_insert_size_metrics'
|
8
|
+
require 'cagnut_picard/functions/sort_sam'
|
9
|
+
require 'cagnut_picard/functions/collect_multiple_metrics'
|
10
|
+
|
11
|
+
|
12
|
+
module CagnutPicard
|
13
|
+
class Base
|
14
|
+
def add_or_replace_readgroups dirs, order, previous_job_id = nil, input = nil
|
15
|
+
opts = { input: input, dirs: dirs, order: order }
|
16
|
+
CagnutPicard::AddOrReplaceReadGroups.new(opts).run previous_job_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def markdup dirs, order, previous_job_id, input = nil
|
20
|
+
opts = { input: input, dirs: dirs, order: order }
|
21
|
+
CagnutPicard::Markdup.new(opts).run previous_job_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_bam_index dirs, order, previous_job_id, input
|
25
|
+
opts = { input: input, dirs: dirs, order: order }
|
26
|
+
CagnutPicard::BuildBamIndex.new(opts).run previous_job_id
|
27
|
+
end
|
28
|
+
|
29
|
+
def mean_quality_by_cycle dirs, order, previous_job_id, input
|
30
|
+
opts = { input: input, dirs: dirs, order: order }
|
31
|
+
CagnutPicard::MeanQualityByCycle.new(opts).run previous_job_id
|
32
|
+
end
|
33
|
+
|
34
|
+
def quality_score_distribution dirs, order, previous_job_id, input
|
35
|
+
opts = { input: input, dirs: dirs, order: order }
|
36
|
+
CagnutPicard::QualityScoreDistribution.new(opts).run previous_job_id
|
37
|
+
end
|
38
|
+
|
39
|
+
def collect_gc_bias_metrics dirs, order, previous_job_id, input
|
40
|
+
opts = { input: input, dirs: dirs, order: order }
|
41
|
+
CagnutPicard::CollectGcBiasMetrics.new(opts).run previous_job_id
|
42
|
+
end
|
43
|
+
|
44
|
+
def collect_insert_size_metrics dirs, order, previous_job_id, input
|
45
|
+
opts = { input: input, dirs: dirs, order: order }
|
46
|
+
CagnutPicard::CollectInsertSizeMetrics.new(opts).run previous_job_id
|
47
|
+
end
|
48
|
+
|
49
|
+
def sort_sam dirs, order, previous_job_id, input = nil
|
50
|
+
opts = { input: input, dirs: dirs, order: order }
|
51
|
+
CagnutPicard::SortSam.new(opts).run previous_job_id
|
52
|
+
end
|
53
|
+
|
54
|
+
def collect_multiple_metrics dirs, order, previous_job_id, input
|
55
|
+
opts = { input: input, dirs: dirs, order: order }
|
56
|
+
CagnutPicard::CollectMultipleMetrics.new(opts).run previous_job_id
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
module CheckTools
|
3
|
+
def check_tool tools_path
|
4
|
+
super if defined?(super)
|
5
|
+
check_Picard tools_path['Picard'] if @java
|
6
|
+
check_picard_dict refs['ref_fasta']
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_Picard path
|
10
|
+
check_tool_ver 'Picard' do
|
11
|
+
`#{@java} -jar #{path} AddOrReplaceReadGroups --version 2>&1` if path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_picard_dict ref_path
|
16
|
+
tool = 'Sequence Dictionary'
|
17
|
+
file = ref_path.gsub '.fasta', '.dict'
|
18
|
+
command =
|
19
|
+
"#{@java} -jar #{@config['tools']['picard']} CreateSequenceDictionary REFERENCE=#{ref_path} OUTPUT=#{file}"
|
20
|
+
check_ref_related file, tool, command
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_ref_related file, tool, command
|
24
|
+
if File.exist?(file)
|
25
|
+
puts "\t#{tool}: Done"
|
26
|
+
else
|
27
|
+
puts "\t#{tool}: Not Found!"
|
28
|
+
puts "\tPlease execute command:"
|
29
|
+
puts "\t\t#{command}"
|
30
|
+
@check_completed = false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Cagnut::Configuration::Checks::Tools.prepend CagnutPicard::CheckTools
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module CagnutPicard
|
4
|
+
class Configuration
|
5
|
+
include Singleton
|
6
|
+
attr_accessor :rg_str_picard, :add_or_replace_readgroups_params, :sort_sam_params,
|
7
|
+
:build_bam_index_params, :quailty_score_distribution_params,
|
8
|
+
:collect_gc_bias_metrics_params, :collect_insert_size_metrics_params,
|
9
|
+
:collect_multiple_metrics_params, :markduplicate_params,
|
10
|
+
:mean_quality_by_cycle_params
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def load config, params
|
14
|
+
instance.load config, params
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def load config, params
|
19
|
+
@config = config
|
20
|
+
@params = params
|
21
|
+
generate_rg_str
|
22
|
+
attributes.each do |name, value|
|
23
|
+
send "#{name}=", value if respond_to? "#{name}="
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def attributes
|
28
|
+
{
|
29
|
+
rg_str_picard: @config['sample']['rg_str_picard'],
|
30
|
+
add_or_replace_readgroups_params: add_java_params(@params['add_or_replace_readgroups'], true),
|
31
|
+
build_bam_index_params: add_java_params(@params['build_bam_index']),
|
32
|
+
collect_gc_bias_metrics_params: add_java_params(@params['collect_gc_bias_metrics']),
|
33
|
+
collect_insert_size_metrics_params: add_java_params(@params['collect_insert_size_metrics']),
|
34
|
+
collect_multiple_metrics_params: add_java_params(@params['collect_multiple_metrics']),
|
35
|
+
markduplicate_params: add_java_params(@params['markduplicate']),
|
36
|
+
mean_quality_by_cycle_params: add_java_params(@params['mean_quality_by_cycle']),
|
37
|
+
quailty_score_distribution_params: add_java_params(@params['quailty_score_distribution']),
|
38
|
+
sort_sam_params: add_java_params(@params['sort_sam'])
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_java_params method_params, verbose=false
|
43
|
+
return if method_params.blank?
|
44
|
+
array = method_params['java'].dup
|
45
|
+
array << "-verbose:sizes" if verbose
|
46
|
+
array << "-jar #{@config['tools']['picard']}"
|
47
|
+
{
|
48
|
+
'java' => array,
|
49
|
+
'params' => method_params['params']
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def generate_rg_str
|
54
|
+
@config['samples'].each do |sample|
|
55
|
+
arg = %W(
|
56
|
+
ID=#{sample['rgid']}
|
57
|
+
SM=#{sample['name']}
|
58
|
+
PL=#{@config['info']['pl']}
|
59
|
+
PU=#{sample['pu']}
|
60
|
+
LB=#{@config['info']['lb']}
|
61
|
+
DS=#{@config['info']['ds']}
|
62
|
+
CN=#{@config['info']['cn']}
|
63
|
+
)
|
64
|
+
rg_str_picard = { 'rg_str_picard' => arg.join(' ') }
|
65
|
+
sample.merge! rg_str_picard
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class AddOrReplaceReadGroups
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :dodebug,
|
6
|
+
:jobs_dir, :magic28, :prefix_name, :ref_fasta, :java_path
|
7
|
+
def_delegators :'CagnutPicard.config', :rg_str_picard, :add_or_replace_readgroups_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@tmp_dir = opts[:dirs][:tmp_dir]
|
12
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_aligned.sam.gz" : opts[:input]
|
13
|
+
@output = "#{opts[:dirs][:output]}/#{sample_name}.bam"
|
14
|
+
@job_name = "#{prefix_name}_addRG_#{sample_name}_addrg"
|
15
|
+
end
|
16
|
+
|
17
|
+
def run previous_job_id = nil
|
18
|
+
puts "Submitting addReadGroup #{sample_name}"
|
19
|
+
script_name = generate_script
|
20
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
21
|
+
[@job_name, @output]
|
22
|
+
end
|
23
|
+
|
24
|
+
def queuing_options previous_job_id = nil
|
25
|
+
{
|
26
|
+
previous_job_id: previous_job_id,
|
27
|
+
adjust_memory: ['h_vmem=10G'],
|
28
|
+
tools: ['picard', 'add_or_replace_readgroups']
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_read_group_options
|
33
|
+
array = add_or_replace_readgroups_params['params'].dup
|
34
|
+
array << "INPUT=#{@input}"
|
35
|
+
array << "OUTPUT=#{@output}"
|
36
|
+
array << "TMP_DIR=#{@tmp_dir} "
|
37
|
+
array << "#{rg_str_picard}"
|
38
|
+
array.uniq
|
39
|
+
end
|
40
|
+
|
41
|
+
def modified_java_array
|
42
|
+
array = add_or_replace_readgroups_params['java'].dup
|
43
|
+
array << 'AddOrReplaceReadGroups'
|
44
|
+
array.unshift(java_path).uniq
|
45
|
+
end
|
46
|
+
|
47
|
+
def params_combination_hash
|
48
|
+
@params_combination_hash ||= {
|
49
|
+
'java' => modified_java_array,
|
50
|
+
'params' => add_read_group_options
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_script
|
55
|
+
script_name = "#{@order}_picard_add_or_replace_readgroups"
|
56
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
57
|
+
File.open(file, 'w') do |f|
|
58
|
+
f.puts <<-BASH.strip_heredoc
|
59
|
+
#!/bin/bash
|
60
|
+
|
61
|
+
cd "#{jobs_dir}/../"
|
62
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
63
|
+
#{params_combination_hash['java'].join("\s")} \\
|
64
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
65
|
+
#{::Cagnut::JobManage.run_local}
|
66
|
+
|
67
|
+
EXITSTATUS=$?
|
68
|
+
|
69
|
+
if [ ! -e "#{@output}" ]
|
70
|
+
then
|
71
|
+
echo "Missing output: #{@output}"
|
72
|
+
exit 100
|
73
|
+
fi
|
74
|
+
|
75
|
+
# Check BAM EOF
|
76
|
+
BAM_28=$(tail -c 28 #{@output}|xxd -p)
|
77
|
+
if [ '#{magic28}' != "$BAM_28" ]
|
78
|
+
then
|
79
|
+
echo "Error with BAM EOF" 1>&2
|
80
|
+
exit 100
|
81
|
+
fi
|
82
|
+
|
83
|
+
if [ $EXITSTATUS -ne 0 ];then exit $EXITSTATUS;fi
|
84
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
85
|
+
|
86
|
+
exit $EXITSTATUS
|
87
|
+
BASH
|
88
|
+
end
|
89
|
+
File.chmod(0700, file)
|
90
|
+
script_name
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class BuildBamIndex
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :prefix_name,
|
6
|
+
:jobs_dir, :dodebug, :java_path
|
7
|
+
def_delegators :'CagnutPicard.config', :build_bam_index_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@job_name = "#{prefix_name}_build_bam_index_#{sample_name}"
|
12
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_markdup.bam" : opts[:input]
|
13
|
+
end
|
14
|
+
|
15
|
+
def run previous_job_id = nil
|
16
|
+
puts "Submitting build_bam_index #{sample_name}"
|
17
|
+
script_name = generate_script
|
18
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
19
|
+
@job_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def queuing_options previous_job_id = nil
|
23
|
+
{
|
24
|
+
previous_job_id: previous_job_id,
|
25
|
+
adjust_memory: ['h_vmem=10G'],
|
26
|
+
tools: ['picard', 'build_bam_index']
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_bam_index_options
|
31
|
+
array = build_bam_index_params['params'].dup
|
32
|
+
array << "I=#{@input}"
|
33
|
+
array.uniq.compact
|
34
|
+
end
|
35
|
+
|
36
|
+
def modified_java_array
|
37
|
+
array = build_bam_index_params['java'].dup
|
38
|
+
array << 'BuildBamIndex'
|
39
|
+
array.unshift(java_path).uniq
|
40
|
+
end
|
41
|
+
|
42
|
+
def params_combination_hash
|
43
|
+
@params_combination_hash ||= {
|
44
|
+
'java' => modified_java_array,
|
45
|
+
'params' => build_bam_index_options
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def generate_script
|
50
|
+
script_name = "#{@order}_picard_build_bam_index"
|
51
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
52
|
+
File.open(file, 'w') do |f|
|
53
|
+
f.puts <<-BASH.strip_heredoc
|
54
|
+
#!/bin/bash
|
55
|
+
|
56
|
+
cd "#{jobs_dir}/../"
|
57
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
58
|
+
#{params_combination_hash['java'].join("\s")} \\
|
59
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
60
|
+
#{::Cagnut::JobManage.run_local}
|
61
|
+
|
62
|
+
EXITSTATUS=$?
|
63
|
+
|
64
|
+
if [ $EXITSTATUS -ne 0 ];then exit $EXITSTATUS;fi
|
65
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
66
|
+
|
67
|
+
exit $EXITSTATUS
|
68
|
+
BASH
|
69
|
+
end
|
70
|
+
File.chmod(0700, file)
|
71
|
+
script_name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class CollectGcBiasMetrics
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :jobs_dir, :dodebug,
|
6
|
+
:ref_fasta, :prefix_name, :java_path
|
7
|
+
def_delegators :'CagnutPicard.config', :collect_gc_bias_metrics_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@tmp_dir = opts[:dirs][:tmp_dir]
|
12
|
+
@job_name = "#{prefix_name}_collect_gc_bias_metrics_#{sample_name}"
|
13
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_recal.bam" : opts[:input]
|
14
|
+
@output = "#{opts[:dirs][:output]}/Gc_Bias_Metrics"
|
15
|
+
@chart_output = "#{opts[:dirs][:output]}/Gc_bias_#{sample_name}.pdf"
|
16
|
+
@summary_output = "#{opts[:dirs][:output]}/sum_out_gc"
|
17
|
+
end
|
18
|
+
|
19
|
+
def run previous_job_id = nil
|
20
|
+
puts "Submitting Picard CollectGcBiasMetrics #{sample_name} Jobs "
|
21
|
+
script_name = generate_script
|
22
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
23
|
+
@job_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def queuing_options previous_job_id = nil
|
27
|
+
{
|
28
|
+
previous_job_id: previous_job_id,
|
29
|
+
adjust_memory: ['h_vmem=5G'],
|
30
|
+
tools: ['picard', 'collect_gc_bias_metrics']
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def collect_gc_bias_metrics_options
|
35
|
+
array = collect_gc_bias_metrics_params['params'].dup
|
36
|
+
array << "REFERENCE_SEQUENCE=#{ref_fasta}"
|
37
|
+
array << "TMP_DIR=#{@tmp_dir}"
|
38
|
+
array << "INPUT=#{@input}"
|
39
|
+
array << "OUTPUT=#{@output}"
|
40
|
+
array << "CHART_OUTPUT=#{@chart_output}"
|
41
|
+
array << "SUMMARY_OUTPUT=#{@summary_output}"
|
42
|
+
array.uniq
|
43
|
+
end
|
44
|
+
|
45
|
+
def modified_java_array
|
46
|
+
array = collect_gc_bias_metrics_params['java'].dup
|
47
|
+
array << 'CollectGcBiasMetrics'
|
48
|
+
array.unshift(java_path).uniq
|
49
|
+
end
|
50
|
+
|
51
|
+
def params_combination_hash
|
52
|
+
@params_combination_hash ||= {
|
53
|
+
'java' => modified_java_array,
|
54
|
+
'params' => collect_gc_bias_metrics_options
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_script
|
59
|
+
script_name = "#{@order}_picard_collect_gc_bias_metrics"
|
60
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
61
|
+
File.open(file, 'w') do |f|
|
62
|
+
f.puts <<-BASH.strip_heredoc
|
63
|
+
#!/bin/bash
|
64
|
+
|
65
|
+
cd "#{jobs_dir}/../"
|
66
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
67
|
+
#{params_combination_hash['java'].join("\s")} \\
|
68
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
69
|
+
#{::Cagnut::JobManage.run_local}
|
70
|
+
|
71
|
+
EXITSTATUS=$?
|
72
|
+
if [ ! -s "#{@chart_output}" ]; then exit 100;fi;
|
73
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
74
|
+
|
75
|
+
exit $EXITSTATUS
|
76
|
+
BASH
|
77
|
+
end
|
78
|
+
File.chmod(0700, file)
|
79
|
+
script_name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class CollectInsertSizeMetrics
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :dodebug,
|
6
|
+
:ref_fasta, :prefix_name, :jobs_dir, :java_path
|
7
|
+
def_delegators :'CagnutPicard.config', :collect_insert_size_metrics_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@tmp_dir = opts[:dirs][:tmp_dir]
|
12
|
+
@job_name = "#{prefix_name}_insertSize_#{sample_name}"
|
13
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_recal.bam" : opts[:input]
|
14
|
+
@output = "#{opts[:dirs][:output]}/Metric_file"
|
15
|
+
@histogram_file = "#{opts[:dirs][:output]}/hst_Insert_#{sample_name}.pdf"
|
16
|
+
end
|
17
|
+
|
18
|
+
def run previous_job_id = nil
|
19
|
+
puts "Submitting Picard CollectInsertSizeMetrics #{sample_name} Jobs"
|
20
|
+
script_name = generate_script
|
21
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
22
|
+
@job_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def queuing_options previous_job_id = nil
|
26
|
+
{
|
27
|
+
previous_job_id: previous_job_id,
|
28
|
+
adjust_memory: ['h_vmem=5G'],
|
29
|
+
tools: ['picard', 'collect_insert_size_metrics']
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def collect_insert_size_metrics_options
|
34
|
+
array = collect_insert_size_metrics_params['params'].dup
|
35
|
+
array << "INPUT=#{@input}"
|
36
|
+
array << "OUTPUT=#{@output}"
|
37
|
+
array << "TMP_DIR=#{@tmp_dir}"
|
38
|
+
array << "HISTOGRAM_FILE=#{@histogram_file}"
|
39
|
+
array.uniq
|
40
|
+
end
|
41
|
+
|
42
|
+
def modified_java_array
|
43
|
+
array = collect_insert_size_metrics_params['java'].dup
|
44
|
+
array << 'CollectInsertSizeMetrics'
|
45
|
+
array.unshift(java_path).uniq
|
46
|
+
end
|
47
|
+
|
48
|
+
def params_combination_hash
|
49
|
+
@params_combination_hash ||= {
|
50
|
+
'java' => modified_java_array,
|
51
|
+
'params' => collect_insert_size_metrics_options
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_script
|
56
|
+
script_name = "#{@order}_picard_collect_insert_size_metrics"
|
57
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
58
|
+
File.open(file, 'w') do |f|
|
59
|
+
f.puts <<-BASH.strip_heredoc
|
60
|
+
#!/bin/bash
|
61
|
+
|
62
|
+
cd "#{jobs_dir}/../"
|
63
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
64
|
+
#{params_combination_hash['java'].join("\s")} \\
|
65
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
66
|
+
#{::Cagnut::JobManage.run_local}
|
67
|
+
|
68
|
+
EXITSTATUS=$?
|
69
|
+
|
70
|
+
#if [ ! -s "#{@histogram_file}" ]; then exit 100;fi;
|
71
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
72
|
+
|
73
|
+
exit $EXITSTATUS
|
74
|
+
|
75
|
+
BASH
|
76
|
+
end
|
77
|
+
File.chmod(0700, file)
|
78
|
+
script_name
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class CollectMultipleMetrics
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :dodebug, :prefix_name,
|
6
|
+
:jobs_dir, :magic28, :java_path, :ref_fasta
|
7
|
+
def_delegators :'CagnutPicard.config', :rg_str_picard, :collect_multiple_metrics_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_recal.bam" : opts[:input]
|
12
|
+
@output = "#{opts[:dirs][:output]}/#{sample_name}_multiple_metrics"
|
13
|
+
@job_name = "#{prefix_name}_CollectMultipleMetrics_#{sample_name}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def run previous_job_id = nil
|
17
|
+
puts "Submitting CollectMultipleMetrics #{sample_name}"
|
18
|
+
script_name = generate_script
|
19
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
20
|
+
@job_name
|
21
|
+
end
|
22
|
+
|
23
|
+
def queuing_options previous_job_id = nil
|
24
|
+
{
|
25
|
+
previous_job_id: previous_job_id,
|
26
|
+
var_env: [rg_str_picard],
|
27
|
+
adjust_memory: ['h_vmem=10G'],
|
28
|
+
tools: ['picard', 'collect_multiple_metrics']
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def collect_multiple_metrics_options
|
33
|
+
array = collect_multiple_metrics_params['params'].dup
|
34
|
+
array << "REFERENCE_SEQUENCE=#{ref_fasta}"
|
35
|
+
array << "I=#{@input}"
|
36
|
+
array << "O=#{@output}"
|
37
|
+
array.uniq
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def modified_java_array
|
42
|
+
array = collect_multiple_metrics_params['java'].dup
|
43
|
+
array << 'CollectMultipleMetrics'
|
44
|
+
array.unshift(java_path).uniq
|
45
|
+
end
|
46
|
+
|
47
|
+
def params_combination_hash
|
48
|
+
@params_combination_hash ||= {
|
49
|
+
'java' => modified_java_array,
|
50
|
+
'params' => collect_multiple_metrics_options
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_script
|
55
|
+
script_name = "#{@order}_picard_collect_multiple_metrics"
|
56
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
57
|
+
File.open(file, 'w') do |f|
|
58
|
+
f.puts <<-BASH.strip_heredoc
|
59
|
+
#!/bin/bash
|
60
|
+
|
61
|
+
cd "#{jobs_dir}/../"
|
62
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
63
|
+
#{params_combination_hash['java'].join("\s")} \\
|
64
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
65
|
+
#{::Cagnut::JobManage.run_local}
|
66
|
+
|
67
|
+
EXITSTATUS=$?
|
68
|
+
|
69
|
+
if [ $EXITSTATUS -ne 0 ];then exit $EXITSTATUS;fi
|
70
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
71
|
+
|
72
|
+
exit $EXITSTATUS
|
73
|
+
BASH
|
74
|
+
end
|
75
|
+
File.chmod(0700, file)
|
76
|
+
script_name
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class Markdup
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :jobs_dir, :magic28,
|
6
|
+
:sample_name, :java_path, :ref_fasta, :prefix_name, :dodebug
|
7
|
+
def_delegators :'CagnutPicard.config', :markduplicate_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@tmp_dir = opts[:dirs][:tmp_dir]
|
12
|
+
@job_name = "#{prefix_name}_markdup_#{sample_name}"
|
13
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_merged.bam" : opts[:input]
|
14
|
+
@output = "#{opts[:dirs][:output]}/#{sample_name}_markdup.bam"
|
15
|
+
end
|
16
|
+
|
17
|
+
def run previous_job_id = nil
|
18
|
+
puts "Submitting markdup #{sample_name}"
|
19
|
+
script_name = generate_script
|
20
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
21
|
+
[@job_name, @output]
|
22
|
+
end
|
23
|
+
|
24
|
+
def queuing_options previous_job_id = nil
|
25
|
+
{
|
26
|
+
previous_job_id: previous_job_id,
|
27
|
+
adjust_memory: ['h_vmem=5G'],
|
28
|
+
tools: ['picard', 'markduplicate']
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def markduplicate_options
|
33
|
+
array = markduplicate_params['params'].dup
|
34
|
+
array << "INPUT=#{@input}"
|
35
|
+
array << "OUTPUT=#{@output}"
|
36
|
+
array << "TMP_DIR=#{@tmp_dir}"
|
37
|
+
array.uniq
|
38
|
+
end
|
39
|
+
|
40
|
+
def modified_java_array
|
41
|
+
array = markduplicate_params['java'].dup
|
42
|
+
array << 'MarkDuplicates'
|
43
|
+
array.unshift(java_path).uniq
|
44
|
+
end
|
45
|
+
|
46
|
+
def params_combination_hash
|
47
|
+
@params_combination_hash ||= {
|
48
|
+
'java' => modified_java_array,
|
49
|
+
'params' => markduplicate_options
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def generate_script
|
54
|
+
script_name = "#{@order}_picard_markdup"
|
55
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
56
|
+
File.open(file, 'w') do |f|
|
57
|
+
f.puts <<-BASH.strip_heredoc
|
58
|
+
#!/bin/bash
|
59
|
+
|
60
|
+
cd "#{jobs_dir}/../"
|
61
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
62
|
+
#{params_combination_hash['java'].join("\s")} \\
|
63
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
64
|
+
#{::Cagnut::JobManage.run_local}
|
65
|
+
|
66
|
+
EXITSTATUS=$?
|
67
|
+
|
68
|
+
if [ ! -e "#{@output}" ]
|
69
|
+
then
|
70
|
+
echo "Missing output: #{@output}"
|
71
|
+
exit 100
|
72
|
+
fi
|
73
|
+
|
74
|
+
# Check BAM EOF
|
75
|
+
BAM_28=$(tail -c 28 #{@output}|xxd -p)
|
76
|
+
if [ "#{magic28}" != "$BAM_28" ]
|
77
|
+
then
|
78
|
+
echo "Error with BAM EOF" 1>&2
|
79
|
+
exit 100
|
80
|
+
fi
|
81
|
+
|
82
|
+
if [ $EXITSTATUS -ne 0 ];then exit $EXITSTATUS;fi
|
83
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
84
|
+
|
85
|
+
exit $EXITSTATUS
|
86
|
+
BASH
|
87
|
+
end
|
88
|
+
File.chmod(0700, file)
|
89
|
+
script_name
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class MeanQualityByCycle
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :jobs_dir, :java_path,
|
6
|
+
:ref_fasta, :prefix_name, :dodebug
|
7
|
+
def_delegators :'CagnutPicard.config', :mean_quality_by_cycle_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@tmp_dir = opts[:dirs][:tmp_dir]
|
12
|
+
@job_name = "#{prefix_name}_meanQbycycle_#{sample_name}"
|
13
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_recal.bam" : opts[:input]
|
14
|
+
@output = "#{opts[:dirs][:output]}/quality_table"
|
15
|
+
@chart_output= "#{opts[:dirs][:output]}/qualityByCycle_#{sample_name}.pdf"
|
16
|
+
end
|
17
|
+
|
18
|
+
def run previous_job_id = nil
|
19
|
+
puts "Submitting Picard MeanQualityByCycle #{sample_name} Jobs"
|
20
|
+
script_name = generate_script
|
21
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
22
|
+
@job_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def queuing_options previous_job_id = nil
|
26
|
+
{
|
27
|
+
previous_job_id: previous_job_id,
|
28
|
+
adjust_memory: ['h_vmem=5G'],
|
29
|
+
tools: ['picard', 'mean_quality_by_cycle']
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def mean_quality_by_cycle_options
|
34
|
+
array = mean_quality_by_cycle_params['params'].dup
|
35
|
+
array << "INPUT=#{@input}"
|
36
|
+
array << "OUTPUT=#{@output}"
|
37
|
+
array << "TMP_DIR=#{@tmp_dir}"
|
38
|
+
array << "CHART_OUTPUT=#{@chart_output}"
|
39
|
+
array.uniq
|
40
|
+
end
|
41
|
+
|
42
|
+
def modified_java_array
|
43
|
+
array = mean_quality_by_cycle_params['java'].dup
|
44
|
+
array << 'MeanQualityByCycle'
|
45
|
+
array.unshift(java_path).uniq
|
46
|
+
end
|
47
|
+
|
48
|
+
def params_combination_hash
|
49
|
+
@params_combination_hash ||= {
|
50
|
+
'java' => modified_java_array,
|
51
|
+
'params' => mean_quality_by_cycle_options
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_script
|
56
|
+
script_name = "#{@order}_picard_meanQbycycle"
|
57
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
58
|
+
File.open(file, 'w') do |f|
|
59
|
+
f.puts <<-BASH.strip_heredoc
|
60
|
+
#!/bin/bash
|
61
|
+
|
62
|
+
cd "#{jobs_dir}/../"
|
63
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
64
|
+
#{params_combination_hash['java'].join("\s")} \\
|
65
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
66
|
+
#{::Cagnut::JobManage.run_local}
|
67
|
+
|
68
|
+
EXITSTATUS=$?
|
69
|
+
if [ ! -s "#{@chart_output}" ]; then exit 100;fi;
|
70
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
71
|
+
|
72
|
+
exit $EXITSTATUS
|
73
|
+
BASH
|
74
|
+
end
|
75
|
+
File.chmod(0700, file)
|
76
|
+
script_name
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class QualityScoreDistribution
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :jobs_dir, :java_path,
|
6
|
+
:ref_fasta, :prefix_name, :dodebug
|
7
|
+
def_delegators :'CagnutPicard.config', :quailty_score_distribution_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@tmp = opts[:dirs][:tmp_dir]
|
12
|
+
@job_name = "#{prefix_name}_meanQScDis_#{sample_name}"
|
13
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_recal.bam" : opts[:input]
|
14
|
+
@output = "#{opts[:dirs][:output]}/quality_table"
|
15
|
+
@chart_output = "#{opts[:dirs][:output]}/quality_filter_score_#{sample_name}.pdf"
|
16
|
+
end
|
17
|
+
|
18
|
+
def run previous_job_id = nil
|
19
|
+
puts "Submitting Picard QualityScoreDistribution #{sample_name} Jobs"
|
20
|
+
script_name = generate_script
|
21
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
22
|
+
@job_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def queuing_options previous_job_id = nil
|
26
|
+
{
|
27
|
+
previous_job_id: previous_job_id,
|
28
|
+
adjust_memory: ['h_vmem=5G'],
|
29
|
+
tools: ['picard', 'quailty_score_distribution']
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def quailty_score_distribution_options
|
34
|
+
array = quailty_score_distribution_params['params'].dup
|
35
|
+
array << "INPUT=#{@input}"
|
36
|
+
array << "OUTPUT=#{@output}"
|
37
|
+
array << "CHART_OUTPUT=#{@chart_output}"
|
38
|
+
array << "TMP_DIR=#{@tmp_dir}"
|
39
|
+
array.uniq
|
40
|
+
end
|
41
|
+
|
42
|
+
def modified_java_array
|
43
|
+
array = quailty_score_distribution_params['java'].dup
|
44
|
+
array << 'QualityScoreDistribution'
|
45
|
+
array.unshift(java_path).uniq
|
46
|
+
end
|
47
|
+
|
48
|
+
def params_combination_hash
|
49
|
+
@params_combination_hash ||= {
|
50
|
+
'java' => modified_java_array,
|
51
|
+
'params' => quailty_score_distribution_options
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_script
|
56
|
+
script_name = "#{@order}_picard_meanQScDis"
|
57
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
58
|
+
File.open(file, 'w') do |f|
|
59
|
+
f.puts <<-BASH.strip_heredoc
|
60
|
+
#!/bin/bash
|
61
|
+
|
62
|
+
cd "#{jobs_dir}/../"
|
63
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
64
|
+
#{params_combination_hash['java'].join("\s")} \\
|
65
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
66
|
+
#{::Cagnut::JobManage.run_local}
|
67
|
+
|
68
|
+
EXITSTATUS=$?
|
69
|
+
if [ ! -s "#{@chart_output}" ]; then exit 100;fi;
|
70
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
71
|
+
|
72
|
+
exit $EXITSTATUS
|
73
|
+
BASH
|
74
|
+
end
|
75
|
+
File.chmod(0700, file)
|
76
|
+
script_name
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class SortSam
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_delegators :'Cagnut::Configuration.base', :sample_name, :dodebug,
|
6
|
+
:jobs_dir, :magic28, :ref_fasta, :prefix_name, :java_path
|
7
|
+
def_delegators :'CagnutPicard.config', :rg_str_picard, :sort_sam_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}_mem.sam" : opts[:input]
|
12
|
+
@output = "#{opts[:dirs][:output]}/#{sample_name}_sort.bam"
|
13
|
+
@job_name = "#{prefix_name}_sort_sam_#{sample_name}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def run previous_job_id = nil
|
17
|
+
puts "Submitting sort_sam #{sample_name}"
|
18
|
+
script_name = generate_script
|
19
|
+
::Cagnut::JobManage.submit script_name, @job_name, queuing_options(previous_job_id)
|
20
|
+
[@job_name, @output]
|
21
|
+
end
|
22
|
+
|
23
|
+
def queuing_options previous_job_id = nil
|
24
|
+
{
|
25
|
+
previous_job_id: previous_job_id,
|
26
|
+
tools: ['picard', 'sort_sam']
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def sort_sam_options
|
31
|
+
array = sort_sam_params['params'].dup
|
32
|
+
array << "I=#{@input}"
|
33
|
+
array << "O=#{@output}"
|
34
|
+
array.uniq
|
35
|
+
end
|
36
|
+
|
37
|
+
def modified_java_array
|
38
|
+
array = sort_sam_params['java'].dup
|
39
|
+
array << 'SortSam'
|
40
|
+
array.unshift(java_path).uniq
|
41
|
+
end
|
42
|
+
|
43
|
+
def params_combination_hash
|
44
|
+
@params_combination_hash ||= {
|
45
|
+
'java' => modified_java_array,
|
46
|
+
'params' => sort_sam_options
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def generate_script
|
51
|
+
script_name = "#{@order}_picard_sort_sam"
|
52
|
+
file = File.join jobs_dir, "#{script_name}.sh"
|
53
|
+
File.open(file, 'w') do |f|
|
54
|
+
f.puts <<-BASH.strip_heredoc
|
55
|
+
#!/bin/bash
|
56
|
+
|
57
|
+
cd "#{jobs_dir}/../"
|
58
|
+
echo "#{script_name} is starting at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
59
|
+
#{params_combination_hash['java'].join("\s")} \\
|
60
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
61
|
+
#{::Cagnut::JobManage.run_local}
|
62
|
+
|
63
|
+
EXITSTATUS=$?
|
64
|
+
|
65
|
+
if [ ! -e "#{@output}" ]
|
66
|
+
then
|
67
|
+
echo "Missing output: #{@output}"
|
68
|
+
exit 100
|
69
|
+
fi
|
70
|
+
|
71
|
+
# Check BAM EOF
|
72
|
+
BAM_28=$(tail -c 28 #{@output}|xxd -p)
|
73
|
+
if [ '#{magic28}' != "$BAM_28" ]
|
74
|
+
then
|
75
|
+
echo "Error with BAM EOF" 1>&2
|
76
|
+
exit 100
|
77
|
+
fi
|
78
|
+
|
79
|
+
if [ $EXITSTATUS -ne 0 ];then exit $EXITSTATUS;fi
|
80
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
81
|
+
|
82
|
+
exit $EXITSTATUS
|
83
|
+
BASH
|
84
|
+
end
|
85
|
+
File.chmod(0700, file)
|
86
|
+
script_name
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module CagnutPicard
|
2
|
+
class Util
|
3
|
+
attr_accessor :picard, :config
|
4
|
+
|
5
|
+
def initialize config
|
6
|
+
@config = config
|
7
|
+
@picard = CagnutPicard::Base.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_or_replace_readgroups dirs, order, previous_job_id, filename
|
11
|
+
job_name, filename = picard.add_or_replace_readgroups dirs, order, previous_job_id, filename
|
12
|
+
[job_name, filename, order+1]
|
13
|
+
end
|
14
|
+
|
15
|
+
def markdup dirs, order=1, previous_job_id=nil, filename=nil
|
16
|
+
job_name, filename = picard.markdup dirs, order, previous_job_id, filename
|
17
|
+
[job_name, filename, order+1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def build_bam_index dirs, order=1, previous_job_id=nil, filename=nil
|
21
|
+
job_name = picard.build_bam_index dirs, order, previous_job_id, filename
|
22
|
+
[job_name, order+1]
|
23
|
+
end
|
24
|
+
|
25
|
+
def picard_qc_metrics dirs, order, previous_job_id, filename
|
26
|
+
order = mean_quality_by_cycle dirs, order, previous_job_id, filename
|
27
|
+
order = quality_score_distribution dirs, order, previous_job_id, filename
|
28
|
+
order = collect_gc_bias_metrics dirs, order, previous_job_id, filename
|
29
|
+
collect_insert_size_metrics dirs, order, previous_job_id, filename
|
30
|
+
end
|
31
|
+
|
32
|
+
def mean_quality_by_cycle dirs, order, previous_job_id, filename
|
33
|
+
picard.mean_quality_by_cycle dirs, order, previous_job_id, filename
|
34
|
+
order+1
|
35
|
+
end
|
36
|
+
|
37
|
+
def quality_score_distribution dirs, order, previous_job_id, filename
|
38
|
+
picard.quality_score_distribution dirs, order, previous_job_id, filename
|
39
|
+
order+1
|
40
|
+
end
|
41
|
+
|
42
|
+
def collect_gc_bias_metrics dirs, order, previous_job_id, filename
|
43
|
+
picard.collect_gc_bias_metrics dirs, order, previous_job_id, filename
|
44
|
+
order+1
|
45
|
+
end
|
46
|
+
|
47
|
+
def collect_insert_size_metrics dirs, order, previous_job_id, filename
|
48
|
+
picard.collect_insert_size_metrics dirs, order, previous_job_id, filename
|
49
|
+
order+1
|
50
|
+
end
|
51
|
+
|
52
|
+
def sort_sam dirs, order=1, previous_job_id, filename
|
53
|
+
job_name, filename = picard.sort_sam dirs, order, previous_job_id, filename
|
54
|
+
[job_name, filename, order+1]
|
55
|
+
end
|
56
|
+
|
57
|
+
def collect_multiple_metrics dirs, order=1, previous_job_id, filename
|
58
|
+
picard.collect_multiple_metrics dirs, order, previous_job_id, filename
|
59
|
+
order+1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "cagnut_picard/version"
|
2
|
+
|
3
|
+
module CagnutPicard
|
4
|
+
class << self
|
5
|
+
def config
|
6
|
+
@config ||= begin
|
7
|
+
CagnutPicard::Configuration.load(Cagnut::Configuration.config, Cagnut::Configuration.params['picard'])
|
8
|
+
CagnutPicard::Configuration.instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'cagnut_picard/configuration'
|
15
|
+
require 'cagnut_picard/base'
|
16
|
+
require 'cagnut_picard/util'
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cagnut_picard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shi-Gang Wang
|
8
|
+
- Tse-Ching Ho
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cagnut_core
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.12'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.12'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
description: Cagnut Picard tools
|
71
|
+
email:
|
72
|
+
- seanwang@goldenio.com
|
73
|
+
- tsechingho@goldenio.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- cagnut_picard.gemspec
|
89
|
+
- lib/cagnut_picard.rb
|
90
|
+
- lib/cagnut_picard/base.rb
|
91
|
+
- lib/cagnut_picard/check_tools.rb
|
92
|
+
- lib/cagnut_picard/configuration.rb
|
93
|
+
- lib/cagnut_picard/functions/add_or_replace_readgroups.rb
|
94
|
+
- lib/cagnut_picard/functions/build_bam_index.rb
|
95
|
+
- lib/cagnut_picard/functions/collect_gc_bias_metrics.rb
|
96
|
+
- lib/cagnut_picard/functions/collect_insert_size_metrics.rb
|
97
|
+
- lib/cagnut_picard/functions/collect_multiple_metrics.rb
|
98
|
+
- lib/cagnut_picard/functions/markdup.rb
|
99
|
+
- lib/cagnut_picard/functions/mean_quality_by_cycle.rb
|
100
|
+
- lib/cagnut_picard/functions/quality_score_distribution.rb
|
101
|
+
- lib/cagnut_picard/functions/sort_sam.rb
|
102
|
+
- lib/cagnut_picard/util.rb
|
103
|
+
- lib/cagnut_picard/version.rb
|
104
|
+
homepage: https://github.com/CAGNUT/cagnut_picard
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.5.1
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Cagnut Picard tools
|
128
|
+
test_files: []
|