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
@author: vguillem, hjulienne, hmenager
"""
import os
import re
import glob
import logging
from pandas import HDFStore, DataFrame, read_csv, concat, options, read_hdf
......@@ -18,7 +19,7 @@ from functools import reduce
options.mode.chained_assignment = None
warnings.filterwarnings("ignore", category=tables.NaturalNameWarning)
from pydantic import BaseModel
valideInitTableNamePattern = re.compile("^([A-Z]*[a-z]*-*\.?[0-9]*)+$")
class InitMeta(object):
def __init__(self, nb_snps, nb_phenotypes):
......
......@@ -3,10 +3,10 @@ from typing import List, Optional
import os
import pandas
import re
from pydantic import BaseModel, validator
from jass.config import config
from jass.models.inittable import valideInitTableNamePattern
class Phenotype(BaseModel):
......@@ -76,16 +76,13 @@ def get_available_phenotypes(init_file_path: str):
return phenotypes
_initTableNamePattern = re.compile("^([A-Z]*[a-z]*-*\.?[0-9]*)+$")
class InitTableNameModel(BaseModel):
initTableName: Optional[str] = "initTable.hdf5"
@validator("initTableName")
def validate_path_injection(cls, value):
if not _initTableNamePattern.match(value):
raise ValueError(f"Prohibited char, only \"{_initTableNamePattern.pattern}\" allowed.")
if not valideInitTableNamePattern.match(value):
raise ValueError(f"Prohibited char, only \"{valideInitTableNamePattern.pattern}\" allowed.")
return value
def get_init_table_path(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment