Changeset 1706 in rotdif


Ignore:
Timestamp:
Aug 15, 2019, 2:10:20 PM (11 months ago)
Author:
yuexi
Message:

adjust length

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bin/get_ellipsoid.py

    r1705 r1706  
    3030            ori_y += float(tmp_ls[7])
    3131            ori_z += float(tmp_ls[8])
    32     end_tmp = tmp[start_ind + count-1]
    33     end_str = ''.join(end_tmp)
    34     end_str = " ".join(end_str.split())
    35     end_ls = end_str.split(" ")
    36     end_atm = [float(end_ls[6]), float(end_ls[7]), float(end_ls[8])]
     32    #end_tmp = tmp[start_ind + count-1]
     33    #end_str = ''.join(end_tmp)
     34    #end_str = " ".join(end_str.split())
     35    #end_ls = end_str.split(" ")
     36    #end_atm = [float(end_ls[6]), float(end_ls[7]), float(end_ls[8])]
    3737    #calculate the protein diameter to get the scale factor
    38     diameter = 0
    39     for i in range(3):
    40         diameter += (start_atm[i] - end_atm[i])**2
    41     math.sqrt(diameter)
     38    #diameter = 0
     39    #for i in range(3):
     40    #    diameter += (start_atm[i] - end_atm[i])**2
     41    #math.sqrt(diameter)
    4242    ori_x = ori_x / count
    4343    ori_y = ori_y / count
    4444    ori_z = ori_z / count
    4545   
    46     return ori_x, ori_y, ori_z, diameter
     46    return ori_x, ori_y, ori_z
    4747
    48 def angle_axe(elm_prediction, diameter):
     48def angle_axe(elm_prediction):
    4949    '''
    5050    input: ELM prediction file
    51     output: 1) 3 ellipsoid semiaxes
    52             2) 3 Euler angles (unit: degree)
     51    output: 1) 3 Euler angles (unit: degree)
    5352    '''
    5453    with open(elm_prediction) as in_f:
    5554        tmp = in_f.readlines()
    5655    for i in range(len(tmp)):
    57         if tmp[i].startswith('Dx'):
    58             dx = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
    59         if tmp[i].startswith('Dy'):
    60             dy = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
    61         if tmp[i].startswith('Dz'):
    62             dz = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
     56        #if tmp[i].startswith('Dx'):
     57        #    dx = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
     58        #if tmp[i].startswith('Dy'):
     59        #    dy = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
     60        #if tmp[i].startswith('Dz'):
     61        #    dz = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
    6362        if tmp[i].startswith('alpha'):
    6463            alpha = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
     
    6766        if tmp[i].startswith('gamma'):
    6867            gamma = [float(it) for it in re.findall(r"[-+]?\d*\.\d+|[-+]?\d+",tmp[i])][0]
    69     diameter = diameter * 0.025
    70     new_dz = diameter
    71     new_dy = diameter * dy / dz
    72     new_dx = diameter * dx / dz
    73     return new_dx, new_dy, new_dz, alpha, beta, gamma
     68    return alpha, beta, gamma
    7469
    7570def find(name, path):
     
    8681    return result
    8782
     83def get_abc():
     84    with open("str_abc.txt") as in_f:
     85        strabc = in_f.readline()
     86    fabc = [float(s) for s in strabc.split(' ')]
     87    return fabc[0], fabc[1], fabc[2]       
     88
    8889def run_elli(base_dir):
    8990    # Input:
     
    9192    elm_prediction = find("ELM_prediction",base_dir)
    9293    # 1. Center of Mass of the molecule
    93     cmx, cmy, cmz, diameter = calc_mass(pdb_file)
     94    cmx, cmy, cmz = calc_mass(pdb_file)
    9495    #2. Ellipsoid Semiaxes (in A)
    9596    #Rotation Input: three euler angles: alpha, beta, gamma (in degrees)
    96     a1, a2, a3, deg1,deg2,deg3 = angle_axe(elm_prediction, diameter)
     97    deg1,deg2,deg3 = angle_axe(elm_prediction)
    9798    rotationInput = [deg1, deg2, deg3]
    9899    color = [0.85, 0.85, 1.00]
    99     all_ls = [cmx, cmy, cmz, diameter, a1, a2, a3, deg1, deg2, deg3, deg1, deg2, deg3]
    100     to_append = "\ncolor = [0.85, 0.85, 1.00]\ncmx, cmy, cmz, diameter = %0.3f, %0.3f, %0.3f, %0.3f\n\
    101 a1, a2, a3, deg1,deg2,deg3 = %0.3f, %0.3f, %0.3f, %0.3f, %0.3f, %0.3f\n\
    102 rotationInput = [%0.3f, %0.3f, %0.3f]\n\
    103 tmp = drawEllipsoid(color, cmx, cmy, cmz, a1, a2, a3, *rotationMatrix(rotationInput))\n\
    104 cmd.load_cgo(tmp, 'ellipsoid-cgo')\n\
    105 cmd.set('cgo_transparency', 0.5, 'ellipsoid-cgo')\n"%(cmx, cmy, cmz, diameter, a1, a2, a3, deg1, deg2, deg3, deg1, deg2, deg3)
    106    
     100    a1, a2, a3 = get_abc()
     101    to_append = """
     102#1. Center of Mass of the molecule
     103cmx, cmy, cmz = %0.3f, %0.3f, %0.3f
     104#2. Ellipsoid semiaxes length (in Angstrom)
     105a1,a2,a3 = %0.3f, %0.3f, %0.3f
     106#3. Color: see https://pymolwiki.org/index.php/Color_Values for more options
     107color = [0.85, 0.85, 1.00]
     108#4. Rotation Input: three Euler angles: alpha, beta, gamma (in degrees)
     109rotationInput = [%0.3f, %0.3f, %0.3f]
     110tmp = drawEllipsoid(color, cmx, cmy, cmz, a1, a2, a3, *rotationMatrix(rotationInput))
     111cmd.load_cgo(tmp, 'ellipsoid-cgo')
     112cmd.set('cgo_transparency', 0.5, 'ellipsoid-cgo')"""%(cmx, cmy, cmz, a1, a2, a3, deg1, deg2, deg3)
    107113    with open("ELM_ellipsoid.py","a") as out_f:
    108114        out_f.write(to_append)
Note: See TracChangeset for help on using the changeset viewer.