def main():


   if len(sys.argv) != 6: # if no input
       print ("ERORR:")
       print ("syntex: distance_cal_no_precomput.py mol2_file(docked poses) mol2_file(find poses close to) threshold hname output ")
       return
 

   infilemol2_poses     = sys.argv[1]
   infilemol2_ref       = sys.argv[2]
   dist_threshold       = float(sys.argv[3])
   hname                = sys.argv[4]
   outfile              = sys.argv[5]

   print ("input file (poses)     = ", infilemol2_poses)
   print ("input file (reference) = ", infilemol2_ref)
   print ("threshold =", dist_threshold)
   print ("head_name =", hname)
   print ("outputprefix =", outfile)
   #mol2_vector  = mol2.read_Mol2_file(infilemol2_poses)
   mol2_vector  = mol2.read_Mol2_file_head(infilemol2_poses)
   mol2_ref  = mol2.read_Mol2_file(infilemol2_ref)[0]


   count = 0
   for mol in mol2_vector: 
       min_dist = 100000
       count_atom_lt_thes = 0
       for atom in mol.atom_list: 
           if (atom.type == 'H'): 
               continue
           #dist = cal_dist_closest_grid_point(grid_dist,gridscale,xn,yn,zn,origin,atom)
           #dist = cal_dist_tri_linear(grid_dist,gridscale,xn,yn,zn,origin,atom)
           dist =  cal_min_dist_atom_mol(atom,mol2_ref)
           if dist < min_dist: 
              min_dist = dist
           if dist < dist_threshold: 
               count_atom_lt_thes = count_atom_lt_thes + 1   
       if min_dist < dist_threshold: 
          print("mol %d,dist=%f,num_atom_lt_threshold=%d"%(count,min_dist,count_atom_lt_thes))
          #close_mol2.append(mol)
          mol.header = mol.header+"##########  %s_dist:                    %f\n"%(hname,min_dist)
          mol.header = mol.header+"##########  %s_num_atom_lt_threshold:   %d\n"%(hname,count_atom_lt_thes)
          mol2.append_mol2(mol, outfile+'.mol2')
       count = count + 1
Пример #2
0
def multimol2_removeH(input, output):
    #print "This file requires the mol2 library written by Trent Balius (AKA Xiaobo Wan) and sudipto mukherjee"

    #print "syntex: multimol2_removeH.py input_file output_file"

    infile = input
    outfile = output

    file = open(outfile, 'w')  # overwrite
    file.close()

    mol_list = mol2.read_Mol2_file_head(infile)
    #print len(mol_list)

    for i in range(len(mol_list)):
        #print "mol ", i
        mol = mol2.remove_hydrogens(mol_list[i])
        mol2.append_mol2(mol, outfile)
print "syntex: mol2_shuffle.py input_file1 input_file2 input_file3 output_file"
print "this file takes in 3 mol2 input files 2 of the files are the same but a different order. "
print "The 3 input is a file that you want to suffle for the order of 1 to 2"
print "(1) origenal order."
print "(2) the new order."
print "(3) mol2 to file to change the order (can be multi mol2)"
print "(4) name to which to write newly reordered mol2."

infile1 = sys.argv[1]
infile2 = sys.argv[2]
infile3 = sys.argv[3]
outfile = sys.argv[4]
mol_1 = mol2.read_Mol2_file(infile1)[0]  # ori order
mol_2 = mol2.read_Mol2_file(infile2)[0]  # new order

mol_3list = mol2.read_Mol2_file_head(infile3)

maping = maping_by_cord(mol_1, mol_2)

for j, mol_3 in enumerate(mol_3list):
    print "molecule %d" % (j)
    #mol_3_new = copy.deepcopy(mol_3)
    atomlist = []
    for i, move in enumerate(maping):
        #print i,move,maping[i]
        atom = mol_3.atom_list[move]
        atom.num = i + 1
        atomlist.append(atom)

    #mol_3_new.atom_list = atomlist
    #bondlist     = copy.deepcopy(mol_2.bond_list)
import mol2
import sys

print "this file requiers the mol2 libary writen by trent balius and sudipto mukherjee"

print "syntex: multimol2_removeH.py input_file output_file"

infile = sys.argv[1]
outfile = sys.argv[2]

file = open(outfile, 'w')  # overwrite
file.close()

mol_list = mol2.read_Mol2_file_head(infile)
print len(mol_list)

for i in range(len(mol_list)):
    print "mol ", i
    mol = mol2.remove_hydrogens(mol_list[i])
    mol2.append_mol2(mol, outfile)