diff --git a/.rubocop.yml b/.rubocop.yml
index b6a4609..8e0b5d6 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -46,6 +46,8 @@ Metrics/ClassLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
+Metrics/ModuleLength:
+ Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Metrics/CyclomaticComplexity:
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
deleted file mode 100644
index d672697..0000000
--- a/app/channels/application_cable/channel.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module ApplicationCable
- class Channel < ActionCable::Channel::Base
- end
-end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
deleted file mode 100644
index 0ff5442..0000000
--- a/app/channels/application_cable/connection.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-module ApplicationCable
- class Connection < ActionCable::Connection::Base
- end
-end
diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb
index 431781e..dbc7451 100644
--- a/app/controllers/api/api_controller.rb
+++ b/app/controllers/api/api_controller.rb
@@ -1,13 +1,6 @@
-require 'octokit'
-
class Api::ApiController < HandleOptionsController
respond_to :json
- before_action :set_headers, only: %i[pept2taxa pept2lca pept2prot pept2funct pept2ec pept2go pept2interpro peptinfo taxa2lca taxonomy taxa2tree protinfo]
- before_action :set_params, only: %i[pept2taxa pept2lca pept2prot pept2funct pept2ec pept2go pept2interpro peptinfo taxa2lca taxonomy taxa2tree protinfo]
- before_action :set_query, only: %i[pept2taxa pept2lca peptinfo taxonomy]
- before_action :set_sequences, only: %i[pept2prot]
-
# before_action :log, only: %i[pept2taxa pept2lca pept2prot pept2funct pept2ec pept2go pept2interpro peptinfo taxa2lca taxonomy taxa2tree]
# sends a message to the ruby cli
@@ -21,277 +14,6 @@ def messages
end
end
- # Returns a list of Uniprot entries containing a given tryptic peptide
- # params[:input]: Array, required, List of input peptides
- # params[:equate_il]: "true" or "false" (default), optional, Equate I and L?
- # params[:extra]: "true" or "false" (default), optional, Output extra info?
- def pept2prot
- lookup = Hash.new { |h, k| h[k] = Set.new }
- if @extra_info
- @result = {}
- # Perform joins and load objects (expensive)
- ids = []
- @sequences.pluck(:sequence, 'uniprot_entries.id').each do |sequence, uniprot_id|
- ids.append uniprot_id
- lookup[uniprot_id] << sequence
- @result[sequence] = Set.new
- end
-
- ids = ids.uniq.compact.sort
- UniprotEntry.includes(:taxon, :ec_cross_references, :go_cross_references)
- .where(id: ids).find_in_batches do |group|
- group.each do |uni|
- lookup[uni.id].each { |s| @result[s] << uni }
- end
- end
- else
- @result = Hash.new { |h, k| h[k] = Set.new }
- @sequences.pluck(:sequence, 'uniprot_entries.uniprot_accession_number', 'uniprot_entries.name', 'uniprot_entries.taxon_id').each do |sequence, uniprot_id, protein_name, taxon_id|
- @result[sequence] << [uniprot_id, protein_name, taxon_id]
- end
- end
-
- filter_input_order
-
- respond_with(@result)
- end
-
- # Returns a list of taxa retrieved from the Uniprot entries containing a given tryptic peptide
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", Include lineage
- # param[names]: "true" or "false", Include the lineage names
- def pept2taxa
- @result = {}
- lookup = Hash.new { |h, k| h[k] = Set.new }
- ids = Set.new
-
- seqid2seq = {}
- Sequence.where(sequence: @input).select(:id, :sequence).each do |seq|
- seqid2seq[seq[:id]] = seq[:sequence]
- @result[seq[:sequence]] = Set.new
- end
-
- rel_name = @equate_il ? :sequence_id : :original_sequence_id
- Peptide.where(rel_name => seqid2seq.keys).select(:id, rel_name, :uniprot_entry_id).find_in_batches do |items|
- uniprot2seqids = Hash.new { |h, k| h[k] = [] }
- items.each { |i| uniprot2seqids[i[:uniprot_entry_id]] << i[rel_name] }
-
- UniprotEntry.where(id: uniprot2seqids.keys).select(:id, :taxon_id).each do |entry|
- uniprot2seqids[entry[:id]].each do |seqid|
- sequence = seqid2seq[seqid]
- lookup[entry[:taxon_id]] << sequence
- ids << entry[:taxon_id]
- end
- end
- end
-
- ids.delete nil
- ids = ids.to_a.sort
-
- @query.where(id: ids).find_in_batches do |group|
- group.each do |t|
- lookup[t.id].each { |s| @result[s] << t }
- end
- end
-
- filter_input_order
-
- respond_with(@result)
- end
-
- # Returns the taxonomic lowest common ancestor for a given tryptic peptide
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", Include lineage
- # param[names]: "true" or "false", Include the lineage names
- def pept2lca
- @result = pept2lca_helper
- respond_with(@result)
- end
-
- # Returns the functional GO terms and EC numbers for a given tryptic peptide
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", optional, Output extra info?
- # param[domains]: "true" or "false", optional, Should GO_terms be split according to namespace?
- def pept2funct
- @result = {}
-
- ec_result = pept2ec_helper
- go_result = pept2go_helper
- interpro_result = pept2interpro_helper
-
- @input_order.each do |seq|
- seq_index = @equate_il ? seq.tr('I', 'L') : seq
-
- next unless go_result.key? seq_index
-
- @result[seq_index] = {
- total: go_result[seq_index][:total],
- go: go_result[seq_index][:go],
- ec: ec_result[seq_index][:ec],
- ipr: interpro_result[seq_index][:ipr]
- }
- end
-
- respond_with(@result)
- end
-
- # Returns both the lca, ec and go information for a given tryptic peptide
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", optional, Output extra info?
- # param[domains]: "true" or "false", optional, Should GO_terms be split according to namespace?
- def peptinfo
- @result = {}
-
- lca_result = pept2lca_helper
- ec_result = pept2ec_helper
- go_result = pept2go_helper
- interpro_result = pept2interpro_helper
-
- @input_order.each do |seq|
- seq_index = @equate_il ? seq.tr('I', 'L') : seq
-
- next unless go_result.key? seq_index
-
- @result[seq_index] = {
- total: go_result[seq_index][:total],
- go: go_result[seq_index][:go],
- ec: ec_result[seq_index][:ec],
- ipr: interpro_result[seq_index][:ipr],
- lca: lca_result[seq_index]
- }
- end
-
- respond_with(@result)
- end
-
- # Returns the functional EC numbers for a given tryptic peptide
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" of "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", optional, Output extra info?
- def pept2ec
- @result = pept2ec_helper
- respond_with(@result)
- end
-
- # Returns the functional GO terms for a given tryptic peptide
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" of "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", optional, Output extra info?
- # param[domains]: "true" or "false", optional, Should GO_terms be split according to namespace?
- def pept2go
- @result = pept2go_helper
- respond_with(@result)
- end
-
- # Returns the functional interpro entries for given tryptic peptides
- # param[input]: Array, required, List of input peptides
- # param[equate_il]: "true" of "false", Indicate if you want to equate I and L
- # param[extra]: "true" or "false", optional, Output extra info?
- # param[domains]: "true" or "false", optional, Should InterPro entries be split according to type?
- def pept2interpro
- @result = pept2interpro_helper
- respond_with(@result)
- end
-
- # Returns the lowest common ancestor for a given list of taxon id's
- # param[input]: Array, required, List of input taxon ids
- # param[extra]: "true" or "false", Include lineage
- # param[names]: "true" or "false", Include the lineage names
- def taxa2lca
- # handle case where 1 is provided
- if @input.include? '1'
- @result = Taxon.find(1)
- else
- lineages = Lineage.includes(Lineage::ORDER_T).where(taxon_id: @input)
- @result = Lineage.calculate_lca_taxon(lineages)
- end
-
- respond_with(@result)
- end
-
- # Returns a tree with all taxa aggregated over the complete lineage.
- # param[input]: Array, required, List of input taxon ids
- # param[extra]: "true" or "false", Include lineage
- # param[names]: "true" or "false", Include the lineage names
- def taxa2tree
- frequencies = Hash.new 0
- if @counts
- # Convert @counts into a hash with default values and integer keys.
- @counts.each do |k, v|
- frequencies[k.to_i] = v.to_i
- end
- else
- @input.each do |id|
- frequencies[id.to_i] += 1
- end
- end
-
- @root = Lineage.build_tree(frequencies)
-
- if @link
- client = Octokit::Client.new(access_token: ENV['TAXA2TREE_AT'])
- result = client.create_gist(
- {
- description: 'Unipept Taxa2Tree results',
- files:
- {
- 'index.html' => { content: render_to_string(template: 'api/api/taxa2tree.html', layout: false) },
- 'readme.md' => { content: render_to_string(template: 'api/api/taxa2tree_readme.md', layout: false) },
- '.block' => { content: 'height: 710' }
- },
- public: false
- }
- )
-
- @gist = result[:html_url]
-
- if @remove
- # Immediately delete the gist again. This is used for testing the uptime of the API server
- client.delete_gist(result[:id])
- end
- end
-
- render layout: false
- end
-
- # Returns the taxonomic information for a given list of taxon id's
- # param[input]: Array, required, List of input taxon ids
- # param[extra]: "true" or "false", Include lineage
- # param[names]: "true" or "false", Include the lineage names
- def taxonomy
- @result = @query.where(id: @input)
- @result = @result.index_by(&:id)
- @input_order = @input.select { |i| @result.key? i.to_i }
- @result = @input_order.map { |i| @result[i.to_i] }
- respond_with(@result)
- end
-
- # Returns the taxonomic and functional information for given uniprot id's
- # param[input]: Array, required, List of input uniprot id's
- def protinfo
- @result = {}
-
- UniprotEntry
- .includes(:taxon, :ec_numbers, :go_terms, :interpro_entries)
- .where(uniprot_accession_number: @input_order)
- .find_in_batches do |batch|
- batch.each do |uniprot_id|
- @result[uniprot_id.uniprot_accession_number] = {
- taxon: uniprot_id.taxon,
- ec: uniprot_id.ec_numbers.map { |ec| { ec_number: ec.code } },
- go: uniprot_id.go_terms.map { |go| { go_term: go.code } },
- ipr: uniprot_id.interpro_entries.map { |interpro| { code: interpro.code } }
- }
- end
- end
-
- respond_with(@result)
- end
-
private
# log all api calls to stathat
@@ -369,194 +91,4 @@ def filter_input_order
@result.key? key
end
end
-
- def pept2lca_helper
- output = {}
- lookup = Hash.new { |h, k| h[k] = Set.new }
- ids = []
- @sequences = Sequence.where(sequence: @input)
- lca_field = @equate_il ? :lca_il : :lca
- @sequences.pluck(:sequence, lca_field).each do |sequence, lca_il|
- ids.append lca_il
- lookup[lca_il] << sequence
- end
-
- ids = ids.uniq.compact.sort
-
- @query.where(id: ids).find_in_batches do |group|
- group.each do |t|
- lookup[t.id].each { |s| output[s] = t }
- end
- end
-
- output
- end
-
- def pept2ec_helper
- output = {}
-
- @sequences = Sequence.where(sequence: @input)
-
- ec_numbers = []
-
- @sequences.each do |seq|
- fa = seq.calculate_fa(@equate_il)
- ecs = fa['data'].select { |k, _v| k.start_with?('EC:') }
-
- output[seq.sequence] = {
- total: fa['num']['all'],
- ec: ecs.map do |k, v|
- {
- ec_number: k[3..],
- protein_count: v
- }
- end
- }
-
- ec_numbers.push(*(ecs.map { |k, _v| k[3..] }))
- end
-
- if @extra_info
- ec_numbers = ec_numbers.uniq.compact.sort
-
- ec_mapping = {}
-
- EcNumber.where(code: ec_numbers).each do |ec_term|
- ec_mapping[ec_term.code] = ec_term.name
- end
-
- output.each do |_k, v|
- v[:ec].each do |value|
- value[:name] = ec_mapping[value[:ec_number]]
- end
- end
- end
-
- output
- end
-
- def pept2go_helper
- output = {}
- go_terms = []
-
- @sequences = Sequence.where(sequence: @input)
-
- @sequences.each do |seq|
- fa = seq.calculate_fa(@equate_il)
- gos = fa['data'].select { |k, _v| k.start_with?('GO:') }
-
- output[seq.sequence] = {
- total: fa['num']['all'],
- go: gos.map do |k, v|
- {
- go_term: k,
- protein_count: v
- }
- end
- }
-
- go_terms.push(*gos.keys)
- end
-
- if @extra_info || @domains
- go_terms = go_terms.uniq.compact.sort
-
- go_mapping = {}
- GoTerm.where(code: go_terms).each do |go_term|
- go_mapping[go_term.code] = go_term
- end
-
- if @domains
-
- set_name = if @extra_info
- ->(value) { value[:name] = go_mapping[value[:go_term]].name }
- else
- # Do nothing
- ->(_value) {}
- end
-
- # We have to transform the input so that the different GO-terms are split per namespace
- output.each do |_k, v|
- splitted = Hash.new { |h, k1| h[k1] = [] }
-
- v[:go].each do |value|
- go_term = go_mapping[value[:go_term]]
- set_name[value]
- splitted[go_term.namespace] << value
- end
-
- v[:go] = splitted
- end
- else
- output.map do |_k, v|
- v[:go].each do |value|
- value[:name] = go_mapping[value[:go_term]].name
- end
- end
- end
- end
-
- output
- end
-
- def pept2interpro_helper
- output = {}
- ipr_entries = []
-
- @sequences = Sequence.where(sequence: @input)
-
- @sequences.each do |seq|
- fa = seq.calculate_fa(@equate_il)
- iprs = fa['data'].select { |k, _v| k.start_with?('IPR:') }
-
- output[seq.sequence] = {
- total: fa['num']['all'],
- ipr: iprs.map do |k, v|
- {
- code: k[4..],
- protein_count: v
- }
- end
- }
-
- ipr_entries.push(*(iprs.map { |k, _v| k[4..] }))
- end
-
- if @extra_info || @domains
- ipr_entries = ipr_entries.uniq.compact.sort
- ipr_mapping = {}
-
- InterproEntry.where(code: ipr_entries).each do |ipr_entry|
- ipr_mapping[ipr_entry.code] = ipr_entry
- end
-
- if @domains
- # We have to transform the input so that the different InterPro entries are split per type
- output.each do |_k, v|
- splitted = Hash.new { |h, k1| h[k1] = [] }
-
- v[:ipr].each do |value|
- ipr_entry = ipr_mapping[value[:code]]
-
- unless ipr_entry.nil?
- value[:name] = ipr_entry.name if @extra_info
- splitted[ipr_entry.category] << value
- end
- end
-
- v[:ipr] = splitted
- end
- else
- output.map do |_k, v|
- v[:ipr].each do |value|
- ipr_entry = ipr_mapping[value[:code]]
- value[:name] = ipr_entry.nil? ? '' : ipr_entry.name
- value[:type] = ipr_entry.nil? ? '' : ipr_entry.category
- end
- end
- end
- end
-
- output
- end
end
diff --git a/app/controllers/api/pept2ec_controller.rb b/app/controllers/api/pept2ec_controller.rb
new file mode 100644
index 0000000..9d70764
--- /dev/null
+++ b/app/controllers/api/pept2ec_controller.rb
@@ -0,0 +1,15 @@
+class Api::Pept2ecController < Api::ApiController
+ include FunctionalityHelper
+
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns the functional EC numbers for a given tryptic peptide
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" of "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", optional, Output extra info?
+ def pept2ec
+ @result = pept2ec_helper
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/pept2funct_controller.rb b/app/controllers/api/pept2funct_controller.rb
new file mode 100644
index 0000000..376f6d1
--- /dev/null
+++ b/app/controllers/api/pept2funct_controller.rb
@@ -0,0 +1,34 @@
+class Api::Pept2functController < Api::ApiController
+ include FunctionalityHelper
+
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns the functional GO terms and EC numbers for a given tryptic peptide
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", optional, Output extra info?
+ # param[domains]: "true" or "false", optional, Should GO_terms be split according to namespace?
+ def pept2funct
+ @result = {}
+
+ ec_result = pept2ec_helper
+ go_result = pept2go_helper
+ interpro_result = pept2interpro_helper
+
+ @input_order.each do |seq|
+ seq_index = @equate_il ? seq.tr('I', 'L') : seq
+
+ next unless go_result.key? seq_index
+
+ @result[seq_index] = {
+ total: go_result[seq_index][:total],
+ go: go_result[seq_index][:go],
+ ec: ec_result[seq_index][:ec],
+ ipr: interpro_result[seq_index][:ipr]
+ }
+ end
+
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/pept2go_controller.rb b/app/controllers/api/pept2go_controller.rb
new file mode 100644
index 0000000..10701f2
--- /dev/null
+++ b/app/controllers/api/pept2go_controller.rb
@@ -0,0 +1,16 @@
+class Api::Pept2goController < Api::ApiController
+ include FunctionalityHelper
+
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns the functional GO terms for a given tryptic peptide
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" of "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", optional, Output extra info?
+ # param[domains]: "true" or "false", optional, Should GO_terms be split according to namespace?
+ def pept2go
+ @result = pept2go_helper
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/pept2interpro_controller.rb b/app/controllers/api/pept2interpro_controller.rb
new file mode 100644
index 0000000..fb3a8da
--- /dev/null
+++ b/app/controllers/api/pept2interpro_controller.rb
@@ -0,0 +1,16 @@
+class Api::Pept2interproController < Api::ApiController
+ include FunctionalityHelper
+
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns the functional interpro entries for given tryptic peptides
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" of "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", optional, Output extra info?
+ # param[domains]: "true" or "false", optional, Should InterPro entries be split according to type?
+ def pept2interpro
+ @result = pept2interpro_helper
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/pept2lca_controller.rb b/app/controllers/api/pept2lca_controller.rb
new file mode 100644
index 0000000..29a6bb2
--- /dev/null
+++ b/app/controllers/api/pept2lca_controller.rb
@@ -0,0 +1,17 @@
+class Api::Pept2lcaController < Api::ApiController
+ include TaxonomyHelper
+
+ before_action :set_headers
+ before_action :set_params
+ before_action :set_query
+
+ # Returns the taxonomic lowest common ancestor for a given tryptic peptide
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", Include lineage
+ # param[names]: "true" or "false", Include the lineage names
+ def pept2lca
+ @result = pept2lca_helper
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/pept2prot_controller.rb b/app/controllers/api/pept2prot_controller.rb
new file mode 100644
index 0000000..6c2c65d
--- /dev/null
+++ b/app/controllers/api/pept2prot_controller.rb
@@ -0,0 +1,40 @@
+class Api::Pept2protController < Api::ApiController
+ before_action :set_headers
+ before_action :set_params
+ before_action :set_sequences
+
+ # Returns a list of Uniprot entries containing a given tryptic peptide
+ # params[:input]: Array, required, List of input peptides
+ # params[:equate_il]: "true" or "false" (default), optional, Equate I and L?
+ # params[:extra]: "true" or "false" (default), optional, Output extra info?
+ def pept2prot
+ lookup = Hash.new { |h, k| h[k] = Set.new }
+ if @extra_info
+ @result = {}
+ # Perform joins and load objects (expensive)
+ ids = []
+ @sequences.pluck(:sequence, 'uniprot_entries.id').each do |sequence, uniprot_id|
+ ids.append uniprot_id
+ lookup[uniprot_id] << sequence
+ @result[sequence] = Set.new
+ end
+
+ ids = ids.uniq.compact.sort
+ UniprotEntry.includes(:taxon, :ec_cross_references, :go_cross_references, :interpro_cross_references)
+ .where(id: ids).find_in_batches do |group|
+ group.each do |uni|
+ lookup[uni.id].each { |s| @result[s] << uni }
+ end
+ end
+ else
+ @result = Hash.new { |h, k| h[k] = Set.new }
+ @sequences.pluck(:sequence, 'uniprot_entries.uniprot_accession_number', 'uniprot_entries.name', 'uniprot_entries.taxon_id', 'uniprot_entries.protein').each do |sequence, uniprot_id, protein_name, taxon_id, protein|
+ @result[sequence] << [uniprot_id, protein_name, taxon_id, protein]
+ end
+ end
+
+ filter_input_order
+
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/pept2taxa_controller.rb b/app/controllers/api/pept2taxa_controller.rb
new file mode 100644
index 0000000..74dd2e9
--- /dev/null
+++ b/app/controllers/api/pept2taxa_controller.rb
@@ -0,0 +1,49 @@
+class Api::Pept2taxaController < Api::ApiController
+ before_action :set_headers
+ before_action :set_params
+ before_action :set_query
+
+ # Returns a list of taxa retrieved from the Uniprot entries containing a given tryptic peptide
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", Include lineage
+ # param[names]: "true" or "false", Include the lineage names
+ def pept2taxa
+ @result = {}
+ lookup = Hash.new { |h, k| h[k] = Set.new }
+ ids = Set.new
+
+ seqid2seq = {}
+ Sequence.where(sequence: @input).select(:id, :sequence).each do |seq|
+ seqid2seq[seq[:id]] = seq[:sequence]
+ @result[seq[:sequence]] = Set.new
+ end
+
+ rel_name = @equate_il ? :sequence_id : :original_sequence_id
+ Peptide.where(rel_name => seqid2seq.keys).select(:id, rel_name, :uniprot_entry_id).find_in_batches do |items|
+ uniprot2seqids = Hash.new { |h, k| h[k] = [] }
+ items.each { |i| uniprot2seqids[i[:uniprot_entry_id]] << i[rel_name] }
+
+ UniprotEntry.where(id: uniprot2seqids.keys).select(:id, :taxon_id).each do |entry|
+ uniprot2seqids[entry[:id]].each do |seqid|
+ sequence = seqid2seq[seqid]
+ lookup[entry[:taxon_id]] << sequence
+ ids << entry[:taxon_id]
+ end
+ end
+ end
+
+ ids.delete nil
+ ids = ids.to_a.sort
+
+ @query.where(id: ids).find_in_batches do |group|
+ group.each do |t|
+ lookup[t.id].each { |s| @result[s] << t }
+ end
+ end
+
+ filter_input_order
+
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/peptinfo_controller.rb b/app/controllers/api/peptinfo_controller.rb
new file mode 100644
index 0000000..1b22e23
--- /dev/null
+++ b/app/controllers/api/peptinfo_controller.rb
@@ -0,0 +1,38 @@
+class Api::PeptinfoController < Api::ApiController
+ include FunctionalityHelper
+ include TaxonomyHelper
+
+ before_action :set_headers
+ before_action :set_params
+ before_action :set_query
+
+ # Returns both the lca, ec and go information for a given tryptic peptide
+ # param[input]: Array, required, List of input peptides
+ # param[equate_il]: "true" or "false", Indicate if you want to equate I and L
+ # param[extra]: "true" or "false", optional, Output extra info?
+ # param[domains]: "true" or "false", optional, Should GO_terms be split according to namespace?
+ def peptinfo
+ @result = {}
+
+ lca_result = pept2lca_helper
+ ec_result = pept2ec_helper
+ go_result = pept2go_helper
+ interpro_result = pept2interpro_helper
+
+ @input_order.each do |seq|
+ seq_index = @equate_il ? seq.tr('I', 'L') : seq
+
+ next unless go_result.key? seq_index
+
+ @result[seq_index] = {
+ total: go_result[seq_index][:total],
+ go: go_result[seq_index][:go],
+ ec: ec_result[seq_index][:ec],
+ ipr: interpro_result[seq_index][:ipr],
+ lca: lca_result[seq_index]
+ }
+ end
+
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/protinfo_controller.rb b/app/controllers/api/protinfo_controller.rb
new file mode 100644
index 0000000..c488497
--- /dev/null
+++ b/app/controllers/api/protinfo_controller.rb
@@ -0,0 +1,26 @@
+class Api::ProtinfoController < Api::ApiController
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns the taxonomic and functional information for given uniprot id's
+ # param[input]: Array, required, List of input uniprot id's
+ def protinfo
+ @result = {}
+
+ UniprotEntry
+ .includes(:taxon, :ec_numbers, :go_terms, :interpro_entries)
+ .where(uniprot_accession_number: @input_order)
+ .find_in_batches do |batch|
+ batch.each do |uniprot_id|
+ @result[uniprot_id.uniprot_accession_number] = {
+ taxon: uniprot_id.taxon,
+ ec: uniprot_id.ec_numbers.map { |ec| { ec_number: ec.code } },
+ go: uniprot_id.go_terms.map { |go| { go_term: go.code } },
+ ipr: uniprot_id.interpro_entries.map { |interpro| { code: interpro.code } }
+ }
+ end
+ end
+
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/taxa2lca_controller.rb b/app/controllers/api/taxa2lca_controller.rb
new file mode 100644
index 0000000..1d8d832
--- /dev/null
+++ b/app/controllers/api/taxa2lca_controller.rb
@@ -0,0 +1,20 @@
+class Api::Taxa2lcaController < Api::ApiController
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns the lowest common ancestor for a given list of taxon id's
+ # param[input]: Array, required, List of input taxon ids
+ # param[extra]: "true" or "false", Include lineage
+ # param[names]: "true" or "false", Include the lineage names
+ def taxa2lca
+ # handle case where 1 is provided
+ if @input.include? '1'
+ @result = Taxon.find(1)
+ else
+ lineages = Lineage.includes(Lineage::ORDER_T).where(taxon_id: @input)
+ @result = Lineage.calculate_lca_taxon(lineages)
+ end
+
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/api/taxa2tree_controller.rb b/app/controllers/api/taxa2tree_controller.rb
new file mode 100644
index 0000000..107dd6d
--- /dev/null
+++ b/app/controllers/api/taxa2tree_controller.rb
@@ -0,0 +1,51 @@
+require 'octokit'
+
+class Api::Taxa2treeController < Api::ApiController
+ before_action :set_headers
+ before_action :set_params
+
+ # Returns a tree with all taxa aggregated over the complete lineage.
+ # param[input]: Array, required, List of input taxon ids
+ # param[extra]: "true" or "false", Include lineage
+ # param[names]: "true" or "false", Include the lineage names
+ def taxa2tree
+ frequencies = Hash.new 0
+ if @counts
+ # Convert @counts into a hash with default values and integer keys.
+ @counts.each do |k, v|
+ frequencies[k.to_i] = v.to_i
+ end
+ else
+ @input.each do |id|
+ frequencies[id.to_i] += 1
+ end
+ end
+
+ @root = Lineage.build_tree(frequencies)
+
+ if @link
+ client = Octokit::Client.new(access_token: ENV['TAXA2TREE_AT'])
+ result = client.create_gist(
+ {
+ description: 'Unipept Taxa2Tree results',
+ files:
+ {
+ 'index.html' => { content: render_to_string(template: 'api/taxa2tree/taxa2tree.html', layout: false) },
+ 'readme.md' => { content: render_to_string(template: 'api/taxa2tree_readme.md', layout: false) },
+ '.block' => { content: 'height: 710' }
+ },
+ public: false
+ }
+ )
+
+ @gist = result[:html_url]
+
+ if @remove
+ # Immediately delete the gist again. This is used for testing the uptime of the API server
+ client.delete_gist(result[:id])
+ end
+ end
+
+ render layout: false
+ end
+end
diff --git a/app/controllers/api/taxonomy_controller.rb b/app/controllers/api/taxonomy_controller.rb
new file mode 100644
index 0000000..68f735c
--- /dev/null
+++ b/app/controllers/api/taxonomy_controller.rb
@@ -0,0 +1,17 @@
+class Api::TaxonomyController < Api::ApiController
+ before_action :set_headers
+ before_action :set_params
+ before_action :set_query
+
+ # Returns the taxonomic information for a given list of taxon id's
+ # param[input]: Array, required, List of input taxon ids
+ # param[extra]: "true" or "false", Include lineage
+ # param[names]: "true" or "false", Include the lineage names
+ def taxonomy
+ @result = @query.where(id: @input)
+ @result = @result.index_by(&:id)
+ @input_order = @input.select { |i| @result.key? i.to_i }
+ @result = @input_order.map { |i| @result[i.to_i] }
+ respond_with(@result)
+ end
+end
diff --git a/app/controllers/datasets/datasets_controller.rb b/app/controllers/datasets/datasets_controller.rb
new file mode 100644
index 0000000..8f349ea
--- /dev/null
+++ b/app/controllers/datasets/datasets_controller.rb
@@ -0,0 +1,10 @@
+class Datasets::DatasetsController < HandleOptionsController
+ before_action :default_format_json
+ before_action :set_headers
+
+ private
+
+ def default_format_json
+ request.format = 'json'
+ end
+end
diff --git a/app/controllers/datasets/sampledata_controller.rb b/app/controllers/datasets/sampledata_controller.rb
new file mode 100644
index 0000000..042a7c4
--- /dev/null
+++ b/app/controllers/datasets/sampledata_controller.rb
@@ -0,0 +1,5 @@
+class Datasets::SampledataController < Datasets::DatasetsController
+ def sampledata
+ @datasets = Dataset.includes(:dataset_items).all
+ end
+end
diff --git a/app/controllers/datasets_controller.rb b/app/controllers/datasets_controller.rb
deleted file mode 100644
index 4047a40..0000000
--- a/app/controllers/datasets_controller.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class DatasetsController < HandleOptionsController
- before_action :set_headers, only: %i[sampledata]
- before_action :default_format_json, only: %i[sampledata]
-
- def sampledata
- @datasets = Dataset.includes(:dataset_items).all
- end
-
- private
-
- def default_format_json
- request.format = 'json'
- end
-end
diff --git a/app/controllers/mpa/mpa_controller.rb b/app/controllers/mpa/mpa_controller.rb
new file mode 100644
index 0000000..2c94b48
--- /dev/null
+++ b/app/controllers/mpa/mpa_controller.rb
@@ -0,0 +1,11 @@
+class Mpa::MpaController < HandleOptionsController
+ before_action :set_headers
+ before_action :default_format_json
+ skip_before_action :verify_authenticity_token, raise: false
+
+ private
+
+ def default_format_json
+ request.format = 'json'
+ end
+end
diff --git a/app/controllers/mpa/pept2data_controller.rb b/app/controllers/mpa/pept2data_controller.rb
new file mode 100644
index 0000000..95e3ae0
--- /dev/null
+++ b/app/controllers/mpa/pept2data_controller.rb
@@ -0,0 +1,40 @@
+class Mpa::Pept2dataController < Mpa::MpaController
+ def pept2data
+ peptides = params[:peptides] || []
+ missed = params[:missed] || false
+ @equate_il = params[:equate_il].nil? ? true : params[:equate_il] == 'true'
+
+ # If equate_il is set, we have to replace all I's by and L in the input peptides.
+ equalized_pepts = @equate_il ? peptides.map { |p| p.gsub('I', 'L') } : peptides
+
+ @peptides = Sequence
+ .includes(Sequence.lca_t_relation_name(@equate_il) => :lineage)
+ .where(sequence: equalized_pepts)
+ .where.not(Sequence.lca_t_relation_name(@equate_il) => nil)
+ if missed
+ @peptides += equalized_pepts
+ .to_set.subtract(@peptides.map(&:sequence))
+ .map { |p| Sequence.missed_cleavage(p, @equate_il) }
+ .compact
+ end
+
+ eq_seq_to_fa = {}
+ eq_seq_to_info = {}
+
+ @peptides.each do |sequence|
+ eq_seq_to_fa[sequence.sequence] = sequence.calculate_fa(@equate_il)
+ eq_seq_to_info[sequence.sequence] = sequence
+ end
+
+ @original_pep_results = {}
+ @original_pep_fas = {}
+
+ peptides.each do |original_seq|
+ equalized_seq = @equate_il ? original_seq.gsub('I', 'L') : original_seq
+ if eq_seq_to_info.key? equalized_seq
+ @original_pep_results[original_seq] = eq_seq_to_info[equalized_seq]
+ @original_pep_fas[original_seq] = eq_seq_to_fa[equalized_seq]
+ end
+ end
+ end
+end
diff --git a/app/controllers/mpa_controller.rb b/app/controllers/mpa/pept2filtered_controller.rb
similarity index 59%
rename from app/controllers/mpa_controller.rb
rename to app/controllers/mpa/pept2filtered_controller.rb
index 494b99e..4c891bb 100644
--- a/app/controllers/mpa_controller.rb
+++ b/app/controllers/mpa/pept2filtered_controller.rb
@@ -1,47 +1,4 @@
-class MpaController < HandleOptionsController
- before_action :set_headers
- before_action :default_format_json
- skip_before_action :verify_authenticity_token, raise: false
-
- def pept2data
- peptides = params[:peptides] || []
- missed = params[:missed] || false
- @equate_il = params[:equate_il].nil? ? true : params[:equate_il]
-
- # If equate_il is set, we have to replace all I's by and L in the input peptides.
- equalized_pepts = @equate_il ? peptides.map { |p| p.gsub('I', 'L') } : peptides
-
- @peptides = Sequence
- .includes(Sequence.lca_t_relation_name(@equate_il) => :lineage)
- .where(sequence: equalized_pepts)
- .where.not(Sequence.lca_t_relation_name(@equate_il) => nil)
- if missed
- @peptides += equalized_pepts
- .to_set.subtract(@peptides.map(&:sequence))
- .map { |p| Sequence.missed_cleavage(p, @equate_il) }
- .compact
- end
-
- eq_seq_to_fa = {}
- eq_seq_to_info = {}
-
- @peptides.each do |sequence|
- eq_seq_to_fa[sequence.sequence] = sequence.calculate_fa(@equate_il)
- eq_seq_to_info[sequence.sequence] = sequence
- end
-
- @original_pep_results = {}
- @original_pep_fas = {}
-
- peptides.each do |original_seq|
- equalized_seq = @equate_il ? original_seq.gsub('I', 'L') : original_seq
- if eq_seq_to_info.key? equalized_seq
- @original_pep_results[original_seq] = eq_seq_to_info[equalized_seq]
- @original_pep_fas[original_seq] = eq_seq_to_fa[equalized_seq]
- end
- end
- end
-
+class Mpa::Pept2filteredController < Mpa::MpaController
def pept2filtered
peptides = params[:peptides] || []
cutoff = params[:cutoff] || 1000
@@ -104,10 +61,4 @@ def pept2filtered
@ipr_entries = InterproCrossReference
.where(uniprot_entry_id: uniprot_ids)
end
-
- private
-
- def default_format_json
- request.format = 'json'
- end
end
diff --git a/app/controllers/private_api/ecnumbers_controller.rb b/app/controllers/private_api/ecnumbers_controller.rb
new file mode 100644
index 0000000..563a434
--- /dev/null
+++ b/app/controllers/private_api/ecnumbers_controller.rb
@@ -0,0 +1,6 @@
+class PrivateApi::EcnumbersController < PrivateApi::PrivateApiController
+ def ecnumbers
+ ec_nrs = params[:ecnumbers]
+ @ecnumbers = EcNumber.where(code: ec_nrs)
+ end
+end
diff --git a/app/controllers/private_api/goterms_controller.rb b/app/controllers/private_api/goterms_controller.rb
new file mode 100644
index 0000000..af72403
--- /dev/null
+++ b/app/controllers/private_api/goterms_controller.rb
@@ -0,0 +1,6 @@
+class PrivateApi::GotermsController < PrivateApi::PrivateApiController
+ def goterms
+ go_terms = params[:goterms] || []
+ @goterms = GoTerm.where(code: go_terms)
+ end
+end
diff --git a/app/controllers/private_api/interpros_controller.rb b/app/controllers/private_api/interpros_controller.rb
new file mode 100644
index 0000000..da268b0
--- /dev/null
+++ b/app/controllers/private_api/interpros_controller.rb
@@ -0,0 +1,6 @@
+class PrivateApi::InterprosController < PrivateApi::PrivateApiController
+ def interpros
+ interpro_entries = params[:interpros]
+ @interpros = InterproEntry.where(code: interpro_entries)
+ end
+end
diff --git a/app/controllers/private_api/metadata_controller.rb b/app/controllers/private_api/metadata_controller.rb
new file mode 100644
index 0000000..c2ae6da
--- /dev/null
+++ b/app/controllers/private_api/metadata_controller.rb
@@ -0,0 +1,7 @@
+class PrivateApi::MetadataController < PrivateApi::PrivateApiController
+ def metadata
+ @data = {
+ db_version: Rails.application.config.versions[:uniprot]
+ }
+ end
+end
diff --git a/app/controllers/private_api/private_api_controller.rb b/app/controllers/private_api/private_api_controller.rb
new file mode 100644
index 0000000..8e3e68a
--- /dev/null
+++ b/app/controllers/private_api/private_api_controller.rb
@@ -0,0 +1,11 @@
+class PrivateApi::PrivateApiController < HandleOptionsController
+ before_action :set_headers
+ before_action :default_format_json
+ skip_before_action :verify_authenticity_token, raise: false
+
+ private
+
+ def default_format_json
+ request.format = 'json'
+ end
+end
diff --git a/app/controllers/private_api_controller.rb b/app/controllers/private_api/proteins_controller.rb
similarity index 75%
rename from app/controllers/private_api_controller.rb
rename to app/controllers/private_api/proteins_controller.rb
index fcbe354..c202a60 100644
--- a/app/controllers/private_api_controller.rb
+++ b/app/controllers/private_api/proteins_controller.rb
@@ -1,28 +1,4 @@
-class PrivateApiController < HandleOptionsController
- before_action :set_headers, only: %i[goterms ecnumbers interpros taxa proteins metadata]
- before_action :default_format_json
- skip_before_action :verify_authenticity_token, raise: false
-
- def goterms
- go_terms = params[:goterms] || []
- @goterms = GoTerm.where(code: go_terms)
- end
-
- def ecnumbers
- ec_nrs = params[:ecnumbers]
- @ecnumbers = EcNumber.where(code: ec_nrs)
- end
-
- def interpros
- interpro_entries = params[:interpros]
- @interpros = InterproEntry.where(code: interpro_entries)
- end
-
- def taxa
- taxids = params[:taxids] || []
- @taxa = Taxon.includes(:lineage).where(id: taxids)
- end
-
+class PrivateApi::ProteinsController < PrivateApi::PrivateApiController
def proteins
unless params[:peptide]
@error_name = 'Invalid peptide provided'
@@ -35,7 +11,7 @@ def proteins
# the sequence or id of the peptide (filter out all characters that are non-ASCII)
seq = params[:peptide].upcase.gsub(/\P{ASCII}/, '')
# should we equate I and L? (true by default)
- equate_il = params.key?(:equate_il) ? params[:equate_il] : true
+ equate_il = params.key?(:equate_il) ? params[:equate_il] == 'true' : true
begin
# process the input, convert seq to a valid @sequence
@@ -110,16 +86,4 @@ def proteins
last_node = last_node.add_child(node)
end
end
-
- def metadata
- @data = {
- db_version: Rails.application.config.versions[:uniprot]
- }
- end
-
- private
-
- def default_format_json
- request.format = 'json'
- end
end
diff --git a/app/controllers/private_api/taxa_controller.rb b/app/controllers/private_api/taxa_controller.rb
new file mode 100644
index 0000000..612ca23
--- /dev/null
+++ b/app/controllers/private_api/taxa_controller.rb
@@ -0,0 +1,6 @@
+class PrivateApi::TaxaController < PrivateApi::PrivateApiController
+ def taxa
+ taxids = params[:taxids] || []
+ @taxa = Taxon.includes(:lineage).where(id: taxids)
+ end
+end
diff --git a/app/helpers/functionality_helper.rb b/app/helpers/functionality_helper.rb
new file mode 100644
index 0000000..0f7f582
--- /dev/null
+++ b/app/helpers/functionality_helper.rb
@@ -0,0 +1,175 @@
+module FunctionalityHelper
+ def pept2ec_helper
+ output = {}
+
+ @sequences = Sequence.where(sequence: @input)
+
+ ec_numbers = []
+
+ @sequences.each do |seq|
+ fa = seq.calculate_fa(@equate_il)
+ # TODO: this ['num'] is a bug and should be removed before merging
+ # ecs = fa['num']['data'].select { |k, _v| k.start_with?('EC:') }
+ ecs = fa['data'].select { |k, _v| k.start_with?('EC:') }
+
+ output[seq.sequence] = {
+ total: fa['num']['all'],
+ ec: ecs.map do |k, v|
+ {
+ ec_number: k[3..],
+ protein_count: v
+ }
+ end
+ }
+
+ ec_numbers.push(*(ecs.map { |k, _v| k[3..] }))
+ end
+
+ if @extra_info
+ ec_numbers = ec_numbers.uniq.compact.sort
+
+ ec_mapping = {}
+
+ EcNumber.where(code: ec_numbers).find_each do |ec_term|
+ ec_mapping[ec_term.code] = ec_term.name
+ end
+
+ output.each_value do |v|
+ v[:ec].each do |value|
+ value[:name] = ec_mapping[value[:ec_number]]
+ end
+ end
+ end
+
+ output
+ end
+
+ def pept2go_helper
+ output = {}
+ go_terms = []
+
+ @sequences = Sequence.where(sequence: @input)
+
+ @sequences.each do |seq|
+ fa = seq.calculate_fa(@equate_il)
+ # TODO: this ['num'] is a bug and should be removed before merging
+ # gos = fa['num']['data'].select { |k, _v| k.start_with?('GO:') }
+ gos = fa['data'].select { |k, _v| k.start_with?('GO:') }
+
+ output[seq.sequence] = {
+ total: fa['num']['all'],
+ go: gos.map do |k, v|
+ {
+ go_term: k,
+ protein_count: v
+ }
+ end
+ }
+
+ go_terms.push(*gos.keys)
+ end
+
+ if @extra_info || @domains
+ go_terms = go_terms.uniq.compact.sort
+
+ go_mapping = {}
+ GoTerm.where(code: go_terms).find_each do |go_term|
+ go_mapping[go_term.code] = go_term
+ end
+
+ if @domains
+
+ set_name = if @extra_info
+ ->(value) { value[:name] = go_mapping[value[:go_term]].name }
+ else
+ # Do nothing
+ ->(_value) {}
+ end
+
+ # We have to transform the input so that the different GO-terms are split per namespace
+ output.each_value do |v|
+ splitted = Hash.new { |h, k1| h[k1] = [] }
+
+ v[:go].each do |value|
+ go_term = go_mapping[value[:go_term]]
+ set_name[value]
+ splitted[go_term.namespace] << value
+ end
+
+ v[:go] = splitted
+ end
+ else
+ output.map do |_k, v|
+ v[:go].each do |value|
+ value[:name] = go_mapping[value[:go_term]].name
+ end
+ end
+ end
+ end
+
+ output
+ end
+
+ def pept2interpro_helper
+ output = {}
+ ipr_entries = []
+
+ @sequences = Sequence.where(sequence: @input)
+
+ @sequences.each do |seq|
+ fa = seq.calculate_fa(@equate_il)
+ # TODO: this ['num'] is a bug and should be removed before merging
+ # iprs = fa['num']['data'].select { |k, _v| k.start_with?('IPR:') }
+ iprs = fa['data'].select { |k, _v| k.start_with?('IPR:') }
+
+ output[seq.sequence] = {
+ total: fa['num']['all'],
+ ipr: iprs.map do |k, v|
+ {
+ code: k[4..],
+ protein_count: v
+ }
+ end
+ }
+
+ ipr_entries.push(*(iprs.map { |k, _v| k[4..] }))
+ end
+
+ if @extra_info || @domains
+ ipr_entries = ipr_entries.uniq.compact.sort
+ ipr_mapping = {}
+
+ InterproEntry.where(code: ipr_entries).find_each do |ipr_entry|
+ ipr_mapping[ipr_entry.code] = ipr_entry
+ end
+
+ if @domains
+ # We have to transform the input so that the different InterPro entries are split per type
+ output.each_value do |v|
+ splitted = Hash.new { |h, k1| h[k1] = [] }
+
+ v[:ipr].each do |value|
+ ipr_entry = ipr_mapping[value[:code]]
+
+ unless ipr_entry.nil?
+ value[:name] = ipr_entry.name if @extra_info
+ splitted[ipr_entry.category] << value
+ end
+ end
+
+ v[:ipr] = splitted
+ end
+ else
+ output.map do |_k, v|
+ v[:ipr].each do |value|
+ ipr_entry = ipr_mapping[value[:code]]
+ value[:name] = ipr_entry.nil? ? '' : ipr_entry.name
+ value[:type] = ipr_entry.nil? ? '' : ipr_entry.category
+ end
+ end
+ end
+ end
+
+ output
+ end
+end
diff --git a/app/helpers/taxonomy_helper.rb b/app/helpers/taxonomy_helper.rb
new file mode 100644
index 0000000..15fb148
--- /dev/null
+++ b/app/helpers/taxonomy_helper.rb
@@ -0,0 +1,23 @@
+module TaxonomyHelper
+ def pept2lca_helper
+ output = {}
+ lookup = Hash.new { |h, k| h[k] = Set.new }
+ ids = []
+ @sequences = Sequence.where(sequence: @input)
+ lca_field = @equate_il ? :lca_il : :lca
+ @sequences.pluck(:sequence, lca_field).each do |sequence, lca_il|
+ ids.append lca_il
+ lookup[lca_il] << sequence
+ end
+
+ ids = ids.uniq.compact.sort
+
+ @query.where(id: ids).find_in_batches do |group|
+ group.each do |t|
+ lookup[t.id].each { |s| output[s] = t }
+ end
+ end
+
+ output
+ end
+end
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
deleted file mode 100644
index d394c3d..0000000
--- a/app/jobs/application_job.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-class ApplicationJob < ActiveJob::Base
- # Automatically retry jobs that encountered a deadlock
- # retry_on ActiveRecord::Deadlocked
-
- # Most jobs are safe to ignore if the underlying records are no longer available
- # discard_on ActiveJob::DeserializationError
-end
diff --git a/app/models/lineage.rb b/app/models/lineage.rb
index a00f5da..7476000 100644
--- a/app/models/lineage.rb
+++ b/app/models/lineage.rb
@@ -141,7 +141,7 @@ def to_a
def to_a_idx
array = ORDER_T.map { |rank| send(rank) }
- array.map { |x| x.nil? ? nil : x.id }
+ array.map { |x| x&.id }
end
def self.ranks
diff --git a/app/models/sequence.rb b/app/models/sequence.rb
index 063f019..deb432f 100644
--- a/app/models/sequence.rb
+++ b/app/models/sequence.rb
@@ -76,7 +76,7 @@ def self.missed_cleavage(sequence, equate_il)
sequences = sequence
.gsub(/([KR])([^P])/, "\\1\n\\2")
.gsub(/([KR])([^P])/, "\\1\n\\2")
- .lines.map(&:strip).reject { |i| i.length.zero? }.to_a
+ .lines.map(&:strip).reject(&:empty?).to_a
# If only one sequence is present in this array, no missed cleavages were detected for this sequence and we don't
# need to continue computing these (since it will not make any difference anyway).
@@ -217,7 +217,7 @@ def unmarshall_fa(prop)
if self[prop].blank?
return nil if self[prop] == false
- self[prop] = { 'num' => { 'all' => 0, 'EC' => 0, 'GO' => 0 }, 'data' => {} }
+ self[prop] = { 'num' => { 'all' => 0, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }
end
return self[prop] if self[prop].is_a?(Hash)
diff --git a/app/views/api/api/_pept2go.json.jbuilder b/app/views/api/_pept2go.json.jbuilder
similarity index 100%
rename from app/views/api/api/_pept2go.json.jbuilder
rename to app/views/api/_pept2go.json.jbuilder
diff --git a/app/views/api/api/_pept2interpro.json.jbuilder b/app/views/api/_pept2interpro.json.jbuilder
similarity index 100%
rename from app/views/api/api/_pept2interpro.json.jbuilder
rename to app/views/api/_pept2interpro.json.jbuilder
diff --git a/app/views/api/api/_pept2lca.json.jbuilder b/app/views/api/_pept2lca.json.jbuilder
similarity index 100%
rename from app/views/api/api/_pept2lca.json.jbuilder
rename to app/views/api/_pept2lca.json.jbuilder
diff --git a/app/views/api/api/_taxa2tree.json.jbuilder b/app/views/api/_taxa2tree.json.jbuilder
similarity index 74%
rename from app/views/api/api/_taxa2tree.json.jbuilder
rename to app/views/api/_taxa2tree.json.jbuilder
index 3a07f9c..0b0cf9e 100644
--- a/app/views/api/api/_taxa2tree.json.jbuilder
+++ b/app/views/api/_taxa2tree.json.jbuilder
@@ -6,5 +6,5 @@ json.data do
json.self_count item.data['self_count']
end
json.children item.children.each do |child|
- json.partial! partial: 'api/api/taxa2tree', locals: { item: child }
+ json.partial! partial: 'api/taxa2tree', locals: { item: child }
end
diff --git a/app/views/api/api/taxa2tree.json.jbuilder b/app/views/api/api/taxa2tree.json.jbuilder
deleted file mode 100644
index 35d9d95..0000000
--- a/app/views/api/api/taxa2tree.json.jbuilder
+++ /dev/null
@@ -1,5 +0,0 @@
-if @link && @gist
- json.gist @gist
-else
- json.partial! partial: 'api/api/taxa2tree', locals: { item: @root }
-end
diff --git a/app/views/api/api/pept2ec.json.jbuilder b/app/views/api/pept2ec/pept2ec.json.jbuilder
similarity index 100%
rename from app/views/api/api/pept2ec.json.jbuilder
rename to app/views/api/pept2ec/pept2ec.json.jbuilder
diff --git a/app/views/api/api/pept2funct.json.jbuilder b/app/views/api/pept2funct/pept2funct.json.jbuilder
similarity index 61%
rename from app/views/api/api/pept2funct.json.jbuilder
rename to app/views/api/pept2funct/pept2funct.json.jbuilder
index 66be73d..7d7586b 100644
--- a/app/views/api/api/pept2funct.json.jbuilder
+++ b/app/views/api/pept2funct/pept2funct.json.jbuilder
@@ -4,7 +4,7 @@ json.array! @input_order do |peptide|
json.peptide peptide
json.total_protein_count @result[seq_index][:total]
json.ec(@result[seq_index][:ec].sort_by { |value| -value[:protein_count] })
- json.partial! partial: 'api/api/pept2go', locals: { data: @result[seq_index][:go] }
- json.partial! partial: 'api/api/pept2interpro', locals: { data: @result[seq_index][:ipr] }
+ json.partial! partial: 'api/pept2go', locals: { data: @result[seq_index][:go] }
+ json.partial! partial: 'api/pept2interpro', locals: { data: @result[seq_index][:ipr] }
end
end
diff --git a/app/views/api/api/pept2go.json.jbuilder b/app/views/api/pept2go/pept2go.json.jbuilder
similarity index 70%
rename from app/views/api/api/pept2go.json.jbuilder
rename to app/views/api/pept2go/pept2go.json.jbuilder
index cd625fe..f75b59f 100644
--- a/app/views/api/api/pept2go.json.jbuilder
+++ b/app/views/api/pept2go/pept2go.json.jbuilder
@@ -3,6 +3,6 @@ json.array! @input_order do |peptide|
if @result.key? seq_index
json.peptide peptide
json.total_protein_count @result[seq_index][:total]
- json.partial! partial: 'api/api/pept2go', locals: { data: @result[seq_index][:go] }
+ json.partial! partial: 'api/pept2go', locals: { data: @result[seq_index][:go] }
end
end
diff --git a/app/views/api/api/pept2interpro.json.jbuilder b/app/views/api/pept2interpro/pept2interpro.json.jbuilder
similarity index 69%
rename from app/views/api/api/pept2interpro.json.jbuilder
rename to app/views/api/pept2interpro/pept2interpro.json.jbuilder
index 5142fef..22cdc29 100644
--- a/app/views/api/api/pept2interpro.json.jbuilder
+++ b/app/views/api/pept2interpro/pept2interpro.json.jbuilder
@@ -3,6 +3,6 @@ json.array! @input_order do |peptide|
if @result.key? seq_index
json.peptide peptide
json.total_protein_count @result[seq_index][:total]
- json.partial! partial: 'api/api/pept2interpro', locals: { data: @result[seq_index][:ipr] }
+ json.partial! partial: 'api/pept2interpro', locals: { data: @result[seq_index][:ipr] }
end
end
diff --git a/app/views/api/api/pept2lca.json.jbuilder b/app/views/api/pept2lca/pept2lca.json.jbuilder
similarity index 65%
rename from app/views/api/api/pept2lca.json.jbuilder
rename to app/views/api/pept2lca/pept2lca.json.jbuilder
index 129ca44..61ca845 100644
--- a/app/views/api/api/pept2lca.json.jbuilder
+++ b/app/views/api/pept2lca/pept2lca.json.jbuilder
@@ -2,6 +2,6 @@ json.array! @input_order do |peptide|
seq_index = @equate_il ? peptide.tr('I', 'L') : peptide
if @result.key? seq_index
json.peptide peptide
- json.partial! partial: 'api/api/pept2lca', locals: { data: @result[seq_index] }
+ json.partial! partial: 'api/pept2lca', locals: { data: @result[seq_index] }
end
end
diff --git a/app/views/api/api/pept2prot.json.erb b/app/views/api/pept2prot/pept2prot.json.erb
similarity index 82%
rename from app/views/api/api/pept2prot.json.erb
rename to app/views/api/pept2prot/pept2prot.json.erb
index 4d09bba..479c940 100644
--- a/app/views/api/api/pept2prot.json.erb
+++ b/app/views/api/pept2prot/pept2prot.json.erb
@@ -7,11 +7,13 @@
v.map do |u|
{ "peptide" => k,
"uniprot_id" => u.uniprot_accession_number,
+
"protein_name" => u.name,
"taxon_id" => u.taxon_id,
"taxon_name" => u.taxon.try(:name),
"ec_references" => u.ec_cross_references.map(&:ec_number_code).join(" "),
- "go_references" => u.go_cross_references.map(&:go_term_code).join(" ")
+ "go_references" => u.go_cross_references.map(&:go_term_code).join(" "),
+ "interpro_references" => u.interpro_cross_references.map(&:interpro_entry_code).join(" "),
}
end
end.flatten).html_safe
@@ -20,11 +22,12 @@
@input_order.map do |k|
seq_index = @equate_il ? k.gsub(/I/,'L') : k
v = @result[seq_index]
- v.map do |uni,name,tax|
+ v.map do |uni,name,tax,prot|
{ "peptide" => k,
"uniprot_id" => uni,
"protein_name" => name,
"taxon_id" => tax,
+ "protein" => prot
}
end
end.flatten).html_safe
diff --git a/app/views/api/api/pept2taxa.json.erb b/app/views/api/pept2taxa/pept2taxa.json.erb
similarity index 100%
rename from app/views/api/api/pept2taxa.json.erb
rename to app/views/api/pept2taxa/pept2taxa.json.erb
diff --git a/app/views/api/api/peptinfo.json.jbuilder b/app/views/api/peptinfo/peptinfo.json.jbuilder
similarity index 51%
rename from app/views/api/api/peptinfo.json.jbuilder
rename to app/views/api/peptinfo/peptinfo.json.jbuilder
index f1e9d5d..209e382 100644
--- a/app/views/api/api/peptinfo.json.jbuilder
+++ b/app/views/api/peptinfo/peptinfo.json.jbuilder
@@ -4,8 +4,8 @@ json.array! @input_order do |peptide|
json.peptide peptide
json.total_protein_count @result[seq_index][:total]
json.ec(@result[seq_index][:ec].sort_by { |value| -value[:protein_count] })
- json.partial! partial: 'api/api/pept2go', locals: { data: @result[seq_index][:go] }
- json.partial! partial: 'api/api/pept2interpro', locals: { data: @result[seq_index][:ipr] }
- json.partial! partial: 'api/api/pept2lca', locals: { data: @result[seq_index][:lca] }
+ json.partial! partial: 'api/pept2go', locals: { data: @result[seq_index][:go] }
+ json.partial! partial: 'api/pept2interpro', locals: { data: @result[seq_index][:ipr] }
+ json.partial! partial: 'api/pept2lca', locals: { data: @result[seq_index][:lca] }
end
end
diff --git a/app/views/api/api/protinfo.json.jbuilder b/app/views/api/protinfo/protinfo.json.jbuilder
similarity index 100%
rename from app/views/api/api/protinfo.json.jbuilder
rename to app/views/api/protinfo/protinfo.json.jbuilder
diff --git a/app/views/api/api/taxa2lca.json.erb b/app/views/api/taxa2lca/taxa2lca.json.erb
similarity index 100%
rename from app/views/api/api/taxa2lca.json.erb
rename to app/views/api/taxa2lca/taxa2lca.json.erb
diff --git a/app/views/api/api/taxa2tree.html.erb b/app/views/api/taxa2tree/taxa2tree.html.erb
similarity index 99%
rename from app/views/api/api/taxa2tree.html.erb
rename to app/views/api/taxa2tree/taxa2tree.html.erb
index 28076ed..789aa87 100644
--- a/app/views/api/api/taxa2tree.html.erb
+++ b/app/views/api/taxa2tree/taxa2tree.html.erb
@@ -253,7 +253,7 @@
openTab('info');
- const data = <%= raw render(:template => "api/api/taxa2tree.json", :locals => { item: @root }) %>;
+ const data = <%= raw render(:template => "api/taxa2tree/taxa2tree", :locals => { item: @root }, :formats => [:json]) %>;
function tooltipContent(d) {
return '' + d.name + ' (' + d.rank + ')
' +
diff --git a/app/views/api/taxa2tree/taxa2tree.json.jbuilder b/app/views/api/taxa2tree/taxa2tree.json.jbuilder
new file mode 100644
index 0000000..5cfc238
--- /dev/null
+++ b/app/views/api/taxa2tree/taxa2tree.json.jbuilder
@@ -0,0 +1,5 @@
+if @link && @gist
+ json.gist @gist
+else
+ json.partial! partial: 'api/taxa2tree', locals: { item: @root }
+end
diff --git a/app/views/api/api/taxa2tree_readme.md.erb b/app/views/api/taxa2tree/taxa2tree_readme.md.erb
similarity index 100%
rename from app/views/api/api/taxa2tree_readme.md.erb
rename to app/views/api/taxa2tree/taxa2tree_readme.md.erb
diff --git a/app/views/api/api/taxonomy.json.erb b/app/views/api/taxonomy/taxonomy.json.erb
similarity index 100%
rename from app/views/api/api/taxonomy.json.erb
rename to app/views/api/taxonomy/taxonomy.json.erb
diff --git a/app/views/datasets/sampledata.json.jbuilder b/app/views/datasets/sampledata/sampledata.json.jbuilder
similarity index 100%
rename from app/views/datasets/sampledata.json.jbuilder
rename to app/views/datasets/sampledata/sampledata.json.jbuilder
diff --git a/app/views/mpa/pept2data.json.jbuilder b/app/views/mpa/pept2data/pept2data.json.jbuilder
similarity index 100%
rename from app/views/mpa/pept2data.json.jbuilder
rename to app/views/mpa/pept2data/pept2data.json.jbuilder
diff --git a/app/views/mpa/pept2filtered.json.jbuilder b/app/views/mpa/pept2filtered/pept2filtered.json.jbuilder
similarity index 100%
rename from app/views/mpa/pept2filtered.json.jbuilder
rename to app/views/mpa/pept2filtered/pept2filtered.json.jbuilder
diff --git a/app/views/private_api/ecnumbers.json.jbuilder b/app/views/private_api/ecnumbers/ecnumbers.json.jbuilder
similarity index 100%
rename from app/views/private_api/ecnumbers.json.jbuilder
rename to app/views/private_api/ecnumbers/ecnumbers.json.jbuilder
diff --git a/app/views/private_api/goterms.json.jbuilder b/app/views/private_api/goterms/goterms.json.jbuilder
similarity index 100%
rename from app/views/private_api/goterms.json.jbuilder
rename to app/views/private_api/goterms/goterms.json.jbuilder
diff --git a/app/views/private_api/interpros.json.jbuilder b/app/views/private_api/interpros/interpros.json.jbuilder
similarity index 100%
rename from app/views/private_api/interpros.json.jbuilder
rename to app/views/private_api/interpros/interpros.json.jbuilder
diff --git a/app/views/private_api/metadata.json.jbuilder b/app/views/private_api/metadata/metadata.json.jbuilder
similarity index 100%
rename from app/views/private_api/metadata.json.jbuilder
rename to app/views/private_api/metadata/metadata.json.jbuilder
diff --git a/app/views/private_api/proteins.json.jbuilder b/app/views/private_api/proteins/proteins.json.jbuilder
similarity index 100%
rename from app/views/private_api/proteins.json.jbuilder
rename to app/views/private_api/proteins/proteins.json.jbuilder
diff --git a/app/views/private_api/taxa.json.jbuilder b/app/views/private_api/taxa/taxa.json.jbuilder
similarity index 100%
rename from app/views/private_api/taxa.json.jbuilder
rename to app/views/private_api/taxa/taxa.json.jbuilder
diff --git a/config/routes.rb b/config/routes.rb
index 800bbb6..3d43bce 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,23 +1,23 @@
Rails.application.routes.draw do
# General information
scope :private_api, as: 'private_api' do
- match "/*path", via: [:options], :to => "handle_options#handle_options_request"
- match "goterms", via: [:get, :post], :to => "private_api#goterms"
- match "ecnumbers", via: [:get, :post], :to => "private_api#ecnumbers"
- match "taxa", via: [:get, :post], :to => "private_api#taxa"
- match "interpros", via: [:get, :post], :to => "private_api#interpros"
- match "proteins", via: [:get, :post], :to => "private_api#proteins"
- match "metadata", via: [:get, :post], :to => "private_api#metadata"
+ match "/*path" => "handle_options#handle_options_request", via: [:options]
+ match "goterms" => "private_api/goterms#goterms", via: [:get, :post]
+ match "ecnumbers" => "private_api/ecnumbers#ecnumbers", via: [:get, :post]
+ match "taxa" => "private_api/taxa#taxa", via: [:get, :post]
+ match "interpros" => "private_api/interpros#interpros", via: [:get, :post]
+ match "proteins" => "private_api/proteins#proteins", via: [:get, :post]
+ match "metadata" => "private_api/metadata#metadata", via: [:get, :post]
end
scope :mpa, as: 'mpa' do
- match '/*path', via: [:options], to: 'handle_options#handle_options_request'
- match 'pept2data', via: %i[get post], to: 'mpa#pept2data'
- match 'pept2filtered', via: %i[get post], to: 'mpa#pept2filtered'
+ match '/*path' => 'handle_options#handle_options_request', via: [:options]
+ match 'pept2data' => 'mpa/pept2data#pept2data', via: %i[get post]
+ match 'pept2filtered' => 'mpa/pept2filtered#pept2filtered', via: %i[get post]
end
scope :datasets, as: 'datasets' do
- match 'sampledata', via: [:post], to: 'datasets#sampledata'
+ match 'sampledata', via: [:post], to: 'datasets/sampledata#sampledata'
end
scope :api, as: 'api' do
@@ -25,35 +25,35 @@
end
namespace :api, path: 'api/v1' do
- match 'pept2taxa' => "api#pept2taxa", via: %i[get post]
- match 'pept2lca' => "api#pept2lca", via: %i[get post]
- match 'taxa2lca' => 'api#taxa2lca', via: %i[get post]
- match 'pept2prot' => 'api#pept2prot', via: %i[get post]
- match 'pept2funct' => 'api#pept2funct', via: %i[get post]
- match 'pept2ec' => 'api#pept2ec', via: %i[get post]
- match 'pept2go' => 'api#pept2go', via: %i[get post]
- match 'pept2interpro' => 'api#pept2interpro', via: %i[get post]
- match 'taxa2tree' => 'api#taxa2tree', via: %i[get post]
- match 'peptinfo' => 'api#peptinfo', via: %i[get post]
- match 'taxonomy' => 'api#taxonomy', via: %i[get post]
+ match 'pept2taxa' => "pept2taxa#pept2taxa", via: %i[get post]
+ match 'pept2lca' => "pept2lca#pept2lca", via: %i[get post]
+ match 'taxa2lca' => 'taxa2lca#taxa2lca', via: %i[get post]
+ match 'pept2prot' => 'pept2prot#pept2prot', via: %i[get post]
+ match 'pept2funct' => 'pept2funct#pept2funct', via: %i[get post]
+ match 'pept2ec' => 'pept2ec#pept2ec', via: %i[get post]
+ match 'pept2go' => 'pept2go#pept2go', via: %i[get post]
+ match 'pept2interpro' => 'pept2interpro#pept2interpro', via: %i[get post]
+ match 'taxa2tree' => 'taxa2tree#taxa2tree', via: %i[get post]
+ match 'peptinfo' => 'peptinfo#peptinfo', via: %i[get post]
+ match 'taxonomy' => 'taxonomy#taxonomy', via: %i[get post]
match 'messages' => 'api#messages', via: %i[get post]
- match 'protinfo' => 'api#protinfo', via: %i[get post]
+ match 'protinfo' => 'protinfo#protinfo', via: %i[get post]
end
namespace :api, path: 'api/v2' do
- match 'pept2taxa' => "api#pept2taxa", via: %i[get post]
- match 'pept2lca' => "api#pept2lca", via: %i[get post]
- match 'taxa2lca' => 'api#taxa2lca', via: %i[get post]
- match 'pept2prot' => 'api#pept2prot', via: %i[get post]
- match 'pept2funct' => 'api#pept2funct', via: %i[get post]
- match 'pept2ec' => 'api#pept2ec', via: %i[get post]
- match 'pept2go' => 'api#pept2go', via: %i[get post]
- match 'pept2interpro' => 'api#pept2interpro', via: %i[get post]
+ match 'pept2taxa' => "pept2taxa#pept2taxa", via: %i[get post]
+ match 'pept2lca' => "pept2lca#pept2lca", via: %i[get post]
+ match 'taxa2lca' => 'taxa2lca#taxa2lca', via: %i[get post]
+ match 'pept2prot' => 'pept2prot#pept2prot', via: %i[get post]
+ match 'pept2funct' => 'pept2funct#pept2funct', via: %i[get post]
+ match 'pept2ec' => 'pept2ec#pept2ec', via: %i[get post]
+ match 'pept2go' => 'pept2go#pept2go', via: %i[get post]
+ match 'pept2interpro' => 'pept2interpro#pept2interpro', via: %i[get post]
match 'pept2gm' => 'api#pept2gm', via: %i[get post]
- match 'taxa2tree' => 'api#taxa2tree', via: %i[get post]
- match 'peptinfo' => 'api#peptinfo', via: %i[get post]
- match 'taxonomy' => 'api#taxonomy', via: %i[get post]
+ match 'taxa2tree' => 'taxa2tree#taxa2tree', via: %i[get post]
+ match 'peptinfo' => 'peptinfo#peptinfo', via: %i[get post]
+ match 'taxonomy' => 'taxonomy#taxonomy', via: %i[get post]
match 'messages' => 'api#messages', via: %i[get post]
- match 'protinfo' => 'api#protinfo', via: %i[get post]
+ match 'protinfo' => 'protinfo#protinfo', via: %i[get post]
end
end
diff --git a/test/controllers/api/api_controller_test.rb b/test/controllers/api/api_controller_test.rb
index d76e2af..7049b60 100644
--- a/test/controllers/api/api_controller_test.rb
+++ b/test/controllers/api/api_controller_test.rb
@@ -1,38 +1,6 @@
require 'test_helper'
class Api::ApiControllerTest < ActionController::TestCase
- test 'set_params should parse single peptide input correctly' do
- get :pept2prot, params: { input: 'AAIER', format: 'json' }
- assert_equal ['AAIER'], assigns(:input)
- assert_not assigns(:equate_il)
- assert_not assigns(:extra_info)
- assert_not assigns(:names)
- end
-
- test 'set_params should parse hash input correctly' do
- get :pept2prot, params: { input: { 0 => 'AAIER' }, format: 'json' }
- assert_equal ['AAIER'], assigns(:input)
- end
-
- test 'set_params should parse array input correctly' do
- get :pept2prot, params: { input: %w[AAIER TEST], format: 'json' }
- assert_equal %w[AAIER TEST], assigns(:input)
- end
-
- test 'set_params should parse json input correctly' do
- get :pept2prot, params: { input: '["AAIER", "TEST"]', format: 'json' }
- assert_equal %w[AAIER TEST], assigns(:input)
- end
-
- test 'set_params should parse boolean options correctly' do
- get :pept2prot, params: { input: 'AAIER', format: 'json', equate_il: 'true', extra: 'true', names: 'true' }
- assert_equal ['AALER'], assigns(:input)
- assert_equal ['AAIER'], assigns(:input_order)
- assert assigns(:equate_il)
- assert assigns(:extra_info)
- assert assigns(:names)
- end
-
test 'should get messages for old version' do
get :messages, params: { version: '0' }
assert_response :success
@@ -44,747 +12,4 @@ class Api::ApiControllerTest < ActionController::TestCase
assert_response :success
assert @response.body.blank?
end
-
- test 'should get pept2prot' do
- get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'uniprot_id'
- assert @response.body.include? 'protein_name'
- assert @response.body.include? 'taxon_id'
- assert_not @response.body.include? 'taxon_name'
- assert_not @response.body.include? '"uniprot_id":"nr2"'
- end
-
- test 'should get pept2prot with il' do
- get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'uniprot_id'
- assert @response.body.include? 'protein_name'
- assert @response.body.include? 'taxon_id'
- assert_not @response.body.include? 'taxon_name'
- assert @response.body.include? '"uniprot_id":"nr2"'
- end
-
- test 'should get pept2prot with extra' do
- get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'uniprot_id'
- assert @response.body.include? 'protein_name'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert_not @response.body.include? '"taxon_name":null'
- assert @response.body.include? 'ec_references'
- assert @response.body.include? 'go_references'
- assert_not @response.body.include? '"uniprot_id":"nr2"'
- end
-
- test 'should get pept2prot with extra and il' do
- get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'uniprot_id'
- assert @response.body.include? 'protein_name'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert_not @response.body.include? '"taxon_name":null'
- assert @response.body.include? 'ec_references'
- assert @response.body.include? 'go_references'
- assert @response.body.include? '"uniprot_id":"nr2"'
- end
-
- test 'should get pept2taxa' do
- get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert_not @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2taxa with il' do
- get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2taxa with extra' do
- get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert_not @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2taxa with names' do
- get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert_not @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2taxa with extra and names' do
- get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert @response.body.include? 'kingdom_name'
- assert_not @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2taxa with extra and names and il' do
- get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2lca' do
- get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2lca with il' do
- get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":1'
- end
-
- test 'should get pept2lca with extra' do
- get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2lca with names' do
- get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2lca with extra and names' do
- get :pept2lca, params: { input: %w[AAIER AAILER], extra: 'true', names: 'true' }, format: 'json'
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":2'
- end
-
- test 'should get pept2lca with extra and names and il' do
- get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert @response.body.include? 'kingdom_name'
- assert @response.body.include? 'AAIER","taxon_id":1'
- end
-
- test 'should get taxa2lca' do
- get :taxa2lca, params: { input: %w[3 2], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxa2lca with root' do
- get :taxa2lca, params: { input: %w[1 2], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxa2lca with extra' do
- get :taxa2lca, params: { input: %w[1 2], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxa2lca with names' do
- get :taxa2lca, params: { input: %w[1 2], format: 'json', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxa2lca with extra and names' do
- get :taxa2lca, params: { input: %w[1 2], format: 'json', names: 'true', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxonomy' do
- get :taxonomy, params: { input: %w[1 2], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxonomy with extra' do
- get :taxonomy, params: { input: %w[1 2], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxonomy with names' do
- get :taxonomy, params: { input: %w[1 2], format: 'json', names: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get taxonomy with extra and names' do
- get :taxonomy, params: { input: %w[1 2], format: 'json', names: 'true', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert @response.body.include? 'kingdom_name'
- end
-
- test "shouldn't crash when logging to stathat" do
- Rails.application.config.unipept_API_logging = true
- Rails.application.config.unipept_stathat_key = 'key'
- get :taxonomy, params: { input: %w[1 2], format: 'json' }
- assert_response :success
- Rails.application.config.unipept_API_logging = false
- end
-
- test 'should get pept2ec' do
- get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'protein_count'
- assert_not @response.body.include? 'name'
- end
-
- test 'should get pept2ec with il' do
- get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'protein_count'
- assert_not @response.body.include? 'name'
- end
-
- test 'should get pept2ec with extra' do
- get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'name'
- end
-
- test 'should get pept2go' do
- get :pept2go, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert_not @response.body.include? 'name'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- end
-
- test 'should get pept2go with il' do
- get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert_not @response.body.include? 'name'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- end
-
- test 'should get pept2go with extra' do
- get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'name'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- end
-
- test 'should get pept2go with domains' do
- get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert_not @response.body.include? 'name'
- assert @response.body.include? 'molecular function'
- assert @response.body.include? 'biological process'
- assert @response.body.include? 'cellular component'
- end
-
- test 'should get pept2go with extra and domains' do
- get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'name'
- assert @response.body.include? 'molecular function'
- assert @response.body.include? 'biological process'
- assert @response.body.include? 'cellular component'
- end
-
- test 'should get pept2funct' do
- get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert_not @response.body.include? 'name'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- end
-
- test 'should get pept2funct with il' do
- get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert_not @response.body.include? 'name'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- end
-
- test 'should get pept2funct with extra' do
- get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'name'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- end
-
- test 'should get pept2funct with domains' do
- get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert_not @response.body.include? 'name'
- assert @response.body.include? 'molecular function'
- assert @response.body.include? 'biological process'
- assert @response.body.include? 'cellular component'
- end
-
- test 'should get pept2funct with extra and domains' do
- get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'name'
- assert @response.body.include? 'molecular function'
- assert @response.body.include? 'biological process'
- assert @response.body.include? 'cellular component'
- end
-
- test 'should get peptinfo' do
- get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert_not @response.body.include? 'some function 2'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get peptinfo with il' do
- get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert_not @response.body.include? 'some function 2'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get peptinfo with extra' do
- get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'some function 2'
- assert_not @response.body.include? 'molecular function'
- assert_not @response.body.include? 'biological process'
- assert_not @response.body.include? 'cellular component'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get peptinfo with domains' do
- get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert_not @response.body.include? 'some function 2'
- assert @response.body.include? 'molecular function'
- assert @response.body.include? 'biological process'
- assert @response.body.include? 'cellular component'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert_not @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
-
- test 'should get peptinfo with extra and domains' do
- get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
- assert_response :success
- assert_equal '*', @response.headers['Access-Control-Allow-Origin']
- assert @response.body.include? 'AAIER'
- assert @response.body.include? 'AAILER'
- assert_not @response.body.include? 'AALLER'
- assert_not @response.body.include? 'AALER'
- assert @response.body.include? 'peptide'
- assert @response.body.include? 'total_protein_count'
- assert @response.body.include? 'go'
- assert @response.body.include? 'go_term'
- assert @response.body.include? 'protein_count'
- assert @response.body.include? 'ec'
- assert @response.body.include? 'ec_number'
- assert @response.body.include? 'some function 2'
- assert @response.body.include? 'molecular function'
- assert @response.body.include? 'biological process'
- assert @response.body.include? 'cellular component'
- assert @response.body.include? 'taxon_id'
- assert @response.body.include? 'taxon_name'
- assert @response.body.include? 'taxon_rank'
- assert @response.body.include? 'kingdom_id'
- assert_not @response.body.include? 'kingdom_name'
- end
end
diff --git a/test/controllers/api/pept2ec_controller_test.rb b/test/controllers/api/pept2ec_controller_test.rb
new file mode 100644
index 0000000..1cd146a
--- /dev/null
+++ b/test/controllers/api/pept2ec_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class Api::Pept2ecControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2ec' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1}]}
+ ]'
+
+ get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2ec with il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ec":[{"ec_number":"2.7.11.1","protein_count":4}]},
+ {"peptide":"AAILER","total_protein_count":0,"ec":[]}
+ ]'
+
+ get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2ec with extra' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1,"name":"Some Enzyme3"}]}
+ ]'
+
+ get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2ec with extra and il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ec":[{"ec_number":"2.7.11.1","protein_count":4,"name":"Some Enzyme2"}]},
+ {"peptide":"AAILER","total_protein_count":0,"ec":[]}
+ ]'
+
+ get :pept2ec, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/pept2funct_controller_test.rb b/test/controllers/api/pept2funct_controller_test.rb
new file mode 100644
index 0000000..d556740
--- /dev/null
+++ b/test/controllers/api/pept2funct_controller_test.rb
@@ -0,0 +1,67 @@
+require 'test_helper'
+
+class Api::Pept2functControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2funct' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"go_term":"GO:0051301","protein_count":3},{"go_term":"GO:0005525","protein_count":3},{"go_term":"GO:0046872","protein_count":3},{"go_term":"GO:0007049","protein_count":3}],"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1}],"go":[{"go_term":"GO:0005576","protein_count":1},{"go_term":"GO:0000287","protein_count":1},{"go_term":"GO:0004634","protein_count":1},{"go_term":"GO:0000015","protein_count":1},{"go_term":"GO:0006096","protein_count":1},{"go_term":"GO:0009986","protein_count":1}],"ipr":[{"code":"IPR000169","protein_count":1}]}
+ ]'
+
+ get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2funct with il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ec":[{"ec_number":"2.7.11.1","protein_count":4}],"go":[{"go_term":"GO:0004674","protein_count":1},{"go_term":"GO:0005634","protein_count":1},{"go_term":"GO:0005524","protein_count":1},{"go_term":"GO:0016301","protein_count":1}],"ipr":[{"code":"IPR000169","protein_count":1}]},
+ {"peptide":"AAILER","total_protein_count":0,"ec":[],"go":[],"ipr":[]}
+ ]'
+
+ get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2funct with extra' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"go_term":"GO:0051301","protein_count":3,"name":"some function 9"},{"go_term":"GO:0005525","protein_count":3,"name":"some function 10"},{"go_term":"GO:0046872","protein_count":3,"name":"some function 11"},{"go_term":"GO:0007049","protein_count":3,"name":"some function 12"}],"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1,"name":"Some Enzyme3"}],"go":[{"go_term":"GO:0005576","protein_count":1,"name":"some function 16"},{"go_term":"GO:0000287","protein_count":1,"name":"some function 17"},{"go_term":"GO:0004634","protein_count":1,"name":"some function 18"},{"go_term":"GO:0000015","protein_count":1,"name":"some function 19"},{"go_term":"GO:0006096","protein_count":1,"name":"some function 20"},{"go_term":"GO:0009986","protein_count":1,"name":"some function 21"}],"ipr":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site","type":"Active_site"}]}
+ ]'
+
+ get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2funct with domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"molecular function":[{"go_term":"GO:0051301","protein_count":3},{"go_term":"GO:0007049","protein_count":3}]},{"cellular component":[{"go_term":"GO:0005525","protein_count":3}]},{"biological process":[{"go_term":"GO:0046872","protein_count":3}]}],"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1}],"go":[{"cellular component":[{"go_term":"GO:0005576","protein_count":1},{"go_term":"GO:0009986","protein_count":1}]},{"molecular function":[{"go_term":"GO:0000287","protein_count":1},{"go_term":"GO:0000015","protein_count":1}]},{"biological process":[{"go_term":"GO:0004634","protein_count":1},{"go_term":"GO:0006096","protein_count":1}]}],"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1}]}]}
+ ]'
+
+ get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
+ end
+
+ test 'should get pept2funct with extra and domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"molecular function":[{"go_term":"GO:0051301","protein_count":3,"name":"some function 9"},{"go_term":"GO:0007049","protein_count":3,"name":"some function 12"}]},{"cellular component":[{"go_term":"GO:0005525","protein_count":3,"name":"some function 10"}]},{"biological process":[{"go_term":"GO:0046872","protein_count":3,"name":"some function 11"}]}],"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1,"name":"Some Enzyme3"}],"go":[{"cellular component":[{"go_term":"GO:0005576","protein_count":1,"name":"some function 16"},{"go_term":"GO:0009986","protein_count":1,"name":"some function 21"}]},{"molecular function":[{"go_term":"GO:0000287","protein_count":1,"name":"some function 17"},{"go_term":"GO:0000015","protein_count":1,"name":"some function 19"}]},{"biological process":[{"go_term":"GO:0004634","protein_count":1,"name":"some function 18"},{"go_term":"GO:0006096","protein_count":1,"name":"some function 20"}]}],"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site"}]}]}
+ ]'
+
+ get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
+ end
+
+ test 'should get pept2funct with extra and domains and il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ec":[{"ec_number":"2.7.11.1","protein_count":4,"name":"Some Enzyme2"}],"go":[{"biological process":[{"go_term":"GO:0004674","protein_count":1,"name":"some function 5"},{"go_term":"GO:0016301","protein_count":1,"name":"some function 8"}]},{"molecular function":[{"go_term":"GO:0005634","protein_count":1,"name":"some function 6"}]},{"cellular component":[{"go_term":"GO:0005524","protein_count":1,"name":"some function 7"}]}],"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site"}]}]},
+ {"peptide":"AAILER","total_protein_count":0,"ec":[],"go":[],"ipr":[]}
+ ]'
+
+ get :pept2funct, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', domains: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/pept2go_controller_test.rb b/test/controllers/api/pept2go_controller_test.rb
new file mode 100644
index 0000000..3356357
--- /dev/null
+++ b/test/controllers/api/pept2go_controller_test.rb
@@ -0,0 +1,66 @@
+require 'test_helper'
+
+class Api::Pept2goControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2go' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"go":[{"go_term":"GO:0051301","protein_count":3},{"go_term":"GO:0005525","protein_count":3},{"go_term":"GO:0046872","protein_count":3},{"go_term":"GO:0007049","protein_count":3}]},
+ {"peptide":"AAILER","total_protein_count":1,"go":[{"go_term":"GO:0005576","protein_count":1},{"go_term":"GO:0000287","protein_count":1},{"go_term":"GO:0004634","protein_count":1},{"go_term":"GO:0000015","protein_count":1},{"go_term":"GO:0006096","protein_count":1},{"go_term":"GO:0009986","protein_count":1}]}
+ ]'
+
+ get :pept2go, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2go with il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"go":[{"go_term":"GO:0004674","protein_count":1},{"go_term":"GO:0005634","protein_count":1},{"go_term":"GO:0005524","protein_count":1},{"go_term":"GO:0016301","protein_count":1}]},{"peptide":"AAILER","total_protein_count":0,"go":[]}
+ ]'
+
+ get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2go with extra' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"go":[{"go_term":"GO:0051301","protein_count":3,"name":"some function 9"},{"go_term":"GO:0005525","protein_count":3,"name":"some function 10"},{"go_term":"GO:0046872","protein_count":3,"name":"some function 11"},{"go_term":"GO:0007049","protein_count":3,"name":"some function 12"}]},
+ {"peptide":"AAILER","total_protein_count":1,"go":[{"go_term":"GO:0005576","protein_count":1,"name":"some function 16"},{"go_term":"GO:0000287","protein_count":1,"name":"some function 17"},{"go_term":"GO:0004634","protein_count":1,"name":"some function 18"},{"go_term":"GO:0000015","protein_count":1,"name":"some function 19"},{"go_term":"GO:0006096","protein_count":1,"name":"some function 20"},{"go_term":"GO:0009986","protein_count":1,"name":"some function 21"}]}
+ ]'
+
+ get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2go with domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"go":[{"molecular function":[{"go_term":"GO:0051301","protein_count":3},{"go_term":"GO:0007049","protein_count":3}]},{"cellular component":[{"go_term":"GO:0005525","protein_count":3}]},{"biological process":[{"go_term":"GO:0046872","protein_count":3}]}]},
+ {"peptide":"AAILER","total_protein_count":1,"go":[{"cellular component":[{"go_term":"GO:0005576","protein_count":1},{"go_term":"GO:0009986","protein_count":1}]},{"molecular function":[{"go_term":"GO:0000287","protein_count":1},{"go_term":"GO:0000015","protein_count":1}]},{"biological process":[{"go_term":"GO:0004634","protein_count":1},{"go_term":"GO:0006096","protein_count":1}]}]}
+ ]'
+
+ get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
+ end
+
+ test 'should get pept2go with extra and domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"go":[{"molecular function":[{"go_term":"GO:0051301","protein_count":3,"name":"some function 9"},{"go_term":"GO:0007049","protein_count":3,"name":"some function 12"}]},{"cellular component":[{"go_term":"GO:0005525","protein_count":3,"name":"some function 10"}]},{"biological process":[{"go_term":"GO:0046872","protein_count":3,"name":"some function 11"}]}]},
+ {"peptide":"AAILER","total_protein_count":1,"go":[{"cellular component":[{"go_term":"GO:0005576","protein_count":1,"name":"some function 16"},{"go_term":"GO:0009986","protein_count":1,"name":"some function 21"}]},{"molecular function":[{"go_term":"GO:0000287","protein_count":1,"name":"some function 17"},{"go_term":"GO:0000015","protein_count":1,"name":"some function 19"}]},{"biological process":[{"go_term":"GO:0004634","protein_count":1,"name":"some function 18"},{"go_term":"GO:0006096","protein_count":1,"name":"some function 20"}]}]}
+ ]'
+
+ get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
+ end
+
+ test 'should get pept2go with extra and domains and il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"go":[{"biological process":[{"go_term":"GO:0004674","protein_count":1,"name":"some function 5"},{"go_term":"GO:0016301","protein_count":1,"name":"some function 8"}]},{"molecular function":[{"go_term":"GO:0005634","protein_count":1,"name":"some function 6"}]},{"cellular component":[{"go_term":"GO:0005524","protein_count":1,"name":"some function 7"}]}]},
+ {"peptide":"AAILER","total_protein_count":0,"go":[]}
+ ]'
+
+ get :pept2go, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', domains: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/pept2interpro_controller_test.rb b/test/controllers/api/pept2interpro_controller_test.rb
new file mode 100644
index 0000000..c69b60a
--- /dev/null
+++ b/test/controllers/api/pept2interpro_controller_test.rb
@@ -0,0 +1,67 @@
+require 'test_helper'
+
+class Api::Pept2interproControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2interpro' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ipr":[{"code":"IPR000169","protein_count":1}]}
+ ]'
+
+ get :pept2interpro, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2interpro with il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ipr":[{"code":"IPR000169","protein_count":1}]},
+ {"peptide":"AAILER","total_protein_count":0,"ipr":[]}
+ ]'
+
+ get :pept2interpro, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2interpro with extra' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ipr":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site","type":"Active_site"}]}
+ ]'
+
+ get :pept2interpro, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2interpro with domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1}]}]}
+ ]'
+
+ get :pept2interpro, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
+ end
+
+ test 'should get pept2interpro with extra and domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ipr":[]},
+ {"peptide":"AAILER","total_protein_count":1,"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site"}]}]}
+ ]'
+
+ get :pept2interpro, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
+ end
+
+ test 'should get pept2interpro with extra and domains and il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site"}]}]},
+ {"peptide":"AAILER","total_protein_count":0,"ipr":[]}
+ ]'
+
+ get :pept2interpro, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', domains: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/pept2lca_controller_test.rb b/test/controllers/api/pept2lca_controller_test.rb
new file mode 100644
index 0000000..a4ecf6c
--- /dev/null
+++ b/test/controllers/api/pept2lca_controller_test.rb
@@ -0,0 +1,67 @@
+require 'test_helper'
+
+class Api::Pept2lcaControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2lca' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}
+ ]'
+
+ get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2lca with il' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}
+ ]'
+
+ get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2lca with extra' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":null,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null}
+ ]'
+
+ get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2lca with names' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}
+ ]'
+
+ get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', names: 'true' }
+ end
+
+ test 'should get pept2lca with extra and names' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":null,"species_name":"","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}
+ ]'
+
+ get :pept2lca, params: { input: %w[AAIER AAILER], extra: 'true', names: 'true' }, format: 'json'
+ end
+
+ test 'should get pept2lca with extra and names and il' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}
+ ]'
+
+ get :pept2lca, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', names: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/pept2prot_controller_test.rb b/test/controllers/api/pept2prot_controller_test.rb
new file mode 100644
index 0000000..61a7df9
--- /dev/null
+++ b/test/controllers/api/pept2prot_controller_test.rb
@@ -0,0 +1,55 @@
+require 'test_helper'
+
+class Api::Pept2protControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2prot' do
+ @expected = '[
+ {"peptide":"AAIER","uniprot_id":"nr","protein_name":"some name","taxon_id":1,"protein":"ELABA"},
+ {"peptide":"AAILER","uniprot_id":"nr3","protein_name":"some name","taxon_id":2,"protein":"AAILERAGGAR"},
+ {"peptide":"AAILER","uniprot_id":"nr4","protein_name":"some name","taxon_id":1,"protein":"AAILERA"}
+ ]'
+
+ get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2prot with il' do
+ @expected = '[
+ {"peptide":"AAIER","uniprot_id":"nr","protein_name":"some name","taxon_id":1,"protein":"ELABA"},
+ {"peptide":"AAIER","uniprot_id":"nr2","protein_name":"some name","taxon_id":2,"protein":"EIABA"},
+ {"peptide":"AAILER","uniprot_id":"nr3","protein_name":"some name","taxon_id":2,"protein":"AAILERAGGAR"},
+ {"peptide":"AAILER","uniprot_id":"nr4","protein_name":"some name","taxon_id":1,"protein":"AAILERA"}
+ ]'
+
+ get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2prot with extra' do
+ @expected = '[
+ {"peptide":"AAIER","uniprot_id":"nr","protein_name":"some name","taxon_id":1,"taxon_name":"species1","ec_references":"1.2.3.4","go_references":"goid","interpro_references":"IPR000126"},
+ {"peptide":"AAILER","uniprot_id":"nr3","protein_name":"some name","taxon_id":2,"taxon_name":"kingdom1","ec_references":"","go_references":"","interpro_references":""},
+ {"peptide":"AAILER","uniprot_id":"nr4","protein_name":"some name","taxon_id":1,"taxon_name":"species1","ec_references":"","go_references":"","interpro_references":""}
+ ]'
+
+ get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2prot with extra and il' do
+ @expected = '[
+ {"peptide":"AAIER","uniprot_id":"nr","protein_name":"some name","taxon_id":1,"taxon_name":"species1","ec_references":"1.2.3.4","go_references":"goid","interpro_references":"IPR000126"},
+ {"peptide":"AAIER","uniprot_id":"nr2","protein_name":"some name","taxon_id":2,"taxon_name":"kingdom1","ec_references":"","go_references":"","interpro_references":""},
+ {"peptide":"AAILER","uniprot_id":"nr3","protein_name":"some name","taxon_id":2,"taxon_name":"kingdom1","ec_references":"","go_references":"","interpro_references":""},
+ {"peptide":"AAILER","uniprot_id":"nr4","protein_name":"some name","taxon_id":1,"taxon_name":"species1","ec_references":"","go_references":"","interpro_references":""}
+ ]'
+
+ get :pept2prot, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/pept2taxa_controller_test.rb b/test/controllers/api/pept2taxa_controller_test.rb
new file mode 100644
index 0000000..755d5fa
--- /dev/null
+++ b/test/controllers/api/pept2taxa_controller_test.rb
@@ -0,0 +1,75 @@
+require 'test_helper'
+
+class Api::Pept2taxaControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2taxa' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"}
+ ]'
+
+ get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2taxa with il' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAIER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"}
+ ]'
+
+ get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2taxa with extra' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"peptide":"AAILER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":null,"subspecies_id":null,"varietas_id":null,"forma_id":null}
+ ]'
+
+ get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get pept2taxa with names' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"}
+ ]'
+
+ get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', names: 'true' }
+ end
+
+ test 'should get pept2taxa with extra and names' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAILER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":null,"species_name":"","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}
+ ]'
+
+ get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', names: 'true' }
+ end
+
+ test 'should get pept2taxa with extra and names and il' do
+ @expected = '[
+ {"peptide":"AAIER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAIER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":null,"species_name":"","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAILER","taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"peptide":"AAILER","taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":null,"species_name":"","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}
+ ]'
+
+ get :pept2taxa, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', names: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/peptinfo_controller_test.rb b/test/controllers/api/peptinfo_controller_test.rb
new file mode 100644
index 0000000..125f7ae
--- /dev/null
+++ b/test/controllers/api/peptinfo_controller_test.rb
@@ -0,0 +1,67 @@
+require 'test_helper'
+
+class Api::PeptinfoControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get peptinfo' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"go_term":"GO:0051301","protein_count":3},{"go_term":"GO:0005525","protein_count":3},{"go_term":"GO:0046872","protein_count":3},{"go_term":"GO:0007049","protein_count":3}],"ipr":[],"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1}],"go":[{"go_term":"GO:0005576","protein_count":1},{"go_term":"GO:0000287","protein_count":1},{"go_term":"GO:0004634","protein_count":1},{"go_term":"GO:0000015","protein_count":1},{"go_term":"GO:0006096","protein_count":1},{"go_term":"GO:0009986","protein_count":1}],"ipr":[{"code":"IPR000169","protein_count":1}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}
+ ]'
+
+ get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get peptinfo with il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ec":[{"ec_number":"2.7.11.1","protein_count":4}],"go":[{"go_term":"GO:0004674","protein_count":1},{"go_term":"GO:0005634","protein_count":1},{"go_term":"GO:0005524","protein_count":1},{"go_term":"GO:0016301","protein_count":1}],"ipr":[{"code":"IPR000169","protein_count":1}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"peptide":"AAILER","total_protein_count":0,"ec":[],"go":[],"ipr":[],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}
+ ]'
+
+ get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get peptinfo with extra' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"go_term":"GO:0051301","protein_count":3,"name":"some function 9"},{"go_term":"GO:0005525","protein_count":3,"name":"some function 10"},{"go_term":"GO:0046872","protein_count":3,"name":"some function 11"},{"go_term":"GO:0007049","protein_count":3,"name":"some function 12"}],"ipr":[],"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":null,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1,"name":"Some Enzyme3"}],"go":[{"go_term":"GO:0005576","protein_count":1,"name":"some function 16"},{"go_term":"GO:0000287","protein_count":1,"name":"some function 17"},{"go_term":"GO:0004634","protein_count":1,"name":"some function 18"},{"go_term":"GO:0000015","protein_count":1,"name":"some function 19"},{"go_term":"GO:0006096","protein_count":1,"name":"some function 20"},{"go_term":"GO:0009986","protein_count":1,"name":"some function 21"}],"ipr":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site","type":"Active_site"}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null}
+ ]'
+
+ get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true' }
+ end
+
+ test 'should get peptinfo with domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"molecular function":[{"go_term":"GO:0051301","protein_count":3},{"go_term":"GO:0007049","protein_count":3}]},{"cellular component":[{"go_term":"GO:0005525","protein_count":3}]},{"biological process":[{"go_term":"GO:0046872","protein_count":3}]}],"ipr":[],"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1}],"go":[{"cellular component":[{"go_term":"GO:0005576","protein_count":1},{"go_term":"GO:0009986","protein_count":1}]},{"molecular function":[{"go_term":"GO:0000287","protein_count":1},{"go_term":"GO:0000015","protein_count":1}]},{"biological process":[{"go_term":"GO:0004634","protein_count":1},{"go_term":"GO:0006096","protein_count":1}]}],"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1}]}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}
+ ]'
+
+ get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', domains: 'true' }
+ end
+
+ test 'should get peptinfo with extra and domains' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":3,"ec":[],"go":[{"molecular function":[{"go_term":"GO:0051301","protein_count":3,"name":"some function 9"},{"go_term":"GO:0007049","protein_count":3,"name":"some function 12"}]},{"cellular component":[{"go_term":"GO:0005525","protein_count":3,"name":"some function 10"}]},{"biological process":[{"go_term":"GO:0046872","protein_count":3,"name":"some function 11"}]}],"ipr":[],"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":null,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"peptide":"AAILER","total_protein_count":1,"ec":[{"ec_number":"4.2.1.11","protein_count":1,"name":"Some Enzyme3"}],"go":[{"cellular component":[{"go_term":"GO:0005576","protein_count":1,"name":"some function 16"},{"go_term":"GO:0009986","protein_count":1,"name":"some function 21"}]},{"molecular function":[{"go_term":"GO:0000287","protein_count":1,"name":"some function 17"},{"go_term":"GO:0000015","protein_count":1,"name":"some function 19"}]},{"biological process":[{"go_term":"GO:0004634","protein_count":1,"name":"some function 18"},{"go_term":"GO:0006096","protein_count":1,"name":"some function 20"}]}],"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site"}]}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null}
+ ]'
+
+ get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', extra: 'true', domains: 'true' }
+ end
+
+ test 'should get peptinfo with extra and domains and il' do
+ @expected = '[
+ {"peptide":"AAIER","total_protein_count":22,"ec":[{"ec_number":"2.7.11.1","protein_count":4,"name":"Some Enzyme2"}],"go":[{"biological process":[{"go_term":"GO:0004674","protein_count":1,"name":"some function 5"},{"go_term":"GO:0016301","protein_count":1,"name":"some function 8"}]},{"molecular function":[{"go_term":"GO:0005634","protein_count":1,"name":"some function 6"}]},{"cellular component":[{"go_term":"GO:0005524","protein_count":1,"name":"some function 7"}]}],"ipr":[{"Active_site":[{"code":"IPR000169","protein_count":1,"name":"Cysteine peptidase, cysteine active site"}]}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"peptide":"AAILER","total_protein_count":0,"ec":[],"go":[],"ipr":[],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null}
+ ]'
+
+ get :peptinfo, params: { input: %w[AAIER AAILER], format: 'json', equate_il: 'true', extra: 'true', domains: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/protinfo_controller_test.rb b/test/controllers/api/protinfo_controller_test.rb
new file mode 100644
index 0000000..3d25362
--- /dev/null
+++ b/test/controllers/api/protinfo_controller_test.rb
@@ -0,0 +1,22 @@
+require 'test_helper'
+
+class Api::ProtinfoControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get protinfo' do
+ @expected = '[
+ {"protein":"nr","ec":[{"ec_number":"1.2.3.4"}],"go":[],"ipr":[{"code":"IPR000126"}],"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"protein":"nr2","ec":[],"go":[],"ipr":[],"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"}
+ ]'
+
+ get :protinfo, params: { input: %w[nr nr2], format: 'json' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/taxa2lca_controller_test.rb b/test/controllers/api/taxa2lca_controller_test.rb
new file mode 100644
index 0000000..99fc6e8
--- /dev/null
+++ b/test/controllers/api/taxa2lca_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class Api::Taxa2lcaControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get taxa2lca' do
+ @expected = '{"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}'
+
+ get :taxa2lca, params: { input: %w[3 2], format: 'json' }
+ end
+
+ test 'should get taxa2lca with root' do
+ @expected = '{"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}'
+
+ get :taxa2lca, params: { input: %w[1 2], format: 'json' }
+ end
+
+ test 'should get taxa2lca with extra' do
+ @expected = '{"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null}'
+
+ get :taxa2lca, params: { input: %w[1 2], format: 'json', extra: 'true' }
+ end
+
+ test 'should get taxa2lca with names' do
+ @expected = '{"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"}'
+
+ get :taxa2lca, params: { input: %w[1 2], format: 'json', names: 'true' }
+ end
+
+ test 'should get taxa2lca with extra and names' do
+ @expected = '{"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}'
+
+ get :taxa2lca, params: { input: %w[1 2], format: 'json', names: 'true', extra: 'true' }
+ end
+
+ test 'should get taxa2lca with extra and names and il' do
+ @expected = '{"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}'
+
+ get :taxa2lca, params: { input: %w[1 2], format: 'json', equate_il: 'true', names: 'true', extra: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/taxa2tree_controller_test.rb b/test/controllers/api/taxa2tree_controller_test.rb
new file mode 100644
index 0000000..cadd30d
--- /dev/null
+++ b/test/controllers/api/taxa2tree_controller_test.rb
@@ -0,0 +1,25 @@
+require 'test_helper'
+
+class Api::Taxa2treeControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get taxa2tree' do
+ @expected = '{
+ "id":1,"name":"Organism","rank":"no rank","data":{"count":1,"self_count":0},"children":[
+ {"id":13,"name":"kingdom2","rank":"kingdom","data":{"count":1,"self_count":0},"children":[
+ {"id":14,"name":"phylum1","rank":"phylum","data":{"count":1,"self_count":1},"children":[]}
+ ]}
+ ]
+ }'
+
+ get :taxa2tree, params: { input: %w[14], format: 'json' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/api/taxonomy_controller_test.rb b/test/controllers/api/taxonomy_controller_test.rb
new file mode 100644
index 0000000..ad8ab00
--- /dev/null
+++ b/test/controllers/api/taxonomy_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class Api::TaxonomyControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get taxonomy' do
+ @expected = '[
+ {"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"}
+ ]'
+
+ get :taxonomy, params: { input: %w[1 2], format: 'json' }
+ end
+
+ test 'should get taxonomy with extra' do
+ @expected = '[
+ {"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":1,"subspecies_id":null,"varietas_id":null,"forma_id":null},
+ {"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"kingdom_id":2,"subkingdom_id":null,"superphylum_id":null,"phylum_id":null,"subphylum_id":null,"superclass_id":null,"class_id":null,"subclass_id":null,"infraclass_id":null,"superorder_id":null,"order_id":null,"suborder_id":null,"infraorder_id":null,"parvorder_id":null,"superfamily_id":null,"family_id":null,"subfamily_id":null,"tribe_id":null,"subtribe_id":null,"genus_id":null,"subgenus_id":null,"species_group_id":null,"species_subgroup_id":null,"species_id":null,"subspecies_id":null,"varietas_id":null,"forma_id":null}
+ ]'
+
+ get :taxonomy, params: { input: %w[1 2], format: 'json', extra: 'true' }
+ end
+
+ test 'should get taxonomy with names' do
+ @expected = '[
+ {"taxon_id":1,"taxon_name":"species1","taxon_rank":"species"},
+ {"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom"}
+ ]'
+
+ get :taxonomy, params: { input: %w[1 2], format: 'json', names: 'true' }
+ end
+
+ test 'should get taxonomy with extra and names' do
+ @expected = '[
+ {"taxon_id":1,"taxon_name":"species1","taxon_rank":"species","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":1,"species_name":"species1","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""},
+ {"taxon_id":2,"taxon_name":"kingdom1","taxon_rank":"kingdom","superkingdom_id":null,"superkingdom_name":"","kingdom_id":2,"kingdom_name":"kingdom1","subkingdom_id":null,"subkingdom_name":"","superphylum_id":null,"superphylum_name":"","phylum_id":null,"phylum_name":"","subphylum_id":null,"subphylum_name":"","superclass_id":null,"superclass_name":"","class_id":null,"class_name":"","subclass_id":null,"subclass_name":"","infraclass_id":null,"infraclass_name":"","superorder_id":null,"superorder_name":"","order_id":null,"order_name":"","suborder_id":null,"suborder_name":"","infraorder_id":null,"infraorder_name":"","parvorder_id":null,"parvorder_name":"","superfamily_id":null,"superfamily_name":"","family_id":null,"family_name":"","subfamily_id":null,"subfamily_name":"","tribe_id":null,"tribe_name":"","subtribe_id":null,"subtribe_name":"","genus_id":null,"genus_name":"","subgenus_id":null,"subgenus_name":"","species_group_id":null,"species_group_name":"","species_subgroup_id":null,"species_subgroup_name":"","species_id":null,"species_name":"","subspecies_id":null,"subspecies_name":"","varietas_id":null,"varietas_name":"","forma_id":null,"forma_name":""}
+ ]'
+
+ get :taxonomy, params: { input: %w[1 2], format: 'json', names: 'true', extra: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/datasets/sampledata_controller_test.rb b/test/controllers/datasets/sampledata_controller_test.rb
new file mode 100644
index 0000000..07ac3a9
--- /dev/null
+++ b/test/controllers/datasets/sampledata_controller_test.rb
@@ -0,0 +1,23 @@
+require 'test_helper'
+
+class Datasets::SampledataControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get sampledata' do
+ @expected = '{
+ "sample_data":[
+ {"id":1,"environment":"env","reference":"ref","url":"url","project_website":"website","datasets":[{"name":"name","data":["data_data"],"order":null}]}
+ ]
+ }'
+
+ post :sampledata, params: { format: 'json' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/mpa/pept2data_controller_test.rb b/test/controllers/mpa/pept2data_controller_test.rb
new file mode 100644
index 0000000..985bb8a
--- /dev/null
+++ b/test/controllers/mpa/pept2data_controller_test.rb
@@ -0,0 +1,57 @@
+require 'test_helper'
+
+class Mpa::Pept2dataControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2data' do
+ @expected = '{
+ "peptides":[
+ {"sequence":"AAIER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":22,"EC":4,"GO":2,"IPR":3},"data":{"EC:2.7.11.1":4,"GO:0004674":1,"GO:0005634":1,"GO:0005524":1,"GO:0016301":1,"IPR:IPR000169":1}}},
+ {"sequence":"AAILER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":0,"EC":0,"GO":0,"IPR":0},"data":{}}}
+ ]
+ }'
+
+ get :pept2data, params: { peptides: %w[AAIER AAILER], format: 'json' }
+ end
+
+ test 'should get pept2data with il' do
+ @expected = '{
+ "peptides":[
+ {"sequence":"AAIER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":22,"EC":4,"GO":2,"IPR":3},"data":{"EC:2.7.11.1":4,"GO:0004674":1,"GO:0005634":1,"GO:0005524":1,"GO:0016301":1,"IPR:IPR000169":1}}},
+ {"sequence":"AAILER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":0,"EC":0,"GO":0,"IPR":0},"data":{}}}
+ ]
+ }'
+
+ get :pept2data, params: { peptides: %w[AAIER AAILER], format: 'json', equate_il: 'true' }
+ end
+
+ test 'should get pept2data with missed' do
+ @expected = '{
+ "peptides":[
+ {"sequence":"AAIER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":22,"EC":4,"GO":2,"IPR":3},"data":{"EC:2.7.11.1":4,"GO:0004674":1,"GO:0005634":1,"GO:0005524":1,"GO:0016301":1,"IPR:IPR000169":1}}},
+ {"sequence":"AAILER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":0,"EC":0,"GO":0,"IPR":0},"data":{}}}
+ ]
+ }'
+
+ get :pept2data, params: { peptides: %w[AAIER AAILER], format: 'json', missed: 'true' }
+ end
+
+ test 'should get pept2data with missed and il' do
+ @expected = '{
+ "peptides":[
+ {"sequence":"AAIER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":22,"EC":4,"GO":2,"IPR":3},"data":{"EC:2.7.11.1":4,"GO:0004674":1,"GO:0005634":1,"GO:0005524":1,"GO:0016301":1,"IPR:IPR000169":1}}},
+ {"sequence":"AAILER","lca":1,"lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null],"fa":{"counts":{"all":0,"EC":0,"GO":0,"IPR":0},"data":{}}}
+ ]
+ }'
+
+ get :pept2data, params: { peptides: %w[AAIER AAILER], format: 'json', equate_il: 'true', missed: 'true' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/mpa/pept2filtered_controller_test.rb b/test/controllers/mpa/pept2filtered_controller_test.rb
new file mode 100644
index 0000000..2d1da4d
--- /dev/null
+++ b/test/controllers/mpa/pept2filtered_controller_test.rb
@@ -0,0 +1,24 @@
+require 'test_helper'
+
+class Mpa::Pept2filteredControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get pept2filtered' do
+ @expected = '{
+ "peptides":[
+ {"sequence":"AALER","taxa":[1,2],"fa":{"go_terms":["goid"],"ec_numbers":["EC:1.2.3.4"],"interpro_entries":["IPR:000126"]}},
+ {"sequence":"AALLER","taxa":[2,1],"fa":{"go_terms":[],"ec_numbers":[],"interpro_entries":[]}}
+ ]
+ }'
+
+ get :pept2filtered, params: { peptides: %w[AAIER AALER AAILER AALLER], taxa: %w[1 2 13 14 15], format: 'json' }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/private_api/ecnumbers_controller_test.rb b/test/controllers/private_api/ecnumbers_controller_test.rb
new file mode 100644
index 0000000..e666458
--- /dev/null
+++ b/test/controllers/private_api/ecnumbers_controller_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class PrivateApi::EcnumbersControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get ecnumbers' do
+ @expected = '[
+ {"code":"1.2.3.4","name":"Some Enzyme"},
+ {"code":"2.7.11.1","name":"Some Enzyme2"}
+ ]'
+
+ get :ecnumbers, params: { ecnumbers: %w[1.2.3.4 2.7.11.1] }
+ end
+
+ test 'should get ecnumbers no match' do
+ @expected = '[]'
+
+ get :ecnumbers, params: { ecnumbers: %w[x.x.x.x] }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/private_api/goterms_controller_test.rb b/test/controllers/private_api/goterms_controller_test.rb
new file mode 100644
index 0000000..df5cf8e
--- /dev/null
+++ b/test/controllers/private_api/goterms_controller_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class PrivateApi::GotermsControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get goterms' do
+ @expected = '[
+ {"code":"GO:0012345","name":"some function","namespace":"cellular component"},
+ {"code":"GO:0016569","name":"some function 2","namespace":"cellular component"}
+ ]'
+
+ get :goterms, params: { goterms: %w[GO:0012345 GO:0016569] }
+ end
+
+ test 'should get goterms no match' do
+ @expected = '[]'
+
+ get :goterms, params: { goterms: %w[GO:xxxxxxx] }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/private_api/interpros_controller_test.rb b/test/controllers/private_api/interpros_controller_test.rb
new file mode 100644
index 0000000..bc53910
--- /dev/null
+++ b/test/controllers/private_api/interpros_controller_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class PrivateApi::InterprosControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get interpros' do
+ @expected = '[
+ {"code":"IPR000126","category":"Active_site","name":"Serine proteases, V8 family, serine active site"},
+ {"code":"IPR000169","category":"Active_site","name":"Cysteine peptidase, cysteine active site"}
+ ]'
+
+ get :interpros, params: { interpros: %w[IPR000126 IPR000169] }
+ end
+
+ test 'should get interpros no match' do
+ @expected = '[]'
+
+ get :interpros, params: { interpros: %w[IPRxxxxx] }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/private_api/metadata_controller_test.rb b/test/controllers/private_api/metadata_controller_test.rb
new file mode 100644
index 0000000..b71926d
--- /dev/null
+++ b/test/controllers/private_api/metadata_controller_test.rb
@@ -0,0 +1,19 @@
+require 'test_helper'
+
+class PrivateApi::MetadataControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get metadata' do
+ @expected = "{\"db_version\":\"#{Rails.application.config.versions[:uniprot]}\"}"
+
+ get :metadata
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/private_api/proteins_controller_test.rb b/test/controllers/private_api/proteins_controller_test.rb
new file mode 100644
index 0000000..36cf54d
--- /dev/null
+++ b/test/controllers/private_api/proteins_controller_test.rb
@@ -0,0 +1,53 @@
+require 'test_helper'
+
+class PrivateApi::ProteinsControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get proteins' do
+ @expected = '{
+ "lca":1,"common_lineage":[2,1],"proteins":[{"uniprotAccessionId":"nr2","name":"some name","organism":2,"ecNumbers":[],"goTerms":[],"interproEntries":[]},{"uniprotAccessionId":"nr","name":"some name","organism":1,"ecNumbers":["1.2.3.4"],"goTerms":["goid"],"interproEntries":["IPR000126"]}]
+ }'
+
+ get :proteins, params: { peptide: "AAIER" }
+ end
+
+ test 'should get proteins with il' do
+ @expected = '{
+ "lca":1,"common_lineage":[2,1],"proteins":[{"uniprotAccessionId":"nr2","name":"some name","organism":2,"ecNumbers":[],"goTerms":[],"interproEntries":[]},{"uniprotAccessionId":"nr","name":"some name","organism":1,"ecNumbers":["1.2.3.4"],"goTerms":["goid"],"interproEntries":["IPR000126"]}]
+ }'
+
+ get :proteins, params: { peptide: "AAIER", equate_il: 'true' }
+ end
+
+ test 'should get proteins no match' do
+ @expected = '{"lca":-1,"common_lineage":[],"proteins":[]}'
+
+ get :proteins, params: { peptide: "AAAAAAAAA" }
+ end
+
+ test 'should get proteins too short sequence' do
+ @expected = '{
+ "name":"Sequence too short",
+ "message":"The peptide sequence you provided is too short. It should contain at least 5 valid amino acids."
+ }'
+
+ get :proteins, params: { peptide: "AAA" }
+ end
+
+ test 'should get proteins without peptides' do
+ @expected = '{
+ "name":"Invalid peptide provided",
+ "message":"No peptide sequence was provided. Please provide a valid peptide sequence."
+ }'
+
+ get :proteins, params: {}
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/controllers/private_api/taxa_controller_test.rb b/test/controllers/private_api/taxa_controller_test.rb
new file mode 100644
index 0000000..3256cb3
--- /dev/null
+++ b/test/controllers/private_api/taxa_controller_test.rb
@@ -0,0 +1,28 @@
+require 'test_helper'
+
+class PrivateApi::TaxaControllerTest < ActionController::TestCase
+ teardown :assert_success
+
+ test 'should get taxa' do
+ @expected = '[
+ {"id":1,"name":"species1","rank":"species","lineage":[null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null]},
+ {"id":13,"name":"kingdom2","rank":"kingdom","lineage":[null,13,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]}
+ ]'
+
+ get :taxa, params: { taxids: %w[1 13] }
+ end
+
+ test 'should get taxa no match' do
+ @expected = '[]'
+
+ get :taxa, params: { taxids: %w[52] }
+ end
+
+ private
+
+ def assert_success
+ assert_response :success
+ assert_equal '*', @response.headers['Access-Control-Allow-Origin']
+ assert_json
+ end
+end
diff --git a/test/fixtures/ec_numbers.yml b/test/fixtures/ec_numbers.yml
index 8372145..3e12012 100644
--- a/test/fixtures/ec_numbers.yml
+++ b/test/fixtures/ec_numbers.yml
@@ -11,3 +11,13 @@ ecnumber1:
id: 1
code: "1.2.3.4"
name: "Some Enzyme"
+
+ecnumber2:
+ id: 2
+ code: "2.7.11.1"
+ name: "Some Enzyme2"
+
+ecnumber3:
+ id: 3
+ code: "4.2.1.11"
+ name: "Some Enzyme3"
diff --git a/test/fixtures/go_terms.yml b/test/fixtures/go_terms.yml
index 9f512d2..6ae6939 100644
--- a/test/fixtures/go_terms.yml
+++ b/test/fixtures/go_terms.yml
@@ -10,7 +10,7 @@
goterm1:
id: 1
- code: "GO:12345"
+ code: "GO:0012345"
namespace: "cellular component"
name: "some function"
diff --git a/test/fixtures/sequences.yml b/test/fixtures/sequences.yml
index 5c3ea8b..04d808d 100644
--- a/test/fixtures/sequences.yml
+++ b/test/fixtures/sequences.yml
@@ -10,15 +10,13 @@
# fa_il :binary(16777215)
#
-
-
sequence1:
id: 1
sequence: "AALER"
lca: 2
lca_il: 1
- fa: '{"num":{"all":1,"EC":1,"GO":1},"data":{"GO:0016569":1,"GO:0006281":1,"GO:0000781":1,"EC:2.7.11.1":1}}'
- fa_il: '{"num":{"all":22,"EC":4,"GO":2},"data":{"EC:2.7.11.1":4,"GO:0004674":1,"GO:0005634":1,"GO:0005524":1,"GO:0016301":1}}'
+ fa: '{"num":{"all":1,"EC":1,"GO":1, "IPR":1},"data":{"GO:0016569":1,"GO:0006281":1,"GO:0000781":1,"EC:2.7.11.1":1,"IPR:IPR000169":1}}'
+ fa_il: '{"num":{"all":22,"EC":4,"GO":2,"IPR":3},"data":{"EC:2.7.11.1":4,"GO:0004674":1,"GO:0005634":1,"GO:0005524":1,"GO:0016301":1,"IPR:IPR000169":1}}'
sequence2:
id: 2
@@ -26,7 +24,7 @@ sequence2:
lca: 2
lca_il: 1
fa: '{"num":{"all":3,"EC":0,"GO":3},"data":{"GO:0051301":3,"GO:0005525":3,"GO:0046872":3,"GO:0007049":3}}'
- fa_il: '{"num":{"all":4,"EC":1,"GO":4},"data":{"GO:0005759":1,"GO:0004760":1,"GO:0051301":3,"GO:0005739":1}}'
+ fa_il: '{"num":{"all":4,"EC":1,"GO":4, "IPR":2},"data":{"GO:0005759":1,"GO:0004760":1,"GO:0051301":3,"GO:0005739":1,"IPR:IPR000169":1}}'
sequence3:
id: 3
sequence: "RANDOM"
@@ -40,7 +38,7 @@ sequence4:
sequence: "AAILER"
lca: 1
lca_il: 2
- fa: '{"num":{"all":1,"EC":1,"GO":1},"data":{"GO:0005576":1,"GO:0000287":1,"GO:0004634":1,"GO:0000015":1,"GO:0006096":1,"EC:4.2.1.11":1,"GO:0009986":1}}'
+ fa: '{"num":{"all":1,"EC":1,"GO":1,"IPR":1},"data":{"GO:0005576":1,"GO:0000287":1,"GO:0004634":1,"GO:0000015":1,"GO:0006096":1,"EC:4.2.1.11":1,"GO:0009986":1,"IPR:IPR000169":1}}'
fa_il:
sequence5:
diff --git a/test/models/sequence_test.rb b/test/models/sequence_test.rb
index bc33f0a..1957440 100644
--- a/test/models/sequence_test.rb
+++ b/test/models/sequence_test.rb
@@ -108,18 +108,18 @@ class SequenceTest < ActiveSupport::TestCase
end
test 'should give correct result for calculate_fa' do
- expected_nil_fallback = { 'num' => { 'all' => 0, 'EC' => 0, 'GO' => 0 }, 'data' => {} }
+ expected_nil_fallback = { 'num' => { 'all' => 0, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }
data1 = { seq: sequences(:sequence1),
- exp_fa: { 'num' => { 'all' => 1, 'EC' => 1, 'GO' => 1 }, 'data' => { 'GO:0016569' => 1, 'GO:0006281' => 1, 'GO:0000781' => 1, 'EC:2.7.11.1' => 1 } },
- exp_il: { 'num' => { 'all' => 22, 'EC' => 4, 'GO' => 2 }, 'data' => { 'EC:2.7.11.1' => 4, 'GO:0004674' => 1, 'GO:0005634' => 1, 'GO:0005524' => 1, 'GO:0016301' => 1 } } }
+ exp_fa: { 'num' => { 'all' => 1, 'EC' => 1, 'GO' => 1, 'IPR' => 1 }, 'data' => { 'GO:0016569' => 1, 'GO:0006281' => 1, 'GO:0000781' => 1, 'EC:2.7.11.1' => 1, "IPR:IPR000169" => 1 } },
+ exp_il: { 'num' => { 'all' => 22, 'EC' => 4, 'GO' => 2, 'IPR' => 3 }, 'data' => { 'EC:2.7.11.1' => 4, 'GO:0004674' => 1, 'GO:0005634' => 1, 'GO:0005524' => 1, 'GO:0016301' => 1, "IPR:IPR000169" => 1 } } }
data2 = { seq: sequences(:sequence2),
exp_fa: { 'num' => { 'all' => 3, 'EC' => 0, 'GO' => 3 }, 'data' => { 'GO:0051301' => 3, 'GO:0005525' => 3, 'GO:0046872' => 3, 'GO:0007049' => 3 } },
- exp_il: { 'num' => { 'all' => 4, 'EC' => 1, 'GO' => 4 }, 'data' => { 'GO:0005759' => 1, 'GO:0004760' => 1, 'GO:0051301' => 3, 'GO:0005739' => 1 } } }
+ exp_il: { 'num' => { 'all' => 4, 'EC' => 1, 'GO' => 4, 'IPR' => 2 }, 'data' => { 'GO:0005759' => 1, 'GO:0004760' => 1, 'GO:0051301' => 3, 'GO:0005739' => 1, "IPR:IPR000169" => 1 } } }
data3 = { seq: sequences(:sequence3),
exp_fa: expected_nil_fallback,
exp_il: expected_nil_fallback }
data4 = { seq: sequences(:sequence4),
- exp_fa: { 'num' => { 'all' => 1, 'EC' => 1, 'GO' => 1 }, 'data' => { 'GO:0005576' => 1, 'GO:0000287' => 1, 'GO:0004634' => 1, 'GO:0000015' => 1, 'GO:0006096' => 1, 'EC:4.2.1.11' => 1, 'GO:0009986' => 1 } },
+ exp_fa: { 'num' => { 'all' => 1, 'EC' => 1, 'GO' => 1, 'IPR' => 1 }, 'data' => { 'GO:0005576' => 1, 'GO:0000287' => 1, 'GO:0004634' => 1, 'GO:0000015' => 1, 'GO:0006096' => 1, 'EC:4.2.1.11' => 1, 'GO:0009986' => 1, "IPR:IPR000169" => 1 } },
exp_il: expected_nil_fallback }
[data1, data2, data3, data4].each do |seq|
@@ -131,22 +131,22 @@ class SequenceTest < ActiveSupport::TestCase
test 'should give correct result for calculate_fa if hash, string given' do
sequence = Sequence.new(
- fa: { 'num' => { 'all' => 1, 'EC' => 0, 'GO' => 0 }, 'data' => {} },
- fa_il: { 'num' => { 'all' => 2, 'EC' => 0, 'GO' => 0 }, 'data' => {} }
+ fa: { 'num' => { 'all' => 1, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} },
+ fa_il: { 'num' => { 'all' => 2, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }
)
sequenceStr = Sequence.new(
- fa: '{"num":{"all":1, "EC" : 0, "GO" : 0 }, "data" : {} }',
- fa_il: '{ "num" : { "all" : 2, "EC" : 0, "GO" : 0 }, "data" : {} }'
+ fa: '{"num":{"all":1, "EC" : 0, "GO" : 0, "IPR" : 0 }, "data" : {} }',
+ fa_il: '{ "num" : { "all" : 2, "EC" : 0, "GO" : 0, "IPR" : 0 }, "data" : {} }'
)
- assert_equal ({ 'num' => { 'all' => 1, 'EC' => 0, 'GO' => 0 }, 'data' => {} }), sequence.calculate_fa(false)
- assert_equal ({ 'num' => { 'all' => 2, 'EC' => 0, 'GO' => 0 }, 'data' => {} }), sequence.calculate_fa(true)
+ assert_equal ({ 'num' => { 'all' => 1, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }), sequence.calculate_fa(false)
+ assert_equal ({ 'num' => { 'all' => 2, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }), sequence.calculate_fa(true)
assert_equal sequence.calculate_fa(false), sequenceStr.calculate_fa(false)
assert_equal sequence.calculate_fa(true), sequenceStr.calculate_fa(true)
# Doube check because JSON decoding is cached
- assert_equal ({ 'num' => { 'all' => 1, 'EC' => 0, 'GO' => 0 }, 'data' => {} }), sequenceStr.calculate_fa(false)
- assert_equal ({ 'num' => { 'all' => 2, 'EC' => 0, 'GO' => 0 }, 'data' => {} }), sequenceStr.calculate_fa(true)
+ assert_equal ({ 'num' => { 'all' => 1, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }), sequenceStr.calculate_fa(false)
+ assert_equal ({ 'num' => { 'all' => 2, 'EC' => 0, 'GO' => 0, 'IPR' => 0 }, 'data' => {} }), sequenceStr.calculate_fa(true)
end
test 'should give correct result for calculate_fa if no data' do
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 4939e14..a5fcbbb 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -23,5 +23,7 @@ class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
- # Add more helper methods to be used by all tests here...
+ def assert_json
+ assert_equal JSON.parse(@response.body), JSON.parse(@expected)
+ end
end