sequence_logo 1.2.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 49b8d62c88fef94b51afe103ca310f00916efdec
4
- data.tar.gz: bd8990d9f2ae74d63a2565152ef5f9a32044c4b2
2
+ SHA256:
3
+ metadata.gz: eaa5c95e4d2e0823719f5a9db61b95e42283fe656b65577cb5fe192df562699c
4
+ data.tar.gz: df60aa00113e82ab99fcd149e53e2c9818004f2a10bf04a543ef4e43746d26e5
5
5
  SHA512:
6
- metadata.gz: d5e46900733670c4e0c50f45f5b839eb71aba62eb9e1998425574d684c3b84c2db38983d51388c1422896e963a92187b1f986230fc6eb5d50ec4bf64eb435eec
7
- data.tar.gz: 51dd020446c145136fad74b845cd6711423439bfa41a3d4cd895b2fb2fbd910f307d175fd83aaeb5d828377bf897c173141ab01a7032e762b25e66f418591f12
6
+ metadata.gz: e4f977a3f7c0a276f3e6468a707153d62f0173f1fc5997606e894936991fb2e02275459799a4657806175ca5f202284975a4822df0807c252362580e49266a78
7
+ data.tar.gz: '068f555ffaabe14d92b472c0ad3e7638f4358d9a1fabfd6b0cd73e0283b0b5eb5cc2f5df38d95597d9bb1c0de3f3a933783a1a2063c1881a12cd54100d09e6a1'
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sequence_logo (1.3.3)
5
+ bioinform (~> 0.3.1)
6
+ rmagick (>= 3.2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ bioinform (0.3.1)
12
+ rmagick (4.1.2)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ sequence_logo!
19
+
20
+ BUNDLED WITH
21
+ 1.17.2
data/README.md CHANGED
@@ -35,10 +35,11 @@ SequenceLogo consists of two tools:
35
35
  * --orientation <direct|revcomp|both> - create logo for a direct, reverse-complement or both orientations of motif
36
36
  * --scheme FOLDER - name of folder containing nucleotide images
37
37
  * --threshold-lines - draw lines on specific levels
38
+ * --output-file - Specify filename for resulting image
38
39
 
39
40
  * Tool **glue_logos** generates a single image of aligned motifs.
40
41
 
41
- ```glue_logos <output file> <file with alignment infos>```
42
+ glue_logos <output file> <file with alignment infos>
42
43
 
43
44
  or
44
45
 
@@ -0,0 +1,14 @@
1
+ FROM ruby:alpine
2
+ RUN apk add --virtual .builddeps --update alpine-sdk curl gzip tar && \
3
+ curl -o ImageMagick-6.9.10-14.tar.gz "http://mirror.checkdomain.de/imagemagick/ImageMagick-6.9.10-14.tar.gz" && \
4
+ tar -zxf ImageMagick-6.9.10-14.tar.gz && \
5
+ apk add --update libgcc libgomp libjpeg-turbo-dev libpng-dev && \
6
+ cd ImageMagick-6.9.10-14 && \
7
+ ./configure && \
8
+ make && \
9
+ make install && \
10
+ gem install rmagick --no-document && \
11
+ apk del .builddeps && \
12
+ cd / && \
13
+ rm -rf ImageMagick-6.9.10-14.tar.gz ImageMagick-6.9.10-14 && \
14
+ rm -rf /var/cache/apk/*
@@ -0,0 +1,8 @@
1
+ FROM ruby:slim
2
+ RUN apt-get update && \
3
+ apt-get install -y ruby build-essential imagemagick libmagickcore-dev libmagickwand-dev pkg-config && \
4
+ gem install rmagick && \
5
+ apt-get purge -y build-essential libmagickcore-dev libmagickwand-dev pkg-config && \
6
+ apt-get autoremove -y && \
7
+ apt-get clean && \
8
+ rm -rf /var/lib/apt/lists/*
@@ -0,0 +1,7 @@
1
+ FROM vorontsovie/rmagick:alpine
2
+ ARG SEQLOGO_VERSION=1.3.2
3
+ RUN gem install sequence_logo -v "$SEQLOGO_VERSION"
4
+ WORKDIR /data
5
+ ENTRYPOINT ["sequence_logo"]
6
+ CMD ["--help"]
7
+ # docker run --rm --mount type=bind,src=$(pwd),dst=/data sequence_logo motif.pcm
@@ -74,7 +74,12 @@ module SequenceLogo
74
74
  else
75
75
  index = letter_index(letter)
76
76
  end
77
- letter_images[index].dup.resize(x_size, y_size)
77
+ letter_clone = letter_images[index].dup
78
+ channels_clone = letter_clone.separate(Magick::AllChannels)
79
+ channels_clone.each{|channel|
80
+ channel.resize!(x_size, y_size)
81
+ }
82
+ channels_clone.combine
78
83
  end
79
84
 
80
85
  def letter_index(letter)
@@ -30,19 +30,19 @@ def make_logo_alignment(aligned_motifs, options)
30
30
  alignment
31
31
  end
32
32
 
33
- def readlines_from_file_or_stdin(argv, options = {})
33
+ def readlines_from_file_or_stdin(argv, from_stdin: , **options)
34
34
  default_options = { source_not_given_msg: 'Specify input data',
35
35
  both_sources_given_msg: 'Specify either file with data or data itself in stdin, not both'}
36
36
  options = default_options.merge(options)
37
- raise options[:both_sources_given_msg] if !argv.empty? && !$stdin.tty?
38
- if !argv.empty?
39
- lines = File.readlines(argv.first)
40
- elsif !$stdin.tty?
41
- lines = $stdin.readlines
37
+ raise ArgumentError, options[:both_sources_given_msg] if from_stdin && !argv.empty?
38
+ raise ArgumentError, options[:source_not_given_msg] if !from_stdin && argv.empty?
39
+ if from_stdin || argv == ['-']
40
+ $stdin.readlines
41
+ elsif argv.length == 1
42
+ File.readlines(argv.first)
42
43
  else
43
- raise ArgumentError, options[:source_not_given_msg]
44
+ raise ArgumentError, 'alignment should either be in stdin or in file, specified by arglist'
44
45
  end
45
- lines
46
46
  end
47
47
 
48
48
  def direct_output_filename(output_file)
@@ -64,7 +64,7 @@ begin
64
64
  Usage:
65
65
  glue_logos <output file> <alignment infos file>
66
66
  or
67
- <alignment infos file> | glue_logos <output file>
67
+ <alignment infos file> | glue_logos <output file> --from-stdin
68
68
 
69
69
  Alignment infos has the following format (tab separated)
70
70
  if motif names not specified - filenames are used as labels:
@@ -78,7 +78,7 @@ begin
78
78
  total_orientation = :direct
79
79
  default_options = { x_unit: 30, y_unit: 60, logo_shift: 300, scheme: 'nucl_simpa',
80
80
  icd_mode: :discrete, threshold_lines: false,
81
- text_size: 24, background_color: 'white' }
81
+ text_size: 24, background_color: 'white', from_stdin: false }
82
82
  cli = SequenceLogo::CLI.new(default_options)
83
83
  cli.instance_eval do
84
84
  parser.banner = doc
@@ -101,13 +101,18 @@ begin
101
101
  options[:background_fill] = Magick::SolidFill.new(v)
102
102
  end
103
103
  end
104
+
105
+ parser.on('--from-stdin') do
106
+ options[:from_stdin] = true
107
+ end
104
108
  end
105
109
  options = cli.parse_options!(argv)
106
110
 
107
111
  output_file = argv.shift
108
112
  raise ArgumentError, 'Specify output file' unless output_file
109
113
 
110
- alignment_lines = readlines_from_file_or_stdin(argv, source_not_given_msg: 'Specify alignment infos',
114
+ alignment_lines = readlines_from_file_or_stdin(argv, from_stdin: options[:from_stdin],
115
+ source_not_given_msg: 'Specify alignment infos',
111
116
  both_sources_given_msg: 'You can specify alignment infos either from file or from stdin. Don\'t use both sources simultaneously')
112
117
  alignment = make_logo_alignment(load_alignment_infos(alignment_lines), options)
113
118
 
@@ -16,9 +16,9 @@ def in_necessary_orientations(objects_to_render, orientation, logo_folder)
16
16
  end.flatten
17
17
  end
18
18
 
19
- def arglist_augmented_with_stdin(argv)
19
+ def arglist_augmented_with_stdin(argv, from_stdin:)
20
20
  result = argv
21
- result += $stdin.read.shellsplit unless $stdin.tty?
21
+ result += $stdin.read.shellsplit if from_stdin
22
22
  result
23
23
  end
24
24
 
@@ -35,7 +35,7 @@ begin
35
35
  Usage:
36
36
  sequence_logo [options] <motif file>...
37
37
  or
38
- ls pcm_folder/*.pcm | sequence_logo [options]
38
+ ls pcm_folder/*.pcm | sequence_logo --from-stdin [options]
39
39
  or
40
40
  sequence_logo --sequence <sequence>...
41
41
  or
@@ -47,7 +47,7 @@ begin
47
47
  default_options = { x_unit: 30, y_unit: 60, scheme: 'nucl_simpa',
48
48
  orientation: :direct, icd_mode: :discrete, threshold_lines: true,
49
49
  logo_folder: '.', background_color: 'white',
50
- from_dinucleotide: false }
50
+ from_dinucleotide: false, from_stdin: false }
51
51
  cli = SequenceLogo::CLI.new(default_options)
52
52
  cli.instance_eval do
53
53
  parser.banner = doc
@@ -73,6 +73,13 @@ begin
73
73
  options[:background_fill] = Magick::SolidFill.new(v)
74
74
  end
75
75
  end
76
+ parser.on('--from-stdin') {
77
+ options[:from_stdin] = true
78
+ }
79
+
80
+ parser.on('--output-file FILE', 'Resulting image name') {|fn|
81
+ options[:output_file] = fn
82
+ }
76
83
 
77
84
  parser.on('--dinucleotide'){ options[:from_dinucleotide] = true }
78
85
  end
@@ -90,7 +97,7 @@ begin
90
97
 
91
98
  objects_to_render = []
92
99
  if options[:sequence]
93
- sequences = arglist_augmented_with_stdin(argv)
100
+ sequences = arglist_augmented_with_stdin(argv, from_stdin: options[:from_stdin])
94
101
  raise ArgumentError, 'Specify at least one sequence' if sequences.empty?
95
102
 
96
103
  sequences.each do |sequence|
@@ -98,7 +105,7 @@ begin
98
105
  name: File.join(logo_folder, sequence)}
99
106
  end
100
107
  elsif options[:sequence_w_snp]
101
- sequences = arglist_augmented_with_stdin(argv)
108
+ sequences = arglist_augmented_with_stdin(argv, from_stdin: options[:from_stdin])
102
109
  raise ArgumentError, 'Specify at least one sequence' if sequences.empty?
103
110
 
104
111
  sequences.each do |sequence_w_snp|
@@ -106,7 +113,7 @@ begin
106
113
  name: File.join(logo_folder, sequence_w_snp.gsub(/[\[\]\/]/, '_'))}
107
114
  end
108
115
  else
109
- filenames = arglist_augmented_with_stdin(argv)
116
+ filenames = arglist_augmented_with_stdin(argv, from_stdin: options[:from_stdin])
110
117
  raise ArgumentError, 'Specify at least one motif file' if filenames.empty?
111
118
 
112
119
  filenames.each do |filename|
@@ -123,8 +130,16 @@ begin
123
130
  end
124
131
  end
125
132
 
133
+ if options[:output_file]
134
+ if objects_to_render.size == 1
135
+ objects_to_render.first[:name] = options[:output_file].sub(/.png$/i, '') # force name
136
+ else
137
+ raise 'When output file is specified, the only one logo can be rendered'
138
+ end
139
+ end
140
+
126
141
  in_necessary_orientations(objects_to_render, options[:orientation], logo_folder).each do |infos|
127
- filename = File.join(logo_folder, infos[:filename])
142
+ filename = File.absolute_path(infos[:filename], logo_folder)
128
143
  infos[:renderable].render(canvas_factory).write("PNG:#{filename}")
129
144
  end
130
145
  rescue => err
@@ -1,3 +1,3 @@
1
1
  module SequenceLogo
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.3"
3
3
  end
@@ -3,7 +3,7 @@ require File.expand_path('../lib/sequence_logo/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Ilya Vorontsov"]
6
- gem.email = ["prijutme4ty@gmail.com"]
6
+ gem.email = ["vorontsov.i.e@gmail.com"]
7
7
  gem.description = %q{SequenceLogo is a tool for drawing sequence logos of motifs. It gets Positional Count Matrices(PCMs) or IUPAC sequences as input and generates png-logos for a motif. Also one can create logo for reverse complement or even generate logos for a whole collection of motifs.
8
8
  Sequence logos are a graphical representation of an amino acid or nucleic acid multiple sequence alignment developed by Tom Schneider and Mike Stephens. Each logo consists of stacks of symbols, one stack for each position in the sequence. The overall height of the stack indicates the sequence conservation at that position, while the height of symbols within the stack indicates the relative frequency of each amino or nucleic acid at that position. In general, a sequence logo provides a richer and more precise description of, for example, a binding site, than would a consensus sequence (see http://weblogo.berkeley.edu/)
9
9
  }
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
  gem.version = SequenceLogo::VERSION
19
19
 
20
- gem.add_dependency('rmagick', '~> 2.13')
20
+ gem.add_dependency('rmagick', '>= 3.2.0')
21
21
  gem.add_dependency('bioinform', '~> 0.3.1')
22
22
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequence_logo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Vorontsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-22 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.13'
19
+ version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.13'
26
+ version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bioinform
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ description: |
42
42
  SequenceLogo is a tool for drawing sequence logos of motifs. It gets Positional Count Matrices(PCMs) or IUPAC sequences as input and generates png-logos for a motif. Also one can create logo for reverse complement or even generate logos for a whole collection of motifs.
43
43
  Sequence logos are a graphical representation of an amino acid or nucleic acid multiple sequence alignment developed by Tom Schneider and Mike Stephens. Each logo consists of stacks of symbols, one stack for each position in the sequence. The overall height of the stack indicates the sequence conservation at that position, while the height of symbols within the stack indicates the relative frequency of each amino or nucleic acid at that position. In general, a sequence logo provides a richer and more precise description of, for example, a binding site, than would a consensus sequence (see http://weblogo.berkeley.edu/)
44
44
  email:
45
- - prijutme4ty@gmail.com
45
+ - vorontsov.i.e@gmail.com
46
46
  executables:
47
47
  - glue_logos
48
48
  - sequence_logo
@@ -51,12 +51,16 @@ extra_rdoc_files: []
51
51
  files:
52
52
  - ".gitignore"
53
53
  - Gemfile
54
+ - Gemfile.lock
54
55
  - LICENSE
55
56
  - README.md
56
57
  - Rakefile
57
58
  - TODO.txt
58
59
  - bin/glue_logos
59
60
  - bin/sequence_logo
61
+ - docker/Dockerfile-rmagick-alpine
62
+ - docker/Dockerfile-rmagick-slim
63
+ - docker/Dockerfile-sequence_logo
60
64
  - lib/sequence_logo.rb
61
65
  - lib/sequence_logo/alignment.rb
62
66
  - lib/sequence_logo/assets/nucl_simpa/a.png
@@ -117,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
121
  - !ruby/object:Gem::Version
118
122
  version: '0'
119
123
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.5.1
124
+ rubygems_version: 3.0.3
122
125
  signing_key:
123
126
  specification_version: 4
124
127
  summary: Tool for drawing sequence logos of motifs