bio-svgenes 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.DS_Store ADDED
Binary file
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ gem "bio", ">= 1.4.2"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bio (1.4.3)
5
+ git (1.2.5)
6
+ jeweler (1.6.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.9.2.2)
11
+ rcov (0.9.11)
12
+ shoulda (2.11.3)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ bio (>= 1.4.2)
19
+ bundler (~> 1.0.0)
20
+ jeweler (~> 1.6.4)
21
+ rcov
22
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dan MacLean
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = bio-svgenes
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to bio-svgenes
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Dan MacLean. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "bio-svgenes"
18
+ gem.homepage = "http://github.com/danmaclean/bioruby-svgenes"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Create pretty SVG-format images of features, gene models and data tracks}
21
+ gem.description = %Q{This bio-gem facilitates the creation of pretty, publication quality SVG images from feature data.}
22
+ gem.email = "maclean.daniel@gmail.com"
23
+ gem.authors = ["Dan MacLean"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "bio-svgenes #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "bio-svgenes"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dan MacLean"]
12
+ s.date = "2012-11-21"
13
+ s.description = "This bio-gem facilitates the creation of pretty, publication quality SVG images from feature data."
14
+ s.email = "maclean.daniel@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".DS_Store",
21
+ ".document",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bio-svgenes.gemspec",
29
+ "examples/.DS_Store",
30
+ "examples/annotate_snps.rb",
31
+ "examples/data.txt",
32
+ "examples/draw_from_json.rb",
33
+ "examples/drawn_from_json.svg",
34
+ "examples/drawn_from_json2.svg",
35
+ "examples/example.rb",
36
+ "examples/example.svg",
37
+ "examples/example_config.json",
38
+ "examples/gene.gff",
39
+ "examples/get_coverage_in_windows.rb",
40
+ "examples/transcripts.gff",
41
+ "lib/.DS_Store",
42
+ "lib/bio-svgenes.rb",
43
+ "lib/bio/.DS_Store",
44
+ "lib/bio/graphics/glyph.rb",
45
+ "lib/bio/graphics/mini_feature.rb",
46
+ "lib/bio/graphics/page.rb",
47
+ "lib/bio/graphics/primitive.rb",
48
+ "lib/bio/graphics/svgee.rb",
49
+ "lib/bio/graphics/track.rb",
50
+ "test/helper.rb",
51
+ "test/test_bio-svgenes.rb"
52
+ ]
53
+ s.homepage = "http://github.com/danmaclean/bioruby-svgenes"
54
+ s.licenses = ["MIT"]
55
+ s.require_paths = ["lib"]
56
+ s.rubygems_version = "1.8.10"
57
+ s.summary = "Create pretty SVG-format images of features, gene models and data tracks"
58
+
59
+ if s.respond_to? :specification_version then
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
64
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
65
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
66
+ s.add_development_dependency(%q<rcov>, [">= 0"])
67
+ s.add_development_dependency(%q<bio>, [">= 1.4.2"])
68
+ else
69
+ s.add_dependency(%q<shoulda>, [">= 0"])
70
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
72
+ s.add_dependency(%q<rcov>, [">= 0"])
73
+ s.add_dependency(%q<bio>, [">= 1.4.2"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<shoulda>, [">= 0"])
77
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
78
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
79
+ s.add_dependency(%q<rcov>, [">= 0"])
80
+ s.add_dependency(%q<bio>, [">= 1.4.2"])
81
+ end
82
+ end
83
+
Binary file
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # untitled
4
+ #
5
+ # Created by Dan MacLean (TSL) on 2012-10-30.
6
+ # Copyright (c) . All rights reserved.
7
+ ###################################################
8
+
9
+ require 'ostruct'
10
+
11
+ class DanGFF
12
+ attr_accessor :seqname, :source, :attributes, :start, :end, :strand, :feature, :phase, :score
13
+
14
+ def initialize(line)
15
+ @seqname, @source, @feature, @start, @end, @score, @strand, @phase, @attributes = line.split(/\t/)
16
+ @start = @start.to_i
17
+ @end = @end.to_i
18
+ end
19
+
20
+ def parent
21
+ self.attributes =~ /Parent=(.*?);/
22
+ $1
23
+ end
24
+
25
+ def overlaps?(other)
26
+ if (self.seqname == other.seqname and self.start >= other.start and self.start <= other.end)
27
+ return true
28
+ elsif (self.seqname == other.seqname and self.end >= other.start and self.end <= other.end)
29
+ return true
30
+ end
31
+ end
32
+
33
+ def contains?(other)
34
+ if self.seqname == other.seqname and self.start <= other.start and self.end >= other.end
35
+ return true
36
+ else
37
+ return false
38
+ end
39
+ end
40
+
41
+ end
42
+ features_file = ARGV.shift
43
+ bam_file = ARGV.shift
44
+ bgi_snp_file = ARGV.shift
45
+ #rest = data dump files from R
46
+
47
+ #get SNP list (position, methodd)
48
+ ARGV.each do |file|
49
+ snps = []
50
+ file =~ /(.*)_r_dump.csv/
51
+ id = $1
52
+ File.open(file,"r").each do |line|
53
+ next if line=~ /Method/
54
+ snp = OpenStruct.new
55
+ snp.index, snp.pos, snp.method =line.chomp.split(/,/)
56
+ snp.index = snp.index.to_i
57
+ snp.pos = snp.pos.to_i
58
+ snp.seqname = id
59
+ snp.start = snp.pos
60
+ snp.end = snp.pos
61
+ snps << snp
62
+ end
63
+ features = []
64
+ File.open(features_file, "r").each do |line|
65
+ feature = DanGFF.new(line)
66
+ features << feature if feature.seqname == id and feature.feature == "mRNA"
67
+ end
68
+
69
+ features.each do |f|
70
+ snps.each do |snp|
71
+ if feature.contains(snp)
72
+ snp_info = case snp.method
73
+ when "BGI"
74
+ get_snp_from_bgi(snp)
75
+ when "PileUp"
76
+ get_snp_from_pileup(snp)
77
+ when "VCF"
78
+ get_snp_from_vcf(snp)
79
+ end
80
+ print snp_out(snp,snp_info)
81
+ end
82
+ end
83
+ end
84
+
85
+ end
86
+
data/examples/data.txt ADDED
@@ -0,0 +1,192 @@
1
+ 900 1000 5
2
+ 1000 1100 98
3
+ 1100 1200 47
4
+ 1200 1300 63
5
+ 1300 1400 58
6
+ 1400 1500 29
7
+ 1500 1600 88
8
+ 1600 1700 58
9
+ 1700 1800 84
10
+ 1800 1900 54
11
+ 1900 2000 100
12
+ 2000 2100 40
13
+ 2100 2200 76
14
+ 2200 2300 20
15
+ 2300 2400 65
16
+ 2400 2500 56
17
+ 2500 2600 64
18
+ 2600 2700 96
19
+ 2700 2800 13
20
+ 2800 2900 5
21
+ 2900 3000 9
22
+ 3000 3100 5
23
+ 3100 3200 16
24
+ 3200 3300 44
25
+ 3300 3400 92
26
+ 3400 3500 20
27
+ 3500 3600 35
28
+ 3600 3700 48
29
+ 3700 3800 49
30
+ 3800 3900 10
31
+ 3900 4000 83
32
+ 4000 4100 96
33
+ 4100 4200 69
34
+ 4200 4300 13
35
+ 4300 4400 27
36
+ 4400 4500 58
37
+ 4500 4600 27
38
+ 4600 4700 6
39
+ 4700 4800 82
40
+ 4800 4900 79
41
+ 4900 5000 94
42
+ 5000 5100 97
43
+ 5100 5200 26
44
+ 5200 5300 42
45
+ 5300 5400 9
46
+ 5400 5500 22
47
+ 5500 5600 13
48
+ 5600 5700 85
49
+ 5700 5800 95
50
+ 5800 5900 82
51
+ 5900 6000 90
52
+ 6000 6100 35
53
+ 6100 6200 20
54
+ 6200 6300 14
55
+ 6300 6400 66
56
+ 6400 6500 13
57
+ 6500 6600 16
58
+ 6600 6700 40
59
+ 6700 6800 38
60
+ 6800 6900 40
61
+ 6900 7000 42
62
+ 7000 7100 92
63
+ 7100 7200 33
64
+ 7200 7300 39
65
+ 7300 7400 21
66
+ 7400 7500 99
67
+ 7500 7600 48
68
+ 7600 7700 91
69
+ 7700 7800 10
70
+ 7800 7900 47
71
+ 7900 8000 16
72
+ 8000 8100 94
73
+ 8100 8200 57
74
+ 8200 8300 99
75
+ 8300 8400 16
76
+ 8400 8500 50
77
+ 8500 8600 13
78
+ 8600 8700 74
79
+ 8700 8800 33
80
+ 8800 8900 29
81
+ 8900 9000 25
82
+ 9000 9100 5
83
+ 9100 9200 90
84
+ 9200 9300 3
85
+ 9300 9400 50
86
+ 9400 9500 62
87
+ 9500 9600 98
88
+ 9600 9700 59
89
+ 9700 9800 36
90
+ 9800 9900 66
91
+ 9900 10000 95
92
+ 10000 10100 33
93
+ 10100 10200 54
94
+ 10200 10300 9
95
+ 10300 10400 63
96
+ 10400 10500 61
97
+ 10500 10600 83
98
+ 10600 10700 62
99
+ 10700 10800 91
100
+ 10800 10900 27
101
+ 10900 11000 14
102
+ 11000 11100 85
103
+ 11100 11200 50
104
+ 11200 11300 34
105
+ 11300 11400 51
106
+ 11400 11500 95
107
+ 11500 11600 46
108
+ 11600 11700 22
109
+ 11700 11800 15
110
+ 11800 11900 32
111
+ 11900 12000 25
112
+ 12000 12100 69
113
+ 12100 12200 60
114
+ 12200 12300 99
115
+ 12300 12400 36
116
+ 12400 12500 19
117
+ 12500 12600 70
118
+ 12600 12700 4
119
+ 12700 12800 13
120
+ 12800 12900 85
121
+ 12900 13000 52
122
+ 13000 13100 12
123
+ 13100 13200 19
124
+ 13200 13300 56
125
+ 13300 13400 49
126
+ 13400 13500 77
127
+ 13500 13600 70
128
+ 13600 13700 79
129
+ 13700 13800 75
130
+ 13800 13900 9
131
+ 13900 14000 7
132
+ 14000 14100 15
133
+ 14100 14200 31
134
+ 14200 14300 57
135
+ 14300 14400 41
136
+ 14400 14500 34
137
+ 14500 14600 31
138
+ 14600 14700 89
139
+ 14700 14800 23
140
+ 14800 14900 82
141
+ 14900 15000 15
142
+ 15000 15100 76
143
+ 15100 15200 16
144
+ 15200 15300 84
145
+ 15300 15400 25
146
+ 15400 15500 98
147
+ 15500 15600 51
148
+ 15600 15700 49
149
+ 15700 15800 10
150
+ 15800 15900 22
151
+ 15900 16000 96
152
+ 16000 16100 40
153
+ 16100 16200 49
154
+ 16200 16300 4
155
+ 16300 16400 73
156
+ 16400 16500 49
157
+ 16500 16600 95
158
+ 16600 16700 77
159
+ 16700 16800 56
160
+ 16800 16900 91
161
+ 16900 17000 57
162
+ 17000 17100 15
163
+ 17100 17200 73
164
+ 17200 17300 19
165
+ 17300 17400 10
166
+ 17400 17500 100
167
+ 17500 17600 50
168
+ 17600 17700 59
169
+ 17700 17800 86
170
+ 17800 17900 35
171
+ 17900 18000 46
172
+ 18000 18100 14
173
+ 18100 18200 4
174
+ 18200 18300 58
175
+ 18300 18400 9
176
+ 18400 18500 3
177
+ 18500 18600 98
178
+ 18600 18700 38
179
+ 18700 18800 21
180
+ 18800 18900 50
181
+ 18900 19000 52
182
+ 19000 19100 98
183
+ 19100 19200 22
184
+ 19200 19300 95
185
+ 19300 19400 40
186
+ 19400 19500 82
187
+ 19500 19600 89
188
+ 19600 19700 4
189
+ 19700 19800 58
190
+ 19800 19900 57
191
+ 19900 20000 44
192
+ 20000 20100 40