Skip to content

Commit

Permalink
Chore: workound for issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoSilvestr committed Mar 20, 2023
1 parent e97b6e8 commit b9f04bb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions docker/src/calculate/calculateMoleculeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,26 @@ export default function calculateMoleculeInfo(
const { ignoreTautomer = false } = options;

const mf = getMF(molecule).parts.sort().join('.');

const mfInfo = new MF(mf).getInfo();
info.unsaturation = mfInfo.unsaturation;
info.atoms = mfInfo.atoms;

info.mf = mfInfo.mf;
info.mw = mfInfo.mass;
info.em = mfInfo.monoisotopicMass;
info.charge = mfInfo.charge;

// This is a workaround for the fact that we didn't consider structures with more than 1 fragment
if (mfInfo.parts?.length > 0) {
let atoms = [];
let unsaturation = [];
for (let part of mfInfo.parts) {
atoms.push(part.atoms);
unsaturation.push(part.unsaturation);
}
info.atoms = JSON.stringify(atoms);
info.unsaturation = Math.max(...unsaturation);
} else {
info.atoms = mfInfo.atoms;
info.unsaturation = mfInfo.unsaturation;
}
info.idCode = molecule.getIDCode();
info.noStereoID = getNoStereoIDCode(molecule);

Expand Down

0 comments on commit b9f04bb

Please sign in to comment.