smi_in_thor.pl

{
/* __________________________________________________________________________
                                         Copyright (C) DataAspects, Inc. 1998  
smi_in_thor.pl_
  Objective: To determine if a SMILES is in a THOR db.
  Actions:
    1. The client smiindb.pl connects to vtxhost.trm 
       running on ChemServer & passes it three parameters:
        parm.0  db_exec -executes a SQL statement (see trim.h).
        parm.1  chemcop.pl - name of trim/pl program on server.
        parm.2  name of SMILES list.

    2. Execute chemcop.pl and pass it a list with a SMILES.
    3. chemcop.pl executes is_smi_in_db.c.
    4. is_smi_in_db.c searches Thor for SMILES and returns 
a single parameter to chemcop.

       Parameters returned by server program is_smi_in_db.pl:
         0 - input smile was found in the database
         1 - input smile was NOT FOUND in the database
         2 - failed to connect to database server
         3 - failed to open cis database
         4 - invalid smile passed by calling program
         5 - other error occurred passed parameters
         6 - failed to generate unique smile from input

5. chemcop returns parameter to the client smiindb.pl.
    6. smiindb.pl decodes and prints the parameter.

   SMILES for testing:
      in Thor:     c1ccccc1
      not in Thor: c1cccc1

...Pat McGreevy, 18 Feb 99
__________________________________________________________________________ */

char smiles[4000];
char thorserver[20];
list smi_list;
list temp_list;
int  rc;
 
status("Wait...Connecting to ChemDB");
thorserver= "xxx.xxx.xx.xx";
printf("Connecting to Chemcop on ThorServer"); 
if (trap({
   connect(0,"net:chemcop@"^^G.thorserver^^"!vtxhost.trm");
   status("Connected to Chemcop");
   })){
       bell();
       status("Failed to connect to Chemcop");
       connect(0);
       break;
       }
smiles= prompt("Enter SMILES: ");
smi_list= list_open("4000",1,"SMILES List");
list_mod(smi_list,1,"'"^^smiles^^"'");
 
rc = exec_sql("smi_in_thor",smi_list);
printf("RC is: "^^rc);
printf(decode(rc,0,"SMILES in Thor",
                 256,"SMILES not in Thor",
                 512,"Failed to connect to database server",
                 768,"Failed to open cis database",
                 1024,"Invalid smile passed by calling program",
                 1280,"Other error occurred passed parameters",
                 1536,"Failed to generate unique siles from input"));
/* Note that the server program is_smi_in_db returns exit(0 to 5), 
   but the system sees these exit values as multiples of 256.  Thus, 
   exit(0) = 0, exit(1)= 256, exit(2)= 512 etc */
}