smi2mol.pl

{
/*___________________________________________________________________________
                                          Copyright (C) DataAspects Corp 2000
  smi2mol.pl
  Objective: Convert a SMILES string into a molfile.
  Actions:
    1. Client smi2mol.pl connects to server chemcop.pl 
       running on the Daylight server & passes it three parameters:
        parm.0  db_exec -executes a SQL statement (see trim.h).
        parm.1  'smi2mol', a flag instructing chemcop.pl to call smi2mol, 
                a Unix script.
        parm.2  list (smi_list)with one field, a SMILES

    2. Chemcop.pl makes a system call to execute smi2mol, a C program.
    3. The system call returns false if successful or true on failure 
       and the rc is returned to the client.
    4. Data returned from smi2mol is written to a file.  There are two types 
       of files depending on the outcome:

       Successful Outcome using SMILES CC:
		NOTE (SMI2MOL): Normal exit (EOF)...
		SMI2MOL: SMI's in:  1
		SMI2MOL: MOL's out: 1
		SMI2MOL: 2D Depictions added: 1
		SMI2MOL: errors: 0

		  SMI2MOL
		CC
		  2  1  0  0  0  0              1 V2000
		   -0.5100    1.5300    0.0000 C   0  0  0  0  0  0
		    0.5100    1.5300    0.0000 C   0  0  0  0  0  0
		  1  2  1  0
		M  END
		$$$$

       Failed Outcome using SMILES XXX:
		ERROR (SMI2MOL) dt_smilin ... "XXX"
		NOTE (SMI2MOL): Normal exit (EOF)...
		SMI2MOL: SMI's in:  1
		SMI2MOL: MOL's out: 0
		SMI2MOL: 2D Depictions added: 0
		SMI2MOL: errors: 1

    5.  The C program smi2mol can be run from the command line:
            smi2mol -s <"infile.smi" >outfile.mol
	
...Pat McGreevy, 20 June 00
_____________________________________________________________________________*/
int rc;                           /* store return code fm server chemcopl.pl */
char smi[2000];
list smi_list;
list temp_list;
 
printf("Wait...Connecting to Chemcop on Daylight Server");
if (trap({
   connect(0,"net:chemcop@1958:216.49.57.52(pamc/rrflat)!VTX17,TRIM_HOME=/usr2/trim");
   status("Connected to Chemcop");
   })){
       bell();
       prompt("Failed to connect to Chemcop");
       connect(0);
       break;
       }
smi= prompt("Enter SMILES: ");
smi_list= list_open("200",1,"SMILES");
list_mod(smi_list,1,smi);

rc= (exec_sql("smi2mol",smi_list));                         /* rpc to chemcop */

if (rc != 0)
  printf("Error executing smi2mol (rc = "^^rc);
else {
  temp_list= list_open("select results",1000);    /* rpc- open server molfile */
  list_view(temp_list,0);
  }
list_file(temp_list,"outfile.mol","a");
}