Python combination of all positive and negative coordinate values -


i have code calculates distance formula 3d coordinates input file

enter image description here

  input_file="mock_data.csv"   cmd=pd.read_csv(input_file)   subset = cmd[['carbon','x_coord', 'y_coord','z_coord']]   coordinate_values = [tuple(x) x in subset.values]    atoms = coordinate_values   atompairs = itertools.combinations(atoms, 2)   pair in atompairs:     x1 = pair[0][1]     y1 = pair[0][2]     z1 = pair[0][3]     x2 = pair[1][1]     y2 = pair[1][2]     z2 = pair[1][3]      """define values distance between atoms"""     def calculate_distance(x1,y1,x2,y2,z1,z2):        dist=math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2-z1)**2)        return dist     d=calculate_distance(x1,y1,x2,y2,z1,z2) 

i have code worked out calculate distance between each 'carbon'. problem coordinates absolute values - each coordinate positive or negative. want calculate distances between each carbon possible coordinates, i.e. positive , negative combinations of each 3d coordinates.

quick example: 'carbon' 1 has coordinates (1.08, 0.49, 0.523) (-1.08, -0.49, -0.523), (-1.08, 0.49, 0.523), (-1.08, -0.49, 0.523), (-1.08, 0.49, -0.523), (1.08, -0.49, 0.523), (1.08, -0.49, -0.523), (1.08, 0.49, -0.523), making total of 8 possibilities each coordinate system.

i need code go through of these possible coordinate values calculate distances have coded for.

here simple example.

import numpy np itertools import product scipy.spatial.distance import cdist  base = np.array([-1,1]) #accounts signed coord  x = 1*base              #change coord values y = 2*base z = 3*base  coords = list(product(x,y,z))    #cartesian product  distances = cdist(coords,coords) #better implementation of distance 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -