-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.py
More file actions
24 lines (18 loc) · 869 Bytes
/
script2.py
File metadata and controls
24 lines (18 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import csv
# Define the CSV file path
csv_file = "CID_IC50_Complete_Data_DS.csv" # Replace with the path to your CSV file
# Create an empty list to store SMILES strings and IC50 values
smiles_ic50_list = []
# Read the CSV file and extract the SMILES and IC50 values
with open(csv_file, "r") as file:
reader = csv.reader(file)
next(reader) # Skip the header row
for row in reader:
cid = int(row[0]) # Assuming the CID is in the first column
smiles = row[2] # Assuming the SMILES is in the third column
ic50 = float(row[1]) # Assuming the IC50 value is in the second column
smiles_ic50_list.append((smiles, ic50))
# Save the SMILES and IC50 values to a "smiles_ic50.dat" file
with open("smiles_ic50.dat", "w") as file:
for smiles, ic50 in smiles_ic50_list:
file.write(f"{smiles},{ic50}\n")