Skip to content

Commit

Permalink
Merge pull request #73 from Eeeeelias/master
Browse files Browse the repository at this point in the history
Fix multiple bugs in DDI extension part
  • Loading branch information
Eeeeelias authored Sep 30, 2024
2 parents ea38381 + 3099c4b commit f992b53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
5 changes: 4 additions & 1 deletion preprocess/main_ddi_extend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
print("This script only works with linux systems")
exit(1)
missing_files = []
if not os.path.isfile("database_sources.yml"):
print("No database_sources.yml file found, please read the README.md in sourcedata for more information.")
sys.exit(1)
for file in needed_files:
if not os.path.isfile(f"sourcedata/{file}"):
missing_files.append(file)
Expand All @@ -26,7 +29,7 @@
sys.exit(1)

# parse yaml file with information about sources
tasks, organism, functions, additional_flags = parse_yaml.parse("sourcedata/database_sources.yml")
tasks, organism, functions, additional_flags = parse_yaml.parse("database_sources.yml")

# purely debug
if 'none' in functions:
Expand Down
39 changes: 20 additions & 19 deletions preprocess/predict_interactions/parse_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,33 @@ def parse_general(parse_sources, counter=1, col_name=None):
if col_name is None:
return tasks, counter

for source in parse_sources[col_name]:
try:
name = parse_sources[source]['name']
except KeyError:
name = source
source = col_name
try:
name = parse_sources[col_name]['name']
except KeyError:
name = source

try:
path = parse_sources[source]['path']
except KeyError:
print(f"YAML not properly formatted, specify a path for mippie")
exit(1)
try:
path = parse_sources[col_name]['path']
except KeyError:
print(f"YAML not properly formatted, specify a path for mippie")
exit(1)

try:
mapping = parse_sources[source]['mapping']
except KeyError:
print(f"YAML not properly formatted, specify mapping for {name}")
exit(1)
tasks.append((f"clean_{source}", path, f"sourcedata/source{counter}_{name}", mapping))
counter += 1
try:
mapping = parse_sources[col_name]['mapping']
except KeyError:
print(f"YAML not properly formatted, specify mapping for {name}")
exit(1)
tasks.append((f"clean_{source}", path, f"sourcedata/source{counter}_{name}", mapping))
counter += 1
return tasks, counter


# feel free to extend this list by adding a new function and updating the dictionary
supported_sources = {'mitab': parse_mitab,
'string': parse_string,
'mippie': parse_general,
'homology': parse_general,
'mippie': parse_mippie,
'homology': parse_homology,
'mint': parse_mint}


Expand All @@ -131,6 +131,7 @@ def parse(file):
if supported_source not in sources_to_parse:
continue
source_tasks, counter = supported_sources[supported_source](sources_to_parse, counter)
tasks.extend(source_tasks)

if 'params' in data:
for param in data['params']:
Expand Down

0 comments on commit f992b53

Please sign in to comment.