frag_pele/PlopRotTemp_S_2017/PlopRotTemp.py
def MatchTempMaeAtoms(mae_file, template_file):
    """
      |
      **Description:** Say which number of atom of th mae_file corresponds to the one on the template_file

      **Input:**
        - mae_file: topology of the ligand
        - template_file: topology of the ligand template

      **Output:**
        - mae2temp: Which number of atom of the template file correspond to the same atom on the mae file
        Example-->[0, 1, 2, 3, 4, 6, 8, 10, 12, 13, 14, 15, 16, 5, 7, 9, 11, 17, 18, 19]

        Explanation--> Atom number 5 from the mae correspond the 6th of the template.

        - temp2mae: Which number of atom of the mae file correspond to the same atom on the template file
        Example--> [0, 1, 2, 3, 4, 13, 5, 14, 6, 15, 7, 16, 8, 9, 10, 11, 12, 17, 18, 19]

        Explanation--> Atom number 5 of the template file corresponds to atom number 13 of the mae file.

    """
    [parent, zmat, temp_names] = read_zmat_template(template_file)
    mae_names = find_names_in_mae(mae_file)
    if ( len(temp_names) != len(mae_names)):
        raise Exception(
            "MAE and template of different length %d!=%d (check if the input file has more then one residue)\n" % (
            len(mae_names), len(temp_names)));
    mae2temp = []
    temp2mae = []
    num_found = 0
    for i in range(len(temp_names)):
        temp_names[i] = re.sub('_', ' ', temp_names[i])
        mae2temp.append(-100)
        temp2mae.append(-100)
    for i in range(len(mae_names)):
        for j in range(len(temp_names)):
            if (temp_names[j] == mae_names[i] ):
                mae2temp[i] = j
                temp2mae[j] = i
                num_found = num_found + 1
            #    print "Match ","[",mae_names[i],"][",temp_names[mae2temp[i]],"]"
    if ( len(mae2temp) < len(mae_names)):
        raise Exception("Mae file and template do not match\n");
    if (len(mae2temp) != num_found):
        ERROR = "Mae file and template do no match: Check to see if all mae atoms have a pdb atom name\nAtoms not Found:  ";
        for i in range(len(mae_names)):
            if (mae2temp[i] == -100): ERROR += " [";ERROR += mae_names[i];ERROR += "]";
        raise Exception(ERROR);
    #  for i in range(len(mae_names)):
    #     print i,mae_names[i],mae2temp[i],temp_names[mae2temp[i]]
    return [mae2temp, temp2mae]

      |
      **Description:** Say which number of atom of th mae_file corresponds to the one on the template_file

      **Input:**
        - mae_file: topology of the ligand
        - template_file: topology of the ligand template

      **Output:**
        - mae2temp: Which number of atom of the template file correspond to the same atom on the mae file
        Example-->[0, 1, 2, 3, 4, 6, 8, 10, 12, 13, 14, 15, 16, 5, 7, 9, 11, 17, 18, 19]

        Explanation--> Atom number 5 from the mae correspond the 6th of the template.

        - temp2mae: Which number of atom of the mae file correspond to the same atom on the template file
        Example--> [0, 1, 2, 3, 4, 13, 5, 14, 6, 15, 7, 16, 8, 9, 10, 11, 12, 17, 18, 19]

        Explanation--> Atom number 5 of the template file corresponds to atom number 13 of the mae file.

    
|
Description:** Say which number of atom of th mae_file corresponds to the one on the template_file

topology of the ligand
template_file: topology of the ligand template



Explanation--> Atom number 5 from the mae correspond the 6th of the template.



