Skip to content

Commit

Permalink
chore: apply string formatting for project columns
Browse files Browse the repository at this point in the history
  • Loading branch information
matinnuhamunada committed Apr 17, 2024
1 parent 90b6d33 commit fe13583
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion workflow/BGC
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ def extract_bgc_project_information(config, project_variable="projects", sample_
print(f" - Processing project {pep_file}", file=sys.stderr)
p = peppy.Project(pep_file, sample_table_index=sample_table_index)


# make sure each project has unique names
assert (
not p.name in df_projects["name"].unique()
), f"Project name [{p.name}] in [{pep_file}] has been used. Please use different name for each project."

# assign column types as string
for col in ["name", "samples", "rules"]:
if not col in df_projects.columns:
df_projects[col] = pd.Series(dtype=str)
else:
df_projects[col] = df_projects[col].astype(str)

# add values
df_projects.loc[p.name, "name"] = p.name
df_projects.loc[p.name, "samples"] = p.config_file
df_projects.loc[p.name, "rules"] = p.config_file
Expand Down
8 changes: 8 additions & 0 deletions workflow/rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,14 @@ def extract_project_information(config, project_variable="projects"):
not p.name in df_projects["name"].unique()
), f"Project name [{p.name}] in [{pep_file}] has been used. Please use different name for each project."

# assign column types as string
for col in ["name", "samples", "rules"]:
if not col in df_projects.columns:
df_projects[col] = pd.Series(dtype=str)
else:
df_projects[col] = df_projects[col].astype(str)

# add values
df_projects.loc[p.name, "name"] = p.name
df_projects.loc[p.name, "samples"] = p.config_file
df_projects.loc[p.name, "rules"] = p.config_file
Expand Down

0 comments on commit fe13583

Please sign in to comment.