thor_load.pl
{
/* **************************************************************************
thor_load.pl
Objective: To create a TDT and insert it into Thor.
Actions:
1. Prompt user for a SMILES.
2. Convert the display SMILES to a USMILES by calling unique_smile.c.
3. Determine if USMILES is already in Thor by calling is_smi_in_db.c.
4. If USMILES is new, insert it into Thor:
a. Create a TDT from prompts.
b. Connect to chemcop.pl, remote procedure, running on Thor Server
and pass it these parameters.
parm.0 db_exec (see trim.h).
parm.1 'load_cis', a flag instructing chemcop.pl
to call load_cis, a shell script
parm.2 'tdt_list', name of list with TDT.
5. Compile: c:\ trimgen thor_load.pl -a
6. Run: c:\ trimrun thor_load
7. Examples:
c1c(CCCCCC)cc(CCCCCC)cc1 is not in the CIS and can be used for practice.
To make a new SMILES insert another c. Use WR >=300000 for the WRNO.
8. Note:
The exit values in the server program is_smi_in_db.c are 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 thorserver[100];
int rc;
list smi_list;
list tdt_list;
list temp_list;
thorserver= "xxx.xxx.xx.xx";
printf("Connecting to Chemcop ThorServer");
if (trap({
connect(0,"net:chemcop@"^^thorserver^^"!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 */
/* Instruct chemcop.pl to run is_smi_in_db */
rc = exec_sql("smi_in_thor",smi_list);
printf(decode(rc, 0,"SMILES in Thor",
256,"SMILES not in Thor",
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"));
if (rc == 256){ /* if SMILES not in Thor */
tdt_list= list_open("2006",100,"TDT" ); /* create list, 1 field, 2006 bytes */
list_mod(tdt_list,1,"$SMI");
list_mod(tdt_list,1,"$WRNO<300000>");
list_mod(tdt_list,1,"AMW<111>");
list_mod(tdt_list,1,"F");
list_mod(tdt_list,1,"$CAS<9999-99-9>");
list_mod(tdt_list,1,"|");
list_view(tdt_list,0); /* display TDT */
if (exec_sql("thor_load",tdt_list)){ /* TRIMrpc-remote procedure call */
bell();
printf("load_tdt.c failed.");
}
else{
temp_list= list_open("select results",1000); /* TRIMrpc-remote proc call */
if(list_rows(temp_list)==2){ /* insert was successful */
list_seek(temp_list,1);
printf(list_curr(temp_list,0)); /* print transaction msg */
}
else /* print error message */
list_view(temp_list,0);
}
}
}