Explanation--> Atom number 5 of the template file corresponds to atom number 13 of the mae file.
| Description : ** Say which number of atom of th mae_file corresponds to the one on the template_file topology of the ligand template_file : topology of the ligand template Explanation -- > Atom number 5 from the mae correspond the 6th of the template . Explanation -- > Atom number 5 of the template file corresponds to atom number 13 of the mae file .
def MatchTempMaeAtoms(mae_file, template_file):
    [parent, zmat, temp_names] = read_zmat_template(template_file)
    mae_names = find_names_in_mae(mae_file)
    if ( len(temp_names) != len(mae_names)):
        raise Exception(
            "MAE and template of different length %d!=%d (check if the input file has more then one residue)\n" % (
            len(mae_names), len(temp_names)));
    mae2temp = []
    temp2mae = []
    num_found = 0
    for i in range(len(temp_names)):
        temp_names[i] = re.sub('_', ' ', temp_names[i])
        mae2temp.append(-100)
        temp2mae.append(-100)
    for i in range(len(mae_names)):
        for j in range(len(temp_names)):
            if (temp_names[j] == mae_names[i] ):
                mae2temp[i] = j
                temp2mae[j] = i
                num_found = num_found + 1
    if ( len(mae2temp) < len(mae_names)):
        raise Exception("Mae file and template do not match\n");
    if (len(mae2temp) != num_found):
        ERROR = "Mae file and template do no match: Check to see if all mae atoms have a pdb atom name\nAtoms not Found:  ";
        for i in range(len(mae_names)):
            if (mae2temp[i] == -100): ERROR += " [";ERROR += mae_names[i];ERROR += "]";
        raise Exception(ERROR);
    return [mae2temp, temp2mae]
def MatchTempMaeAtoms ( mae_file , template_file ) : [ parent , zmat , temp_names ] = read_zmat_template ( template_file ) mae_names = find_names_in_mae ( mae_file ) if ( len ( temp_names ) != len ( mae_names ) ) : raise Exception ( "MAE and template of different length %d!=%d (check if the input file has more then one residue)\n" % ( len ( mae_names ) , len ( temp_names ) ) ) ; mae2temp = [ ] temp2mae = [ ] num_found = 0 for i in range ( len ( temp_names ) ) : temp_names [ i ] = re . sub ( '_' , ' ' , temp_names [ i ] ) mae2temp . append ( - 100 ) temp2mae . append ( - 100 ) for i in range ( len ( mae_names ) ) : for j in range ( len ( temp_names ) ) : if ( temp_names [ j ] == mae_names [ i ] ) : mae2temp [ i ] = j temp2mae [ j ] = i num_found = num_found + 1 if ( len ( mae2temp ) < len ( mae_names ) ) : raise Exception ( "Mae file and template do not match\n" ) ; if ( len ( mae2temp ) != num_found ) : ERROR = "Mae file and template do no match: Check to see if all mae atoms have a pdb atom name\nAtoms not Found:  " ; for i in range ( len ( mae_names ) ) : if ( mae2temp [ i ] == - 100 ) : ERROR += " [" ; ERROR += mae_names [ i ] ; ERROR += "]" ; raise Exception ( ERROR ) ; return [ mae2temp , temp2mae ]
|
Description:** Say which number of atom of th mae_file corresponds to the one on the template_file
| Description : ** Say which number of atom of th mae_file corresponds to the one on the template_file
"""
      |
      **Description:** Say which number of atom of th mae_file corresponds to the one on the template_file

      **Input:**
        - mae_file: topology of the ligand
        - template_file: topology of the ligand template

      **Output:**
        - mae2temp: Which number of atom of the template file correspond to the same atom on the mae file
        Example-->[0, 1, 2, 3, 4, 6, 8, 10, 12, 13, 14, 15, 16, 5, 7, 9, 11, 17, 18, 19]

        Explanation--> Atom number 5 from the mae correspond the 6th of the template.

        - temp2mae: Which number of atom of the mae file correspond to the same atom on the template file
        Example--> [0, 1, 2, 3, 4, 13, 5, 14, 6, 15, 7, 16, 8, 9, 10, 11, 12, 17, 18, 19]

        Explanation--> Atom number 5 of the template file corresponds to atom number 13 of the mae file.

    """ #    print "Match ","[",mae_names[i],"][",temp_names[mae2temp[i]],"]" #  for i in range(len(mae_names)): #     print i,mae_names[i],mae2temp[i],temp_names[mae2temp[i]]
mae_file
template_file