Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ms2query/create_new_library/calculate_tanimoto_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@


def get_fingerprint(smiles: str):
fingerprint = np.array(Chem.RDKFingerprint(Chem.MolFromSmiles(smiles), fpSize=2048))
try:
fingerprint = np.array(Chem.RDKFingerprint(Chem.MolFromSmiles(smiles), fpSize=2048))
except:
# TODO: this is to avoid workflows breaking because of an incorrect smiles. Should be handled better.
fingerprint = np.zeros(2048)
assert isinstance(fingerprint, np.ndarray), \
f"Fingerprint for 1 spectrum could not be set smiles is {smiles}"
return fingerprint
Expand Down
6 changes: 3 additions & 3 deletions ms2query/create_new_library/train_ms2deepscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def train_ms2ds_model(training_spectra,
reference_scores_df=tanimoto_df,
dim=len(spectrum_binner.known_bins), # The number of bins created
same_prob_bins=same_prob_bins,
num_turns=2,
num_turns=1,
augment_noise_max=10,
augment_noise_intensity=0.01)

Expand All @@ -58,9 +58,9 @@ def train_ms2ds_model(training_spectra,
augment_removal_max=0, augment_removal_intensity=0, augment_intensity=0, augment_noise_max=0, use_fixed_set=True
)

model = SiameseModel(spectrum_binner, base_dims=(500, 500), embedding_dim=200, dropout_rate=0.2)
model = SiameseModel(spectrum_binner, base_dims=(1000, 1000, 1000), embedding_dim=500, dropout_rate=0.2)

model.compile(loss='mse', optimizer=Adam(lr=0.001), metrics=["mae", tf.keras.metrics.RootMeanSquaredError()])
model.compile(loss='mse', optimizer=Adam(lr=0.0005), metrics=["mae", tf.keras.metrics.RootMeanSquaredError()])

# Save best model and include early stopping
checkpointer = ModelCheckpoint(filepath=output_model_file_name, monitor='val_loss', mode="min", verbose=1, save_best_only=True)
Expand Down