Skip to content

Commit

Permalink
Merge pull request #369 from EGA-archive/develop
Browse files Browse the repository at this point in the history
Some improvements on parameters and adding conf for ri-tools image usage
  • Loading branch information
costero-e authored Sep 3, 2024
2 parents d7b620e + 4451b99 commit 19c610e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 35 deletions.
2 changes: 1 addition & 1 deletion beacon/api_version.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
api_version: v2.0-442ded8
api_version: v2.0-d7b620e
3 changes: 2 additions & 1 deletion beacon/db/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ def apply_ontology_filter(query: dict, filter: OntologyFilter, collection: str,
def format_value(value: Union[str, List[int]]) -> Union[List[int], str, int, float]:
if isinstance(value, list):
return value
elif isinstance(value, int):
return value

elif value.isnumeric():
if float(value).is_integer():
Expand Down Expand Up @@ -729,7 +731,6 @@ def apply_alphanumeric_filter(query: dict, filter: AlphanumericFilter, collectio
#LOG.debug(filter.id)
if collection == 'g_variants' and scope != 'individual' and scope != 'run':
if filter.id == "identifiers.genomicHGVSId":
LOG.debug('hoaaaa')
list_chromosomes = ['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22']
dict_regex={}
if filter.value == 'GRCh38':
Expand Down
61 changes: 30 additions & 31 deletions beacon/request/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class OntologyFilter(CamelModel):

class AlphanumericFilter(CamelModel):
id: str
value: Union[str, List[int]]
value: Union[str, int, List[int]]
scope: Optional[str] = None
operator: Operator = Operator.EQUAL

Expand Down Expand Up @@ -95,7 +95,7 @@ class RequestParams(CamelModel):

class SequenceQuery(BaseModel):
referenceName: Union[str,int]
start: int
start: Union[int, list, str]
alternateBases:str
referenceBases: str
clinicalRelevance: Optional[str] =None
Expand All @@ -104,8 +104,8 @@ class SequenceQuery(BaseModel):

class RangeQuery(BaseModel):
referenceName: Union[str,int]
start: int
end: int
start: Union[int, str, list]
end: Union[int, str, list]
variantType: Optional[str] =None
alternateBases: Optional[str] =None
aminoacidChange: Optional[str] =None
Expand Down Expand Up @@ -163,33 +163,32 @@ class RequestParams(CamelModel):
query: RequestQuery = RequestQuery()

def from_request(self, request: Request) -> Self:
request_params={}
if request.method != "POST" or not request.has_body or not request.can_read_body:
for k, v in request.query.items():
if k == "requestedSchema":
self.meta.requested_schemas = [html.escape(v)] # comprovar si és la sanitització recomanada
elif k == "skip":
self.query.pagination.skip = int(html.escape(v))
elif k == "limit":
self.query.pagination.limit = int(html.escape(v))
elif k == "includeResultsetResponses":
self.query.include_resultset_responses = IncludeResultsetResponses(html.escape(v))
elif k == 'filters':
self.query.request_parameters[k] = html.escape(v)
elif k in ["start", "end", "assemblyId", "referenceName", "referenceBases", "alternateBases", "variantType","variantMinLength","variantMaxLength","geneId","genomicAlleleShortForm","aminoacidChange","clinicalRelevance", "mateName"]:
try:
if ',' in v:
v_splitted = v.split(',')
request_params[k]=[int(v) for v in v_splitted]
else:
request_params[k]=int(v)
except Exception as e:
request_params[k]=v
self.query.request_parameters[k] = html.escape(v)
else:
raise web.HTTPBadRequest(text='request parameter introduced is not allowed')
if request_params != {}:
LOG.debug(request_params)
request_params={}
for k, v in request.query.items():
if k == "requestedSchema":
self.meta.requested_schemas = [html.escape(v)] # comprovar si és la sanitització recomanada
elif k == "skip":
self.query.pagination.skip = int(html.escape(v))
elif k == "limit":
self.query.pagination.limit = int(html.escape(v))
elif k == "includeResultsetResponses":
self.query.include_resultset_responses = IncludeResultsetResponses(html.escape(v))
elif k == 'filters':
self.query.request_parameters[k] = html.escape(v)
elif k in ["start", "end", "assemblyId", "referenceName", "referenceBases", "alternateBases", "variantType","variantMinLength","variantMaxLength","geneId","genomicAlleleShortForm","aminoacidChange","clinicalRelevance", "mateName"]:
try:
if ',' in v:
v_splitted = v.split(',')
request_params[k]=[int(v) for v in v_splitted]
else:
request_params[k]=int(v)
except Exception as e:
request_params[k]=v
self.query.request_parameters[k] = html.escape(v)
else:
raise web.HTTPBadRequest(text='request parameter introduced is not allowed')
if request_params != {} or self.query.request_parameters != {}:
request_params = self.query.request_parameters
try:
RangeQuery(**request_params)
return self
Expand Down
12 changes: 10 additions & 2 deletions deploy/ri-tools/conf/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#### Input and Output files config parameters ####
csv_folder = './csv/examples/'
csv_folder = './csv/DATOS-CAT/'
output_docs_folder='./output_docs/'

#### VCF Conversion config parameters ####
allele_frequency=1 # introduce float number, leave 1 if you want to convert all the variants
reference_genome='GRCh38' # Choose one between NCBI36, GRCh37, GRCh38
reference_genome='GRCh38' # Choose one between NCBI36, GRCh37, GRCh38

### MongoDB parameters ###
database_host = 'mongo'
database_port = 27017
database_user = 'root'
database_password = 'example'
database_name = 'beacon'
database_auth_source = 'admin'

0 comments on commit 19c610e

Please sign in to comment.