Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
LonnekeScheffer committed Nov 8, 2023
1 parent de05f14 commit 6c2986c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
48 changes: 24 additions & 24 deletions immuneML/api/galaxy/build_dataset_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,34 @@ def build_metadata_column_mapping(columns_str):

return {colname: colname for colname in colnames if colname != ""}

def get_dataset_specs(args):
dataset_specs = {"format": args.format,
"params": {"region_type": RegionType.IMGT_CDR3.name,
"result_path": "./",
"path": "./"}}

if args.is_repertoire == "True":
dataset_specs["params"]["is_repertoire"] = True
dataset_specs["params"]["metadata_file"] = args.metadata_file
else:
dataset_specs["params"]["is_repertoire"] = False

paired = True if args.paired == "True" else False

dataset_specs["params"]["paired"] = paired
if paired:
dataset_specs["params"]["receptor_chains"] = args.receptor_chains

if args.metadata_columns != "":
dataset_specs["params"]["metadata_column_mapping"] = build_metadata_column_mapping(args.metadata_columns)

return {args.dataset_name: dataset_specs}


def build_specs(args):
specs = {
"definitions": {
"datasets": {
args.dataset_name: {
"format": args.format,
"params": {}
}
},
"datasets": get_dataset_specs(args),
},
"instructions": {
"my_dataset_generation_instruction": {
Expand All @@ -34,24 +52,6 @@ def build_specs(args):
}
}

specs["definitions"]["datasets"][args.dataset_name]["params"]["region_type"] = RegionType.IMGT_CDR3.name
specs["definitions"]["datasets"][args.dataset_name]["params"]["result_path"] = "./"
specs["definitions"]["datasets"][args.dataset_name]["params"]["path"] = "./"

if args.is_repertoire == "True":
specs["definitions"]["datasets"][args.dataset_name]["params"]["is_repertoire"] = True
specs["definitions"]["datasets"][args.dataset_name]["params"]["metadata_file"] = args.metadata_file
else:
specs["definitions"]["datasets"][args.dataset_name]["params"]["is_repertoire"] = False

paired = True if args.paired == "True" else False

specs["definitions"]["datasets"][args.dataset_name]["params"]["paired"] = paired
if paired:
specs["definitions"]["datasets"][args.dataset_name]["params"]["receptor_chains"] = args.receptor_chains

if args.metadata_columns != "":
specs["definitions"]["datasets"][args.dataset_name]["params"]["metadata_column_mapping"] = build_metadata_column_mapping(args.metadata_columns)

return specs

Expand Down
6 changes: 3 additions & 3 deletions immuneML/api/galaxy/build_yaml_from_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ def build_settings_specs(enc_names, ml_names):


def discover_dataset_params():
dataset = glob.glob("*.yaml")
dataset = glob.glob("*dataset.yaml")

assert len(dataset) > 0, "no .yaml file was present in the current working directory"
assert len(dataset) < 2, "multiple .yaml files were present in the current working directory"
assert len(dataset) > 0, "no *dataset.yaml file was present in the current working directory"
assert len(dataset) < 2, f"multiple *dataset.yaml files were present in the current working directory: {list(glob.glob('*dataset.yaml'))}"

dataset_path = dataset[0]

Expand Down

0 comments on commit 6c2986c

Please sign in to comment.