00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdlib.h>
00014 #include <stdio.h>
00015 #include <time.h>
00016
00017
00018
00019 #ifndef __MSD_USER_H__
00020 #include "msd_user.h"
00021 #endif
00022
00023
00024 int main(int argc, char* argv[]) {
00025 double difs;
00026 double dd;
00027 time_t starts;
00028 time_t ends;
00029
00030 clock_t time_start;
00031 clock_t time_end;
00032
00033
00034 int cr=1;
00035 int i=1;
00036 void* vcr=&cr;
00037 int iparam=0;
00038 double dparam=0;
00039 char sparam[16]="";
00040 int fparam=0;
00041 int xargc;
00042 int row;
00043 char** xargv;
00044 const char* un="api1";
00045 const char* pass="api155";
00046 const char* host="msdsrchd";
00047
00048
00049 char* sql;
00050 char* strval;
00051 char* strval2;
00052 MSDEnv msd;
00053 float f;
00054
00055 char* statement="SELECT "
00056 "a.chem_comp_code, a.Orig_x, a.Orig_y, a.Orig_z, "
00057 "a.residue_id, a.residue_pdb_seq, a.residue_pdb_insert_code, a.chain_id, "
00058 "a.chain_code, a.Non_Assembly_Valid "
00059 "FROM atom_data a "
00060 "WHERE a.assembly_id = 43472 "
00061 "AND a.entry_id = :f<int> ";
00062
00063
00064
00065
00066 char* loginstr=(char*)malloc(129);
00067
00068
00069 time_start=clock();
00070
00071
00072
00073
00074 sprintf(loginstr, "%s/%s@%s",un, pass, host);
00075
00076 xargc=argc;
00077 xargv=argv;
00078
00079 argc--;
00080 argv++;
00081
00082
00083 while (argc > 0 && (*argv[0] == '-')){
00084
00085 if (strncmp (*argv,"-i",2) == 0) {
00086
00087 argv++;
00088 argc--;
00089 iparam = atoi(*argv);
00090 }
00091 else if (strncmp (*argv,"-d",2) == 0) {
00092
00093 argv++;
00094 argc--;
00095 dparam = atof(*argv);
00096 }
00097 else if (strncmp (*argv,"-f",2) == 0) {
00098
00099 fparam = 1;}
00100
00101 else if (strncmp (*argv,"-s",2) == 0) {
00102
00103 argv++;
00104 argc--;
00105 strcpy(sparam,*argv);
00106 }
00107
00108 else {
00109 printf ("\nUnknown switch: %s", *argv);}
00110
00111
00112 argv++;
00113 argc--;
00114 }
00115
00116 printf ("\nInteger parameter = %d", iparam );
00117 printf ("\nDouble parameter = %f " , dparam );
00118 printf ("\nString parameter = %s ", sparam );
00119 printf ("\nFlag parameter = %d ", fparam );
00120
00121 printf ("\nRemaining arguments =\n");
00122
00123 while (argc > 0){
00124 printf (*argv);
00125 printf ("\n");
00126 argv++;
00127 argc--;
00128 }
00129
00130
00131 starts = time (NULL);
00132 msd_lisp_init(xargc, xargv);
00133 msd_lisp_load("xlisp.lsp");
00134 printf ("Process starts...\n");
00135
00136
00137
00138 if (msd_init(&msd)==0)
00139 {
00140 printf ("\nConnection to the PDBe initialized.\n");
00141 }
00142
00143
00144 if (msd_attach(&msd,host)==0)
00145 {
00146 printf ("\nAttached to 'msdsrch1' server successfully.\n");
00147 }
00148 if (msd_begin(&msd,un,pass)==0)
00149 {
00150 printf ("\nLogin to 'msdsrch1' successfully.\n");
00151 }
00152
00153 sql = (char*)malloc(strlen(statement)+1);
00154 strcpy(sql, statement);
00155 msd_sqlinit(&msd, sql);
00156 msd_setcriteria(&msd,"i",38175);
00157
00158
00159
00160 row = msd_getrownum(&msd);
00161 while (row<26612)
00162 { row = msd_getrownum(&msd);
00163 msd_getnext(&msd);
00164 if (row % 1000 == 0){
00165 MSDGetValue (msd,1,f,vfloat);
00166 printf ("\nFloat value = %.4lf ", f );
00167
00168 MSDGetValue (msd,0,strval,vstr);
00169
00170 printf ("\nString value = %s ", strval );
00171
00172 f = msd_ugetfloat(&msd,1);
00173 printf ("\nSecond float value = %.4lf ", f );
00174 printf ("\nString value = %s ",msd_ugetstr(&msd,0,strval2));
00175
00176 }
00177 }
00178
00179
00180
00181 msd_manager(&msd);
00182 msd_get_object_entry(&msd,38175);
00183 printf ("\nNumber of atoms: %d.\n", msd_get_number_of_atoms(&msd));
00184
00185 printf ("\nEntry ID for: %i.\n", msd_get_entry_id(&msd, "1gw5"));
00186 printf ("\nACCESSION CODE for: %s.\n", msd_get_accession_code(&msd, 38175));
00187
00188 msd_end(&msd);
00189 msd_detach(&msd);
00190 msd_logoff(&msd);
00191 ends = time (NULL);
00192 difs = difftime (ends,starts);
00193 time_end = clock();
00194 printf ("Process has taken %.2lf seconds.\n", difs );
00195 printf ("Process has taken %.2lf milliseconds.\n", (time_end - time_start)/CLOCKS_PER_SEC);
00196 msd_free(&msd);
00197
00198 return 0;
00199 }
00200
00201
00202
00203