-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b97d71
commit 8706b0e
Showing
4 changed files
with
86 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { predictProton as predictProtonSpectrum } from 'nmr-processing'; | ||
import OCL from 'openchemlib/full'; | ||
|
||
const baseURL = 'https://nmr-prediction.service.zakodium.com'; | ||
|
||
async function predictCarbon(molfile: string): Promise<any> { | ||
const response = await fetch(`${baseURL}/v1/predict/carbon`, { | ||
headers: { | ||
accept: 'application/json', | ||
'content-type': 'application/json', | ||
}, | ||
body: JSON.stringify({ molfile }), | ||
method: 'POST', | ||
}); | ||
return (await response.json()).data; | ||
} | ||
|
||
async function predictProton(molfile: string): Promise<any> { | ||
const molecule = OCL.Molecule.fromMolfile(molfile); | ||
return predictProtonSpectrum(molecule, {}); | ||
} | ||
|
||
export default async function predictSpectrum(molfile: string, options) { | ||
const promises: any = []; | ||
if (options.spectra['1H']) { | ||
const promises1H = predictProton(molfile).then((result) => ({ | ||
nucleus: '1H', | ||
...result, | ||
})); | ||
promises.push(promises1H); | ||
} | ||
|
||
if (options.spectra['13C']) { | ||
const promises13C = predictCarbon(molfile).then((result) => ({ | ||
nucleus: '13C', | ||
...result, | ||
})); | ||
promises.push(promises13C); | ||
} | ||
|
||
return Promise.all(promises); | ||
} |