MASSA-Algorithm 2.2.0__py3-none-any.whl → 2.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,8 +27,8 @@ def name_extraction(file):
27
27
  else:
28
28
  duplicates[name] = [[idx, mol]]
29
29
 
30
- final_names = []
31
30
  final_names_dict = {}
31
+ idx_names = {}
32
32
  for k, v in duplicates.items():
33
33
  name = k
34
34
  replicates = v
@@ -39,7 +39,7 @@ def name_extraction(file):
39
39
  final_key = f"{name}_idx-_{index}"
40
40
  molecule.SetProp("_Name", final_key)
41
41
  final_names_dict[final_key] = molecule
42
- final_names.append(final_key)
42
+ idx_names[index] = final_key
43
43
  else:
44
44
  for r in replicates:
45
45
  index = r[0]
@@ -47,8 +47,15 @@ def name_extraction(file):
47
47
  final_key = name
48
48
  molecule.SetProp("_Name", final_key)
49
49
  final_names_dict[final_key] = molecule
50
- final_names.append(final_key)
51
- dataframe = pd.DataFrame({'molecules': pd.Series(final_names_dict)})
50
+ idx_names[index] = final_key
51
+ f_names = [None] * (max(idx_names) + 1)
52
+ for i_idx, i_name in idx_names.items():
53
+ f_names[i_idx] = i_name
54
+ final_names = f_names
55
+ dataframe = pd.DataFrame(
56
+ {'molecules': [final_names_dict[name] for name in final_names]},
57
+ index=final_names
58
+ )
52
59
  return final_names, dataframe
53
60
 
54
61
 
@@ -20,7 +20,7 @@ def initial_print():
20
20
  ██░░░▓▓▓▓░░░░░░░▓▓▓▓░░░░░░░▓▓▓▓░░░░█
21
21
  ██░░░░▓▓▓▓▓▓░░░░░▓▓▓▓▓▓░░░░░▓▓▓▓▓▓░░░░█ MASSA Algorithm:
22
22
  ████░░░░░▓▓▓▓░░░░░░░▓▓▓▓░░░░░░░▓▓▓▓░░░░░█████ Molecular data set sampling — Training-Test Separation
23
- █▓▓▓███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███▓▓▓█ Version: v. 2.2.0
23
+ █▓▓▓███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███▓▓▓█ Version: v. 2.2.2
24
24
  █▒▓▓▒▒▒████░░░░░░░░░░░░░░░░░░░░░░░░░░░░████▒▒▓▓▒█
25
25
  ██▓▒▒▒▓▓▓▓██████████████████████████████▓▓▓▒▒▒▒▓█ Developed by: Gabriel Corrêa Veríssimo
26
26
  ██▒▒▒▓▓▒▒▒▒▓▓▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▒▒▒▒▓▓▒▒▒▓▓▒▒██ LICENSE: AGPL-3.0
@@ -143,6 +143,30 @@ def read_CSV_smiles(file, write_log, drop_errors):
143
143
  return mols_sanitized
144
144
 
145
145
 
146
+ def read_SMI_smiles(file, write_log, drop_errors):
147
+ # Not designed for MASSA execution.
148
+ # It will not read the "Activity" column if the .smi file doesn't have headers.
149
+ first_row = pd.read_csv(file, sep="\t", nrows=1, header=None)
150
+ first_value = str(first_row.iloc[0, 0])
151
+ has_header = AllChem.MolFromSmiles(first_value) is None
152
+
153
+ if has_header:
154
+ df = pd.read_csv(file, sep="\t", header=0)
155
+ else:
156
+ df = pd.read_csv(file, sep="\t", header=None)
157
+ df = df.iloc[:, :2] # Keep only the first two columns
158
+ df.columns = ["SMILES", "Name"]
159
+
160
+ mols_sanitized = read_df_smiles(df, write_log, drop_errors)
161
+ return mols_sanitized
162
+
163
+ def read_SMI_smiles(file, write_log, drop_errors):
164
+ df_supplier = pd.read_csv(file, sep="\t", header=None)
165
+ df_supplier.columns = ["SMILES", "Name"]
166
+ mols_sanitized = read_df_smiles(df_supplier, write_log, drop_errors)
167
+ return mols_sanitized
168
+
169
+
146
170
  def read_SDF(file, write_log, drop_errors):
147
171
  """Reads an SDF file and returns a sanitized molecule supplier.
148
172
 
@@ -283,6 +307,8 @@ def read_molecules(file, write_log, drop_errors):
283
307
  molecules = read_EXCEL_smiles(file, write_log, drop_errors)
284
308
  elif file.endswith(".csv"):
285
309
  molecules = read_CSV_smiles(file, write_log, drop_errors)
310
+ elif file.endswith(".smi"):
311
+ molecules = read_SMI_smiles(file, write_log, drop_errors)
286
312
  return molecules
287
313
 
288
314