| |||||||||||
| |||||||||||
convert xyz cordinates to distance Posted by andyng (andyng), 7 April 2005 Hi,I am new to perl, but I would like write a perl script that can convert xyz cordinates from a pdb file to distances using the formula: distance = SQRT[(X1-X2)^2 + (Y1-Y2)^2 + (Z1-Z2)^2] eg: line 1 xyz to line2 xyz line 1 xyz to line3 xyz line 1 to ...73 line 2 to 3 and so on. But I need to know which line to which line. Any help would be so great and appreciated. The pdb file format look like this REMARK ATOM 1 O1 VVA 1 20.542 18.415 14.035 ATOM 2 C2 VVA 1 21.588 17.620 14.671 ATOM 3 H3 VVA 1 21.893 18.095 15.605 ATOM 4 C4 VVA 1 22.849 17.597 13.752 ATOM 5 H5 VVA 1 22.659 16.957 12.887 ATOM 6 C6 VVA 1 23.208 19.009 13.227 ATOM 7 H7 VVA 1 22.404 19.424 12.617 ATOM 8 H8 VVA 1 23.407 19.695 14.054 ATOM 9 H9 VVA 1 24.101 18.970 12.600 ATOM 10 C10 VVA 1 24.078 17.043 14.513 ATOM 11 1H1 VVA 1 24.986 17.171 13.920 ATOM 12 2H1 VVA 1 24.223 17.571 15.458 ATOM 13 3H1 VVA 1 23.979 15.976 14.725 ATOM 14 C14 VVA 1 21.040 16.197 15.003 ATOM 15 H15 VVA 1 21.881 15.519 15.161 ATOM 16 C16 VVA 1 20.191 15.577 13.866 ATOM 17 H17 VVA 1 19.272 16.141 13.690 ATOM 18 H18 VVA 1 20.755 15.531 12.932 ATOM 19 H19 VVA 1 19.903 14.555 14.128 ATOM 20 C20 VVA 1 20.251 16.232 16.295 ATOM 21 1H2 VVA 1 19.164 16.223 16.236 ATOM 22 C22 VVA 1 20.938 16.240 17.456 ATOM 23 3H2 VVA 1 22.026 16.209 17.459 ATOM 24 C24 VVA 1 20.334 16.237 18.802 ATOM 25 O25 VVA 1 21.027 16.110 19.792 ATOM 26 N26 VVA 1 19.002 16.363 18.881 ATOM 27 H27 VVA 1 18.499 16.585 18.031 ATOM 28 C28 VVA 1 18.216 16.150 20.098 ATOM 29 H29 VVA 1 17.316 15.589 19.827 ATOM 30 H30 VVA 1 18.789 15.543 20.809 ATOM 31 C31 VVA 1 17.831 17.455 20.752 ATOM 32 2H3 VVA 1 18.521 18.288 20.656 ATOM 33 C33 VVA 1 16.697 17.496 21.476 ATOM 34 H34 VVA 1 16.082 16.598 21.541 ATOM 35 C35 VVA 1 16.202 18.631 22.258 ATOM 36 C36 VVA 1 14.930 18.374 23.045 ATOM 37 H37 VVA 1 14.504 17.389 22.841 ATOM 38 H38 VVA 1 15.118 18.425 24.120 ATOM 39 H39 VVA 1 14.160 19.107 22.799 ATOM 40 C40 VVA 1 16.857 19.811 22.304 ATOM 41 1H4 VVA 1 17.770 19.982 21.740 ATOM 42 C42 VVA 1 16.408 20.965 23.174 ATOM 43 3H4 VVA 1 15.564 20.703 23.820 ATOM 44 O44 VVA 1 17.518 21.298 23.996 ATOM 45 H45 VVA 1 17.779 20.471 24.446 ATOM 46 C46 VVA 1 16.044 22.195 22.332 ATOM 47 H47 VVA 1 15.935 23.063 22.985 ATOM 48 2H7 VVA 1 16.850 22.414 21.628 ATOM 49 C48 VVA 1 14.737 21.988 21.602 ATOM 50 O49 VVA 1 13.715 21.695 22.187 ATOM 51 C50 VVA 1 14.735 22.201 20.116 ATOM 52 1H5 VVA 1 15.288 23.110 19.879 ATOM 53 3H7 VVA 1 13.709 22.333 19.773 ATOM 54 C52 VVA 1 15.359 21.029 19.445 ATOM 55 O57 VVA 1 14.648 19.867 19.311 ATOM 56 C55 VVA 1 15.520 19.141 18.547 ATOM 57 H56 VVA 1 15.181 18.143 18.295 ATOM 58 N53 VVA 1 16.534 21.087 18.817 ATOM 59 C54 VVA 1 16.659 19.831 18.223 ATOM 60 C58 VVA 1 17.676 19.179 17.346 ATOM 61 O59 VVA 1 17.563 18.044 16.918 ATOM 62 N60 VVA 1 18.792 19.912 17.045 ATOM 63 C61 VVA 1 19.319 20.979 17.904 ATOM 64 H68 VVA 1 19.237 20.714 18.963 ATOM 65 H69 VVA 1 18.788 21.915 17.700 ATOM 66 C65 VVA 1 20.795 21.104 17.489 ATOM 67 H66 VVA 1 21.450 20.689 18.260 ATOM 68 H67 VVA 1 21.068 22.146 17.309 ATOM 69 C63 VVA 1 20.870 20.278 16.230 ATOM 70 H64 VVA 1 21.723 20.344 15.559 ATOM 71 C62 VVA 1 19.723 19.613 16.010 ATOM 72 C70 VVA 1 19.462 18.882 14.714 ATOM 73 O71 VVA 1 18.357 18.764 14.209 END Posted by admin (Graham Ellis), 7 April 2005 I've had a quick look at the desription of the .pdb format and it tells me that a CONECT record is used to specify which ATOMs are linked to which other ATOMs; I don't fully understand the data you've provided but I can't see that there's enough there for it to tell me this information. Have you any CONECT or other records that might be of help?I've looked at http://www.rcsb.org/pdb/docs/format/pdbguide2.2/guide2.2_frame.html to reseach CONECT ... Your algorithm for the distances is correct, though you'd write sqrt in lower case, use round brackets, put $ characters in front of the variable names and use ** not ^ for "power of" in Perl. $dist = sqrt(($x1-$x2)**2+($y1-$y2)**2+($z1-$z2)**2); Posted by andyng (andyng), 7 April 2005 Hi Graham,My PDB file does not have CONNECT information. I want to calculate NOE distances, which is the distance of 2 hydrogen atoms through space. For eg: I would like to calculate the distance of H3 to H5; H3 to H7 and so on. I have hundreds of PDB files with the same format, they just difference in XYZ coordinates. My aim is to write a perl script to calculate those specific H to H distances. I am thinking about array, I think it is called 'list' in perl, I need to name each XYZ cordinates of those H, so that the variable for the formula can be used. Am i right? Posted by Custard (Custard), 7 April 2005 So what you really want is a parser to parse the ATOM lines in a pdb file, and store the data in a way, so as to be able to find it using the names in column 3?So assuming column 3 names are all unique, which at a glance looks like they are, I would suggest a hash. Hashes are like special arrays, but the index is a string, so can be something like H1, H2 Code:
(incomplete and untested example) You'll have to modify to get it to do what you want.. see: perldoc perlintro perldoc perldata perldoc perlreftut B This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |