35 lines
840 B
Python
35 lines
840 B
Python
import re
|
|
|
|
from logzero import logger
|
|
|
|
|
|
def check_pgroup(pgroup):
|
|
if pgroup is None:
|
|
return pgroup
|
|
pgroup = str(pgroup)
|
|
if re.match(r"^p\d{5}$", pgroup, re.I):
|
|
return pgroup.lower()
|
|
if re.match(r"^\d{5}$", pgroup):
|
|
return "p" + pgroup
|
|
msg = f"Pgroup {pgroup} supplied in incorrect format. Proper format 'pXXXXX', X is a digit"
|
|
logger.error(msg)
|
|
raise SystemExit(msg)
|
|
|
|
|
|
def get_run_from_pth(pth):
|
|
return re.search(r"/run(\d{4})", pth).group(1)
|
|
|
|
|
|
def get_acq_from_pth(pth):
|
|
return re.search(r"/acq(\d{4})", pth).group(1)
|
|
|
|
|
|
def get_pgroup_from_pth(pth):
|
|
return re.search(r"data/p(\d{5})", pth).group(1)
|
|
|
|
|
|
def get_es_from_pth(pth):
|
|
return re.search(r"sf/([^/]+)/data", pth).group(1)
|
|
|
|
def get_jf_from_pth(pth):
|
|
return re.search(r"JF\d{2}T\d{2}V\d{2}(?=.h5$)", pth).group(0) |