Skip to content
Snippets Groups Projects

Dev cne

Merged Cyril NERIN requested to merge dev_cne into dev
5 files
+ 1077
591
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 90
17
@@ -5,6 +5,7 @@ compute joint statistics and generate plots for a given set of phenotypes
from __future__ import absolute_import
from typing import List, Dict
import os, sys
import shutil
import hashlib
import traceback
@@ -285,14 +286,42 @@ def create_project_csv_file(worktable_path, csv_file, Nchunk):
@app.task
def create_project_data(
phenotype_ids, init_table_path, worktable_path, global_plot_path, quadrant_plot_path, csv_file=None
):
try:
Nchunk = create_worktable_file(phenotype_ids,
init_table_path,
worktable_path,
False,
csv_file=csv_file)
phenotype_ids,
init_table_path,
worktable_path,
remove_nan = False,
stat = "jass.models.stats:omnibus_stat",
csv_file = None,
chunk_size = 50,
significance_treshold = 5*10**-8,
post_filtering = True,
delayed_gen_csv_file = False,
chromosome = None,
start = None,
end = None,
custom_loadings = None,
global_plot_path = None,
quadrant_plot_path = None
):
try:
Nchunk = create_worktable_file(
phenotype_ids = phenotype_ids,
init_file_path = init_table_path,
project_hdf_path = worktable_path,
remove_nan = remove_nan,
stat = stat,
optim_na = True,
csv_file = csv_file,
chunk_size = chunk_size,
significance_treshold = significance_treshold,
post_filtering = post_filtering,
delayed_gen_csv_file = delayed_gen_csv_file,
chromosome = chromosome,
pos_Start = start,
pos_End = end,
custom_loadings = custom_loadings
)
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
log_path = get_file_building_tb_path(worktable_path)
@@ -300,9 +329,13 @@ def create_project_data(
traceback.print_exception(exc_type, exc_value, exc_traceback, file=log_fh)
log_fh.close()
return
create_project_global_plot.delay(worktable_path, global_plot_path)
create_project_quadrant_plot.delay(worktable_path, quadrant_plot_path)
create_project_csv_file.delay(worktable_path, csv_file, Nchunk=Nchunk)
if (global_plot_path is not None):
create_project_global_plot.delay(worktable_path, global_plot_path)
if (quadrant_plot_path is not None):
create_project_quadrant_plot.delay(worktable_path, quadrant_plot_path)
if (delayed_gen_csv_file and (csv_file is not None)):
create_project_csv_file.delay(worktable_path, csv_file, Nchunk=Nchunk)
def create_project(phenotype_ids: List[str], available_phenotypes: List[Phenotype]):
@@ -321,11 +354,51 @@ def create_project(phenotype_ids: List[str], available_phenotypes: List[Phenotyp
if project.status == Project.DOES_NOT_EXIST:
os.makedirs(folder_path)
create_project_data.delay(
phenotype_ids,
os.path.join(config["DATA_DIR"], "initTable.hdf5"),
project.get_worktable_path(),
project.get_global_manhattan_plot_path(),
project.get_quadrant_plot_path(),
csv_file=project.get_csv_path()
phenotype_ids=phenotype_ids,
init_table_path=os.path.join(config["DATA_DIR"], "initTable.hdf5"),
worktable_path=project.get_worktable_path(),
global_plot_path=project.get_global_manhattan_plot_path(),
quadrant_plot_path=project.get_quadrant_plot_path(),
csv_file=project.get_csv_path(),
delayed_gen_csv_file=True
)
return project
def create_project_local(
phenotype_ids: List[str],
available_phenotypes: List[Phenotype],
ip: str,
chromosome: str,
start: str = None,
end: str = None
):
available_phenotype_ids = [phenotype.id for phenotype in available_phenotypes]
unavailable_requested_ids = set(phenotype_ids).difference(
set(available_phenotype_ids)
)
if len(unavailable_requested_ids) > 0:
raise Exception() # FIXME with a nice exception
phenotypes = [
phenotype for phenotype in available_phenotypes if phenotype.id in phenotype_ids
]
ip = ip.replace('.', '_')
id_project = "local_{}".format(ip)
project = Project(phenotypes=phenotypes, id=id_project)
folder_path = project.get_folder_path()
# If the folder exists, it is deleted with the files it contains
if os.path.exists(folder_path):
shutil.rmtree(folder_path)
# The folder is created
os.makedirs(folder_path)
create_project_data.delay(
phenotype_ids=phenotype_ids,
init_table_path=os.path.join(config["DATA_DIR"], "initTable.hdf5"),
worktable_path=project.get_worktable_path(),
csv_file=project.get_csv_path(),
chromosome=chromosome,
start=start,
end=end
)
return project
\ No newline at end of file