snp-search 0.23.0 → 0.26.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.
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/VERSION +1 -1
- data/bin/snp-search +14 -6
- data/lib/snp-search.rb +49 -41
- data/snp-search.gemspec +5 -2
- metadata +30 -19
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -10,6 +10,9 @@ GEM
|
|
10
10
|
activesupport (= 3.1.3)
|
11
11
|
arel (~> 2.2.1)
|
12
12
|
tzinfo (~> 0.3.29)
|
13
|
+
activerecord-import (0.2.8)
|
14
|
+
activerecord (~> 3.0pre)
|
15
|
+
activerecord (~> 3.0pre)
|
13
16
|
activesupport (3.1.3)
|
14
17
|
multi_json (~> 1.0)
|
15
18
|
arel (2.2.1)
|
@@ -42,6 +45,7 @@ PLATFORMS
|
|
42
45
|
|
43
46
|
DEPENDENCIES
|
44
47
|
activerecord (~> 3.1.3)
|
48
|
+
activerecord-import (~> 0.2.8)
|
45
49
|
bio (~> 1.4.2)
|
46
50
|
bundler (~> 1.0.0)
|
47
51
|
jeweler (~> 1.6.4)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.26.0
|
data/bin/snp-search
CHANGED
@@ -22,17 +22,25 @@ opts = Slop.new :help do
|
|
22
22
|
end
|
23
23
|
opts.parse
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
error_msg = ""
|
26
|
+
|
27
|
+
error_msg += "You must supply the -n option, it's a required field\n" unless opts[:name]
|
28
|
+
error_msg += "You must supply the -r option, it's a required field\n" unless opts[:reference_file]
|
29
|
+
error_msg += "You must supply the -v option, it's a required field" unless opts[:vcf_file]
|
30
|
+
|
31
|
+
unless error_msg == ""
|
32
|
+
puts error_msg
|
33
|
+
puts opts.help unless opts.empty?
|
34
|
+
exit
|
35
|
+
end
|
28
36
|
|
29
37
|
begin
|
30
|
-
|
38
|
+
abort "#{opts[:reference_file]} file does not exist!" unless File.exist?(opts[:reference_file])
|
31
39
|
rescue
|
32
40
|
end
|
33
41
|
|
34
42
|
begin
|
35
|
-
|
43
|
+
abort "#{opts[:vcf_file]} file does not exist!" unless File.exist?(opts[:vcf_file])
|
36
44
|
rescue
|
37
45
|
end
|
38
46
|
|
@@ -62,7 +70,7 @@ sequence_format = guess_sequence_format(ref)
|
|
62
70
|
vcf_mpileup_file = opts[:vcf_file]
|
63
71
|
|
64
72
|
# The populate_features_and_annotations method populates the features and annotations. It uses the embl/gbk file.
|
65
|
-
populate_features_and_annotations(sequence_flatfile)
|
73
|
+
# populate_features_and_annotations(sequence_flatfile)
|
66
74
|
|
67
75
|
#The populate_snps_alleles_genotypes method populates the snps, alleles and genotypes. It uses the vcf file, and if specified, the SNP quality cutoff and genotype quality cutoff
|
68
76
|
populate_snps_alleles_genotypes(vcf_mpileup_file, opts[:cuttoff_snp].to_i, opts[:cuttoff_genotype].to_i)
|
data/lib/snp-search.rb
CHANGED
@@ -2,10 +2,9 @@ require 'rubygems'
|
|
2
2
|
gem "bio", "~> 1.4.2"
|
3
3
|
require 'bio'
|
4
4
|
require 'snp_db_models'
|
5
|
+
require 'activerecord-import'
|
5
6
|
#establish_connection
|
6
7
|
|
7
|
-
GC.disable
|
8
|
-
|
9
8
|
def guess_sequence_format(reference_genome)
|
10
9
|
file_extension = File.extname(reference_genome).downcase
|
11
10
|
file_format = nil
|
@@ -22,29 +21,30 @@ end
|
|
22
21
|
# We include all features that are not 'source' or 'gene' as they are repetitive info. 'CDS' is the gene.
|
23
22
|
# The annotation table includes also the start and end coordinates of the CDS. The strand is also included. the 'locations' method is defined in bioruby under genbank. It must be required at the top (bio).
|
24
23
|
# Also, the qualifier and value are extracted from the embl file and added to the database.
|
25
|
-
def populate_features_and_annotations(sequence_file)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
24
|
+
# def populate_features_and_annotations(sequence_file)
|
25
|
+
# ActiveRecord::Base.transaction do
|
26
|
+
# sequence_file.features.each do |feature|
|
27
|
+
# unless feature.feature == "source" || feature.feature == "gene"
|
28
|
+
# db_feature = Feature.new
|
29
|
+
# db_feature.start = feature.locations.first.from
|
30
|
+
# db_feature.end = feature.locations.first.to
|
31
|
+
# db_feature.strand = feature.locations.first.strand
|
32
|
+
# db_feature.name = feature.feature
|
33
|
+
# db_feature.save
|
34
|
+
# puts "populating #{db_feature.name}, start: #{db_feature.start}, end: #{db_feature.end}, strand: #{db_feature.strand} for feature: #{db_feature.id}"
|
35
|
+
# # Populate the Annotation table with qualifier information from the genbank file
|
36
|
+
# feature.qualifiers.each do |qualifier|
|
37
|
+
# a = Annotation.new
|
38
|
+
# a.qualifier = qualifier.qualifier
|
39
|
+
# a.value = qualifier.value
|
40
|
+
# a.save
|
41
|
+
# db_feature.annotations << a
|
42
|
+
# puts "populating #{a.qualifier} for feature: #{db_feature.id}"
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
# end
|
48
48
|
|
49
49
|
#This method populates the rest of the information, i.e. SNP information, Alleles and Genotypes.
|
50
50
|
# It requires the strain_names as array and the output (vcf file) from mpileup-snp identification algorithm.
|
@@ -134,23 +134,31 @@ def populate_snps_alleles_genotypes(vcf_file, cuttoff_snp, cuttoff_genotype)
|
|
134
134
|
snp_allele.save
|
135
135
|
|
136
136
|
puts "Adding SNP base: #{snp_base}"
|
137
|
-
|
138
137
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
138
|
+
a = Time.now
|
139
|
+
|
140
|
+
puts "Adding Genotype information..."
|
141
|
+
ActiveRecord::Base.transaction do
|
142
|
+
genotypes.each_with_index do |gt, index|
|
143
|
+
genotype = Genotype.new
|
144
|
+
genotype.strain = strains[index]
|
145
|
+
puts index if strains[index].nil?
|
146
|
+
# print "#{gt}(#{genotypes_qualities[index]}) "
|
147
|
+
if gt == "0/0" # wild type
|
148
|
+
genotype.allele = ref_allele
|
149
|
+
elsif gt == "1/1" # snp type
|
150
|
+
genotype.allele = snp_allele
|
151
|
+
else
|
152
|
+
puts "Strange SNP #{gt}"
|
153
|
+
end
|
154
|
+
#genotype.save
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
b = Time.now
|
159
|
+
mm, ss = (b-a).divmod(60)
|
160
|
+
puts "Time taken: #{mm} minutes #{ss} seconds"
|
161
|
+
a = Time.now
|
154
162
|
end
|
155
163
|
end
|
156
164
|
|
data/snp-search.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "snp-search"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.26.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ali Al-Shahib", "Anthony Underwood"]
|
12
|
-
s.date = "2011-12-
|
12
|
+
s.date = "2011-12-13"
|
13
13
|
s.description = "Use the snp-search toolset to query the SNP database"
|
14
14
|
s.email = "ali.al-shahib@hpa.org.uk"
|
15
15
|
s.executables = ["snp-search"]
|
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.add_runtime_dependency(%q<bio>, ["~> 1.4.2"])
|
56
56
|
s.add_runtime_dependency(%q<slop>, ["~> 2.4.0"])
|
57
57
|
s.add_runtime_dependency(%q<sqlite3>, ["~> 1.3.4"])
|
58
|
+
s.add_runtime_dependency(%q<activerecord-import>, ["~> 0.2.8"])
|
58
59
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
59
60
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
61
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
@@ -64,6 +65,7 @@ Gem::Specification.new do |s|
|
|
64
65
|
s.add_dependency(%q<bio>, ["~> 1.4.2"])
|
65
66
|
s.add_dependency(%q<slop>, ["~> 2.4.0"])
|
66
67
|
s.add_dependency(%q<sqlite3>, ["~> 1.3.4"])
|
68
|
+
s.add_dependency(%q<activerecord-import>, ["~> 0.2.8"])
|
67
69
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
68
70
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
69
71
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
@@ -74,6 +76,7 @@ Gem::Specification.new do |s|
|
|
74
76
|
s.add_dependency(%q<bio>, ["~> 1.4.2"])
|
75
77
|
s.add_dependency(%q<slop>, ["~> 2.4.0"])
|
76
78
|
s.add_dependency(%q<sqlite3>, ["~> 1.3.4"])
|
79
|
+
s.add_dependency(%q<activerecord-import>, ["~> 0.2.8"])
|
77
80
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
78
81
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
79
82
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snp-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-13 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153046460 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.1.3
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153046460
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bio
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153045960 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.4.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153045960
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: slop
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153045420 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 2.4.0
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153045420
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: sqlite3
|
50
|
-
requirement: &
|
50
|
+
requirement: &2153044880 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,21 @@ dependencies:
|
|
55
55
|
version: 1.3.4
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153044880
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: activerecord-import
|
61
|
+
requirement: &2153044340 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.2.8
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *2153044340
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
71
|
name: rspec
|
61
|
-
requirement: &
|
72
|
+
requirement: &2153043800 !ruby/object:Gem::Requirement
|
62
73
|
none: false
|
63
74
|
requirements:
|
64
75
|
- - ~>
|
@@ -66,10 +77,10 @@ dependencies:
|
|
66
77
|
version: 2.3.0
|
67
78
|
type: :development
|
68
79
|
prerelease: false
|
69
|
-
version_requirements: *
|
80
|
+
version_requirements: *2153043800
|
70
81
|
- !ruby/object:Gem::Dependency
|
71
82
|
name: bundler
|
72
|
-
requirement: &
|
83
|
+
requirement: &2153043300 !ruby/object:Gem::Requirement
|
73
84
|
none: false
|
74
85
|
requirements:
|
75
86
|
- - ~>
|
@@ -77,10 +88,10 @@ dependencies:
|
|
77
88
|
version: 1.0.0
|
78
89
|
type: :development
|
79
90
|
prerelease: false
|
80
|
-
version_requirements: *
|
91
|
+
version_requirements: *2153043300
|
81
92
|
- !ruby/object:Gem::Dependency
|
82
93
|
name: jeweler
|
83
|
-
requirement: &
|
94
|
+
requirement: &2153042820 !ruby/object:Gem::Requirement
|
84
95
|
none: false
|
85
96
|
requirements:
|
86
97
|
- - ~>
|
@@ -88,10 +99,10 @@ dependencies:
|
|
88
99
|
version: 1.6.4
|
89
100
|
type: :development
|
90
101
|
prerelease: false
|
91
|
-
version_requirements: *
|
102
|
+
version_requirements: *2153042820
|
92
103
|
- !ruby/object:Gem::Dependency
|
93
104
|
name: rcov
|
94
|
-
requirement: &
|
105
|
+
requirement: &2153042340 !ruby/object:Gem::Requirement
|
95
106
|
none: false
|
96
107
|
requirements:
|
97
108
|
- - ! '>='
|
@@ -99,7 +110,7 @@ dependencies:
|
|
99
110
|
version: '0'
|
100
111
|
type: :development
|
101
112
|
prerelease: false
|
102
|
-
version_requirements: *
|
113
|
+
version_requirements: *2153042340
|
103
114
|
description: Use the snp-search toolset to query the SNP database
|
104
115
|
email: ali.al-shahib@hpa.org.uk
|
105
116
|
executables:
|
@@ -146,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
157
|
version: '0'
|
147
158
|
segments:
|
148
159
|
- 0
|
149
|
-
hash:
|
160
|
+
hash: -2048575630589609763
|
150
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
162
|
none: false
|
152
163
|
requirements:
|