smi_unique.pl

{
/* __________________________________________________________________________
                                         Copyright (C) DataAspects, Inc. 1998
  smi_unique.pl
  Objective: To generate a unique SMILES from user input.
  Actions:
    1. Prompt user for a SMILES.
    2. Connect to chemcop.pl, a remote procedure, running on Thor Server
       and pass it these parameters.
            parm.0  db_exec (see trim.h).
            parm.1  'unique', a flag instructing chemcop.pl 
                     to run the unique module.
            parm.2  'smi_list', name of list with user SMILES.

    3. Chemcop runs unique_smile.c on the Daylight Server 
       and passes it the user's SMILES. The C program returns an 
       integer message code called rc and a result list. If the user 
       SMILES was converted to a USMILES, the MF, MW and USMILES are 
       returned in the list. Otherwise, an error message is returned
       in the list.

    4. Compile:  c:\ trimgen smi_unique.pl -a
    5. Run:      c:\ trimrun smi_unique or c:\ trimrunc smi_unique

    6. Examples:
         Enter c1ccccc1O and USMILES Oc1ccccc1 will be returned.
         Enter c1c1 to generate an error message.

    7. Note: 
       The exit values in the server program unique_smile.c are small integers
       like 0 to 6, but the UNIX system sees these values as multiples of 256 
       (= bit manipulations).  Thus, exit(0) = 0, exit(1)= 256, exit(2)= 512               
       etc).
...Pat McGreevy, 18 Feb 99
_____________________________________________________________________________ */
char smiles[2000];
char chemserver[100];
int  rc;
list smi_list;
list temp_list;

chemserver= "xxx.xxx.xx.xx";
printf("Connecting to Chemcop ChemServer"); 
if (trap({
   connect(0,"net:chemcop@"^^chemserver^^"!vtxhost.trm");
   printf("Connected to Chemcop");
   })){
       bell();
       printf("Failed to connect to Chemcop");
       connect(0);
       break;
       }

smiles= prompt("Enter SMILES: ");
smi_list= list_open("2000",1,"SMILES List");
list_mod(smi_list,1,"'"^^smiles^^"'");                /* put SMILES in a list */
rc = exec_sql("smi_unique",smi_list);        /* TRIMrpc-remote procedure call */

printf(decode(rc,  0,"Generated USMILES",
                   1,"unique module in chemcop not found",
                 256,"Failed to generate USMILES",
                 512,"Failed to connect to Thor Server",
                 768,"Failed to open Thor database",
                 1024,"Invalid SMILES submitted by caller",
                 1280,"SMILES OK; Other parameters invalid",
                 1536,"Failed to generate unique SMILES from input",
                35584,"Can't make unique SMILES",
                      "Unkown error"));

temp_list= list_open("select results",1000);    /* TRIMrpc-remote proc call   */
if (rc == 0)                                    /* Thor created Unique SMILES */
  list_view(temp_list,0);
else
  list_view(temp_list,0);                              /* print error message */
}