unipept 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +26 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +8 -10
  5. data/Gemfile.lock +35 -21
  6. data/README.md +6 -4
  7. data/Rakefile +11 -10
  8. data/VERSION +1 -1
  9. data/bin/peptfilter +2 -44
  10. data/bin/prot2pept +4 -49
  11. data/bin/unipept +2 -197
  12. data/bin/uniprot +4 -53
  13. data/lib/batch_iterator.rb +73 -0
  14. data/lib/batch_order.rb +20 -0
  15. data/lib/commands/peptfilter.rb +118 -0
  16. data/lib/commands/prot2pept.rb +61 -0
  17. data/lib/commands/unipept/api_runner.rb +199 -0
  18. data/lib/commands/unipept/config.rb +29 -0
  19. data/lib/commands/unipept/pept2lca.rb +12 -0
  20. data/lib/commands/unipept/pept2prot.rb +13 -0
  21. data/lib/{unipept/commands → commands/unipept}/pept2taxa.rb +7 -0
  22. data/lib/commands/unipept/taxa2lca.rb +18 -0
  23. data/lib/{unipept/commands → commands/unipept}/taxonomy.rb +3 -0
  24. data/lib/commands/unipept.rb +226 -0
  25. data/lib/commands/uniprot.rb +69 -0
  26. data/lib/commands.rb +10 -0
  27. data/lib/configuration.rb +45 -0
  28. data/lib/formatters.rb +252 -0
  29. data/lib/version.rb +3 -0
  30. data/test/commands/test_peptfilter.rb +170 -0
  31. data/test/commands/test_prot2pept.rb +82 -0
  32. data/test/commands/test_unipept.rb +37 -0
  33. data/test/commands/test_uniprot.rb +136 -0
  34. data/test/commands/unipept/test_api_runner.rb +486 -0
  35. data/test/commands/unipept/test_config.rb +64 -0
  36. data/test/commands/unipept/test_pept2lca.rb +40 -0
  37. data/test/commands/unipept/test_pept2prot.rb +39 -0
  38. data/test/commands/unipept/test_pept2taxa.rb +39 -0
  39. data/test/commands/unipept/test_taxa2lca.rb +39 -0
  40. data/test/commands/unipept/test_taxonomy.rb +37 -0
  41. data/test/helper.rb +69 -23
  42. data/test/test_bach_order.rb +57 -0
  43. data/test/test_base.rb +6 -0
  44. data/test/test_batch_iterator.rb +87 -0
  45. data/test/test_configuration.rb +43 -0
  46. data/test/test_formatters.rb +140 -0
  47. data/unipept.gemspec +55 -33
  48. metadata +62 -40
  49. data/lib/unipept/batch_order.rb +0 -28
  50. data/lib/unipept/commands/api_runner.rb +0 -239
  51. data/lib/unipept/commands/pept2lca.rb +0 -6
  52. data/lib/unipept/commands/pept2prot.rb +0 -20
  53. data/lib/unipept/commands/taxa2lca.rb +0 -12
  54. data/lib/unipept/commands.rb +0 -7
  55. data/lib/unipept/configuration.rb +0 -29
  56. data/lib/unipept/formatters.rb +0 -135
  57. data/lib/unipept/version.rb +0 -3
  58. data/lib/unipept.rb +0 -8
  59. data/test/test_unipept.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e41863544a208f7a233fcba1e5d53d7b19ed2e79
4
- data.tar.gz: 2c9ac26e6bcc27b4bc9c5f7a31ef8c4dba1682a4
3
+ metadata.gz: 2079ea0c1b40f957d73ba24d167f5ec468f71c5e
4
+ data.tar.gz: c9a508bdc4a5293d5801e8bfba74dc8c52d641a8
5
5
  SHA512:
6
- metadata.gz: 3dd2bff19c1e90b6818f67b3320b2d1fc295b7c9c771d793aee69a9fd7dafeaa491e6b46ace0fecc19b77c2ab2a84217bc206935c74c70f4379b75f91e9a7d14
7
- data.tar.gz: 315478728af58af13fac482240619c3349b9b4d00f451ca1302664724501203729018ebeb4427398bc84077bd982d305afea8bc02754583b681afc8aaeda3daa
6
+ metadata.gz: eff7e936edc50c79d0f9d33486b5e9666da22ba937d3989ad19e70a4a3b1b36aee106ef15e7441c6cd422fa8779980dbb7be4f5695bfbf4511566004c425c6a1
7
+ data.tar.gz: c411d49dc862f28bbde1edafe74f7b2275c0b9735cea484d3fb75f43ecaf4f3d2e51141a409db7ea35b8d9864178f233986731fa1b2e64817be104aefee1afb2
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ AllCops:
2
+ Include:
3
+ -
4
+ Exclude:
5
+ - 'unipept.gemspec'
6
+ - 'vendor/**/*'
7
+
8
+ Style/ClassAndModuleChildren:
9
+ EnforcedStyle: compact
10
+ Enabled: false
11
+
12
+ # disable for now
13
+ Style/ClassVars:
14
+ Enabled: false
15
+ Style/Documentation:
16
+ Enabled: false
17
+ Style/RescueModifier:
18
+ Enabled: false
19
+ Metrics/AbcSize:
20
+ Enabled: false
21
+ Metrics/ClassLength:
22
+ Enabled: false
23
+ Metrics/LineLength:
24
+ Enabled: false
25
+ Metrics/MethodLength:
26
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ - 2.1.6
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - jruby-19mode
data/Gemfile CHANGED
@@ -1,17 +1,15 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem "cri", "~> 2.7"
7
- gem "typhoeus", "~> 0.6"
6
+ gem 'cri', '~> 2.7'
7
+ gem 'typhoeus', '~> 0.6'
8
8
 
9
- # Add dependencies to develop your gem here.
10
- # Include everything needed to run rake, tests, features, etc.
11
9
  group :development do
12
- gem "shoulda", "~> 3.5"
13
- gem "rdoc", "~> 3.12"
14
- gem "bundler", "~> 1.0"
15
- gem "jeweler", "~> 2.0"
16
- gem "simplecov", "~> 0.8"
10
+ gem 'rake'
11
+ gem 'minitest'
12
+ gem 'rubocop'
13
+ gem 'jeweler'
14
+ gem 'coveralls', require: false
17
15
  end
data/Gemfile.lock CHANGED
@@ -1,15 +1,18 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (4.2.1)
5
- i18n (~> 0.7)
6
- json (~> 1.7, >= 1.7.7)
7
- minitest (~> 5.1)
8
- thread_safe (~> 0.3, >= 0.3.4)
9
- tzinfo (~> 1.1)
10
4
  addressable (2.3.8)
5
+ ast (2.0.0)
6
+ astrolabe (1.3.0)
7
+ parser (>= 2.2.0.pre.3, < 3.0)
11
8
  builder (3.2.2)
12
9
  colored (1.2)
10
+ coveralls (0.7.1)
11
+ multi_json (~> 1.3)
12
+ rest-client
13
+ simplecov (>= 0.7)
14
+ term-ansicolor
15
+ thor
13
16
  cri (2.7.0)
14
17
  colored (~> 1.2)
15
18
  descendants_tracker (0.0.4)
@@ -31,7 +34,6 @@ GEM
31
34
  oauth2
32
35
  hashie (3.4.1)
33
36
  highline (1.7.2)
34
- i18n (0.7.0)
35
37
  jeweler (2.0.1)
36
38
  builder
37
39
  bundler (>= 1.0)
@@ -43,11 +45,13 @@ GEM
43
45
  rdoc
44
46
  json (1.8.2)
45
47
  jwt (1.4.1)
48
+ mime-types (2.4.3)
46
49
  mini_portile (0.6.2)
47
50
  minitest (5.6.1)
48
51
  multi_json (1.11.0)
49
52
  multi_xml (0.5.5)
50
53
  multipart-post (2.0.0)
54
+ netrc (0.9.0)
51
55
  nokogiri (1.6.6.2)
52
56
  mini_portile (~> 0.6.0)
53
57
  oauth2 (1.0.0)
@@ -56,35 +60,45 @@ GEM
56
60
  multi_json (~> 1.3)
57
61
  multi_xml (~> 0.5)
58
62
  rack (~> 1.2)
63
+ parser (2.2.0.2)
64
+ ast (>= 1.1, < 3.0)
65
+ powerpack (0.0.9)
59
66
  rack (1.6.0)
67
+ rainbow (2.0.0)
60
68
  rake (10.4.2)
61
- rdoc (3.12.2)
69
+ rdoc (4.2.0)
62
70
  json (~> 1.4)
