wnprpc Example: autofit



Usage:
autofit target_file source_file1 [source_file2, ...]"

Description:
Produces a table of results of fitting a set of protein structures in PDB files source_file1, source_file2, ... to a target protein in PDB file target. Only C-alpha positions of the first model per file are used in the fit. The output is filtered, i.e. only results where at least 50% of the C-alpha atoms are matched with the target structures, and where the r.m.s.d. between matched atomic positions is less than 5 Å are writen to stdout.



Notes: (click here to see the script)

The autofit script is a typical example of a script that starts its own Wit!P XML/RPC server by creating the wnpRPCserver object 'w':

w=wnpRPCserver(graphics=False,ports=range(19501,15525)

The 'graphics' and 'wait' arguments are left at their defaults, i.e. the Wit!P session will run without graphics. The XML/RPC server will use the first available port in the range 19501...19525 to listen for incoming requests, or fail to start, if none of these ports is available.  The following 'if' statement exits if the server could not be started:

if w.server is None:
print >>sys.stderr,"sorry, could not start Wit!P/XML/RPC"
sys.exit(3)

Next, the script prints out the server's port number, and a 'secret' tag ("WNP/RPC pid/random", where pid is the server's process id, and random is a random number) which provides some minimal protection against accidental connections from other processes.

The C-alpha atom records of the target protein (1st command line argument) is sent to the server as a PDB file:

w.loadMolTypes(name="target",type="pdb",data=target)

which will create the molecule /target in the Wit!P session by sending the atom records of the target, which were read using

target=firstModel(sys.argv[1])

to the PDB file parser. Next, the source protein structures, defined by the remaing command line arguments are fitted to the target protein using the autoFit function. This function takes a wnpRPCserver object and a PDB file name as arguments, reads the PDB file using firstModel, uses loadMolTypes to create the /source molecule in the Wit!P session, and uses the 'cmd' method of the wnpRPCserver object to send the following commands to the Wit!P session:

fit autopairs /target * -done /source * -done structal -3
delete molecule /source

The 'cmd' method returns a status, prompt, responseText triple. The script uses status (the number of error that occured in the Wit!P session during the execution requested by the 'cmd' method) to check for normal completion, and parses the responseText block (a list of LF terminated strings) to determine the number of atoms in the source molecule, the number of atom pairs used in the automatic fit, and the r.m.s.d between matched atom positions. If the 'cmd' method terminated without error, responseText will be a list of 5 lines of the following type:

330 atoms selected in template /target
98 atoms selected in source /source
r.m.s. ( /target , /source ) = 14.177
90 automatic pairs.
1 mol-nodes deleted.

i.e. he script needs to extract the first field from the second line, the first field from the fourth line, and the last field form the third line.

Finally, results that pass a simple acceptance test are written to stdout.


Sample output:

AW on camm7 786> autofit /db/pdb/4apr.pdb /db/pdb/1r??.pdb
Server started on port 19501, tag=WNP/RPC 4497/703125

1161 targets.
/db/pdb/1r7d.pdb    31    22    4.624
/db/pdb/1r7f.pdb    31    23    4.735
/db/pdb/1r8t.pdb    15    11    2.253
/db/pdb/1r9u.pdb    16    13    4.197
/db/pdb/1rg3.pdb    16    13    1.969
/db/pdb/1rg4.pdb    16     9    0.577
/db/pdb/1rik.pdb    29    23    4.558
/db/pdb/1rim.pdb    33    22    4.683
/db/pdb/1rkk.pdb    18    15    1.922
/db/pdb/1rl8.pdb   198   124    3.339
/db/pdb/1rne.pdb   329   227    1.038
/db/pdb/1rpc.pdb    21    14    4.495
/db/pdb/1rpv.pdb    17    13    0.659
/db/pdb/1rq9.pdb   198   107    2.337
/db/pdb/1rsw.pdb    12     7    1.845
/db/pdb/1rsx.pdb    12     9    2.915
/db/pdb/1rt0.pdb    12     8    1.229
/db/pdb/1rvs.pdb    11     9    2.064


A.Widmer, NIBR/CPC/CSG-SB