thor_getlist
{
/* ________________________________________________________________________________
Copyright (C) DataAspects, Inc. 1998
thor_getlist.pl
Objective: Search the CIS Thor database with a list of structure numbers
and return a corresponding list with WRNO, CAS, MW, MF, SMILES.
Actions:
1. Client thor_getlist.pl connects to chemcop.pl running on the
Thor Server and passes it three parameters:
parm.0 db_exec - orders chemcop to run a command procedure
parm.1 'thor_getlist' - name of chemcop procedure that executes
'wrno_list_from_cis.c' on the Daylight Server
parm.2 wrno_list which has multiple rows of WRNOs
2. chemcop.pl executes 'wrno_list_from_cis.c'
3. 'wrno_list_from_cis.c' searches Thor for each WRNO,
and returns an exit code and a results list to Chemcop.
--input list of WRNOs:
123456
12345
008014
599999
121213
Note: only the first 6 characters of the list are read by
'wrno_list_from_cis.c'
--Return Code:
0 - SMILES found for all WRNOs in input list
1 - WRNOs not in Thor are displayed below asterisks in results list
2 - Failed to connect to Thor server
3 - Could not open CIS Thor database
4 - Could not read input parameters
5 - Failed to create/open temp_tdt.out or missing.wrno files
NOTE: If 'wrno_list_from_cis.c' can't deal with an input value,
the input line is written to the out list and the program continues
as opposed to exiting with an error code.
--Results list:
123456,NONE,297.29,C15H11N3O4,COc1nc2ccccc2nc1Oc3ccc(cc3)N(=O)=O
008014,108-88-3,92.15,C7H8,Cc1ccccc1
121213,NONE,513.15,C28H24NiO2P2,O#C[Ni]C#O.C(CP(c1ccccc1)c2ccccc2)P(c3ccccc3)c4ccccc4
****
12345
599999
4. chemcop.pl sends the return code and results list to the client
thor_getlist.pl.
5. thor_getlist.pl parses the data.
6. wrno_list_from_cis.c can be run from the command line:
wrno_list_from_cis infile.txt
All hits are displayed on the screen. All misses are written to missing.wrno.
...Pat McGreevy, 18 Feb 99
________________________________________________________________________________ */
int c[5]; /* store position of comma delimiters */
int i; /* counter */
int rc; /* store return code fm TRIMrpc chemcop */
char data[100];
char thorserver[20]; /* store ip address of Thor server */
list structure_list; /* list of structure numbers for Thor */
list temp_list; /* list of WRNOS,CAS,MW,MF,SMILES fm Thor*/
/* _____________________________________________________________________________ */
/* Connect to TRIMrpc Program, ChemCop.pl */
/* _____________________________________________________________________________ */
printf("Wait...Connecting to ChemCop on ThorServer");
thorserver= "xxx.xxx.xx.xx";
if (trap({
connect(0,"net:chemcop@"^^G.thorserver^^"!vtxhost.trm");
printf("Connected to ChemCop");
})){
bell();
printf("Failed to connect to Chemcop");
connect(0);
break;
}
/* _____________________________________________________________________________ */
/* Load list of Structure Numbers */
/* _____________________________________________________________________________ */
structure_list= list_open("6",1,"WRNO List");
list_mod(structure_list,1,"123456"); /* TDT W/O CAS */
list_mod(structure_list,1,"12345"); /* invalid WRNO */
list_mod(structure_list,1,"008014"); /* valid WRNO */
list_mod(structure_list,1,"599999"); /* invalid WRNO */
list_mod(structure_list,1,"121213"); /* TDT W/O CAS */
list_view(structure_list,0);
/* _____________________________________________________________________________ */
/* Call ChemCop to run 'thor_getlist' block which executes 'wrno_list_from_cis.c'*/
/* _____________________________________________________________________________ */
rc= (exec_sql("thor_getlist",structure_list)); /* TRIMrpc-remote procedure call */
printf(decode(rc,
0,"rc=0: SMILES found for all WRNOs in structure_list",
256,"rc=1: WRNOs not in Thor are displayed below asteriks in results list",
512,"rc=2: Failed to connect to Thor server",
768,"rc=3: Could not open CIS Thor database",
1024,"rc=4: Could not read input parameters",
1280,"rc=5: Failed to create/open temp_tdt.out or missing.wrno files",
"Cannot interpret value '"^^rc^^"' from chemcop"));
/* _____________________________________________________________________________ */
/* Call ChemCop to run 'select results' procedure to open/return data file */
/* _____________________________________________________________________________ */
if (rc == 0 || rc == 256){
temp_list= list_open("select results",1000); /* open file returned fm chemcop */
list_view(temp_list,0);
if (temp_list){ /*list opened successfully */
for(i=1;i<=4;i++) /* find pos of commas */
c[i]= instr(list_curr(temp_list,0),",",1,i);
printf(substr(list_curr(temp_list,0),1,c[1]-1)); /* parse WRNO*/
printf(substr(list_curr(temp_list,0),c[1]+1, c[2]-c[1]-1)); /* parse CAS */
printf(substr(list_curr(temp_list,0),c[2]+1, c[3]-c[2]-1)); /* parse MW */
printf(substr(list_curr(temp_list,0),c[3]+1, c[4]-c[3]-1)); /* parse MF */
printf(substr(list_curr(temp_list,0),c[4]+1)); /* parse SMILES */
} /* end if (list_rows(temp_list)==2){ */
} /* end else if (rc == 0){ */
}