63
- shoulda (3.5.0)
64
- shoulda-context (~> 1.0, >= 1.0.1)
65
- shoulda-matchers (>= 1.4.1, < 3.0)
66
- shoulda-context (1.2.1)
67
- shoulda-matchers (2.8.0)
68
- activesupport (>= 3.0.0)
71
+ rest-client (1.7.2)
72
+ mime-types (>= 1.16, < 3.0)
73
+ netrc (~> 0.7)
74
+ rubocop (0.28.0)
75
+ astrolabe (~> 1.3)
76
+ parser (>= 2.2.0.pre.7, < 3.0)
77
+ powerpack (~> 0.0.6)
78
+ rainbow (>= 1.99.1, < 3.0)
79
+ ruby-progressbar (~> 1.4)
80
+ ruby-progressbar (1.7.1)
69
81
  simplecov (0.10.0)
70
82
  docile (~> 1.1.0)
71
83
  json (~> 1.8)
72
84
  simplecov-html (~> 0.10.0)
73
85
  simplecov-html (0.10.0)
86
+ term-ansicolor (1.3.0)
87
+ tins (~> 1.0)
88
+ thor (0.19.1)
74
89
  thread_safe (0.3.5)
90
+ tins (1.3.3)
75
91
  typhoeus (0.7.1)
76
92
  ethon (>= 0.7.1)
77
- tzinfo (1.2.2)
78
- thread_safe (~> 0.1)
79
93
 
80
94
  PLATFORMS
81
95
  ruby
82
96
 
83
97
  DEPENDENCIES
84
- bundler (~> 1.0)
98
+ coveralls
85
99
  cri (~> 2.7)
