Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
elixir
beacon
Commits
cc910986
Commit
cc910986
authored
Jun 12, 2019
by
Jacek Lebioda
Browse files
Validation of strings simplified
parent
786ba61e
Pipeline
#10639
passed with stage
in 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
code/backend/beacon/data_types.py
View file @
cc910986
...
...
@@ -44,14 +44,14 @@ def validate_input(**kwargs):
an `APIArgumentError` exception is raised
"""
def
wrap
(
name
,
message
,
regexp
,
can_skip
=
False
):
re_regexp
=
re
.
compile
(
regexp
)
re_regexp
=
re
.
compile
(
regexp
,
re
.
IGNORECASE
)
if
not
test_input_with_regex
(
kwargs
,
name
,
re_regexp
)
and
not
can_skip
:
arg
=
kwargs
.
get
(
name
)
if
kwargs
.
get
(
name
)
is
not
None
else
'<<None>>'
raise
APIArgumentError
(
"Invalid {0} ({1}) - {2}"
.
format
(
name
,
arg
,
message
))
wrap
(
'referenceName'
,
'accepted ones are: 1-22, X, Y, M, MT'
,
r
'^([1-9]|1\d|2[012]|
[Xx]|[Yy]|[Mm][Tt]
?)$'
)
r
'^([1-9]|1\d|2[012]|
x|y|mt
?)$'
)
wrap
(
'start'
,
'should be a positive number'
,
...
...
@@ -85,21 +85,20 @@ def validate_input(**kwargs):
wrap
(
'assemblyId'
,
'accepted ones are: GRCh38, GRCh37 and NCBI36'
,
r
'^(
[Gg][Rr][Cc][Hh](38|37)|[Nn][Cc][Bb][Ii]
36)$'
)
r
'^(
grch(38|37)|ncbi
36)$'
)
wrap
(
'referenceBases'
,
'should contain only A, C, T, G, D'
,
r
'^[
AaCcTtGgD
d]*$'
)
r
'^[
actg
d]*$'
)
wrap
(
'alternateBases'
,
'should contain only A, C, T, G, D'
,
r
'^[
AaCcTtGgD
d]*$'
,
r
'^[
actg
d]*$'
,
True
)
wrap
(
'includeDatasetResponses'
,
'accepts only "ALL", "HIT", "MISS", "NONE" and empty string'
,
r
'^([Hh][Ii][Tt]$)|([Aa][Ll]{2}$)|([Mm][Ii][Ss]{2}$)|([Nn][Oo][Nn][Ee]$)|($)'
,
True
)
r
'^(hit|all|miss|none)?$'
)
return
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment