Skip to content

Commit

Permalink
fix: data type and column name
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoSilvestr committed Mar 20, 2023
1 parent 748fe75 commit 44fc325
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docker/src/MoleculeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export type MoleculeInfo = {
rotatableBondCount: number;
polarSurfaceArea: number;
unsaturation: number;
atom: string;
atoms: string;
};
2 changes: 1 addition & 1 deletion docker/src/calculate/calculateMoleculeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function calculateMoleculeInfo(

const mfInfo = new MF(mf).getInfo();
info.unsaturation = mfInfo.unsaturation;
info.atom = mfInfo.atoms;
info.atoms = mfInfo.atoms;
info.mf = mfInfo.mf;
info.mw = mfInfo.mass;
info.em = mfInfo.monoisotopicMass;
Expand Down
2 changes: 1 addition & 1 deletion docker/src/db/getDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CREATE TABLE IF NOT EXISTS molecules (
logS data_type REAL,
nbFragments data_type INT,
unsaturation data_type INT,
atom data_type OBJECT,
atoms data_type TEXT,
logP data_type REAL,
acceptorCount data_type INT,
donorCount data_type INT,
Expand Down
2 changes: 1 addition & 1 deletion docker/src/db/insertInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let stmt: Statement;
export function insertInfo(info: InternalMoleculeInfo, db: Database) {
if (!stmt) {
stmt = db.prepare(
'INSERT INTO molecules VALUES (@idCode, @mf, @em, @mw, @charge, @noStereoID, @noStereoTautomerID, @logS, @logP, @acceptorCount, @donorCount, @rotatableBondCount, @stereoCenterCount, @polarSurfaceArea, @ssIndex, @nbFragments , @unsaturation, @atom)',
'INSERT INTO molecules VALUES (@idCode, @mf, @em, @mw, @charge, @noStereoID, @noStereoTautomerID, @logS, @logP, @acceptorCount, @donorCount, @rotatableBondCount, @stereoCenterCount, @polarSurfaceArea, @ssIndex, @nbFragments , @unsaturation, @atoms)',
);
}
try {
Expand Down
9 changes: 5 additions & 4 deletions docker/src/db/insertMolecule.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Database, Statement } from 'better-sqlite3';

import { InternalMoleculeInfo } from '../InternalMoleculeInfo';
import calculateMoleculeInfoFromIDCodePromise from '../calculate/calculateMoleculeInfoFromIDCodePromise';

let stmt: Statement;

export async function insertMolecule(
Expand All @@ -11,12 +9,15 @@ export async function insertMolecule(
): Promise<InternalMoleculeInfo> {
if (!stmt) {
stmt = db.prepare(
'INSERT INTO molecules VALUES (@idCode, @mf, @em, @mw, @charge, @noStereoID, @noStereoTautomerID, @logS, @logP, @acceptorCount, @donorCount, @rotatableBondCount, @stereoCenterCount, @polarSurfaceArea, @ssIndex, @nbFragments, @unsaturation, @atom)',
'INSERT INTO molecules VALUES (@idCode, @mf, @em, @mw, @charge, @noStereoID, @noStereoTautomerID, @logS, @logP, @acceptorCount, @donorCount, @rotatableBondCount, @stereoCenterCount, @polarSurfaceArea, @ssIndex, @nbFragments, @unsaturation, @atoms)',
);
}

const { promise } = await calculateMoleculeInfoFromIDCodePromise(molecule);
const info = await promise;
// convert Uint8Array(64) to number[] to be able to store it in sqlite
info.ssIndex = Buffer.from(info.ssIndex);
info.atoms = JSON.stringify(info.atoms);

stmt.run(info);
return info;
}

0 comments on commit 44fc325

Please sign in to comment.