bioinform 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/Gemfile +16 -16
- data/LICENSE +21 -21
- data/README.md +35 -35
- data/Rakefile +4 -4
- data/TODO.txt +37 -37
- data/bin/merge_into_collection +3 -3
- data/bin/pcm2pwm +3 -3
- data/bin/split_motifs +3 -3
- data/bioinform.gemspec +19 -19
- data/lib/bioinform/cli/convert_motif.rb +107 -107
- data/lib/bioinform/cli/merge_into_collection.rb +79 -79
- data/lib/bioinform/cli/pcm2pwm.rb +46 -46
- data/lib/bioinform/cli/split_motifs.rb +46 -46
- data/lib/bioinform/cli.rb +29 -29
- data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +18 -18
- data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +19 -19
- data/lib/bioinform/data_models/collection.rb +74 -74
- data/lib/bioinform/data_models/motif.rb +55 -55
- data/lib/bioinform/data_models/pcm.rb +23 -23
- data/lib/bioinform/data_models/pm.rb +169 -169
- data/lib/bioinform/data_models/ppm.rb +9 -9
- data/lib/bioinform/data_models/pwm.rb +55 -55
- data/lib/bioinform/data_models.rb +10 -10
- data/lib/bioinform/formatters/raw_formatter.rb +40 -40
- data/lib/bioinform/formatters/transfac_formatter.rb +38 -38
- data/lib/bioinform/formatters.rb +1 -1
- data/lib/bioinform/parsers/jaspar_parser.rb +34 -34
- data/lib/bioinform/parsers/parser.rb +87 -87
- data/lib/bioinform/parsers/splittable_parser.rb +56 -56
- data/lib/bioinform/parsers/string_fantom_parser.rb +34 -34
- data/lib/bioinform/parsers/string_parser.rb +71 -71
- data/lib/bioinform/parsers/trivial_parser.rb +33 -33
- data/lib/bioinform/parsers/yaml_parser.rb +34 -34
- data/lib/bioinform/parsers.rb +6 -6
- data/lib/bioinform/support/array_product.rb +5 -5
- data/lib/bioinform/support/array_zip.rb +5 -5
- data/lib/bioinform/support/collect_hash.rb +6 -6
- data/lib/bioinform/support/deep_dup.rb +4 -4
- data/lib/bioinform/support/delete_many.rb +13 -13
- data/lib/bioinform/support/inverf.rb +12 -12
- data/lib/bioinform/support/multiline_squish.rb +5 -5
- data/lib/bioinform/support/parameters.rb +27 -27
- data/lib/bioinform/support/partial_sums.rb +15 -15
- data/lib/bioinform/support/same_by.rb +12 -12
- data/lib/bioinform/support/strip_doc.rb +8 -8
- data/lib/bioinform/support/third_part/active_support/hash_with_indifferent_access.rb +3 -0
- data/lib/bioinform/support.rb +17 -17
- data/lib/bioinform/version.rb +3 -3
- data/lib/bioinform.rb +10 -10
- data/spec/cli/cli_spec.rb +13 -13
- data/spec/cli/convert_motif_spec.rb +106 -106
- data/spec/cli/data/merge_into_collection/GABPA_f1.pwm +14 -14
- data/spec/cli/data/merge_into_collection/KLF4_f2.pwm +11 -11
- data/spec/cli/data/merge_into_collection/SP1_f1.pwm +12 -12
- data/spec/cli/data/merge_into_collection/collection.txt.result +40 -40
- data/spec/cli/data/merge_into_collection/collection.yaml.result +188 -188
- data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +188 -188
- data/spec/cli/data/merge_into_collection/pwm_folder/GABPA_f1.pwm +14 -14
- data/spec/cli/data/merge_into_collection/pwm_folder/KLF4_f2.pwm +11 -11
- data/spec/cli/data/merge_into_collection/pwm_folder/SP1_f1.pwm +12 -12
- data/spec/cli/data/pcm2pwm/KLF4 f2 spaced name.pcm +11 -11
- data/spec/cli/data/pcm2pwm/KLF4_f2.pcm +11 -11
- data/spec/cli/data/pcm2pwm/KLF4_f2.pwm.result +11 -11
- data/spec/cli/data/pcm2pwm/SP1_f1.pcm +12 -12
- data/spec/cli/data/pcm2pwm/SP1_f1.pwm.result +12 -12
- data/spec/cli/data/split_motifs/GABPA_f1.mat.result +14 -14
- data/spec/cli/data/split_motifs/KLF4_f2.mat.result +11 -11
- data/spec/cli/data/split_motifs/SP1_f1.mat.result +12 -12
- data/spec/cli/data/split_motifs/collection.yaml +188 -188
- data/spec/cli/data/split_motifs/plain_collection.txt +38 -38
- data/spec/cli/merge_into_collection_spec.rb +99 -99
- data/spec/cli/pcm2pwm_spec.rb +79 -79
- data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +17 -17
- data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +14 -14
- data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +49 -49
- data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +4 -4
- data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +3 -3
- data/spec/cli/split_motifs_spec.rb +76 -76
- data/spec/data_models/collection_spec.rb +97 -97
- data/spec/data_models/motif_spec.rb +223 -223
- data/spec/data_models/pcm_spec.rb +55 -55
- data/spec/data_models/pm_spec.rb +359 -359
- data/spec/data_models/ppm_spec.rb +7 -7
- data/spec/data_models/pwm_spec.rb +82 -82
- data/spec/fabricators/collection_fabricator.rb +7 -7
- data/spec/fabricators/motif_fabricator.rb +32 -32
- data/spec/fabricators/motif_formats_fabricator.rb +124 -124
- data/spec/fabricators/pcm_fabricator.rb +24 -24
- data/spec/fabricators/pm_fabricator.rb +51 -51
- data/spec/fabricators/ppm_fabricator.rb +13 -13
- data/spec/fabricators/pwm_fabricator.rb +16 -16
- data/spec/parsers/parser_spec.rb +152 -152
- data/spec/parsers/string_fantom_parser_spec.rb +69 -69
- data/spec/parsers/string_parser_spec.rb +76 -76
- data/spec/parsers/trivial_parser_spec.rb +63 -63
- data/spec/parsers/yaml_parser_spec.rb +50 -50
- data/spec/spec_helper.rb +10 -10
- data/spec/spec_helper_source.rb +59 -59
- data/spec/support/advanced_scan_spec.rb +31 -31
- data/spec/support/array_product_spec.rb +14 -14
- data/spec/support/array_zip_spec.rb +14 -14
- data/spec/support/collect_hash_spec.rb +14 -14
- data/spec/support/delete_many_spec.rb +43 -43
- data/spec/support/inverf_spec.rb +18 -18
- data/spec/support/multiline_squish_spec.rb +24 -24
- data/spec/support/partial_sums_spec.rb +30 -30
- data/spec/support/same_by_spec.rb +35 -35
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87a54b5aaa1e53b6b097f041616b7f80db6c7418
|
4
|
+
data.tar.gz: 4978a977e8e9d60c26bcd680aaa4a7defc11b80d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b70dcd8272b784de1a6ba31d162520bd2e11ac15f9b48383b0202a8669667a3b2021a314b7c885e5e3662fd12b4b9646033c4b789ed9672235d98120e5ebded6
|
7
|
+
data.tar.gz: 3bc6c2d508bbab0e9853282442358aa42d3d3b1dd51dcacc635da490b81778f27578afaf368946411cf3ec45ee2ff1cc86a253737a0ebcbd6f1f6d526f247cfa
|
data/.gitignore
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
*.log
|
2
|
-
*.gem
|
3
|
-
*.rbc
|
4
|
-
.bundle
|
5
|
-
.config
|
6
|
-
.yardoc
|
7
|
-
Gemfile.lock
|
8
|
-
InstalledFiles
|
9
|
-
_yardoc
|
10
|
-
coverage
|
11
|
-
doc/
|
12
|
-
lib/bundler/man
|
13
|
-
pkg
|
14
|
-
rdoc
|
15
|
-
spec/reports
|
16
|
-
test/tmp
|
17
|
-
test/version_tmp
|
1
|
+
*.log
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
18
|
tmp
|
data/Gemfile
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in bioinform.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
|
7
|
-
group :development do
|
8
|
-
# gem 'win32console'
|
9
|
-
gem 'rspec', '>= 2.0'
|
10
|
-
gem 'fabrication', '~> 2.5.0'
|
11
|
-
gem 'rspec-given', '>= 2.0.0'
|
12
|
-
gem 'spork', '>= 0.9.2'
|
13
|
-
gem 'fakefs', '~> 0.4.2'
|
14
|
-
gem 'wdm', :require => false
|
15
|
-
gem 'guard-rspec', '>=2.1.0'
|
16
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in bioinform.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
# gem 'win32console'
|
9
|
+
gem 'rspec', '>= 2.0'
|
10
|
+
gem 'fabrication', '~> 2.5.0'
|
11
|
+
gem 'rspec-given', '>= 2.0.0'
|
12
|
+
gem 'spork', '>= 0.9.2'
|
13
|
+
gem 'fakefs', '~> 0.4.2'
|
14
|
+
gem 'wdm', :require => false
|
15
|
+
gem 'guard-rspec', '>=2.1.0'
|
16
|
+
end
|
data/LICENSE
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2012 Ilya Vorontsov
|
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
|
1
|
+
Copyright (c) 2012 Ilya Vorontsov
|
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
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
# Bioinform
|
2
|
-
Bioinform is a bunch of classes extracted from daily bioinformatics work. This classes is an attempt to encapsulate loading(parsing) logic for positional matrices in different formats and common transformations. It also includes several core classes extensions which are particularly useful on Enumerables
|
3
|
-
|
4
|
-
Bioinform is in its development phase. API is changing very quickly. Each version is tested and consistent but no one guarantees that code worked in your version will work in future versions. However last version of bioinform is always consistent with latest version of macroape, and cli-tools that're built on top of libraries changes their interface not so often, so you can use them thinking about library as about black-box that makes able to do some useful things
|
5
|
-
|
6
|
-
## Installation
|
7
|
-
|
8
|
-
Add this line to your application's Gemfile:
|
9
|
-
|
10
|
-
gem 'bioinform'
|
11
|
-
|
12
|
-
And then execute:
|
13
|
-
|
14
|
-
$ bundle
|
15
|
-
|
16
|
-
Or install it yourself as:
|
17
|
-
|
18
|
-
$ gem install bioinform
|
19
|
-
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
Usage is under construction. I don't recommend use this gem for a while: syntax is on the way to change to more simple and concise. But stay tuned
|
23
|
-
|
24
|
-
### Command-line applications
|
25
|
-
* pcm2pwm
|
26
|
-
* split_motifs
|
27
|
-
* merge_into_collection
|
28
|
-
|
29
|
-
## Contributing
|
30
|
-
|
31
|
-
1. Fork it
|
32
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
-
5. Create new Pull Request
|
1
|
+
# Bioinform
|
2
|
+
Bioinform is a bunch of classes extracted from daily bioinformatics work. This classes is an attempt to encapsulate loading(parsing) logic for positional matrices in different formats and common transformations. It also includes several core classes extensions which are particularly useful on Enumerables
|
3
|
+
|
4
|
+
Bioinform is in its development phase. API is changing very quickly. Each version is tested and consistent but no one guarantees that code worked in your version will work in future versions. However last version of bioinform is always consistent with latest version of macroape, and cli-tools that're built on top of libraries changes their interface not so often, so you can use them thinking about library as about black-box that makes able to do some useful things
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'bioinform'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install bioinform
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Usage is under construction. I don't recommend use this gem for a while: syntax is on the way to change to more simple and concise. But stay tuned
|
23
|
+
|
24
|
+
### Command-line applications
|
25
|
+
* pcm2pwm
|
26
|
+
* split_motifs
|
27
|
+
* merge_into_collection
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
require "bundler/gem_tasks"
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
5
|
RSpec::Core::RakeTask.new
|
data/TODO.txt
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
! Make matrices immutable - it will allow more safe interface and better caching
|
2
|
-
|
3
|
-
Collection contain Motif-s, each Motif can contain any of list: pcm,pwm,ppm.
|
4
|
-
Name, background, tags and any other parameters should be removed from PM class to be placed in Motif
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
ToDo:
|
9
|
-
how to make PM#equal? and PM#hash so that using PMs in Sets wouldn't destroy comparability of Sets and two sets with the same PMs(but different objects) would be equal. (also using pm as a hash-key)
|
10
|
-
Make specs and fix code in such a way that Parser.split_on_motifs and so on returned consistent result. E.g. Parser.parse! raised an error on multiple times invocation
|
11
|
-
|
12
|
-
refactor CLI::SplitMotifs in place where it splits collection file and choose real data models or makes PM
|
13
|
-
|
14
|
-
Make Collection convenient way to store both pwm and pcm for a single motif (may be both should be in parameters of motif?). Also make methods like sort! that can change collection inner structure without working with @collection-variable directly. For example collection.sort!{|a,b| a.length<=>b.length} (here sort yielded only motif, but now it yields both motif and infos - it's inconvenient)
|
15
|
-
|
16
|
-
Make parser exception print out text where parsing was broken (processing line +- 2 nearest lines and command and line numbers)
|
17
|
-
Prevent parser going into infinity loop
|
18
|
-
|
19
|
-
Create CLI-apps:
|
20
|
-
-- to merge many files(or whole folder) to a Collection (in a way that makes able to give collection a name)
|
21
|
-
|
22
|
-
Make Parsers to be switcheable in runtime so that one could parse string composed of two motifs in different formats.
|
23
|
-
|
24
|
-
Decide:
|
25
|
-
-- Whether PPM should have `words_count`/`weight`?
|
26
|
-
PPM format such that parser got both matrix and count (if PPM have `word_count`)
|
27
|
-
-- can_parse?
|
28
|
-
-- Whether to cache suffices: cache :best_suffix, obsolete: [:discrete!, :background!, ...]
|
29
|
-
-- behaviour of PM#== for PMs with different tags
|
30
|
-
-- should background be in PM by default?
|
31
|
-
-- refactor PM.new #== and so on to make possible consistently introduce or remove a variable at a single line
|
32
|
-
-- Make PCM#valid? and PPM#valid? more specific. This shouldn't destroy functionality to load arbitrary data as matrix, but only in force mode (I don't understand yet where should it be: in a constructor or where? And which validation-"severity" levels should be? Strong validation - size-only-validation - size-and-type-validation - no validation ??? or may be options: valid_strictness: 'strict', 'usual', 'strict_with_name' ??? It should be considered)
|
33
|
-
-- PM#to_pcm and friends have unintuitive behavior. E.g. pm.to_pcm.to_pwm != pm.to_pwm First is matrix treated as pcm and then converted, while second is matrix treated as pwm from start
|
34
|
-
-- Should parser be reloadable or not? May be delete #reset_scanner?
|
35
|
-
-- Should Collection has infos for each motif if it already has parameters? (see also discussion above about Collection#sort! and so on)
|
36
|
-
|
37
|
-
Specs
|
1
|
+
! Make matrices immutable - it will allow more safe interface and better caching
|
2
|
+
|
3
|
+
Collection contain Motif-s, each Motif can contain any of list: pcm,pwm,ppm.
|
4
|
+
Name, background, tags and any other parameters should be removed from PM class to be placed in Motif
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
ToDo:
|
9
|
+
how to make PM#equal? and PM#hash so that using PMs in Sets wouldn't destroy comparability of Sets and two sets with the same PMs(but different objects) would be equal. (also using pm as a hash-key)
|
10
|
+
Make specs and fix code in such a way that Parser.split_on_motifs and so on returned consistent result. E.g. Parser.parse! raised an error on multiple times invocation
|
11
|
+
|
12
|
+
refactor CLI::SplitMotifs in place where it splits collection file and choose real data models or makes PM
|
13
|
+
|
14
|
+
Make Collection convenient way to store both pwm and pcm for a single motif (may be both should be in parameters of motif?). Also make methods like sort! that can change collection inner structure without working with @collection-variable directly. For example collection.sort!{|a,b| a.length<=>b.length} (here sort yielded only motif, but now it yields both motif and infos - it's inconvenient)
|
15
|
+
|
16
|
+
Make parser exception print out text where parsing was broken (processing line +- 2 nearest lines and command and line numbers)
|
17
|
+
Prevent parser going into infinity loop
|
18
|
+
|
19
|
+
Create CLI-apps:
|
20
|
+
-- to merge many files(or whole folder) to a Collection (in a way that makes able to give collection a name)
|
21
|
+
|
22
|
+
Make Parsers to be switcheable in runtime so that one could parse string composed of two motifs in different formats.
|
23
|
+
|
24
|
+
Decide:
|
25
|
+
-- Whether PPM should have `words_count`/`weight`?
|
26
|
+
PPM format such that parser got both matrix and count (if PPM have `word_count`)
|
27
|
+
-- can_parse?
|
28
|
+
-- Whether to cache suffices: cache :best_suffix, obsolete: [:discrete!, :background!, ...]
|
29
|
+
-- behaviour of PM#== for PMs with different tags
|
30
|
+
-- should background be in PM by default?
|
31
|
+
-- refactor PM.new #== and so on to make possible consistently introduce or remove a variable at a single line
|
32
|
+
-- Make PCM#valid? and PPM#valid? more specific. This shouldn't destroy functionality to load arbitrary data as matrix, but only in force mode (I don't understand yet where should it be: in a constructor or where? And which validation-"severity" levels should be? Strong validation - size-only-validation - size-and-type-validation - no validation ??? or may be options: valid_strictness: 'strict', 'usual', 'strict_with_name' ??? It should be considered)
|
33
|
+
-- PM#to_pcm and friends have unintuitive behavior. E.g. pm.to_pcm.to_pwm != pm.to_pwm First is matrix treated as pcm and then converted, while second is matrix treated as pwm from start
|
34
|
+
-- Should parser be reloadable or not? May be delete #reset_scanner?
|
35
|
+
-- Should Collection has infos for each motif if it already has parameters? (see also discussion above about Collection#sort! and so on)
|
36
|
+
|
37
|
+
Specs
|
38
38
|
-- PWM#probabilities, #score_variance, #gauss_estimation
|
data/bin/merge_into_collection
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../lib/bioinform/cli/merge_into_collection'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/bioinform/cli/merge_into_collection'
|
4
4
|
Bioinform::CLI::MergeIntoCollection.main(ARGV)
|
data/bin/pcm2pwm
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../lib/bioinform/cli/pcm2pwm'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/bioinform/cli/pcm2pwm'
|
4
4
|
Bioinform::CLI::PCM2PWM.main(ARGV)
|
data/bin/split_motifs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../lib/bioinform/cli/split_motifs'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require_relative '../lib/bioinform/cli/split_motifs'
|
4
4
|
Bioinform::CLI::SplitMotifs.main(ARGV)
|
data/bioinform.gemspec
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/bioinform/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Ilya Vorontsov"]
|
6
|
-
gem.email = ["prijutme4ty@gmail.com"]
|
7
|
-
gem.description = %q{A bunch of useful classes for bioinformatics}
|
8
|
-
gem.summary = %q{Classes for work with different input formats of positional matrices and IUPAC-words and making simple transform and statistics with them. Also module includes several useful extensions for Enumerable module like parametric map and callable symbols }
|
9
|
-
gem.homepage = ""
|
10
|
-
|
11
|
-
gem.files = `git ls-files`.split($/)
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
-
gem.name = "bioinform"
|
15
|
-
gem.require_paths = ["lib"]
|
16
|
-
gem.version = Bioinform::VERSION
|
17
|
-
|
18
|
-
gem.add_dependency('docopt', '= 0.5.0')
|
19
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/bioinform/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Ilya Vorontsov"]
|
6
|
+
gem.email = ["prijutme4ty@gmail.com"]
|
7
|
+
gem.description = %q{A bunch of useful classes for bioinformatics}
|
8
|
+
gem.summary = %q{Classes for work with different input formats of positional matrices and IUPAC-words and making simple transform and statistics with them. Also module includes several useful extensions for Enumerable module like parametric map and callable symbols }
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($/)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "bioinform"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Bioinform::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('docopt', '= 0.5.0')
|
19
|
+
end
|
@@ -1,108 +1,108 @@
|
|
1
|
-
require_relative '../../bioinform'
|
2
|
-
require 'optparse'
|
3
|
-
|
4
|
-
require 'logger'
|
5
|
-
$logger = Logger.new('convert_motif.log')
|
6
|
-
|
7
|
-
module Bioinform
|
8
|
-
module CLI
|
9
|
-
class ConvertMotif
|
10
|
-
|
11
|
-
def arguments
|
12
|
-
@arguments ||= []
|
13
|
-
end
|
14
|
-
def options
|
15
|
-
@options ||= {}
|
16
|
-
end
|
17
|
-
|
18
|
-
def main(argv)
|
19
|
-
parse!(argv, filename_format: './{name}.{ext}')
|
20
|
-
motif_files = arguments
|
21
|
-
motif_files += $stdin.read.shellsplit unless $stdin.tty?
|
22
|
-
if motif_files.empty?
|
23
|
-
puts option_parser.help()
|
24
|
-
return
|
25
|
-
end
|
26
|
-
|
27
|
-
output_motifs = []
|
28
|
-
motifs = motif_files.map do |filename|
|
29
|
-
case options[:model_from]
|
30
|
-
when 'pwm'
|
31
|
-
PWM.new(File.read(filename))
|
32
|
-
when 'pcm'
|
33
|
-
PCM.new(File.read(filename))
|
34
|
-
when 'ppm'
|
35
|
-
PPM.new(File.read(filename))
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
motifs.each do |motif|
|
40
|
-
begin
|
41
|
-
case options[:model_to]
|
42
|
-
when 'pwm'
|
43
|
-
output_motifs << motif.to_pwm
|
44
|
-
when 'pcm'
|
45
|
-
output_motifs << motif.to_pcm
|
46
|
-
when 'ppm'
|
47
|
-
output_motifs << motif.to_ppm
|
48
|
-
end
|
49
|
-
rescue
|
50
|
-
$stderr.puts "One can't convert from #{options[:model_from]} data-model to #{options[:model_to]} data-model"
|
51
|
-
raise
|
52
|
-
end
|
53
|
-
end
|
54
|
-
puts output_motifs.join("\n\n")
|
55
|
-
rescue
|
56
|
-
$stderr.puts "Error! Conversion wasn't performed"
|
57
|
-
end
|
58
|
-
|
59
|
-
def option_parser
|
60
|
-
@option_parser ||= OptionParser.new do |cli|
|
61
|
-
banner = <<-BANNER
|
62
|
-
Usage:
|
63
|
-
convert_motif [options] <motif-files>...
|
64
|
-
ls | convert_motif [options]
|
65
|
-
|
66
|
-
convert_motif - tool for converting motifs from different input formats
|
67
|
-
to different output formats.
|
68
|
-
It can change both formatting style and motif models.
|
69
|
-
Resulting model is sent to stdout (this can be overriden with --save option).
|
70
|
-
BANNER
|
71
|
-
|
72
|
-
cli.summary_indent = ''
|
73
|
-
cli.banner = strip_doc(banner)
|
74
|
-
cli.separator ""
|
75
|
-
cli.separator "Options:"
|
76
|
-
cli.on('--parser PARSER', 'Parser for input motif.'){|parser| options[:parser] = parser}
|
77
|
-
cli.on('--formatter FORMATTER', 'Formatter for output motif.'){|formatter| options[:formatter] = formatter}
|
78
|
-
cli.on('--from MODEL_OF_INPUT', 'Specify motif model of input.',
|
79
|
-
'It can be overriden by --parser option',
|
80
|
-
'(when parser implies certain input model)'){|model_from| options[:model_from] = model_from}
|
81
|
-
cli.on('--to MODEL_OF_OUTPUT', 'Specify motif model to convert to.',
|
82
|
-
'It can be overriden by --formatter option',
|
83
|
-
'(when formatter implies certain output model)'){|model_to| options[:model_to] = model_to}
|
84
|
-
cli.on('--algorithm ALGORITHM', 'Conversion algorithm to transform model.'){|conversion_algorithm| options[:conversion_algorithm] = conversion_algorithm}
|
85
|
-
cli.on('--save [FILENAME_FORMAT]', 'Save resulting motifs to according files.',
|
86
|
-
'filename format by default is ' + options[:filename_format],
|
87
|
-
'one can specify output folder here',
|
88
|
-
'{name} is a placeholder for motif name',
|
89
|
-
'{ext} is a placeholder for motif model') {|filename_format| options[:filename_format] = filename_format if filename_format}
|
90
|
-
cli.on('--[no-]force', 'Overwrite existing files.'){|force| options[:force] = force}
|
91
|
-
cli.on('--[no-]silent', 'Suppress error messages and notifications.'){|silent| options[:silent] = silent}
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def parse!(argv, default_options = {})
|
96
|
-
@options = default_options.dup
|
97
|
-
option_parser.parse!(argv)
|
98
|
-
@arguments = argv
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def self.main(argv)
|
103
|
-
self.new.main(argv)
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|
1
|
+
require_relative '../../bioinform'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
require 'logger'
|
5
|
+
$logger = Logger.new('convert_motif.log')
|
6
|
+
|
7
|
+
module Bioinform
|
8
|
+
module CLI
|
9
|
+
class ConvertMotif
|
10
|
+
|
11
|
+
def arguments
|
12
|
+
@arguments ||= []
|
13
|
+
end
|
14
|
+
def options
|
15
|
+
@options ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def main(argv)
|
19
|
+
parse!(argv, filename_format: './{name}.{ext}')
|
20
|
+
motif_files = arguments
|
21
|
+
motif_files += $stdin.read.shellsplit unless $stdin.tty?
|
22
|
+
if motif_files.empty?
|
23
|
+
puts option_parser.help()
|
24
|
+
return
|
25
|
+
end
|
26
|
+
|
27
|
+
output_motifs = []
|
28
|
+
motifs = motif_files.map do |filename|
|
29
|
+
case options[:model_from]
|
30
|
+
when 'pwm'
|
31
|
+
PWM.new(File.read(filename))
|
32
|
+
when 'pcm'
|
33
|
+
PCM.new(File.read(filename))
|
34
|
+
when 'ppm'
|
35
|
+
PPM.new(File.read(filename))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
motifs.each do |motif|
|
40
|
+
begin
|
41
|
+
case options[:model_to]
|
42
|
+
when 'pwm'
|
43
|
+
output_motifs << motif.to_pwm
|
44
|
+
when 'pcm'
|
45
|
+
output_motifs << motif.to_pcm
|
46
|
+
when 'ppm'
|
47
|
+
output_motifs << motif.to_ppm
|
48
|
+
end
|
49
|
+
rescue
|
50
|
+
$stderr.puts "One can't convert from #{options[:model_from]} data-model to #{options[:model_to]} data-model"
|
51
|
+
raise
|
52
|
+
end
|
53
|
+
end
|
54
|
+
puts output_motifs.join("\n\n")
|
55
|
+
rescue
|
56
|
+
$stderr.puts "Error! Conversion wasn't performed"
|
57
|
+
end
|
58
|
+
|
59
|
+
def option_parser
|
60
|
+
@option_parser ||= OptionParser.new do |cli|
|
61
|
+
banner = <<-BANNER
|
62
|
+
Usage:
|
63
|
+
convert_motif [options] <motif-files>...
|
64
|
+
ls | convert_motif [options]
|
65
|
+
|
66
|
+
convert_motif - tool for converting motifs from different input formats
|
67
|
+
to different output formats.
|
68
|
+
It can change both formatting style and motif models.
|
69
|
+
Resulting model is sent to stdout (this can be overriden with --save option).
|
70
|
+
BANNER
|
71
|
+
|
72
|
+
cli.summary_indent = ''
|
73
|
+
cli.banner = strip_doc(banner)
|
74
|
+
cli.separator ""
|
75
|
+
cli.separator "Options:"
|
76
|
+
cli.on('--parser PARSER', 'Parser for input motif.'){|parser| options[:parser] = parser}
|
77
|
+
cli.on('--formatter FORMATTER', 'Formatter for output motif.'){|formatter| options[:formatter] = formatter}
|
78
|
+
cli.on('--from MODEL_OF_INPUT', 'Specify motif model of input.',
|
79
|
+
'It can be overriden by --parser option',
|
80
|
+
'(when parser implies certain input model)'){|model_from| options[:model_from] = model_from}
|
81
|
+
cli.on('--to MODEL_OF_OUTPUT', 'Specify motif model to convert to.',
|
82
|
+
'It can be overriden by --formatter option',
|
83
|
+
'(when formatter implies certain output model)'){|model_to| options[:model_to] = model_to}
|
84
|
+
cli.on('--algorithm ALGORITHM', 'Conversion algorithm to transform model.'){|conversion_algorithm| options[:conversion_algorithm] = conversion_algorithm}
|
85
|
+
cli.on('--save [FILENAME_FORMAT]', 'Save resulting motifs to according files.',
|
86
|
+
'filename format by default is ' + options[:filename_format],
|
87
|
+
'one can specify output folder here',
|
88
|
+
'{name} is a placeholder for motif name',
|
89
|
+
'{ext} is a placeholder for motif model') {|filename_format| options[:filename_format] = filename_format if filename_format}
|
90
|
+
cli.on('--[no-]force', 'Overwrite existing files.'){|force| options[:force] = force}
|
91
|
+
cli.on('--[no-]silent', 'Suppress error messages and notifications.'){|silent| options[:silent] = silent}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def parse!(argv, default_options = {})
|
96
|
+
@options = default_options.dup
|
97
|
+
option_parser.parse!(argv)
|
98
|
+
@arguments = argv
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
def self.main(argv)
|
103
|
+
self.new.main(argv)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
108
|
end
|