cagnut_snpeff 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_snpeff.gemspec +27 -0
- data/lib/cagnut_snpeff/base.rb +11 -0
- data/lib/cagnut_snpeff/check_tools.rb +30 -0
- data/lib/cagnut_snpeff/configuration.rb +57 -0
- data/lib/cagnut_snpeff/functions/snp_annotation.rb +85 -0
- data/lib/cagnut_snpeff/util.rb +14 -0
- data/lib/cagnut_snpeff/version.rb +3 -0
- data/lib/cagnut_snpeff.rb +16 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 49567d185fa2c730ba7a3a37eec9ab4ef675f655
|
4
|
+
data.tar.gz: 1e36fdf1efa937f926624d850b96305c38b65151
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 56ee237742544b69ed0b8149098e68d1557e002997291646a7898b168ea46df757c73fdf66929dfbacb8d84b0ef0599c7c24ba9acd858903319dfd451984fcc3
|
7
|
+
data.tar.gz: 5b7b9e537e0c54f421c47ffb88d2106366ee2f51582ced6ff8b6ef5f74e6520a5dddb54b8b0e75cf773eec7f34ffcb9d967611252fc6320faaf3cd47beb64235
|
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
|
+
# CagnutSnpeff
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'cagnut_snpeff'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install cagnut_snpeff
|
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_snpeff.
|
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_snpeff"
|
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_snpeff/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cagnut_snpeff"
|
8
|
+
spec.version = CagnutSnpeff::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 Snpeff tools}
|
13
|
+
spec.description = %q{Cagnut Snpeff tools}
|
14
|
+
spec.homepage = "https://github.com/CAGNUT/cagnut_snpeff"
|
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,11 @@
|
|
1
|
+
require 'cagnut_snpeff/functions/snp_annotation'
|
2
|
+
|
3
|
+
module CagnutSnpeff
|
4
|
+
class Base
|
5
|
+
def snp_annotation dirs, order, previous_job_id, input = nil
|
6
|
+
opts = { input: input, dirs: dirs, order: order }
|
7
|
+
snp_annotation = CagnutSnpeff::SnpAnnotation.new opts
|
8
|
+
snp_annotation.run previous_job_id
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module CagnutSnpeff
|
2
|
+
module CheckTools
|
3
|
+
def check_tool tools_path, ref=nil
|
4
|
+
super if defined?(super)
|
5
|
+
check_snpeff tools['snpeff'], refs['snpeff']['db'], refs['snpeff']['config'] if @java
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_snpeff path, db_version, config_path
|
9
|
+
check_tool_ver 'snpEff' do
|
10
|
+
`#{@java} -jar #{path} -version 2>&1` if path
|
11
|
+
end
|
12
|
+
|
13
|
+
if db_version.nil?
|
14
|
+
@check_completed = false
|
15
|
+
puts "\tNot Set Snpeff DB in config.yml"
|
16
|
+
else
|
17
|
+
puts "\tSnpeff DB: #{db_version}"
|
18
|
+
end
|
19
|
+
|
20
|
+
if config_path
|
21
|
+
path = File.exist?(config_path) ? config_path : 'Not Found' if config_path
|
22
|
+
puts "\tSnpeff config file: #{path}"
|
23
|
+
else
|
24
|
+
puts "\tSnpeff config Not Found"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
CagnutSnpeff.config::Checks::Tools.prepend CagnutSnpeff::CheckTools
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module CagnutSnpeff
|
4
|
+
class Configuration
|
5
|
+
include Singleton
|
6
|
+
attr_accessor :annotation_params
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def load config, tools_config
|
10
|
+
instance.load config, tools_config
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def load config, tools_config
|
15
|
+
@config = config
|
16
|
+
@tools_config = tools_config
|
17
|
+
attributes.each do |name, value|
|
18
|
+
send "#{name}=", value if respond_to? "#{name}="
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def attributes
|
23
|
+
{
|
24
|
+
annotation_params: annotation_params_setup
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def annotation_params_setup
|
31
|
+
{
|
32
|
+
'java' => add_java_params,
|
33
|
+
'params' => add_annotation_options
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_java_params verbose=false
|
38
|
+
return if @tools_config['annotation'].blank?
|
39
|
+
array = @tools_config['annotation']['java'].dup
|
40
|
+
array << "-verbose:sizes" if verbose
|
41
|
+
array << "-jar #{@config['tools']['snpeff']}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_annotation_options
|
45
|
+
return if @tools_config['annotation'].blank?
|
46
|
+
array = @tools_config['annotation']['params'].dup
|
47
|
+
array << @config['refs']['snpeff']['db']
|
48
|
+
array << snpeff_config_tag if snpeff_config_tag
|
49
|
+
array.uniq
|
50
|
+
end
|
51
|
+
|
52
|
+
def snpeff_config_tag
|
53
|
+
config = @config['refs']['snpeff']['config']
|
54
|
+
config.nil? ? nil : "-c #{config}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module CagnutSnpeff
|
2
|
+
class SnpAnnotation
|
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 :'CagnutSnpeff.config', :annotation_params
|
8
|
+
|
9
|
+
def initialize opts = {}
|
10
|
+
@order = sprintf '%02i', opts[:order]
|
11
|
+
@input = opts[:input].nil? ? "#{opts[:dirs][:input]}/#{sample_name}.vcf" : opts[:input]
|
12
|
+
@output = "#{opts[:dirs][:output]}/#{sample_name}_snpeff.vcf"
|
13
|
+
@job_name = "#{prefix_name}_snpEff_#{sample_name}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def run previous_job_id = nil
|
17
|
+
puts "Submitting snpAnnotation #{sample_name} Jobs"
|
18
|
+
script_name = generate_script
|
19
|
+
::Cagnut::JobManage.submit script_name, @job_name, cluster_options(previous_job_id)
|
20
|
+
@job_name
|
21
|
+
end
|
22
|
+
|
23
|
+
def cluster_options previous_job_id = nil
|
24
|
+
{
|
25
|
+
previous_job_id: previous_job_id,
|
26
|
+
adjust_memory: ['h_stack=256M', 'h_vmem=8G'],
|
27
|
+
tools: ['snpeff', 'annotation']
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def annotation_options
|
32
|
+
array = annotation_params['params'].dup
|
33
|
+
array << "#{@input} > #{@output}"
|
34
|
+
array.uniq
|
35
|
+
end
|
36
|
+
|
37
|
+
def modified_java_array
|
38
|
+
array = annotation_params['java'].dup
|
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' => annotation_options
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def generate_script
|
50
|
+
script_name = "#{@order}_snpeff_snp_annotation"
|
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
|
+
|
59
|
+
#{params_combination_hash['java'].join("\s")} \\
|
60
|
+
#{params_combination_hash['params'].join(" \\\n ")} \\
|
61
|
+
#{::Cagnut::JobManage.run_local}
|
62
|
+
|
63
|
+
EXITSTATUS=$?
|
64
|
+
|
65
|
+
#force error when missing output
|
66
|
+
if [ ! -s "#{@output}" ]; then exit 100;fi;
|
67
|
+
if [ $(grep -cv "^#" "#{@output}") -eq "0" ]
|
68
|
+
then
|
69
|
+
echo "No variants!"
|
70
|
+
exit 100;
|
71
|
+
fi
|
72
|
+
|
73
|
+
if [ $EXITSTATUS -eq 1 ];then
|
74
|
+
echo "Error in Java"
|
75
|
+
exit 100
|
76
|
+
fi
|
77
|
+
echo "#{script_name} is finished at $(date +%Y%m%d%H%M%S)" >> "#{jobs_dir}/finished_jobs"
|
78
|
+
|
79
|
+
BASH
|
80
|
+
end
|
81
|
+
File.chmod(0700, file)
|
82
|
+
script_name
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CagnutSnpeff
|
2
|
+
class Util
|
3
|
+
attr_accessor :snpeff
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@snpeff = CagnutSnpeff::Base.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def snp_annotation dirs, order=1, previous_job_id=nil, filename=nil
|
10
|
+
job_name = snpeff.snp_annotation dirs, order, previous_job_id, filename
|
11
|
+
[job_name, order]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "cagnut_snpeff/version"
|
2
|
+
|
3
|
+
module CagnutSnpeff
|
4
|
+
class << self
|
5
|
+
def config
|
6
|
+
@config ||= begin
|
7
|
+
CagnutSnpeff::Configuration.load(Cagnut::Configuration.config, Cagnut::Configuration.params['snpeff'])
|
8
|
+
CagnutSnpeff::Configuration.instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'cagnut_snpeff/configuration'
|
15
|
+
require 'cagnut_snpeff/base'
|
16
|
+
require 'cagnut_snpeff/util'
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cagnut_snpeff
|
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 Snpeff 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_snpeff.gemspec
|
89
|
+
- lib/cagnut_snpeff.rb
|
90
|
+
- lib/cagnut_snpeff/base.rb
|
91
|
+
- lib/cagnut_snpeff/check_tools.rb
|
92
|
+
- lib/cagnut_snpeff/configuration.rb
|
93
|
+
- lib/cagnut_snpeff/functions/snp_annotation.rb
|
94
|
+
- lib/cagnut_snpeff/util.rb
|
95
|
+
- lib/cagnut_snpeff/version.rb
|
96
|
+
homepage: https://github.com/CAGNUT/cagnut_snpeff
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Cagnut Snpeff tools
|
120
|
+
test_files: []
|