86
- jeweler (~> 2.0)
87
- rdoc (~> 3.12)
88
- shoulda (~> 3.5)
89
- simplecov (~> 0.8)
100
+ jeweler
101
+ minitest
102
+ rake
103
+ rubocop
90
104
  typhoeus (~> 0.6)
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # unipept-cli
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/unipept/unipept-cli/badges/gpa.svg)](https://codeclimate.com/github/unipept/unipept-cli)
4
3
  [![Gem Version](https://badge.fury.io/rb/unipept.svg)](http://badge.fury.io/rb/unipept)
4
+ [![Build Status](https://api.travis-ci.org/unipept/unipept-cli.svg)](https://travis-ci.org/unipept/unipept-cli)
5
+ [![Coverage Status](https://coveralls.io/repos/unipept/unipept-cli/badge.svg)](https://coveralls.io/r/unipept/unipept-cli)
6
+ [![Code Climate](https://codeclimate.com/github/unipept/unipept-cli/badges/gpa.svg)](https://codeclimate.com/github/unipept/unipept-cli)
5
7
 
6
8
  Unipept-cli offers a command line interface to the [Unipept](http://unipept.ugent.be) web service.
7
9
  Documentation about the web service can be found at [http://unipept.ugent.be/apidocs](http://unipept.ugent.be/apidocs).
@@ -21,8 +23,8 @@ The Unipept CLI is available as a *gem*. This means it can easily be installed w
21
23
 
22
24
  ```bash
23
25
  $ gem install unipept
24
- Successfully installed unipept-0.7.1
25
- Parsing documentation for unipept-0.7.1
26
+ Successfully installed unipept-0.8.0
27
+ Parsing documentation for unipept-0.8.0
26
28
  Done installing documentation for unipept after 0 seconds
27
29
  1 gem installed
28
30
  ```
@@ -31,7 +33,7 @@ After successful installation, the unipept command should be available:
31
33
 
32
34
  ```bash
33
35
  $ unipept -v
34
- 0.7.1
36
+ 0.8.0
35
37
  ```
36
38
 
37
39
  The help can be accessed by running `unipept -h`.
data/Rakefile CHANGED
@@ -10,6 +10,8 @@ rescue Bundler::BundlerError => e
10
10
  exit e.status_code
11
11
  end
12
12
  require 'rake'
13
+ require 'rake/testtask'
14
+ require 'rubocop/rake_task'
13
15
 
14
16
  require 'jeweler'
15
17
  Jeweler::Tasks.new do |gem|
@@ -30,19 +32,18 @@ Jeweler::Tasks.new do |gem|
30
32
  end
31
33
  Jeweler::RubygemsDotOrgTasks.new
32
34
 
33
- require 'rake/testtask'
34
- Rake::TestTask.new(:test) do |test|
35
- test.libs << 'lib' << 'test'
36
- test.pattern = 'test/**/test_*.rb'
37
- test.verbose = true
38
- end
35
+ task :test_unit do
36
+ require './test/helper.rb'
39
37
 
40
- desc 'Code coverage detail'
41
- task :simplecov do
42
- ENV['COVERAGE'] = 'true'
43
- Rake::Task['test'].execute
38
+ FileList['./test/**/test_*.rb', './test/**/*_spec.rb'].each do |fn|
39
+ require fn
40
+ end
44
41
  end
45
42
 
43
+ RuboCop::RakeTask.new(:test_style)
44
+
45
+ task test: [:test_unit, :test_style]
46
+
46
47
  task default: :test
47
48
 
48
49
  require 'rdoc/task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.8.0
data/bin/peptfilter CHANGED
@@ -1,49 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'cri'
2
+ require_relative '../lib/commands'
3
3
 
4
4
  Signal.trap('PIPE', 'EXIT')
5
5
  Signal.trap('INT', 'EXIT')
6
- root_cmd = Cri::Command.new_basic_root.modify do
7
- name 'peptfilter'
8
- summary 'Filter peptides based on specific criteria.'
9
- usage 'peptfilter [options]'
10
- description <<-EOS
11
- The peptfilter command filters a list of peptides according to specific criteria. The command expects a list of peptides that are passed
12
6
 
13
- - as separate command line arguments
14
-
15
- - in one or more text files that are passed as an argument to the -i option
16
-
17
- - to standard input
18
-
19
- The command will give priority to the first way peptides are passed, in the order as listed above. Text files and standard input should have one peptide per line. FASTA headers are preserved in the output, so that peptides remain bundled.
20
- EOS
21
- # flag :u, :unique, "filter duplicate peptides."
22
- required nil, :minlen, 'only retain tryptic peptides that have at least min (default: 5) amino acids.'
23
- required nil, :maxlen, 'only retain tryptic peptides that have at most max (default: 50) amino acids.'
24
- required :l, :lacks, 'only retain tryptic peptides that lack all amino acids from the string of residues.'
25
- required :c, :contains, 'only retain tryptic peptides that contain all amino acids from the string of residues.'
26
- run do |opts, _args, _cmd|
27
- minlen = opts.fetch(:minlen, '5').to_i
28
- maxlen = opts.fetch(:maxlen, '50').to_i
29
- lacks = opts.fetch(:lacks, '').chars.to_a
30
- contains = opts.fetch(:contains, '').chars.to_a
31
- $stdin.each_line do |pept|
32
- # FASTA headers
33
- if pept.start_with? '>'
34
- puts pept
35
- next
36
- end
37
- pept = pept.chomp
38
- length_ok = pept.length >= minlen && pept.length <= maxlen
39
- lacks_ok = (pept.chars.to_a & lacks).size == 0
40
- contains_ok = (pept.chars.to_a & contains).size == contains.size
41
-
42
- if length_ok && lacks_ok && contains_ok
43
- puts pept
44
- end
45
- end
46
- end
47
- end
48
-
49
- root_cmd.run(ARGV)
7
+ Unipept::Commands::Peptfilter.run(ARGV)
data/bin/prot2pept CHANGED
@@ -1,52 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'cri'
2
+ require_relative '../lib/commands'
3
3
 
4
- Signal.trap("PIPE", "EXIT")
5
- Signal.trap("INT", "EXIT")
6
- root_cmd = Cri::Command.new_basic_root.modify do
7
- name 'prot2pept'
8
- summary 'Split protein sequences into peptides.'
9
- usage 'prot2pept [options]'
10
- description <<-EOS
11
- The prot2pept command splits each protein sequence into a list of peptides according to a given cleavage-pattern. The command expects a list of protein sequences that are passed
4
+ Signal.trap('PIPE', 'EXIT')
5
+ Signal.trap('INT', 'EXIT')
12
6
 
13
- - as separate command line arguments
14
-
15
- - in one or more text files that are passed as an argument to the -i option
16
-
17
- - to standard input
18
-
19
- The command will give priority to the first way protein sequences are passed, in the order as listed above. Text files and standard input should have either one protein sequence per line or contain a FASTA formatted list of protein sequences. FASTA headers are preserved in the output, so that peptides can be bundled per protein sequence.
20
-
21
- EOS
22
- required :p, :pattern, 'specify cleavage-pattern (regex) as the pattern after which the next peptide will be cleaved (default: ([KR])([^P]) for tryptic peptides).'
23
- run do |opts, args, cmd|
24
- pattern = opts.fetch(:pattern, "([KR])([^P])")
25
- # decide if we have FASTA input
26
- fasta_header = $stdin.gets
27
- if fasta_header.start_with? '>'
28
- # fasta input, need to join lines
29
- while !$stdin.eof?
30
- prot = ""
31
- # Sometimes you just got to accept this weird and ugly code
32
- until $stdin.eof? || (line = gets).start_with?('>')
33
- prot += line.chomp
34
- end
35
- puts fasta_header
36
- puts prot.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?)
37
-
38
- fasta_header = line
39
- end
40
- else
41
- # handle our already read line
42
- puts fasta_header.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?)
43
-
44
- # we no longer have to join lines as input is now more sane
45
- $stdin.each_line do |prot|
46
- puts prot.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?)
47
- end
48
- end
49
- end
50
- end
51
-
52
- root_cmd.run(ARGV)
7
+ Unipept::Commands::Prot2pept.run(ARGV)
data/bin/unipept CHANGED
@@ -1,203 +1,8 @@
1
1
  #!usr/bin/env ruby
2
-
3
- require 'cri'
4
- require 'typhoeus'
5
- require 'yaml'
6
- require 'json'
7
- require 'fileutils'
8
-
9
- require_relative '../lib/unipept'
2
+ require_relative '../lib/commands'
10
3
 
11
4
  # Prevent broken pipe errors
12
5
  Signal.trap('PIPE', 'EXIT')
13
6
  Signal.trap('INT', 'EXIT')
14
7
 
15
- root_cmd = Cri::Command.new_basic_root.modify do
16
- name 'unipept'
17
- summary 'Command line interface to Unipept web services.'
18
- usage 'unipept subcommand [options]'
19
- description <<-EOS
20
- The unipept subcommands are command line wrappers around the Unipept web services.
21
-
22
- Subcommands that start with pept expect a list of tryptic peptides as input. Subcommands that start with tax expect a list of NCBI Taxonomy Identifiers as input. Input is passed
23
-
24
- - as separate command line arguments
25
-
26
- - in one or more text files that are passed as an argument to the -i option
27
-
28
- - to standard input
29
-
30
- The command will give priority to the first way the input is passed, in the order as listed above. Text files and standard input should have one tryptic peptide or one NCBI Taxonomy Identifier per line.
31
- EOS
32
- flag :v, :version, 'displays the version'
33
- flag :q, :quiet, 'disable service messages'
34
- option :i, :input, 'read input from file', argument: :required
35
- option :o, :output, 'write output to file', argument: :required
36
- option :f, :format, "define the output format (available: #{Unipept::Formatter.available.join ', ' }) (default: #{Unipept::Formatter.default})", argument: :required
37
-
38
- # Configuration options
39
- option nil, 'host', 'specify the server running the Unipept web service', argument: :required
40
-
41
- run do |opts, _args, _cmd|
42
- if opts[:version]
43
- puts File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
44
- elsif
45
- root_cmd.run(['help'])
46
- end
47
- end
48
- end
49
-
50
- root_cmd.define_command('config') do
51
- summary 'Set configuration options.'
52
- usage 'config option [value]'
53
- description <<-EOS
54
- Sets or shows the value for configuration options. All settings are stored in the .unipeptrc file in the home directory of the user.
55
-
56
- Running the command with a value will set that value for the given option, running it without will show the current value.
57
-
58
- These options are currently supported:
59
-
60
- - host: Set the default host for api calls.
61
-
62
- Example: "unipept config host http://api.unipept.ugent.be" will set the default host to the public unipept server.
63
- EOS
64
-
65
- run do |_opts, args, _cmd|
66
- config = Unipept::Configuration.new
67
- if args.size > 1
68
- config[args.first] = args[1]
69
- config.save
70
- elsif args.size == 1
71
- puts config[args.first]
72
- elsif args.size == 0
73
- root_cmd.run(['config', '-h'])
74
- end
75
- end
76
- end
77
-
78
- root_cmd.define_command('pept2taxa') do
79
- usage 'pept2taxa [options]'
80
- aliases :pt
81
- summary 'Fetch taxa of Uniprot records that match tryptic peptides.'
82
- description <<-EOS
83
- For each tryptic peptide the unipept pept2taxa command retrieves from Unipept the set of taxa from all Uniprot records whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides that are passed
84
-
85
- - as separate command line arguments
86
-
87
- - in one or more text files that are passed as an argument to the -i option
88
-
89
- - to standard input
90
-
91
- The command will give priority to the first way tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.
92
-
93
- The unipept pept2taxa subcommand yields NCBI Taxonomy records as output.
94
- EOS
95
-
96
- flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
97
- flag :a, :all, 'report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.'
98
- option :s, :select, 'select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.', argument: :required, multiple: true
99
- option :x, :xml, 'Download the matched records from the NCBI web service as an xml-formatted file (specify output filename)', argument: :required
100
-
101
- runner Unipept::Commands::Pept2taxa
102
- end
103
-
104
- root_cmd.define_command('pept2lca') do
105
- usage 'pept2lca [options]'
106
- aliases :pl
107
- summary 'Fetch taxonomic lowest common ancestor of Uniprot records that match tryptic peptides.'
108
- description <<-EOS
109
- For each tryptic peptide the unipept pept2lca command retrieves from Unipept the lowest common ancestor of the set of taxa from all Uniprot records whose protein sequence contains an exact matches to the tryptic peptide. The lowest common ancestor is based on the topology of the Unipept Taxonomy -- a cleaned up version of the NCBI Taxonomy -- and is itself a record from the NCBI Taxonomy. The command expects a list of tryptic peptides that are passed
110
-
111
- - as separate command line arguments
112
-
113
- - in one or more text files that are passed as an argument to the -i option
114
-
115
- - to standard input
116
-
117
- The command will give priority to the first way tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.
118
-
119
- The unipept pept2lca subcommand yields an NCBI Taxonomy record as output.
120
- EOS
121
-
122
- flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
123
- flag :a, :all, 'report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.'
124
- option :s, :select, 'select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.', argument: :required, multiple: true
125
-
126
- runner Unipept::Commands::Pept2lca
127
- end
128
-
129
- root_cmd.define_command('taxa2lca') do
130
- usage 'taxa2lca [options]'
131
- aliases :tl
132
- summary 'Compute taxonomic lowest common ancestor for given list of taxa.'
133
- description <<-EOS
134
- The unipept taxa2lca command computes the lowest common ancestor of a given list of NCBI Taxonomy Identifiers. The lowest common ancestor is based on the topology of the Unipept Taxonomy -- a cleaned up version of the NCBI Taxonomy -- and is itself a record from the NCBI Taxonomy. The command expects a list of NCBI Taxonomy Identifiers that are passed
135
-
136
- - as separate command line arguments
137
-
138
- - in one or more text files that are passed as an argument to the -i option
139
-
140
- - to standard input
141
-
142
- The command will give priority to the first way NCBI Taxonomy Identifiers are passed, in the order as listed above. Text files and standard input should have one NCBI Taxonomy Identifier per line.
143
-
144
- The unipept taxonomy subcommand yields NCBI Taxonomy records as output.
145
- EOS
146
-
147
- flag :a, :all, 'report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.'
148
- option :s, :select, 'select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.', argument: :required, multiple: true
149
-
150
- runner Unipept::Commands::Taxa2lca
151
- end
152
-
153
- root_cmd.define_command('pept2prot') do
154
- usage 'pept2prot [options]'
155
- aliases :pp
156
- summary 'Fetch Uniprot records that match tryptic peptides.'
157
- description <<-EOS
158
- For each tryptic peptide the unipept pept2prot command retrieves from Unipept all Uniprot records whose protein sequence contains an exact matches to the tryptic peptide. The command expects a list of tryptic peptides that are passed
159
-
160
- - as separate command line arguments
161
-
162
- - in one or more text files that are passed as an argument to the -i option
163
-
164
- - to standard input
165
-
166
- The command will give priority to the first way tryptic peptides are passed, in the order as listed above. Text files and standard input should have one tryptic peptide per line.
167
-
168
- The unipept pept2prot subcommand yields Uniprot records as output.
169
- EOS
170
-
171
- flag :e, :equate, 'equate isoleucine (I) and leucine (L) when matching peptides'
172
- flag :a, :all, 'report all information fields of Uniprot records available in Unipept. Note that this may have a performance penalty.'
173
- option :s, :select, 'select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.', argument: :required, multiple: true
174
- option :x, :xml, 'download XML-formatted Uniprot records into the specified download-directory. ', argument: :required
175
-
176
- runner Unipept::Commands::Pept2prot
177
- end
178
-
179
- root_cmd.define_command('taxonomy') do
180
- usage 'taxonomy [options]'
181
- aliases :tax
182
- summary 'Fetch taxonomic information from Unipept Taxonomy.'
183
- description <<-EOS
184
- The unipept taxonomy command yields information from the Unipept Taxonomy records for a given list of NCBI Taxonomy Identifiers. The Unipept Taxonomy is a cleaned up version of the NCBI Taxonomy, and its records are also records of the NCBI Taxonomy. The command expects a list of NCBI Taxonomy Identifiers that are passed
185
-
186
- - as separate command line arguments
187
-
188
- - in one or more text files that are passed as an argument to the -i option
189
-
190
- - to standard input
191
-
192
- The command will give priority to the first way NCBI Taxonomy Identifiers are passed, in the order as listed above. Text files and standard input should have one NCBI Taxonomy Identifier per line.
193
-
194
- The unipept taxonomy subcommand yields NCBI Taxonomy records as output.
195
- EOS
196
-
197
- flag :a, :all, 'report all information fields of NCBI Taxonomy records available in Unipept. Note that this may have a performance penalty.'
198
- option :s, :select, 'select the information fields to return. Selected fields are passed as a comma separated list of field names. Multiple -s (or --select) options may be used.', argument: :required, multiple: true
199
-
200
- runner Unipept::Commands::Taxonomy
201
- end
202
-
203
- root_cmd.run(ARGV)
8
+ Unipept::Commands::Unipept.run(ARGV)
data/bin/uniprot CHANGED
@@ -1,56 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require 'typhoeus'
3
- require 'cri'
2
+ require_relative '../lib/commands'
4
3
 
5
- Signal.trap("PIPE", "EXIT")
6
- Signal.trap("INT", "EXIT")
4
+ Signal.trap('PIPE', 'EXIT')
5
+ Signal.trap('INT', 'EXIT')
7
6
 
8
- valid_formats = Set.new ["fasta", "txt", "xml", "rdf", "gff"]
9
-
10
- def get_uniprot_entry(arg, format)
11
- if format.nil? || format.empty?
12
- resp = Typhoeus.get("http://www.uniprot.org/uniprot/#{arg}.fasta")
13
- if resp.success?
14
- puts resp.response_body.lines.map(&:chomp)[1..-1].join("")
15
- end
16
- else
17
- # other format has been specified, just download and output
18
- resp = Typhoeus.get("http://www.uniprot.org/uniprot/#{arg}.#{format}")
19
- if resp.success?
20
- puts resp.response_body
21
- end
22
- end
23
- end
24
-
25
- root_cmd = Cri::Command.new_basic_root.modify do
26
- name 'uniprot'
27
- summary 'Command line interface to Uniprot web services.'
28
- usage 'uniprot [options]'
29
- description <<-EOS
30
- The uniprot command is a command line wrapper around the Uniprot web services. The command expects a list of Uniprot Accession Numbers that are passed
31
-
32
- - as separate command line arguments
33
-
34
- - in one or more text files that are passed as an argument to the -i option
35
-
36
- - to standard input
37
-
38
- The command will give priority to the first way Uniprot Accession Numbers are passed, in the order as listed above. Text files and standard input should have one Uniprot Accession Number per line.
39
-
40
- The uniprot command yields Uniprot records as output.
41
- EOS
42
- required :f, :format, "specify output format (available: " + valid_formats.to_a.join(", ") + ")"
43
- run do |opts, args, cmd|
44
- if !opts[:format].nil? and !valid_formats.include? opts[:format]
45
- $stderr.puts opts[:format] + " is not a valid output format. Available formats are: " + valid_formats.to_a.join(", ")
46
- exit 1
47
- end
48
- iterator = args.empty? ? $stdin.each_line : args
49
- iterator.each do |pept|
50
- get_uniprot_entry(pept.chomp, opts[:format])
51
- end
52
- end
53
- end
54
-
55
- # run_this runs this command without subcommands! Absolutely needed here
56
- root_cmd.run_this(ARGV)
7
+ Unipept::Commands::Uniprot.run(ARGV)