make_circos 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a295838ae019e0aaeb4de434b5ca0be5a075cc47
4
+ data.tar.gz: 127f4a3eb96ef598ac27f69d6a45df0a2bb85e0e
5
+ SHA512:
6
+ metadata.gz: ae3ffd4ef777ca6164f33be4d6bc9fda2e6e81c9b02f61408e8fbd787a1b3551a6a6b053b6e4238c05d56b655d5586f0d99fe55e2c74fd670455073399cd9ea5
7
+ data.tar.gz: b7731c4afe1442da8cdd184e41338b4ad4ce6d4fbed214aca3d0a395512ea81da34fd2eef0deb7e689c57dee28fc566638ded4bd0928c972fada1b75e15d674c
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in make_circos.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # MakeCircos
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'make_circos'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install make_circos
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/make_circos/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,21 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ all_seqs = []
4
+ name = nil
5
+ seq = ''
6
+ File.open(ARGV[0]).each do |line|
7
+ line.chomp!
8
+ if line =~ /^>/
9
+ all_seqs << [name, seq.length] if !name.nil?
10
+ name = line.gsub('>', '')
11
+ seq = ''
12
+ else
13
+ seq << line
14
+ end
15
+
16
+ end
17
+ all_seqs << [name, seq.length]
18
+ all_seqs.sort!{|s1, s2| s2.last <=> s1.last}
19
+ all_seqs.each do |name, seq_length|
20
+ puts "#{name}\t1\t#{seq_length}"
21
+ end
@@ -0,0 +1,227 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ ROOT_PATH=File.dirname(__FILE__)
4
+ $: << File.expand_path(File.join(ROOT_PATH, "../lib/"))
5
+ $: << File.expand_path(File.join(ROOT_PATH, "../lib/make_circos"))
6
+
7
+ require 'fileutils'
8
+ require 'optparse'
9
+
10
+ #################################################################################################
11
+ ## INPUT PARSING
12
+ #################################################################################################
13
+ options = {}
14
+
15
+ optparse = OptionParser.new do |opts|
16
+ options[:karyotype_file] = nil
17
+ opts.on( '-k', '--karyotype_file FILE', 'Input tabulated file' ) do |karyotype_file|
18
+ options[:karyotype_file] = karyotype_file
19
+ end
20
+
21
+ options[:prefix_label] = ''
22
+ opts.on( '-p', '--prefix_label STRING', 'Prefix to use with with labels' ) do |prefix|
23
+ options[:prefix_label] = prefix
24
+ end
25
+
26
+ options[:output_folder] = Dir.pwd
27
+ opts.on( '-o', '--output_folder PATH', 'Path to folder which circos files must be saved' ) do |output_folder|
28
+ options[:output_folder] = output_folder
29
+ end
30
+
31
+ options[:system_coords] = 0
32
+ opts.on( '-c', '--system_coords INTEGER', 'Base of coordinates used in karyotype_file') do |system_coords|
33
+ options[:system_coords] = system_coords.to_i
34
+ end
35
+
36
+ options[:magnitude] = ['1', '1']
37
+ opts.on( '-m', '--magnitude STRING', 'Units:multiplier' ) do |mag|
38
+ options[:magnitude] = mag.split(':')
39
+ end
40
+
41
+ options[:track_length] = 0.06
42
+ opts.on( '-l', '--track_length STRING', 'Length for each data track 0.2,0.4...' ) do |length|
43
+ options[:track_length] = length.split(',').map{|i| i.to_f}
44
+ end
45
+
46
+ options[:histograms] = []
47
+ opts.on( '-t', '--histograms PATHS', 'Paths to data, PATH1;PATH2...' ) do |hist|
48
+ options[:histograms] = hist.split(',')
49
+ end
50
+
51
+ options[:visualization] = []
52
+ opts.on( '-v', '--visualization_track STRING', 'h for histogram, m for heatmap, l for links, s for highlights E.g hmhm' ) do |vis|
53
+ options[:visualization] = vis.split('')
54
+ end
55
+
56
+ options[:heatmap_limits] = nil
57
+ opts.on( '-s', '--heatmap_limits STRING', 'Lower and upper limit for heatmps. Format lower,upper : 0,100' ) do |hl|
58
+ options[:heatmap_limits] = hl.split(',')
59
+ end
60
+
61
+
62
+ # Set a banner, displayed at the top of the help screen.
63
+ opts.banner = "Usage: table_header.rb -t tabulated_file \n\n"
64
+
65
+ # This displays the help screen
66
+ opts.on( '-h', '--help', 'Display this screen' ) do
67
+ puts opts
68
+ exit
69
+ end
70
+
71
+ end # End opts
72
+
73
+ # parse options and remove from ARGV
74
+ optparse.parse!
75
+
76
+ #####################################################################################
77
+ ## MAIN
78
+ ####################################################################################
79
+
80
+ if options[:karyotype_file].nil? || !File.exists?(options[:karyotype_file])
81
+ Process.exit
82
+ end
83
+
84
+ FileUtils.mkdir('data') if !Dir.exists?('data')
85
+ FileUtils.mkdir('etc') if !Dir.exists?('etc')
86
+
87
+ paths = {}
88
+ paths['data_folder'] = File.join(options[:output_folder], 'data')
89
+ paths['etc_folder'] = File.join(options[:output_folder], 'etc')
90
+ paths['templates'] = File.join(File.dirname(__FILE__), '..', 'lib', 'make_circos', 'circos_conf_files')
91
+
92
+ ## GENERATE KARYOTYPE FILE
93
+ sequences= {}
94
+
95
+ File.open(options[:karyotype_file]).each do |line|
96
+ line.chomp!
97
+ fields = line.split("\t")
98
+ name = fields.shift + options[:prefix_label]
99
+ sequences[name] = [fields.first, fields.last].map{|coord| coord.to_i - options[:system_coords]}
100
+ end
101
+
102
+ paths['karyotype_path'] = File.join(paths['data_folder'], options[:karyotype_file]+ '_kar')
103
+ karyotype = File.open(paths['karyotype_path'], 'w')
104
+ count = 1
105
+ sequences.each do |sequence_name, coords|
106
+ karyotype.puts "chr - #{sequence_name} #{sequence_name} #{coords.first} #{coords.last} chr#{count}" # the chr field is used to indicate taht color has de sequence
107
+ count += 1
108
+ end
109
+ karyotype.close
110
+
111
+ ## GENERATE IDEOGRAM FILE
112
+ ideogram_file_template = File.open(File.join(paths['templates'], 'ideogram.conf')).read
113
+ paths['ideogram'] = File.join(paths['etc_folder'], 'ideogram.conf')
114
+ File.open(paths['ideogram'], 'w') {|f| f.write(ideogram_file_template) }
115
+
116
+ ## GENERATE TICKS FILE
117
+ ticks_file_template = File.open(File.join(paths['templates'], 'ticks.conf')).read
118
+ ticks_file_template.gsub!('multiplier = mult', "multiplier = #{options[:magnitude].last}")
119
+ paths['ticks'] = File.join(paths['etc_folder'], 'ticks.conf')
120
+ File.open(paths['ticks'], 'w') {|f| f.write(ticks_file_template) }
121
+
122
+
123
+ ## GENERATE CONF FILE
124
+ conf_file_template = File.open(File.join(paths['templates'], 'circos.conf')).read
125
+ conf_file_template.gsub!("chromosomes_units = units", "chromosomes_units = #{options[:magnitude].first}") #magnitude of units to redeuce de number length
126
+ conf_file_template.gsub!("karyotype = path", "karyotype = #{paths['karyotype_path']}") # karyotype file whith main axis coords
127
+ conf_file_template.gsub!("<<include path_ideogram>>", "<<include #{paths['ideogram']}>>") #ideogram file configures main axis style
128
+ conf_file_template.gsub!("<<include path_ticks>>", "<<include #{paths['ticks']}>>") #ticks file configures the scale style of main axis
129
+ plot_section = ""
130
+ if options[:histograms].length > 0
131
+ plot_section << "<plots>\n" if options[:visualization].include?('h') || options[:visualization].include?('m')
132
+ if options[:track_length].class != Array
133
+ track_length = Array.new(options[:histograms].length, options[:track_length])
134
+ else
135
+ track_length = options[:track_length]
136
+ end
137
+ track_separation = 0.02
138
+ histogram_template = '
139
+ <plot>
140
+ min = 0
141
+ type = visualization_type
142
+ file = DATA_PATH
143
+ r1 = r1_lengthr
144
+ r0 = r0_lengthr
145
+ fill_color = vdgrey
146
+ extend_bin = no
147
+ <backgrounds>
148
+ # Show the backgrounds only for ideograms that have data
149
+ <background>
150
+ color = BACKGROUND_COLOR #vvlgrey
151
+ </background>
152
+
153
+ </backgrounds>
154
+ </plot>
155
+ '
156
+ last_r = 1
157
+ options[:histograms].each_with_index do |data_path, i|
158
+ if options[:visualization][i] == 'h' || options[:visualization][i] == 'm'
159
+ if i == 0
160
+ r1 = 1 - track_separation
161
+ else
162
+ r1 = last_r - track_separation
163
+ end
164
+ r0 = r1 - track_length[i]
165
+ last_r = r0
166
+ data_file_path = File.join(paths['data_folder'], File.basename(data_path))
167
+ FileUtils.cp(data_path, data_file_path)
168
+ custom_track = histogram_template.gsub('DATA_PATH', data_file_path)
169
+ if options[:visualization][i] == 'h'
170
+ visualization_type = 'histogram'
171
+ elsif options[:visualization][i] == 'm'
172
+ #visualization_type = "heatmap\ncolor = spectral-11-div\n"
173
+ visualization_type = "heatmap\ncolor = ylorrd-5-seq-rev\n"
174
+ visualization_type << "min*=#{options[:heatmap_limits].first}\nmax=#{options[:heatmap_limits].last}\n" if options[:heatmap_limits].class == Array
175
+ end
176
+ custom_track.gsub!('visualization_type', visualization_type)
177
+ custom_track.gsub!('r1_length', r1.to_s)
178
+ custom_track.gsub!('r0_length', r0.to_s)
179
+ if i % 2 == 0
180
+ custom_track.gsub!('BACKGROUND_COLOR', '240,240,240')
181
+ else
182
+ custom_track.gsub!('BACKGROUND_COLOR', '227,227,227')
183
+ end
184
+ plot_section << custom_track
185
+ end
186
+ end
187
+ plot_section << "</plots>\n" if options[:visualization].include?('h') || options[:visualization].include?('m')
188
+
189
+ plot_section << "\n<links>"
190
+ link_template= '
191
+ <link>
192
+ file = DATA_PATH
193
+ radius = radius_lengthr
194
+ bezier_radius = 0.1r
195
+ thickness = 4
196
+ </link>
197
+ '
198
+ options[:histograms].each_with_index do |data_path, i|
199
+ next if options[:visualization][i] != 'l'
200
+ data_file_path = File.join(paths['data_folder'], File.basename(data_path))
201
+ FileUtils.cp(data_path, data_file_path)
202
+ custom_track = link_template.gsub('DATA_PATH', data_file_path)
203
+ last_r = last_r - 0.02
204
+ custom_track.gsub!('radius_length', last_r.to_s)
205
+ plot_section << custom_track
206
+ end
207
+ plot_section << "</links>"
208
+ if options[:visualization].include?('s')
209
+ plot_section << "\n\n<highlights>"
210
+
211
+ options[:histograms].each_with_index do |data_path, i|
212
+ next if options[:visualization][i] != 's'
213
+ data_file_path = File.join(paths['data_folder'], File.basename(data_path))
214
+ FileUtils.cp(data_path, data_file_path)
215
+ high= "\n<highlight>\nfile=" + data_file_path
216
+ high << "\nstroke_thickness = 1\nstroke_color = black\n</highlight>\n"
217
+ plot_section << high
218
+ end
219
+ plot_section << "</highlights>"
220
+ end
221
+ end
222
+
223
+ conf_file_template.gsub!("plot_section", plot_section)
224
+ paths['conf'] = File.join(paths['etc_folder'], 'circos.conf')
225
+ File.open(paths['conf'], 'w') {|f| f.write(conf_file_template) }
226
+
227
+
@@ -0,0 +1,36 @@
1
+
2
+ # Chromosome name, size and color definition
3
+ karyotype = path
4
+
5
+ # The <ideogram> block defines the position, size, labels and other
6
+ # properties of the segments on which data are drawn. These segments
7
+ # are usually chromosomes, but can be any integer axis.
8
+
9
+ # The chromosomes_unit value is used as a unit (suffix "u") to shorten
10
+ # values in other parts of the configuration file. Some parameters,
11
+ # such as ideogram and tick spacing, accept "u" suffixes, so instead of
12
+ #
13
+ # spacing = 10000000
14
+ #
15
+ # you can write
16
+ #
17
+ # spacing = 10u
18
+ #
19
+ # See ticks.conf for examples.
20
+
21
+ chromosomes_units = units
22
+
23
+ plot_section
24
+
25
+ <<include path_ideogram>>
26
+
27
+ <<include path_ticks>>
28
+
29
+ <image>
30
+ <<include etc/image.conf>>
31
+ </image>
32
+
33
+ <<include etc/colors_fonts_patterns.conf>>
34
+
35
+ <<include etc/housekeeping.conf>>
36
+
@@ -0,0 +1,27 @@
1
+
2
+ <ideogram>
3
+
4
+ <spacing>
5
+ default = 0.005r
6
+ break = 5r
7
+ </spacing>
8
+
9
+ # Ideogram position, fill and outline
10
+ radius = 0.90r
11
+ thickness = 20p
12
+ fill = yes
13
+ stroke_color = dgrey
14
+ stroke_thickness = 2p
15
+
16
+ # Minimum definition for ideogram labels.
17
+
18
+ show_label = yes
19
+ # see etc/fonts.conf for list of font names
20
+ label_font = default
21
+ label_radius = dims(image,radius) - 60p
22
+ label_size = 30
23
+ label_parallel = yes
24
+
25
+ </ideogram>
26
+
27
+
@@ -0,0 +1,41 @@
1
+ show_ticks = yes
2
+ show_tick_labels = yes
3
+
4
+ <ticks>
5
+ radius = 1r
6
+ color = black
7
+ thickness = 2p
8
+
9
+ # the tick label is derived by multiplying the tick position
10
+ # by 'multiplier' and casting it in 'format':
11
+ #
12
+ # sprintf(format,position*multiplier)
13
+ #
14
+
15
+ multiplier = mult
16
+
17
+ # %d - integer
18
+ # %f - float
19
+ # %.1f - float with one decimal
20
+ # %.2f - float with two decimals
21
+ #
22
+ # for other formats, see http://perldoc.perl.org/functions/sprintf.html
23
+
24
+ format = %d
25
+
26
+ <tick>
27
+ spacing = 5u
28
+ size = 10p
29
+ </tick>
30
+
31
+ <tick>
32
+ spacing = 25u
33
+ size = 15p
34
+ show_label = yes
35
+ label_size = 20p
36
+ label_offset = 10p
37
+ format = %d
38
+ </tick>
39
+
40
+ </ticks>
41
+
@@ -0,0 +1,3 @@
1
+ module MakeCircos
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "make_circos/version"
2
+
3
+ module MakeCircos
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'make_circos/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "make_circos"
8
+ spec.version = MakeCircos::VERSION
9
+ spec.authors = ["Pedro Seoane Zonjic"]
10
+ spec.email = ["seoanezonjic@uma.es"]
11
+ spec.summary = %q{Gem helper to ahndle the CIRCOS suite}
12
+ spec.description = %q{Helper that generate preconfigured conf files of the CIRCOS suite.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: make_circos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pedro Seoane Zonjic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Helper that generate preconfigured conf files of the CIRCOS suite.
42
+ email:
43
+ - seoanezonjic@uma.es
44
+ executables:
45
+ - fasta2kariotype.rb
46
+ - make_circos_configuration.rb
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/fasta2kariotype.rb
56
+ - bin/make_circos_configuration.rb
57
+ - lib/make_circos.rb
58
+ - lib/make_circos/circos_conf_files/circos.conf
59
+ - lib/make_circos/circos_conf_files/ideogram.conf
60
+ - lib/make_circos/circos_conf_files/ticks.conf
61
+ - lib/make_circos/version.rb
62
+ - make_circos.gemspec
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.6.14
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Gem helper to ahndle the CIRCOS suite
87
+ test_files: []