Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify type definition in headers.ts #38

Merged
merged 10 commits into from
Sep 3, 2021
20 changes: 10 additions & 10 deletions src/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const ATOM_EL_LEN = 6; // length of ASCIIZ element symbol field
export const NUM_H_ISOTOPES = 3; // number of hydrogen isotopes: protium, D, T
export const ISOTOPIC_SHIFT_FLAG = 10000; // add to isotopic mass if isotopic_mass = (isotopic mass - average atomic mass) /* (isotopic mass - average atomic mass) */
export const ISOTOPIC_SHIFT_MAX = 100; // max abs(isotopic mass - average atomic mass)

export const MAX_ARRAY_SIZE = 999; // to create array with huge size
export type MAXVALTuple = [
number,
number,
Expand Down Expand Up @@ -592,8 +592,8 @@ export interface INCHIStereo0D {
// }inchi_Input;

export const inchi_Input = NAPIStructType({
atom: NAPIArrayType(inchi_Atom, 999),
stereo0D: NAPIArrayType(inchi_Stereo0D, 999),
atom: NAPIArrayType(inchi_Atom, MAX_ARRAY_SIZE),
stereo0D: NAPIArrayType(inchi_Stereo0D, MAX_ARRAY_SIZE),
szOptions: refNAPI.types.CString,
num_atoms: refNAPI.types.short,
num_stereo0D: refNAPI.types.short,
Expand Down Expand Up @@ -728,7 +728,7 @@ export interface INCHIInputPolymerUnit {
// } inchi_Input_Polymer;

export const inchi_Input_Polymer = NAPIStructType({
units: NAPIArrayType(refNAPI.refType(inchi_Input_PolymerUnit), 999),
units: NAPIArrayType(refNAPI.refType(inchi_Input_PolymerUnit), MAX_ARRAY_SIZE),
n: refNAPI.types.int,
});
export interface INCHIInputPolymer {
Expand Down Expand Up @@ -788,13 +788,13 @@ export const inchi_Input_V3000 = NAPIStructType({
n_collections: refNAPI.types.int,
n_non_haptic_bonds: refNAPI.types.int,
n_haptic_bonds: refNAPI.types.int,
lists_haptic_bonds: NAPIArrayType(refNAPI.types.int, 999),
lists_haptic_bonds: NAPIArrayType(refNAPI.types.int, MAX_ARRAY_SIZE),
n_steabs: refNAPI.types.int,
lists_steabs: NAPIArrayType(NAPIArrayType(refNAPI.types.int, 999), 999),
lists_steabs: NAPIArrayType(NAPIArrayType(refNAPI.types.int, MAX_ARRAY_SIZE), MAX_ARRAY_SIZE),
n_sterel: refNAPI.types.int,
lists_sterel: NAPIArrayType(NAPIArrayType(refNAPI.types.int, 999), 999),
lists_sterel: NAPIArrayType(NAPIArrayType(refNAPI.types.int, MAX_ARRAY_SIZE), MAX_ARRAY_SIZE),
n_sterac: refNAPI.types.int,
lists_sterac: NAPIArrayType(NAPIArrayType(refNAPI.types.int, 999), 999),
lists_sterac: NAPIArrayType(NAPIArrayType(refNAPI.types.int, MAX_ARRAY_SIZE), MAX_ARRAY_SIZE),
});
export interface INCHIInputV3000 {
nNonStartAtoms: number;
Expand Down Expand Up @@ -870,8 +870,8 @@ export interface INCHIInputV3000 {
// } inchi_InputEx;

export const inchi_InputEx = NAPIStructType({
atom: NAPIArrayType(inchi_Atom, 999),
Stereo0D: NAPIArrayType(inchi_Stereo0D, 999),
atom: NAPIArrayType(inchi_Atom, MAX_ARRAY_SIZE),
stereo0D: NAPIArrayType(inchi_Stereo0D, MAX_ARRAY_SIZE),
szOptions: refNAPI.types.CString,
num_atoms: refNAPI.types.short,
num_stereo0D: refNAPI.types.short,
Expand Down
18 changes: 3 additions & 15 deletions tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ describe("test api wrapped ffis functions", () => {
test("Check if GetStructFromINCHI method is working properly", () => {
const {
status,
data: {
atom,
szMessage,
szLog,
},
data: { atom, szMessage, szLog },
} = GetStructFromINCHI("InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3");
expect(status).toBe(0);
expect(atom.length).toBe(0);
Expand All @@ -38,11 +34,7 @@ describe("test api wrapped ffis functions", () => {
test("Check if GetStructFromINCHIEx method is working properly", () => {
const {
status,
data: {
atom,
szMessage,
szLog,
},
data: { atom, szMessage, szLog },
} = GetStructFromINCHIEx("InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3");
expect(status).toBe(0);
expect(atom.length).toBe(0);
Expand All @@ -53,11 +45,7 @@ describe("test api wrapped ffis functions", () => {
test("Check if GetStructFromStdINCHI method is working properly", () => {
const {
status,
data: {
atom,
szMessage,
szLog,
},
data: { atom, szMessage, szLog },
} = GetStructFromStdINCHI("InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3");
expect(status).toBe(0);
expect(atom.length).toBe(0);
Expand Down
58 changes: 30 additions & 28 deletions tests/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,30 @@ describe("test inchi headers", () => {
* Instantiate inchi_Input
*/
const inchiInput = new inchi_Input({
atom: [new inchi_Atom({
x: 1.1,
y: 2.2,
z: 3.3,
neighbor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
bond_type: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
bond_stereo: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
elname: [1, 2, 3, 4, 5, 6],
num_bonds: 3,
num_iso_H: [1, 2, 3, 4],
isotopic_mass: 10,
radical: 2,
charge: -2,
})],
stereo0D: [new inchi_Stereo0D({
neighbor: [1, 2, 3, 4],
central_atom: 1,
type: 1,
parity: 1,
})],
atom: [
new inchi_Atom({
x: 1.1,
y: 2.2,
z: 3.3,
neighbor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
bond_type: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
bond_stereo: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],
elname: [1, 2, 3, 4, 5, 6],
num_bonds: 3,
num_iso_H: [1, 2, 3, 4],
isotopic_mass: 10,
radical: 2,
charge: -2,
}),
],
stereo0D: [
new inchi_Stereo0D({
neighbor: [1, 2, 3, 4],
central_atom: 1,
type: 1,
parity: 1,
}),
],
szOptions: "some-string",
num_atoms: 32767,
num_stereo0D: -32768,
Expand Down Expand Up @@ -217,15 +221,15 @@ describe("test inchi headers", () => {
*/
const inchiInputEx = new inchi_InputEx({
atom: [new inchi_Atom()],
Stereo0D: [new inchi_Stereo0D()],
stereo0D: [new inchi_Stereo0D()],
szOptions: "some-string",
num_atoms: 11,
num_stereo0D: 13,
polymer: new inchi_Input_Polymer().ref(),
v3000: new inchi_Input_V3000().ref(),
});
expect(inchiInputEx.atom[0].x).toBe(0);
expect(inchiInputEx.Stereo0D[0].parity).toBe(0);
expect(inchiInputEx.stereo0D[0].parity).toBe(0);
expect(inchiInputEx.szOptions).toBe("some-string");
expect(inchiInputEx.num_atoms).toBe(11);
expect(inchiInputEx.num_stereo0D).toBe(13);
Expand Down Expand Up @@ -267,7 +271,7 @@ describe("test inchi headers", () => {
*/
const inchiOutputStruct = new inchi_OutputStruct({
atom: [new inchi_Atom()],
Stereo0D: [new inchi_Stereo0D()],
stereo0D: [new inchi_Stereo0D()],
num_atoms: 1,
num_stereo0D: 2,
szMessage: "some-string",
Expand All @@ -278,8 +282,7 @@ describe("test inchi headers", () => {
],
});
expect(inchiOutputStruct.atom[0].x).toBe(0);
// compiler doesn't seem to read the value of inchiOutputStruct.Stereo0D
expect(inchiOutputStruct.Stereo0D[0].parity).toBe(0);
expect(inchiOutputStruct.stereo0D[0].parity).toBe(0);
expect(inchiOutputStruct.num_atoms).toBe(1);
expect(inchiOutputStruct.num_stereo0D).toBe(2);
expect(inchiOutputStruct.szMessage).toBe("some-string");
Expand All @@ -293,7 +296,7 @@ describe("test inchi headers", () => {
*/
const inchiOutputStructEx = new inchi_OutputStructEx({
atom: [new inchi_Atom()],
Stereo0D: [new inchi_Stereo0D()],
stereo0D: [new inchi_Stereo0D()],
num_atoms: 1,
num_stereo0D: 2,
szMessage: "some-string",
Expand All @@ -306,8 +309,7 @@ describe("test inchi headers", () => {
v3000: new inchi_Input_V3000().ref(),
});
expect(inchiOutputStructEx.atom[0].x).toBe(0);
// compiler doesn't seem to read the value of inchiOutputStruct.Stereo0D
expect(inchiOutputStructEx.Stereo0D[0].parity).toBe(0);
expect(inchiOutputStructEx.stereo0D[0].parity).toBe(0);
expect(inchiOutputStructEx.num_atoms).toBe(1);
expect(inchiOutputStructEx.num_stereo0D).toBe(2);
expect(inchiOutputStructEx.szMessage).toBe("some-string");
Expand Down