sequenceserver 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b058e493103527b8d0120243180b748b256997416d9886c3d349539d0afe9420
4
- data.tar.gz: 836645ba201b125b1f379b934b86186128b76717c5bd456c85caa71e5cdc9269
3
+ metadata.gz: 1579fdcd4e8dc694025ccde8534ab3a48d935cfef4830a8de2c446657449aaf8
4
+ data.tar.gz: 25561e738f1511d4ee40730eec04c943148749313d29ccf362098b15a1e922c5
5
5
  SHA512:
6
- metadata.gz: 16e202385e0704918489da25ade9f938e3afe92a3298e338a2462188da049d9c780e80ba3cfe6de1c156196901d50570c845e030de71980151b2580ffd15a65f
7
- data.tar.gz: a1033d77cb3feb609d0cf0b2f6af7dbfd558cca05027c4a6308d176f39c39b281d9dbf16b5de4d4d58620d00e372078a14103b35b456dc79b153d2d76c3c24e0
6
+ metadata.gz: 965a7ab34577a0180d8ac1ac830c84737118e4c3fe2997cc61886424929066a95d3df3869c01ca46ffceb3a9ef3d39b96676e87841bf57c0c4903cd99700fde0
7
+ data.tar.gz: 3a5fa2dce619076a5e0b626981c2bb95ffc544ae8b920942b2979cabe4869120e549f494cbd15a02bf10e265bb303f8988264824839ea934f80797e280b8045a
@@ -52,6 +52,30 @@ module SequenceServer
52
52
  end
53
53
  end
54
54
 
55
+ # InvalidParameterError is a more generic error class that can be
56
+ # raised when the frontend sends a request with an invalid parameter
57
+ class InvalidParameterError < ValidationError
58
+ attr_reader :more_info
59
+
60
+ def initialize(more_info)
61
+ super
62
+ @more_info = more_info
63
+ end
64
+
65
+ def http_status
66
+ 422
67
+ end
68
+
69
+ def title
70
+ 'Invalid parameter'
71
+ end
72
+
73
+ def message
74
+ "The action you're trying to perform is not possible because \
75
+ one of the provided parameters is invalid."
76
+ end
77
+ end
78
+
55
79
  # API errors have an http status, title, message, and additional information
56
80
  # like stacktrace or information from program output.
57
81
  APIError = Class.new(Error)
@@ -1,3 +1,9 @@
1
1
  require_relative 'blast/job'
2
2
  require_relative 'blast/report'
3
3
  require_relative 'blast/constants'
4
+
5
+ module SequenceServer
6
+ module BLAST
7
+ VALID_SEQUENCE_ID = /\A[a-zA-Z0-9\-_.:*#|\[\]]+\z/
8
+ end
9
+ end
@@ -37,8 +37,19 @@ module SequenceServer
37
37
  alias path name
38
38
 
39
39
  def retrieve(accession, coords = nil)
40
+ fail(
41
+ InvalidSequenceIdError,
42
+ "Invalid sequence id: #{accession}"
43
+ ) unless accession =~ SequenceServer::BLAST::VALID_SEQUENCE_ID
44
+
40
45
  cmd = "blastdbcmd -db #{name} -entry '#{accession}'"
46
+
41
47
  if coords
48
+ fail(
49
+ InvalidParameterError,
50
+ "Invalid range coordinates: #{coords}"
51
+ ) unless coords =~ /[0-9]+-[0-9]*/
52
+
42
53
  cmd << " -range #{coords}"
43
54
  end
44
55
  out, = sys(cmd, path: config[:bin])
@@ -52,6 +63,8 @@ module SequenceServer
52
63
  # Returns true if the database contains the given sequence id.
53
64
  # Returns false otherwise.
54
65
  def include?(id)
66
+ fail ArgumentError, "Invalid sequence id: #{id}" unless id =~ SequenceServer::BLAST::VALID_SEQUENCE_ID
67
+
55
68
  cmd = "blastdbcmd -entry '#{id}' -db #{name}"
56
69
  sys(cmd, path: config[:bin]) rescue false
57
70
  end
@@ -232,9 +232,8 @@ module SequenceServer
232
232
  )
233
233
  end
234
234
 
235
- valid_id_regex = /\A[a-zA-Z0-9-_.:*#|\[\]]+\z/
236
235
  invalid_sequence_ids = sequence_ids.reject do |id|
237
- id =~ valid_id_regex
236
+ id =~ SequenceServer::BLAST::VALID_SEQUENCE_ID
238
237
  end
239
238
 
240
239
  unless invalid_sequence_ids.empty?
@@ -1,4 +1,4 @@
1
1
  # Define version number.
2
2
  module SequenceServer
3
- VERSION = '3.1.1'.freeze
3
+ VERSION = '3.1.2'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequenceserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Queen Mary University of London
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-07-02 00:00:00.000000000 Z
12
+ date: 2024-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_pure