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

transmit initTable name when creating project

parent fc14511d
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,12 @@ export default { ...@@ -87,7 +87,12 @@ export default {
}, },
runAnalysis(){ runAnalysis(){
const { selectedRows, $axios } = this; const { selectedRows, $axios } = this;
const phenotypeIds = {phenotypeID: selectedRows.map(function(phenotype){return phenotype.id})}; const phenotypeIds = {
phenotypeID: selectedRows.map(function(phenotype){return phenotype.id}),
initTableName: "initTable.hdf5"
// phenotypeID: ["z_MAGIC_FAST-GLUCOSE", "z_MAGIC_FAST-INSULIN"],
// initTableName: "initTableTest.hdf5"
};
console.log("REQUEST POST") console.log("REQUEST POST")
console.log(phenotypeIds) console.log(phenotypeIds)
......
...@@ -85,5 +85,5 @@ class ProjectNameModel(BaseModel): ...@@ -85,5 +85,5 @@ class ProjectNameModel(BaseModel):
raise ValueError(f"Prohibited char, only \"{_initTableNamePattern.pattern}\" allowed.") raise ValueError(f"Prohibited char, only \"{_initTableNamePattern.pattern}\" allowed.")
return value return value
class PhenotypeIdList(BaseModel): class PhenotypeIdList(ProjectNameModel, BaseModel):
phenotypeID: List[str] = [] phenotypeID: List[str] = []
...@@ -70,7 +70,7 @@ def inittable_meta(): ...@@ -70,7 +70,7 @@ def inittable_meta():
def project_create(phenotype_id_list: PhenotypeIdList): def project_create(phenotype_id_list: PhenotypeIdList):
return create_project( return create_project(
phenotype_id_list.phenotypeID, phenotype_id_list.phenotypeID,
get_available_phenotypes(os.path.join(config["DATA_DIR"], "initTable.hdf5")), init_table_name=phenotype_id_list.initTableName,
) )
......
...@@ -10,7 +10,7 @@ from flask import Flask ...@@ -10,7 +10,7 @@ from flask import Flask
import jass.models.project import jass.models.project
from jass.models.project import GlobalProject, Project, ensure_space_in_project_dir from jass.models.project import GlobalProject, Project, ensure_space_in_project_dir
from jass.models.phenotype import Phenotype from jass.models.phenotype import Phenotype, get_available_phenotypes
from jass.config import config from jass.config import config
...@@ -155,22 +155,22 @@ def run_project_analysis_if_needed(project): ...@@ -155,22 +155,22 @@ def run_project_analysis_if_needed(project):
def create_project( def create_project(
phenotype_ids: List[str], phenotype_ids: List[str],
available_phenotypes: List[Phenotype],
chromosome: str = None, chromosome: str = None,
start: str = None, start: str = None,
end: str = None, end: str = None,
init_table_name: str = None,
): ):
init_table_path = os.path.join(config["DATA_DIR"], init_table_name)
available_phenotype_ids = [phenotype.id for phenotype in available_phenotypes] available_phenotypes=get_available_phenotypes(init_table_path)
unavailable_requested_ids = set(phenotype_ids).difference( unavailable_requested_ids = set(phenotype_ids).difference(
set(available_phenotype_ids) set(phenotype.id for phenotype in available_phenotypes)
) )
if len(unavailable_requested_ids) > 0: if len(unavailable_requested_ids) > 0:
raise HTTPException(status_code=404, detail=f"Phenotype IDs not found: {','.join(unavailable_requested_ids)}") raise HTTPException(status_code=404, detail=f"Phenotype IDs not found: {','.join(unavailable_requested_ids)}")
phenotypes = [ phenotypes = [
phenotype for phenotype in available_phenotypes if phenotype.id in phenotype_ids phenotype for phenotype in available_phenotypes if phenotype.id in phenotype_ids
] ]
project = GlobalProject(phenotypes=phenotypes) project = GlobalProject(phenotypes=phenotypes, init_table_path=init_table_path)
project.create(fail_if_exists=False) project.create(fail_if_exists=False)
ensure_space_in_project_dir(except_project_id=project.id) ensure_space_in_project_dir(except_project_id=project.id)
......
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