- Files supplied.
nmrccssfn.cpp - the example application
nmrsoapfn.cpp - the servr functions used by the application.
nmrsoapfn.h - the servr functions used by the application.
nmrsoapif.h - the gSOAP interface file.
makefile - a linux makefile.
- Set up the soap structure.
soap_init(&g_soap);
soap_init2(&g_soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);
We nned to server to stay alive until the disconnect call.
- Get the command line arguments.
Usual stuff.
for (int p = 2; p < argc; p=p+2){
if (strcmp(argv[p-1], "-p") == 0){
poption = atoi(argv[p]);
}
else if (strcmp(argv[p-1], "-s") == 0){
server = argv[p];
}
more lines
- Set up the parameters.
// Remember this stuff between calls
int xnucleus = NUCLEUSC13; // 1 = C13, 2 = O17, 3=N15, 4=F19, 5=P31, 6=B11 7=Si29
int proton = HBITINC; // HBITCONF = conformer, HBITINC2 = increment3d, HBITINC = Increment 2d
int nconf = 0; // remember the number of conformers for the call to get the conformer spectrum.
int h1solvent = eCDCl3; // see protoninfo.h
int iconf = 0;
There are two proton methods. The usual combinations of options are: just 2d Inc or 2d and 3d Inc and Conformer, ie
int proton = HBITINC // = Increment 2d
int proton = HBITINC + HBITINC2 + HBITCONF; // 2d, 3d Inc and Conformer.
The 2d method is much quicker but not as accurate. The 3d method also calculates the 'best' value.
- Make a call to each function.
These function calls encapsuate the complexities of the server. The only parameters you are likely to need are define by these funtions.
// Connect to the server and login.
// The login function sets up the server address and port.
// The server might be a url: www.nmrpreidction.com
// A servername define locally by a .hosts file
// or an IP address: 192.168.0.22
int istatus = nmrsoapfn_connect(server.c_str(), poption, xnucleus);
istatus = nmrsoapfn_login();
// Repeat these indented functions to predict a number of MOl file.
//
// read a mol file, one line per element.
struct ns__schararray armol;
nmrsoapfn_readMolFile(molefile.c_str(), armol);
// Set up the prediction parameters.
struct ns__sparam params;
// You can predict one x nucleus and proton in a single call.
istatus = nmrsoapfn_setpreditionparams(params, xnucleus, proton, h1solvent);
istatus = nmrsoapfn_predict(molfile.c_str(), params, armol);
// Get the results.
// To get the spectrum need to set the option here.
proton = HBITINC + HBITINC2 + HBITCONF;
istatus = nmrsoapfn_results_full(op, nconf, xnucleus, proton);
iconf = 0; // get the 3d mol file for a particular conformer.
istatus = nmrsoapfn_3dmolfile(op, iconf);
iconf = nconf; // get the averaged conformer spectrum for the conformer method
// The spectrum for a particular conformer would be 0 to n-1.
istatus = nmrsoapfn_conformerspectrum(op, iconf);
iconf = nconf + 100; // get the averaged conformer spectrum for the increment method.
// The spectrum for a particular conformer would be 100 to 100 + n-1.
istatus = nmrsoapfn_conformerspectrum(op, iconf);
// These steps 'nmrsoapfn_predict' to 'nmrsoapfn_conformerspectrum' may repeated.
// logout and disconnect.
istatus = nmrsoapfn_logout();
istatus = nmrsoapfn_disconnect();
- Application styles.
Using the above application it would be very easy to write applications in a number of styles
- A command line application called from a main app. The MOL file and other parameters could be passed n the command line, then the results file read.
- A library function. The 'main' function could be re-written as a function call, passing the MOl filename or content as a paramters and returning the results in a structure.
- A cgi type application, which returned the results in a web page.
- A web service.
If you would like any further help with any of the above, do not hesitate to contact me.