Datasets:
Update MutagenLou2023 Preprocessing.py
Browse files
MutagenLou2023 Preprocessing.py
CHANGED
@@ -76,7 +76,7 @@ from rdkit import DataStructs
|
|
76 |
from rdkit.Chem import AllChem as Chem
|
77 |
from rdkit.Chem import PandasTools
|
78 |
|
79 |
-
#7. Split the dataset into
|
80 |
|
81 |
class MolecularFingerprint:
|
82 |
def __init__(self, fingerprint):
|
@@ -143,7 +143,7 @@ def butina_cluster(fingerprints, num_points, distance_threshold, reordering=Fals
|
|
143 |
|
144 |
def hierarchal_cluster(fingerprints):
|
145 |
|
146 |
-
|
147 |
|
148 |
av_cluster_size = 8
|
149 |
dists = []
|
@@ -178,11 +178,9 @@ def cluster_fingerprints(fingerprints, method="Auto"):
|
|
178 |
print("Butina clustering is selected. Dataset size is:", num_fingerprints)
|
179 |
clusters = butina_cluster(fingerprints, num_fingerprints, cutoff)
|
180 |
|
181 |
-
return clusters
|
182 |
-
|
183 |
elif method == "Hierarchy":
|
184 |
print("Hierarchical clustering is selected. Dataset size is:", num_fingerprints)
|
185 |
-
clusters = hierarchal_cluster(fingerprints
|
186 |
|
187 |
return clusters
|
188 |
|
@@ -261,8 +259,8 @@ def split_df_into_train_and_test_sets(df):
|
|
261 |
|
262 |
# 8. Test and train datasets have been made
|
263 |
|
264 |
-
smiles_index = 0
|
265 |
-
realistic = realistic_split(
|
266 |
realistic_train, realistic_test = split_df_into_train_and_test_sets(realistic)
|
267 |
|
268 |
#9. Select columns and name the datasets
|
|
|
76 |
from rdkit.Chem import AllChem as Chem
|
77 |
from rdkit.Chem import PandasTools
|
78 |
|
79 |
+
# 7. Split the dataset into train and test
|
80 |
|
81 |
class MolecularFingerprint:
|
82 |
def __init__(self, fingerprint):
|
|
|
143 |
|
144 |
def hierarchal_cluster(fingerprints):
|
145 |
|
146 |
+
num_fingerprints = len(fingerprints)
|
147 |
|
148 |
av_cluster_size = 8
|
149 |
dists = []
|
|
|
178 |
print("Butina clustering is selected. Dataset size is:", num_fingerprints)
|
179 |
clusters = butina_cluster(fingerprints, num_fingerprints, cutoff)
|
180 |
|
|
|
|
|
181 |
elif method == "Hierarchy":
|
182 |
print("Hierarchical clustering is selected. Dataset size is:", num_fingerprints)
|
183 |
+
clusters = hierarchal_cluster(fingerprints)
|
184 |
|
185 |
return clusters
|
186 |
|
|
|
259 |
|
260 |
# 8. Test and train datasets have been made
|
261 |
|
262 |
+
smiles_index = 0 # Because smiles is in the first column
|
263 |
+
realistic = realistic_split(newLou2023.copy(), smiles_index, 0.8, split_for_exact_frac=True, cluster_method="Auto")
|
264 |
realistic_train, realistic_test = split_df_into_train_and_test_sets(realistic)
|
265 |
|
266 |
#9. Select columns and name the datasets
|