Skip to content
Snippets Groups Projects
Commit e7c45862 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Update structure command to use all_statistics file

parent bde570e1
No related branches found
No related tags found
1 merge request!158pae as image
Pipeline #118831 passed
......@@ -2,6 +2,8 @@ import typer
import sys
import re
import shutil
import csv
import yaml
from typing_extensions import Annotated
from typing import Optional, List
from pathlib import Path
......@@ -78,13 +80,35 @@ def lint(
@app.command()
def structure(
stat: Annotated[
Path,
typer.Option(
exists=True,
file_okay=True,
dir_okay=True,
writable=False,
readable=True,
resolve_path=True,
),
],
map: Annotated[
Path,
typer.Option(
exists=True,
file_okay=True,
dir_okay=True,
writable=False,
readable=True,
resolve_path=True,
),
],
dir: Annotated[
Path,
typer.Option(
exists=True,
file_okay=False,
dir_okay=True,
writable=False,
writable=True,
readable=True,
resolve_path=True,
),
......@@ -101,13 +125,30 @@ def structure(
),
],
):
console.rule(f"[bold blue]{dir.name}", style="blue")
for f in dir.iterdir():
console.print(f"[green] {f.name}")
# get the system name
system = re.split("_|\.|-0", f.name)[0].lower()
console.print(system)
systemDir = output / system
systemDir.mkdir(parents=True, exist_ok=True)
shutil.copy2(f, systemDir)
with open(map, "r") as map_f:
system_to_dir = yaml.safe_load(map_f)
with open(stat, "r") as stat_f:
reader = csv.DictReader(stat_f)
for row in reader:
dir_name = system_to_dir[row["system"]]
# console.rule(f"[bold blue]{dir_name}", style="blue")
files = [
{"f": Path(row["pdb"]), "d": "PDB"},
{"f": Path(row["pae_table"]), "d": "PAE"},
{"f": Path(row["fasta_file"]), "d": "Fastas"},
{"f": Path(row["Foldseek_name"]), "d": "foldseek_monomers_html"},
]
target_dir = output / dir_name
target_dir.mkdir(parents=True, exist_ok=True)
for f in files:
str_f = str(f["f"])
if str_f and str_f != "." and str_f != "" and str_f != "na":
# console.print("--" + str(f["f"]) + "--")
# console.print(f"[green] copy {f['f'].name} to {target_dir}")
file_to_copy = dir / f["d"] / f["f"]
if file_to_copy.exists():
shutil.copy2(file_to_copy, target_dir)
else:
console.print(f"[red] file {str(file_to_copy.name)} does not exist")
[tool.poetry]
name = "df-wiki-cli"
version = "0.1.2"
version = "0.1.3"
description = ""
authors = ["Remi PLANEL <rplanel@pasteur.fr>"]
readme = "README.md"
......
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