Skip to content
Snippets Groups Projects
Commit f6e776c1 authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

move valideInitTableNamePattern into initTable sources

parent f4d32385
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ Created on Tue Mar 28 09:57:33 2017 ...@@ -5,6 +5,7 @@ Created on Tue Mar 28 09:57:33 2017
@author: vguillem, hjulienne, hmenager @author: vguillem, hjulienne, hmenager
""" """
import os import os
import re
import glob import glob
import logging import logging
from pandas import HDFStore, DataFrame, read_csv, concat, options, read_hdf from pandas import HDFStore, DataFrame, read_csv, concat, options, read_hdf
...@@ -18,7 +19,7 @@ from functools import reduce ...@@ -18,7 +19,7 @@ from functools import reduce
options.mode.chained_assignment = None options.mode.chained_assignment = None
warnings.filterwarnings("ignore", category=tables.NaturalNameWarning) warnings.filterwarnings("ignore", category=tables.NaturalNameWarning)
from pydantic import BaseModel valideInitTableNamePattern = re.compile("^([A-Z]*[a-z]*-*\.?[0-9]*)+$")
class InitMeta(object): class InitMeta(object):
def __init__(self, nb_snps, nb_phenotypes): def __init__(self, nb_snps, nb_phenotypes):
......
...@@ -3,10 +3,10 @@ from typing import List, Optional ...@@ -3,10 +3,10 @@ from typing import List, Optional
import os import os
import pandas import pandas
import re
from pydantic import BaseModel, validator from pydantic import BaseModel, validator
from jass.config import config from jass.config import config
from jass.models.inittable import valideInitTableNamePattern
class Phenotype(BaseModel): class Phenotype(BaseModel):
...@@ -76,16 +76,13 @@ def get_available_phenotypes(init_file_path: str): ...@@ -76,16 +76,13 @@ def get_available_phenotypes(init_file_path: str):
return phenotypes return phenotypes
_initTableNamePattern = re.compile("^([A-Z]*[a-z]*-*\.?[0-9]*)+$")
class InitTableNameModel(BaseModel): class InitTableNameModel(BaseModel):
initTableName: Optional[str] = "initTable.hdf5" initTableName: Optional[str] = "initTable.hdf5"
@validator("initTableName") @validator("initTableName")
def validate_path_injection(cls, value): def validate_path_injection(cls, value):
if not _initTableNamePattern.match(value): if not valideInitTableNamePattern.match(value):
raise ValueError(f"Prohibited char, only \"{_initTableNamePattern.pattern}\" allowed.") raise ValueError(f"Prohibited char, only \"{valideInitTableNamePattern.pattern}\" allowed.")
return value return value
def get_init_table_path(self): def get_init_table_path(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment