ChAFF / CHAFF_processing_scripts /st3_extract_active_compounds.py
haneulpark's picture
Upload 5 files
e623e49 verified
raw
history blame
619 Bytes
import os
import pandas as pd
import glob
file_path = "./raw/*.csv"
# Extract active compounds from the datasets
for file in glob.glob(file_path):
name = os.path.splitext(os.path.basename(file))[0]
output_path = f"./active/{name}_active.csv"
if os.path.exists(output_path):
print(f"Skipping {name}, already exists.")
continue
raw_df = pd.read_csv(file)
active_df = raw_df[raw_df['AssayOutcome'] == 'Active']
# Save new CSV file
active_df.to_csv(output_path, index=False)
print(f"Saved {len(active_df)} active compounds out of {len(raw_df)} to {output_path}")