File size: 619 Bytes
e623e49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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}")