Skip to content

Commit

Permalink
feat: database can have ocl property that will be used index if ava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
lpatiny committed Jul 3, 2022
1 parent 8c84764 commit 9afad9b
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/data/data1d/database.ts
Expand Up @@ -87,9 +87,44 @@ function prepareGetSolvents(data) {
function prepareMoleculesDB(array: Array<DatabaseNMREntry>) {
let moleculesDB = new MoleculesDB(OCL);
for (let entry of array) {
if (entry.smiles) {
const molecule = OCL.Molecule.fromSmiles(entry.smiles);
moleculesDB.pushEntry(molecule, entry);
//@ts-expect-error property will be defined in next release of nmr-processing
if (entry.ocl) {
try {
const molecule = OCL.Molecule.fromIDCode(
//@ts-expect-error property will be defined in next release of nmr-processing
entry.ocl.idCode,
//@ts-expect-error property will be defined in next release of nmr-processing
entry.ocl.coordinates,
);
moleculesDB.pushEntry(
molecule,
entry,
{},
{
//@ts-expect-error property will be defined in next release of nmr-processing
idCode: entry.ocl.idCode,
//@ts-expect-error property will be defined in next release of nmr-processing
index: entry.ocl.index,
},
);
} catch (e) {
// eslint-disable-next-line no-console
console.log(
`Could not parse idCode: ${JSON.stringify(
//@ts-expect-error property will be defined in next release of nmr-processing
entry.ocl,
)}`,
e,
);
}
} else if (entry.smiles) {
try {
const molecule = OCL.Molecule.fromSmiles(entry.smiles);
moleculesDB.pushEntry(molecule, entry);
} catch (e) {
// eslint-disable-next-line no-console
console.log(`Could not parse smiles: ${entry.smiles}`, e);
}
}
}
return moleculesDB;
Expand Down

0 comments on commit 9afad9b

Please sign in to comment.