unipept 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +49 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +81 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/bin/peptfilter +32 -0
- data/bin/prot2pept +14 -0
- data/bin/unipept +216 -0
- data/bin/uniprot +8 -0
- data/lib/unipept/configuration.rb +29 -0
- data/lib/unipept/formatters.rb +99 -0
- data/lib/unipept.rb +5 -0
- data/test/helper.rb +34 -0
- data/test/test_unipept.rb +7 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03aafb9cbcaa8776d094bbd65c42c5fe4f4fbd3a
|
4
|
+
data.tar.gz: 2b2b6f19a6d7d0e263f85501407d3add70324ede
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5191cb4452871172c7b3e2b5115dbf0b77b9a0f533a0e3047258a75cdaf84f0bd3ba7c1982f0e9c337232a31f608e3b885e5a4d996f0593c88c122510e4e918b
|
7
|
+
data.tar.gz: 3b13ff181339f1c5cac5fb833c918cab4b987defea3bfba3fc4a68e24f08dc5730743d0f0cdbf115d6bb2faf20cdb8f3c3c0f1113f8fdb97a8d77574bec0dc90
|
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
#
|
31
|
+
#.DS_Store
|
32
|
+
|
33
|
+
# For TextMate
|
34
|
+
#*.tmproj
|
35
|
+
#tmtags
|
36
|
+
|
37
|
+
# For emacs:
|
38
|
+
#*~
|
39
|
+
#\#*
|
40
|
+
#.\#*
|
41
|
+
|
42
|
+
# For vim:
|
43
|
+
#*.swp
|
44
|
+
|
45
|
+
# For redcar:
|
46
|
+
#.redcar
|
47
|
+
|
48
|
+
# For rubinius:
|
49
|
+
#*.rbc
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", "~> 3.5"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0"
|
13
|
+
gem "simplecov", "~> 0.8"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.0.3)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
minitest (~> 4.2)
|
7
|
+
multi_json (~> 1.3)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 0.3.37)
|
10
|
+
addressable (2.3.5)
|
11
|
+
atomic (1.1.15)
|
12
|
+
builder (3.2.2)
|
13
|
+
descendants_tracker (0.0.3)
|
14
|
+
docile (1.1.3)
|
15
|
+
faraday (0.9.0)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
git (1.2.6)
|
18
|
+
github_api (0.11.3)
|
19
|
+
addressable (~> 2.3)
|
20
|
+
descendants_tracker (~> 0.0.1)
|
21
|
+
faraday (~> 0.8, < 0.10)
|
22
|
+
hashie (>= 1.2)
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
24
|
+
nokogiri (~> 1.6.0)
|
25
|
+
oauth2
|
26
|
+
hashie (2.0.5)
|
27
|
+
highline (1.6.21)
|
28
|
+
i18n (0.6.9)
|
29
|
+
jeweler (2.0.1)
|
30
|
+
builder
|
31
|
+
bundler (>= 1.0)
|
32
|
+
git (>= 1.2.5)
|
33
|
+
github_api
|
34
|
+
highline (>= 1.6.15)
|
35
|
+
nokogiri (>= 1.5.10)
|
36
|
+
rake
|
37
|
+
rdoc
|
38
|
+
json (1.8.1)
|
39
|
+
jwt (0.1.11)
|
40
|
+
multi_json (>= 1.5)
|
41
|
+
mini_portile (0.5.2)
|
42
|
+
minitest (4.7.5)
|
43
|
+
multi_json (1.9.0)
|
44
|
+
multi_xml (0.5.5)
|
45
|
+
multipart-post (2.0.0)
|
46
|
+
nokogiri (1.6.1)
|
47
|
+
mini_portile (~> 0.5.0)
|
48
|
+
oauth2 (0.9.3)
|
49
|
+
faraday (>= 0.8, < 0.10)
|
50
|
+
jwt (~> 0.1.8)
|
51
|
+
multi_json (~> 1.3)
|
52
|
+
multi_xml (~> 0.5)
|
53
|
+
rack (~> 1.2)
|
54
|
+
rack (1.5.2)
|
55
|
+
rake (10.1.1)
|
56
|
+
rdoc (3.12.2)
|
57
|
+
json (~> 1.4)
|
58
|
+
shoulda (3.5.0)
|
59
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
60
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
61
|
+
shoulda-context (1.1.6)
|
62
|
+
shoulda-matchers (2.5.0)
|
63
|
+
activesupport (>= 3.0.0)
|
64
|
+
simplecov (0.8.2)
|
65
|
+
docile (~> 1.1.0)
|
66
|
+
multi_json
|
67
|
+
simplecov-html (~> 0.8.0)
|
68
|
+
simplecov-html (0.8.0)
|
69
|
+
thread_safe (0.2.0)
|
70
|
+
atomic (>= 1.1.7, < 2)
|
71
|
+
tzinfo (0.3.39)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
ruby
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
bundler (~> 1.0)
|
78
|
+
jeweler (~> 2.0)
|
79
|
+
rdoc (~> 3.12)
|
80
|
+
shoulda (~> 3.5)
|
81
|
+
simplecov (~> 0.8)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Toon Willems
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= unipept
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to unipept
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2014 Toon Willems. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "unipept"
|
18
|
+
gem.executables = ['unipept', 'prot2pept', 'peptfilter', 'uniprot']
|
19
|
+
gem.homepage = "http://github.ugent.be/bmesuere/unipept/"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{CLI interface to unipept}
|
22
|
+
gem.description = %Q{CLI interface to unipept}
|
23
|
+
gem.email = "willemstoon@gmail.com"
|
24
|
+
gem.authors = ["Toon Willems"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
gem.add_dependency 'faraday', '~> 0.9'
|
27
|
+
gem.add_dependency 'cri', '~> 2.5'
|
28
|
+
gem.add_dependency 'ruby-progressbar', '~> 1.4'
|
29
|
+
end
|
30
|
+
Jeweler::RubygemsDotOrgTasks.new
|
31
|
+
|
32
|
+
require 'rake/testtask'
|
33
|
+
Rake::TestTask.new(:test) do |test|
|
34
|
+
test.libs << 'lib' << 'test'
|
35
|
+
test.pattern = 'test/**/test_*.rb'
|
36
|
+
test.verbose = true
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Code coverage detail"
|
40
|
+
task :simplecov do
|
41
|
+
ENV['COVERAGE'] = "true"
|
42
|
+
Rake::Task['test'].execute
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rdoc/task'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "unipept #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/bin/peptfilter
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'cri'
|
3
|
+
|
4
|
+
root_cmd = Cri::Command.new_basic_root.modify do
|
5
|
+
name 'peptfilter'
|
6
|
+
flag :i, :unique, "only output unique peptides"
|
7
|
+
required :l, :minlen, "minimum length (default: 5)"
|
8
|
+
required :u, :maxlen, "minimum length (default: 50)"
|
9
|
+
required :a, :lacks, "a string whose letters represent amino acids that may not occur in the peptide"
|
10
|
+
required :c, :contains, "a string whose letters represent amino acids that must all occur in the peptide"
|
11
|
+
run do |opts, args, cmd|
|
12
|
+
minlen = opts.fetch(:minlen, "5").to_i
|
13
|
+
maxlen = opts.fetch(:maxlen, "50").to_i
|
14
|
+
lacks = opts.fetch(:lacks, "").chars.to_a
|
15
|
+
contains = opts.fetch(:contains, "").chars.to_a
|
16
|
+
filtered = $stdin.readlines.select do |pept|
|
17
|
+
pept = pept.chomp
|
18
|
+
length_ok = pept.length >= minlen && pept.length <= maxlen
|
19
|
+
lacks_ok = (pept.chars & lacks).size == 0
|
20
|
+
contains_ok = (pept.chars & contains).size == contains.size
|
21
|
+
|
22
|
+
length_ok && lacks_ok && contains_ok
|
23
|
+
end
|
24
|
+
if opts[:unique]
|
25
|
+
puts filtered.uniq
|
26
|
+
else
|
27
|
+
puts filtered
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
root_cmd.run(ARGV)
|
data/bin/prot2pept
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'cri'
|
3
|
+
|
4
|
+
root_cmd = Cri::Command.new_basic_root.modify do
|
5
|
+
name 'prot2pept'
|
6
|
+
required :p, :pattern, "cleavage pattern to split input protein (default: ([KR])([^P]))"
|
7
|
+
run do |opts, args, cmd|
|
8
|
+
pattern = opts.fetch(:pattern, "([KR])([^P])")
|
9
|
+
puts $stdin.readlines.map { |prot| prot.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2") }.
|
10
|
+
map {|s| s.split("\n")}.flatten.reject(&:empty?)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
root_cmd.run(ARGV)
|
data/bin/unipept
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cri'
|
4
|
+
require 'faraday'
|
5
|
+
require 'ruby-progressbar'
|
6
|
+
require 'yaml'
|
7
|
+
require 'json'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
require_relative '../lib/unipept'
|
11
|
+
|
12
|
+
|
13
|
+
class ApiRunner < Cri::CommandRunner
|
14
|
+
|
15
|
+
def initialize(args, opts, cmd)
|
16
|
+
super
|
17
|
+
host = Unipept::Configuration.new['host']
|
18
|
+
if host.nil? || host.empty?
|
19
|
+
puts "WARNING: no host has been set, you can set the host with `unipept config host http://localhost:3000/`"
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
@url = "#{host}/api/v1/#{mapping[cmd.name]}.json"
|
23
|
+
end
|
24
|
+
|
25
|
+
def mapping
|
26
|
+
{'pept2taxa' => 'single', 'pept2lca' => 'lca'}
|
27
|
+
end
|
28
|
+
|
29
|
+
def read_input
|
30
|
+
if options[:input]
|
31
|
+
peptides = File.readlines(options[:input])
|
32
|
+
else
|
33
|
+
peptides = STDIN.readlines
|
34
|
+
end
|
35
|
+
|
36
|
+
peptides
|
37
|
+
end
|
38
|
+
|
39
|
+
def batch_size
|
40
|
+
1000
|
41
|
+
end
|
42
|
+
|
43
|
+
def url_options(sub_part)
|
44
|
+
{:sequences => sub_part,
|
45
|
+
:equate_il => options[:equate],
|
46
|
+
:full_lineage => options[:lineage]}
|
47
|
+
end
|
48
|
+
|
49
|
+
def run
|
50
|
+
formatter = Unipept::Formatter.new_for_format(options[:format])
|
51
|
+
peptides = read_input
|
52
|
+
|
53
|
+
filter = options[:select] rescue nil
|
54
|
+
filter = glob_to_regex(filter) if filter
|
55
|
+
|
56
|
+
progress = ProgressBar.create(total: peptides.size, output: $stderr)
|
57
|
+
|
58
|
+
result = []
|
59
|
+
peptides.each_slice(self.batch_size) do |sub_division|
|
60
|
+
|
61
|
+
sub_result = JSON[Faraday.post(@url, url_options(sub_division)).body]
|
62
|
+
|
63
|
+
sub_result = [sub_result] if not sub_result.kind_of? Array
|
64
|
+
|
65
|
+
sub_result.map! {|r| r.select! {|k,v| filter.match k } } if filter
|
66
|
+
|
67
|
+
result << sub_result
|
68
|
+
|
69
|
+
progress.progress += sub_division.size
|
70
|
+
end
|
71
|
+
|
72
|
+
download_xml(result)
|
73
|
+
|
74
|
+
result = formatter.format(result)
|
75
|
+
if options[:output]
|
76
|
+
File.open(options[:output], 'w') do |f|
|
77
|
+
f.write result
|
78
|
+
end
|
79
|
+
else
|
80
|
+
puts result
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def download_xml(result)
|
85
|
+
if options[:xml]
|
86
|
+
File.open(options[:xml] + ".xml", "wb") do |f|
|
87
|
+
f.write Faraday.get("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&id=#{result.first.map{|h| h['taxon_id'] }.join(",")}&retmode=xml").body
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def glob_to_regex(glob_string)
|
95
|
+
# only implement * -> . for now
|
96
|
+
Regexp.new glob_string.gsub("*", ".*")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Taxa2lca < ApiRunner
|
101
|
+
|
102
|
+
def mapping
|
103
|
+
{"taxa2lca" => "taxa2lca"}
|
104
|
+
end
|
105
|
+
|
106
|
+
def url_options(sub_part)
|
107
|
+
{:taxon_ids => sub_part, :full_lineage => options[:lineage]}
|
108
|
+
end
|
109
|
+
|
110
|
+
def batch_size
|
111
|
+
100000
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
class Pept2pro < ApiRunner
|
119
|
+
|
120
|
+
def mapping
|
121
|
+
{"pept2pro" => "pept2pro"}
|
122
|
+
end
|
123
|
+
|
124
|
+
def url_options(sub_part)
|
125
|
+
{:sequences => sub_part, :equate_il => options[:equate]}
|
126
|
+
end
|
127
|
+
|
128
|
+
def download_xml(result)
|
129
|
+
if options[:xml]
|
130
|
+
FileUtils.mkdir_p(options[:xml])
|
131
|
+
result.first.each do |prot|
|
132
|
+
File.open(options[:xml] + "/#{prot['uniprot_id']}.xml", "wb") do |f|
|
133
|
+
f.write Faraday.get("http://www.uniprot.org/uniprot/#{prot['uniprot_id']}.xml").body
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
root_cmd = Cri::Command.new_basic_root.modify do
|
142
|
+
name 'unipept'
|
143
|
+
flag :v, :verbose, "verbose mode"
|
144
|
+
option :i, :input, "input file", :argument => :required
|
145
|
+
option :o, :output, "output file", :argument => :required
|
146
|
+
option :f, :format, "output format (available: #{Unipept::Formatter.available.join "," }) (default: #{Unipept::Formatter.default})", :argument => :required
|
147
|
+
end
|
148
|
+
|
149
|
+
root_cmd.define_command('config') do
|
150
|
+
usage 'config attr [value]'
|
151
|
+
|
152
|
+
run do |opts, args, cmd|
|
153
|
+
config = Unipept::Configuration.new
|
154
|
+
if args.size > 1
|
155
|
+
config[args.first] = args[1]
|
156
|
+
config.save
|
157
|
+
elsif args.size == 1
|
158
|
+
puts config[args.first]
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
root_cmd.define_command('pept2taxa') do
|
165
|
+
usage 'pepttotaxa [options]'
|
166
|
+
aliases :s
|
167
|
+
summary 'Single Peptide Search'
|
168
|
+
description 'Search Unipept for the given peptide and return taxons'
|
169
|
+
|
170
|
+
flag :e, :equate, "equate I and L"
|
171
|
+
option :s, :select, "select the attributes", :argument => :required
|
172
|
+
option :l, :lineage, "Show full lineage"
|
173
|
+
option :x, :xml, "Download taxonomy from NCBI as xml (specify output filename)", :argument => :required
|
174
|
+
|
175
|
+
runner ApiRunner
|
176
|
+
end
|
177
|
+
|
178
|
+
root_cmd.define_command('pept2lca') do
|
179
|
+
usage 'pepttolca [options]'
|
180
|
+
aliases :l
|
181
|
+
summary 'Give lowest common ancestor for given peptide'
|
182
|
+
description 'Search Unipept for the given peptide and return the lowest common ancestor'
|
183
|
+
|
184
|
+
flag :e, :equate, "equate I and L"
|
185
|
+
option :s, :select, "select the attributes", :argument => :required
|
186
|
+
option :l, :lineage, "Show full lineage"
|
187
|
+
|
188
|
+
runner ApiRunner
|
189
|
+
end
|
190
|
+
|
191
|
+
root_cmd.define_command('taxa2lca') do
|
192
|
+
usage 'taxa2lca [options]'
|
193
|
+
aliases :t
|
194
|
+
summary 'Give lowest common ancestor for taxon ids'
|
195
|
+
description 'Search Unipept for the given taxon ids and return the lowest common ancestor'
|
196
|
+
|
197
|
+
option :s, :select, "select the attributes", :argument => :required
|
198
|
+
option :l, :lineage, "Show full lineage"
|
199
|
+
|
200
|
+
runner Taxa2lca
|
201
|
+
end
|
202
|
+
|
203
|
+
root_cmd.define_command('pept2pro') do
|
204
|
+
usage 'pept2pro [options]'
|
205
|
+
aliases :p
|
206
|
+
summary 'Give protein information for given peptides'
|
207
|
+
description 'Search Unipept for the given peptides and return the lowest common ancestor'
|
208
|
+
|
209
|
+
flag :e, :equate, "equate I and L"
|
210
|
+
option :s, :select, "select the attributes", :argument => :required
|
211
|
+
option :x, :xml, "download uniprot record in specified directory", :argument => :required
|
212
|
+
|
213
|
+
runner Pept2pro
|
214
|
+
end
|
215
|
+
|
216
|
+
root_cmd.run(ARGV)
|
data/bin/uniprot
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Unipept
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
attr_reader :config
|
5
|
+
attr_reader :file_name
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@file_name = File.join(Dir.home, ".unipeptrc")
|
9
|
+
if !File.exists? file_name
|
10
|
+
@config = {}
|
11
|
+
else
|
12
|
+
@config = YAML.load_file file_name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def save
|
17
|
+
File.open(file_name, 'w') { |f| f.write config.to_yaml }
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](*args)
|
21
|
+
config.[](*args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def []=(*args)
|
25
|
+
config.[]=(*args)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Unipept
|
2
|
+
class Formatter
|
3
|
+
|
4
|
+
def self.formatters
|
5
|
+
@@formatters ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.new_for_format(format)
|
9
|
+
begin
|
10
|
+
formatters[format].new
|
11
|
+
rescue
|
12
|
+
formatters[self.default].new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.register(format)
|
17
|
+
self.formatters[format.to_s] = self
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.available
|
21
|
+
self.formatters.keys
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default
|
25
|
+
'json'
|
26
|
+
end
|
27
|
+
|
28
|
+
# JSON formatted data goes in, something other comes out
|
29
|
+
def format(data)
|
30
|
+
data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class JSONFormatter < Formatter
|
35
|
+
require 'json'
|
36
|
+
register :json
|
37
|
+
|
38
|
+
def format(data)
|
39
|
+
data.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
class CSVFormatter < Formatter
|
44
|
+
require 'csv'
|
45
|
+
|
46
|
+
register :csv
|
47
|
+
|
48
|
+
def format(data)
|
49
|
+
CSV.generate do |csv|
|
50
|
+
first = data.first
|
51
|
+
if first.kind_of? Array
|
52
|
+
first = first.first
|
53
|
+
end
|
54
|
+
csv << first.keys.map(&:to_s)
|
55
|
+
|
56
|
+
data.each do |o|
|
57
|
+
if o.kind_of? Array
|
58
|
+
o.each {|h| csv << h.values }
|
59
|
+
else
|
60
|
+
csv << o.values
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class XMLFormatter < Formatter
|
68
|
+
|
69
|
+
# Monkey patch (do as to_xml, but saner)
|
70
|
+
|
71
|
+
class ::Object
|
72
|
+
def to_xml(name = nil)
|
73
|
+
name ? %{<#{name}>#{self.to_s}</#{name}>} : self.to_s
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class ::Array
|
78
|
+
def to_xml( array_name = :array, item_name = :item )
|
79
|
+
%|<#{array_name} size="#{self.size}">|+map{|n|n.to_xml( :item )}.join+"</#{array_name}>"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class ::Hash
|
84
|
+
def to_xml( name = nil )
|
85
|
+
data = to_a.map{|k,v|v.to_xml(k)}.join
|
86
|
+
name ? "<#{name}>#{data}</#{name}>" : data
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
register :xml
|
91
|
+
|
92
|
+
def format(data)
|
93
|
+
data.to_xml
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
end
|
data/lib/unipept.rb
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_adapter 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
+
add_filter "/.rvm/"
|
16
|
+
end
|
17
|
+
require 'rubygems'
|
18
|
+
require 'bundler'
|
19
|
+
begin
|
20
|
+
Bundler.setup(:default, :development)
|
21
|
+
rescue Bundler::BundlerError => e
|
22
|
+
$stderr.puts e.message
|
23
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
+
exit e.status_code
|
25
|
+
end
|
26
|
+
require 'test/unit'
|
27
|
+
require 'shoulda'
|
28
|
+
|
29
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
31
|
+
require 'unipept'
|
32
|
+
|
33
|
+
class Test::Unit::TestCase
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: unipept
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toon Willems
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: shoulda
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.8'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.9'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.9'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: cri
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.5'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.5'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: ruby-progressbar
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.4'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.4'
|
125
|
+
description: CLI interface to unipept
|
126
|
+
email: willemstoon@gmail.com
|
127
|
+
executables:
|
128
|
+
- unipept
|
129
|
+
- prot2pept
|
130
|
+
- peptfilter
|
131
|
+
- uniprot
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".document"
|
136
|
+
- ".gitignore"
|
137
|
+
- Gemfile
|
138
|
+
- Gemfile.lock
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.rdoc
|
141
|
+
- Rakefile
|
142
|
+
- VERSION
|
143
|
+
- bin/peptfilter
|
144
|
+
- bin/prot2pept
|
145
|
+
- bin/unipept
|
146
|
+
- bin/uniprot
|
147
|
+
- lib/unipept.rb
|
148
|
+
- lib/unipept/configuration.rb
|
149
|
+
- lib/unipept/formatters.rb
|
150
|
+
- test/helper.rb
|
151
|
+
- test/test_unipept.rb
|
152
|
+
homepage: http://github.ugent.be/bmesuere/unipept/
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.2.0
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: CLI interface to unipept
|
176
|
+
test_files: []
|