Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated paths in capri_ss cli_analyse #615

Merged
merged 3 commits into from
Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/haddock/clis/cli_analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,31 @@ def get_cluster_ranking(capri_clt_filename, top_cluster):
return cl_ranking


def update_paths(capri_ss_filename, toch="../", toadd="../../"):
"""
Update paths in capri_ss_filename.

Parameters
----------
capri_ss_filename : str or Path
capri ss filename
toch : str
string to be replaced
toadd : str
string to be added
"""
new_lines = []
with open(capri_ss_filename, "r") as rfile:
for ln in rfile:
new_ln = ln.replace(toch, toadd)
new_lines.append(new_ln)

with open(capri_ss_filename, "w") as wfile:
for ln in new_lines:
wfile.write(ln)
return


# Command line interface parser
ap = argparse.ArgumentParser(
prog="haddock3-analyse",
Expand Down Expand Up @@ -395,6 +420,13 @@ def main(run_dir, modules, top_cluster, format, scale, **kwargs):
if directory.exists():
shutil.rmtree(directory)

# substituting the correct paths in the capri_ss files
for directory in good_folder_paths:
ss_file = Path(outdir, directory, "capri_ss.tsv")
if ss_file.exists():
log.info(f"updating paths in {ss_file}")
update_paths(ss_file, "../", "../../")

os.chdir(ori_cwd)
return

Expand Down