Blampey Quentin
commited on
Commit
·
f24cbed
1
Parent(s):
09a699b
can run add_files from anywhere
Browse files- add_files.py +6 -7
add_files.py
CHANGED
|
@@ -8,9 +8,10 @@ import pandas as pd
|
|
| 8 |
|
| 9 |
def main(args):
|
| 10 |
path = Path(args.path)
|
|
|
|
| 11 |
|
| 12 |
-
df_all = pd.read_csv("metadata_all.csv", index_col=0)
|
| 13 |
-
df = pd.read_csv("metadata.csv", index_col=0)
|
| 14 |
|
| 15 |
missing_files = np.array(list(set(df_all.index) - set(df.index)))
|
| 16 |
exists = np.array([(path / f"{f}.h5ad").exists() for f in missing_files])
|
|
@@ -20,13 +21,13 @@ def main(args):
|
|
| 20 |
existing_files = missing_files[exists]
|
| 21 |
|
| 22 |
if args.dry_run:
|
| 23 |
-
print(f"Files will be copied inside {
|
| 24 |
else:
|
| 25 |
for name in existing_files:
|
| 26 |
species, tissue = df_all.loc[name, ["species", "tissue"]].values
|
| 27 |
|
| 28 |
src = path / f"{name}.h5ad"
|
| 29 |
-
dst_dir: Path =
|
| 30 |
dst = dst_dir / f"{name}.h5ad"
|
| 31 |
|
| 32 |
dst_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -36,9 +37,7 @@ def main(args):
|
|
| 36 |
|
| 37 |
if not args.dry_run:
|
| 38 |
print(f"Appending {len(existing_files)} files to metadata.csv")
|
| 39 |
-
df_all.loc[existing_files].to_csv(
|
| 40 |
-
Path(__file__).parent / "metadata.csv", mode="a", header=False
|
| 41 |
-
)
|
| 42 |
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
|
|
|
| 8 |
|
| 9 |
def main(args):
|
| 10 |
path = Path(args.path)
|
| 11 |
+
root = Path(__file__).parent
|
| 12 |
|
| 13 |
+
df_all = pd.read_csv(root / "metadata_all.csv", index_col=0)
|
| 14 |
+
df = pd.read_csv(root / "metadata.csv", index_col=0)
|
| 15 |
|
| 16 |
missing_files = np.array(list(set(df_all.index) - set(df.index)))
|
| 17 |
exists = np.array([(path / f"{f}.h5ad").exists() for f in missing_files])
|
|
|
|
| 21 |
existing_files = missing_files[exists]
|
| 22 |
|
| 23 |
if args.dry_run:
|
| 24 |
+
print(f"Files will be copied inside {root}/<species>/<tissue>")
|
| 25 |
else:
|
| 26 |
for name in existing_files:
|
| 27 |
species, tissue = df_all.loc[name, ["species", "tissue"]].values
|
| 28 |
|
| 29 |
src = path / f"{name}.h5ad"
|
| 30 |
+
dst_dir: Path = root / species / tissue
|
| 31 |
dst = dst_dir / f"{name}.h5ad"
|
| 32 |
|
| 33 |
dst_dir.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 37 |
|
| 38 |
if not args.dry_run:
|
| 39 |
print(f"Appending {len(existing_files)} files to metadata.csv")
|
| 40 |
+
df_all.loc[existing_files].to_csv(root / "metadata.csv", mode="a", header=False)
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|