Skip to content
Snippets Groups Projects
Commit ab2a3eda authored by nfontrod's avatar nfontrod
Browse files

src/db_utils/config.py: modification of Config.db_file and Config.output +...

src/db_utils/config.py: modification of Config.db_file and Config.output + deletion of LOGGING_CONFIG, logging_def and LoggingLevelError
parent 95509aac
No related branches found
No related tags found
No related merge requests found
...@@ -16,73 +16,14 @@ class Config: ...@@ -16,73 +16,14 @@ class Config:
""" """
A class containing every parameters used in the submodule db_utils A class containing every parameters used in the submodule db_utils
""" """
db_file = Path(__file__).parents[1] / "db.sqlite3" db_file = Path(__file__).parents[2] / "results" / 'chia_pet_database.db'
tables = ["gin_gene", "gin_exon", "gin_frequency", "gin_interaction"] tables = ["gin_gene", "gin_exon", "gin_frequency", "gin_interaction"]
bed_orf = Path(__file__).parents[1] / "data" / "exon_orf.bed" bed_orf = Path(__file__).parents[1] / "data" / "exon_orf.bed"
bed_exon = Path(__file__).parents[1] / "data" / "exon_freq.bed" bed_exon = Path(__file__).parents[1] / "data" / "exon_freq.bed"
output = Path(__file__).parents[1] / "results" output = Path(__file__).parents[2] / "results"
exon_intern = Path(__file__).parents[1] / "data" / "exon_intern.bed" exon_intern = Path(__file__).parents[1] / "data" / "exon_intern.bed"
ctrl_exon_file = output / "CTRL_exons.txt" ctrl_exon_file = output / "CTRL_exons.txt"
exon_file = output / "exons.txt" exon_file = output / "exons.txt"
gene_file = Path(__file__).parents[1] / "data" / "genes.csv" gene_file = Path(__file__).parents[1] / "data" / "genes.csv"
frequency_file = output / "frequency.txt" frequency_file = output / "frequency.txt"
class LoggingLevelError(Exception):
pass
def logging_def(output: Path, level: str = "INFO"):
"""
Define a logging at the current level of the script
:param output: Folder where the result will be created
:param level: The log level
"""
possible_levels = ["INFO", "DEBUG", "ERROR", "WARNING", "CRITICAL"]
if level in possible_levels:
basename = str(Path(__file__).name).replace(".py", ".log")
LOGGING_CONFIG["handlers"]["file"]["filename"] = output / basename
LOGGING_CONFIG["loggers"][""]["level"] = level
logging.config.dictConfig(LOGGING_CONFIG)
elif level != "DISABLE":
raise LoggingLevelError(f"Logging level unknown : choose from "
f"{possible_levels} or DISABLE to disable the "
f"initialisation of logging in {__file__}")
LOGGING_CONFIG = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'complex': {
'format': '%(filename)s:%(lineno)s:%(funcName)s():%(asctime)s - %('
'levelname)s - %(message)s'
},
"simple": {
'format': '%(message)s'
}
},
'handlers': {
'default': {
'level': 'NOTSET',
'formatter': 'simple',
'class': 'logging.StreamHandler',
'stream': 'ext://sys.stdout', # Default is stderr
},
'file': {
'level': 'NOTSET',
'formatter': 'complex',
'class': 'logging.FileHandler',
'filename': 'test.log',
'mode': 'w',
},
},
'loggers': {
'': { # root logger
'handlers': ['default', "file"],
'level': 'NOTSET',
'propagate': True
},
}
} # type: Dict[str, Any]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment