Exemplo n.º 1
0
def rot_mol_plane_3_1(frame1_cords,frame2_cords,part='ring',atom_list=[]):
  part_rotation=0
  if part=='ring':
    _atom_list=range(config.ring_start_atom_no,config.ring_end_atom_no+1)
  elif part=='track':
    _atom_list=range(config.track_start_atom_no,config.track_end_atom_no+1)
  else:
    assert len(atom_list)!=0,'atoms_list should not be empty'
    _atom_list=atom_list
  if config.axis=='x':
    axis=0
  elif config.axis=='y':
    axis=1
  elif config.axis=='z':
    axis=2
  frame1_cords,frame2_cords=shift_origin.shiftOrigin(frame1_cords,frame2_cords,process='rotation')
  frame1_part_cords_df=frame1_cords[frame1_cords['atom_no'].isin(_atom_list)]
  frame2_part_cords_df=frame2_cords[frame2_cords['atom_no'].isin(_atom_list)]
  coplanar_atom_no_list=findCoplanarAtoms(frame1_part_cords_df)
  frame1_coplanar_atom_cords_list=frame1_part_cords_df[frame1_part_cords_df['atom_no'].isin(coplanar_atom_no_list)][['x','y','z']].values[:-1]
  frame2_coplanar_atom_cords_list=frame2_part_cords_df[frame2_part_cords_df['atom_no'].isin(coplanar_atom_no_list)][['x','y','z']].values[:-1]
  frame1_plane=vector.getPlaneNormal(frame1_coplanar_atom_cords_list)
  frame2_plane=vector.getPlaneNormal(frame2_coplanar_atom_cords_list)
  frame1_plane[axis]=0
  frame2_plane[axis]=0
  part_rotation=getRPYAngles(frame1_plane,frame2_plane,axis=config.axis)[axis]
  return math.degrees(part_rotation)
def trans_atomic_r_t(frame1_cords, frame2_cords, part='ring', atom_list=[]):
    part_translation = 0
    avg_part_translation = 0
    if part == 'ring':
        _atom_list = range(config.ring_start_atom_no,
                           config.ring_end_atom_no + 1)
    elif part == 'track':
        _atom_list = range(config.track_start_atom_no,
                           config.track_end_atom_no + 1)
    else:
        assert len(atom_list) != 0, 'atoms_list should not be empty'
        _atom_list = atom_list
    if config.axis == 'x':
        axis = 0
    elif config.axis == 'y':
        axis = 1
    elif config.axis == 'z':
        axis = 2
    frame1_cords, frame2_cords = shift_origin.shiftOrigin(
        frame1_cords, frame2_cords, process='translation')
    for atom_no in _atom_list:
        frame1_atom_cords = frame1_cords[frame1_cords['atom_no'] == atom_no][[
            'x', 'y', 'z'
        ]].values[0]
        frame2_atom_cords = frame2_cords[frame2_cords['atom_no'] == atom_no][[
            'x', 'y', 'z'
        ]].values[0]
        #getRPYAngles with new prev_frame_cords
        #translate cords of prev_frame
        trans_vec = getAtomicDisplacement(frame1_atom_cords, frame2_atom_cords)
        part_translation += trans_vec[axis]
    avg_part_translation = part_translation / len(_atom_list)
    return avg_part_translation * constants.angstrom
Exemplo n.º 3
0
def rot_mol_plane_3(frame1_cords,frame2_cords,part='ring',atom_list=[]):
  part_rotation=0
  if part=='ring':
    _atom_list=range(config.ring_start_atom_no,config.ring_end_atom_no+1)
  elif part=='track':
    _atom_list=range(config.track_start_atom_no,config.track_end_atom_no+1)
  else:
    assert len(atom_list)!=0,'atoms_list should not be empty'
    _atom_list=atom_list
  if config.axis=='x':
    axis=0
  elif config.axis=='y':
    axis=1
  elif config.axis=='z':
    axis=2
  frame1_cords,frame2_cords=shift_origin.shiftOrigin(frame1_cords,frame2_cords,process='rotation')
  frame1_part_cords_df=frame1_cords[frame1_cords['atom_no'].isin(_atom_list)]
  frame2_part_cords_df=frame2_cords[frame2_cords['atom_no'].isin(_atom_list)]
  coplanar_atom_no_list=findCoplanarAtoms(frame1_part_cords_df)
  frame1_coplanar_atom_cords_list=frame1_part_cords_df[frame1_part_cords_df['atom_no'].isin(coplanar_atom_no_list)][['x','y','z']].values[:-1]
  frame2_coplanar_atom_cords_list=frame2_part_cords_df[frame2_part_cords_df['atom_no'].isin(coplanar_atom_no_list)][['x','y','z']].values[:-1]
  frame1_plane=vector.getPlaneNormal(frame1_coplanar_atom_cords_list)
  frame2_plane=vector.getPlaneNormal(frame2_coplanar_atom_cords_list)
  part_rotation=getRPYAngles(frame1_plane,frame2_plane,axis=config.axis)[axis]
  '''
  RPY gives accurate results when vector are perpendicular to the axis of rotation
  RPY gives both positive and negative values
  Following angle calulation will give only positive values 
  frame1_plane[axis]=0
  frame2_plane[axis]=0
  part_rotation=vector.getAngleR(frame1_plane,frame2_plane)
  '''
  return math.degrees(part_rotation)
Exemplo n.º 4
0
def rot_atomic_r_t_3(frame1_cords,frame2_cords,part='ring',atom_list=[]):
  part_rotation=0
  if part=='ring':
    _atom_list=config.ring_atom_no_list
  elif part=='track':
    _atom_list=config.track_atom_no_list
  else:
    assert len(atom_list)!=0,'atoms_list should not be empty'
    _atom_list=atom_list
  if config.axis=='x':
    axis=0
  elif config.axis=='y':
    axis=1
  elif config.axis=='z':
    axis=2
  frame1_cords,frame2_cords=shift_origin.shiftOrigin(frame1_cords,frame2_cords,process='rotation')
  frame1_cords[config.axis]=0
  frame2_cords[config.axis]=0
  for atom_no in _atom_list:
    frame1_atom_cords=frame1_cords[frame1_cords['atom_no']==atom_no][['x','y','z']].values[0]
    frame2_atom_cords=frame2_cords[frame2_cords['atom_no']==atom_no][['x','y','z']].values[0]
    atom_rotation=getRPYAngles(frame1_atom_cords,frame2_atom_cords,axis=config.axis)
    part_rotation+=atom_rotation[axis]
  avg_part_rotation=part_rotation/len(_atom_list)
  return math.degrees(avg_part_rotation)
Exemplo n.º 5
0
def rot_atomic_r_t_2(frame1_cords,frame2_cords,part='ring',atom_list=[]):
  if part=='ring':
    _atom_list=range(config.ring_start_atom_no,config.ring_end_atom_no+1)
  elif part=='track':
    _atom_list=range(config.track_start_atom_no,config.track_end_atom_no+1)
  else:
    assert len(atom_list)!=0,'atoms_list should not be empty'
    _atom_list=atom_list
  if config.axis=='x':
    axis=0
  elif config.axis=='y':
    axis=1
  elif config.axis=='z':
    axis=2
  atom_rotation_list=[]
  frame1_cords,frame2_cords=shift_origin.shiftOrigin(frame1_cords,frame2_cords,process='rotation')
  frame1_cords[config.axis]=0
  frame2_cords[config.axis]=0 
  for atom_no in _atom_list:
    frame1_atom_cords=frame1_cords[frame1_cords['atom_no']==atom_no][['x','y','z']].values[0]
    frame2_atom_cords=frame2_cords[frame2_cords['atom_no']==atom_no][['x','y','z']].values[0]
    atom_rotation=vector.getAngleR(frame1_atom_cords,frame2_atom_cords)
    sign=vector.getCrossProduct(frame1_atom_cords,frame2_atom_cords)[axis]
    if sign<0:
      sign=-1
    else:
      sign=1 
    #print(math.degrees(sign*atom_rotation))
    atom_rotation_list.append(sign*atom_rotation)
  #part_rotation=stats.mode(atom_rotation_list)[0]
  part_rotation=np.average(atom_rotation_list)
  return math.degrees(part_rotation)
Exemplo n.º 6
0
def rot_atomic_r_t_1(frame1_cords,frame2_cords,part='ring',atom_list=[]):
  part_rotation=0
  if part=='ring':
    _atom_list=range(config.ring_start_atom_no,config.ring_end_atom_no+1)
  elif part=='track':
    _atom_list=range(config.track_start_atom_no,config.track_end_atom_no+1)
  else:
    assert len(atom_list)!=0,'atoms_list should not be empty'
    _atom_list=atom_list
  if config.axis=='x':
    axis=0
  elif config.axis=='y':
    axis=1
  elif config.axis=='z':
    axis=2
  frame1_cords,frame2_cords=shift_origin.shiftOrigin(frame1_cords,frame2_cords,process='rotation')
  for atom_no in _atom_list:
    frame1_atom_cords=frame1_cords[frame1_cords['atom_no']==atom_no][['x','y','z']].values[0]
    frame2_atom_cords=frame2_cords[frame2_cords['atom_no']==atom_no][['x','y','z']].values[0]  
    atom_rotation=getRPYAngles(frame1_atom_cords,frame2_atom_cords,axis=config.axis)
    #getRPYAngles with new prev_frame_cords
    #translate cords of prev_frame
    part_rotation+=atom_rotation[axis]
  avg_part_rotation=part_rotation/len(_atom_list)
  return math.degrees(avg_part_rotation)
Exemplo n.º 7
0
def rot_mol_plane_1(frame1_cords,frame2_cords,part='ring',atom_list=[]):
  part_rotation=0
  if part=='ring':
    _atom_list=range(config.ring_start_atom_no,config.ring_end_atom_no+1)
  elif part=='track':
    _atom_list=range(config.track_start_atom_no,config.track_end_atom_no+1)
  else:
    assert len(atom_list)!=0,'atoms_list should not be empty'
    _atom_list=atom_list
  if config.axis=='x':
    axis=0
  elif config.axis=='y':
    axis=1
  elif config.axis=='z':
    axis=2
  frame1_cords,frame2_cords=shift_origin.shiftOrigin(frame1_cords,frame2_cords,process='rotation')
  frame1_part_df=frame1_cords[frame1_cords['atom_no'].isin(_atom_list)]
  frame2_part_df=frame2_cords[frame2_cords['atom_no'].isin(_atom_list)]
  frame1_plane=findMolecularPlane(frame1_part_df)
  frame2_plane=findMolecularPlane(frame2_part_df)
  part_rotation=getRPYAngles(frame1_plane,frame2_plane,axis=config.axis)[axis]
  return math.degrees(part_rotation)
def trans_com_1(frame1_cords, frame2_cords, part='ring', atom_list=[]):
    if part == 'ring':
        _atom_list = config.ring_atom_no_list
    elif part == 'track':
        _atom_list = config.track_atom_no_list
    else:
        assert len(atom_list) != 0, 'atoms_list should not be empty'
        _atom_list = atom_list
    frame1_cords, frame2_cords = shift_origin.shiftOrigin(
        frame1_cords, frame2_cords, process='translation')
    com1 = physics.getCom(frame1_cords, atom_list=_atom_list)
    com2 = physics.getCom(frame2_cords, atom_list=_atom_list)
    translation = [0.0, 0.0, 0.0]
    translation[0] = com2[0] - com1[0]
    translation[1] = com2[1] - com1[1]
    translation[2] = com2[2] - com1[2]
    if config.axis == 'x':
        axis = 0
    elif config.axis == 'y':
        axis = 1
    elif config.axis == 'z':
        axis = 2
    return translation[axis] * constants.angstrom