bioinform 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -17
  3. data/Gemfile +16 -16
  4. data/LICENSE +21 -21
  5. data/README.md +35 -35
  6. data/Rakefile +4 -4
  7. data/TODO.txt +37 -37
  8. data/bin/merge_into_collection +3 -3
  9. data/bin/pcm2pwm +3 -3
  10. data/bin/split_motifs +3 -3
  11. data/bioinform.gemspec +19 -19
  12. data/lib/bioinform/cli/convert_motif.rb +107 -107
  13. data/lib/bioinform/cli/merge_into_collection.rb +79 -79
  14. data/lib/bioinform/cli/pcm2pwm.rb +46 -46
  15. data/lib/bioinform/cli/split_motifs.rb +46 -46
  16. data/lib/bioinform/cli.rb +29 -29
  17. data/lib/bioinform/conversion_algorithms/pcm2ppm_converter.rb +18 -18
  18. data/lib/bioinform/conversion_algorithms/pcm2pwm_converter.rb +19 -19
  19. data/lib/bioinform/data_models/collection.rb +74 -74
  20. data/lib/bioinform/data_models/motif.rb +55 -55
  21. data/lib/bioinform/data_models/pcm.rb +23 -23
  22. data/lib/bioinform/data_models/pm.rb +169 -169
  23. data/lib/bioinform/data_models/ppm.rb +9 -9
  24. data/lib/bioinform/data_models/pwm.rb +55 -55
  25. data/lib/bioinform/data_models.rb +10 -10
  26. data/lib/bioinform/formatters/raw_formatter.rb +40 -40
  27. data/lib/bioinform/formatters/transfac_formatter.rb +38 -38
  28. data/lib/bioinform/formatters.rb +1 -1
  29. data/lib/bioinform/parsers/jaspar_parser.rb +34 -34
  30. data/lib/bioinform/parsers/parser.rb +87 -87
  31. data/lib/bioinform/parsers/splittable_parser.rb +56 -56
  32. data/lib/bioinform/parsers/string_fantom_parser.rb +34 -34
  33. data/lib/bioinform/parsers/string_parser.rb +71 -71
  34. data/lib/bioinform/parsers/trivial_parser.rb +33 -33
  35. data/lib/bioinform/parsers/yaml_parser.rb +34 -34
  36. data/lib/bioinform/parsers.rb +6 -6
  37. data/lib/bioinform/support/array_product.rb +5 -5
  38. data/lib/bioinform/support/array_zip.rb +5 -5
  39. data/lib/bioinform/support/collect_hash.rb +6 -6
  40. data/lib/bioinform/support/deep_dup.rb +4 -4
  41. data/lib/bioinform/support/delete_many.rb +13 -13
  42. data/lib/bioinform/support/inverf.rb +12 -12
  43. data/lib/bioinform/support/multiline_squish.rb +5 -5
  44. data/lib/bioinform/support/parameters.rb +27 -27
  45. data/lib/bioinform/support/partial_sums.rb +15 -15
  46. data/lib/bioinform/support/same_by.rb +12 -12
  47. data/lib/bioinform/support/strip_doc.rb +8 -8
  48. data/lib/bioinform/support/third_part/active_support/hash_with_indifferent_access.rb +3 -0
  49. data/lib/bioinform/support.rb +17 -17
  50. data/lib/bioinform/version.rb +3 -3
  51. data/lib/bioinform.rb +10 -10
  52. data/spec/cli/cli_spec.rb +13 -13
  53. data/spec/cli/convert_motif_spec.rb +106 -106
  54. data/spec/cli/data/merge_into_collection/GABPA_f1.pwm +14 -14
  55. data/spec/cli/data/merge_into_collection/KLF4_f2.pwm +11 -11
  56. data/spec/cli/data/merge_into_collection/SP1_f1.pwm +12 -12
  57. data/spec/cli/data/merge_into_collection/collection.txt.result +40 -40
  58. data/spec/cli/data/merge_into_collection/collection.yaml.result +188 -188
  59. data/spec/cli/data/merge_into_collection/collection_pwm.yaml.result +188 -188
  60. data/spec/cli/data/merge_into_collection/pwm_folder/GABPA_f1.pwm +14 -14
  61. data/spec/cli/data/merge_into_collection/pwm_folder/KLF4_f2.pwm +11 -11
  62. data/spec/cli/data/merge_into_collection/pwm_folder/SP1_f1.pwm +12 -12
  63. data/spec/cli/data/pcm2pwm/KLF4 f2 spaced name.pcm +11 -11
  64. data/spec/cli/data/pcm2pwm/KLF4_f2.pcm +11 -11
  65. data/spec/cli/data/pcm2pwm/KLF4_f2.pwm.result +11 -11
  66. data/spec/cli/data/pcm2pwm/SP1_f1.pcm +12 -12
  67. data/spec/cli/data/pcm2pwm/SP1_f1.pwm.result +12 -12
  68. data/spec/cli/data/split_motifs/GABPA_f1.mat.result +14 -14
  69. data/spec/cli/data/split_motifs/KLF4_f2.mat.result +11 -11
  70. data/spec/cli/data/split_motifs/SP1_f1.mat.result +12 -12
  71. data/spec/cli/data/split_motifs/collection.yaml +188 -188
  72. data/spec/cli/data/split_motifs/plain_collection.txt +38 -38
  73. data/spec/cli/merge_into_collection_spec.rb +99 -99
  74. data/spec/cli/pcm2pwm_spec.rb +79 -79
  75. data/spec/cli/shared_examples/convert_motif/motif_list_empty.rb +17 -17
  76. data/spec/cli/shared_examples/convert_motif/several_motifs_specified.rb +14 -14
  77. data/spec/cli/shared_examples/convert_motif/single_motif_specified.rb +49 -49
  78. data/spec/cli/shared_examples/convert_motif/yield_help_string.rb +4 -4
  79. data/spec/cli/shared_examples/convert_motif/yield_motif_conversion_error.rb +3 -3
  80. data/spec/cli/split_motifs_spec.rb +76 -76
  81. data/spec/data_models/collection_spec.rb +97 -97
  82. data/spec/data_models/motif_spec.rb +223 -223
  83. data/spec/data_models/pcm_spec.rb +55 -55
  84. data/spec/data_models/pm_spec.rb +359 -359
  85. data/spec/data_models/ppm_spec.rb +7 -7
  86. data/spec/data_models/pwm_spec.rb +82 -82
  87. data/spec/fabricators/collection_fabricator.rb +7 -7
  88. data/spec/fabricators/motif_fabricator.rb +32 -32
  89. data/spec/fabricators/motif_formats_fabricator.rb +124 -124
  90. data/spec/fabricators/pcm_fabricator.rb +24 -24
  91. data/spec/fabricators/pm_fabricator.rb +51 -51
  92. data/spec/fabricators/ppm_fabricator.rb +13 -13
  93. data/spec/fabricators/pwm_fabricator.rb +16 -16
  94. data/spec/parsers/parser_spec.rb +152 -152
  95. data/spec/parsers/string_fantom_parser_spec.rb +69 -69
  96. data/spec/parsers/string_parser_spec.rb +76 -76
  97. data/spec/parsers/trivial_parser_spec.rb +63 -63
  98. data/spec/parsers/yaml_parser_spec.rb +50 -50
  99. data/spec/spec_helper.rb +10 -10
  100. data/spec/spec_helper_source.rb +59 -59
  101. data/spec/support/advanced_scan_spec.rb +31 -31
  102. data/spec/support/array_product_spec.rb +14 -14
  103. data/spec/support/array_zip_spec.rb +14 -14
  104. data/spec/support/collect_hash_spec.rb +14 -14
  105. data/spec/support/delete_many_spec.rb +43 -43
  106. data/spec/support/inverf_spec.rb +18 -18
  107. data/spec/support/multiline_squish_spec.rb +24 -24
  108. data/spec/support/partial_sums_spec.rb +30 -30
  109. data/spec/support/same_by_spec.rb +35 -35
  110. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bce1095da9311ea0d77479899064e74e5979c516
4
- data.tar.gz: 3cdd8b774e7ad7cb930965bb5112c9046552f924
3
+ metadata.gz: 87a54b5aaa1e53b6b097f041616b7f80db6c7418
4
+ data.tar.gz: 4978a977e8e9d60c26bcd680aaa4a7defc11b80d
5
5
  SHA512:
6
- metadata.gz: 40c7a5191db1b2137de61d5e4b038fca9bb2ec14289ef3010a012a1fd1adb8f47d0b650bcd66b04ecfdac44104754a699ff8cf9b3e004e21834c8aeedddf521c
7
- data.tar.gz: 9c2c7ce0367b030b318117f6fc7b597ed9886312e26c64f0bea32157485896f836cb7f30e91777b5f6df1944ac6cc2d53cf1b5c96019a236036fe306d4b86c9c
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
@@ -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