Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Calculate Centroid in python
    text
    copied!<p>I'm beginner to python coding. I'm working over structural coordinates. I have pdb structure which have xyz coordinate information (last three col) </p> <pre><code>ATOM 1 N SER A 1 27.130 7.770 34.390 ATOM 2 1H SER A 1 27.990 7.760 34.930 ATOM 3 2H SER A 1 27.160 6.960 33.790 ATOM 4 3H SER A 1 27.170 8.580 33.790 ATOM 5 CA SER A 1 25.940 7.780 35.250 ATOM 6 CB SER A 1 25.980 9.090 36.020 ATOM 7 OG SER A 1 26.740 10.100 35.320 ATOM 8 HG SER A 1 26.750 10.940 35.860 ATOM 9 C SER A 1 24.640 7.790 34.460 ATOM 10 O SER A 1 24.530 8.510 33.500 ATOM 11 N CYS A 2 23.590 7.070 34.760 ATOM 12 H CYS A 2 23.590 6.550 35.610 ATOM 13 CA CYS A 2 22.420 7.010 33.900 ATOM 14 CB CYS A 2 21.620 5.760 34.270 ATOM 15 SG CYS A 2 22.480 4.210 33.970 ATOM 16 C CYS A 2 21.590 8.220 34.040 ATOM 17 O CYS A 2 21.370 8.690 35.160 </code></pre> <ul> <li>I have 1000 atoms in my structure. </li> <li>I have two queries.</li> </ul> <p>How I can calculate the centroid of the structure from xyz coordinates.<br> From the centroid I want to draw a sphere of radius 20cm. </p> <pre><code>I try this from __future__ import division import math as mean import numpy as nx from string import* infile = open('file.pdb', 'r') #open my file text1 = infile.read().split('\n') infile.close() text = [] for i in text1: if i != '': text.append(i) for j in text: x1 = eval(replace(j[30:38], ' ', '')) #extract x-coordinate y1 = eval(replace(j[38:46], ' ', '')) #extract y-coordinate z1 = eval(replace(j[46:54], ' ', '')) #extract z-coordinate idcord = [] idcord.append(x1); idcord.append(y1); idcord.append(z1) centroid = nx.mean(idcord) print centroid </code></pre> <p>it gives the centroid of each atom (xyz) i need a central point how??????</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload