frag_pele/PlopRotTemp_S_2017/PlopRotTemp.py
def assign_rank(bonds, assign, atom_num):
    """
    |
    **Description:** Define a list of ranks for each grup of atoms or cluster in assign
    which will show which atoms are closer to the group.
    As small is the number of the rank as close to the atom we are making the rank from it will be.


    **Input:**
      - bonds: Ligand connectivity
      - assign: List of atoms with numbers assigned in order to cluster them
      - atom_num: number of the atom to calculate the rank respect to.
    **Output:**
      - Rank: list of numbers for each grup of atoms or cluster in assign
            which will show which atoms are closer to the group.

    E.g.

    Rank From number 1:

    Start: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
      
    Middle: [0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] (look for the closest atoms)
      
    Final: [0, 0, 0, 1, 2, 3, 4, 3, 2, 3, 4, 5, 5, 3, 4, 5, 4, 6, 6, 6] As small is the number as close to atom number 2 is positioned on the ligand.
    
    """

    rank = []
    num_assign = 1;
    for i in range(len(assign)):
        rank.append(-1)
    rank = assign_rank_group(atom_num, assign, rank, 0)  # assigns atom_num a rank of zero
    while (min_value(rank) < 0):  # do until all are assigned
        cur_rank = max_value(rank)  #the loop is over ranks
        # print(cur_rank)
        changed = 1
        while (changed == 1):  #while we haven't assigned any atoms
            changed = 0
            for i in range(len(bonds)):  #bonds is a list of pairs of atoms that are bonded
                if ( rank[bonds[i][0]] == cur_rank and rank[bonds[i][1]] < 0):
                    rank[bonds[i][1]] = rank[bonds[i][0]] + 1
                    changed = 1
                if ( rank[bonds[i][1]] == cur_rank and rank[bonds[i][0]] < 0):
                    rank[bonds[i][0]] = rank[bonds[i][1]] + 1
                    changed = 1
    return rank

    |
    **Description:** Define a list of ranks for each grup of atoms or cluster in assign
    which will show which atoms are closer to the group.
    As small is the number of the rank as close to the atom we are making the rank from it will be.


    **Input:**
      - bonds: Ligand connectivity
      - assign: List of atoms with numbers assigned in order to cluster them
      - atom_num: number of the atom to calculate the rank respect to.
    **Output:**
      - Rank: list of numbers for each grup of atoms or cluster in assign
            which will show which atoms are closer to the group.

    E.g.

    Rank From number 1:

    Start: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
      
    Middle: [0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] (look for the closest atoms)
      
    Final: [0, 0, 0, 1, 2, 3, 4, 3, 2, 3, 4, 5, 5, 3, 4, 5, 4, 6, 6, 6] As small is the number as close to atom number 2 is positioned on the ligand.
    
    
|
Description:** Define a list of ranks for each grup of atoms or cluster in assign
which will show which atoms are closer to the group.
As small is the number of the rank as close to the atom we are making the rank from it will be.

Ligand connectivity
assign: List of atoms with numbers assigned in order to cluster them
atom_num: number of the atom to calculate the rank respect to.
Output:
Rank: list of numbers for each grup of atoms or cluster in assign
which will show which atoms are closer to the group.



Rank From number 1.






| Description : ** Define a list of ranks for each grup of atoms or cluster in assign which will show which atoms are closer to the group . As small is the number of the rank as close to the atom we are making the rank from it will be . Ligand connectivity assign : List of atoms with numbers assigned in order to cluster them atom_num : number of the atom to calculate the rank respect to . Output : Rank : list of numbers for each grup of atoms or cluster in assign which will show which atoms are closer to the group . Rank From number 1 .
def assign_rank(bonds, assign, atom_num):
    rank = []
    num_assign = 1;
    for i in range(len(assign)):
        rank.append(-1)
    rank = assign_rank_group(atom_num, assign, rank, 0)  
    while (min_value(rank) < 0):  
        cur_rank = max_value(rank)  
        changed = 1
        while (changed == 1):  
            changed = 0
            for i in range(len(bonds)):  
                if ( rank[bonds[i][0]] == cur_rank and rank[bonds[i][1]] < 0):
                    rank[bonds[i][1]] = rank[bonds[i][0]] + 1
                    changed = 1
                if ( rank[bonds[i][1]] == cur_rank and rank[bonds[i][0]] < 0):
                    rank[bonds[i][0]] = rank[bonds[i][1]] + 1
                    changed = 1
    return rank
def assign_rank ( bonds , assign , atom_num ) : rank = [ ] num_assign = 1 ; for i in range ( len ( assign ) ) : rank . append ( - 1 ) rank = assign_rank_group ( atom_num , assign , rank , 0 ) while ( min_value ( rank ) < 0 ) : cur_rank = max_value ( rank ) changed = 1 while ( changed == 1 ) : changed = 0 for i in range ( len ( bonds ) ) : if ( rank [ bonds [ i ] [ 0 ] ] == cur_rank and rank [ bonds [ i ] [ 1 ] ] < 0 ) : rank [ bonds [ i ] [ 1 ] ] = rank [ bonds [ i ] [ 0 ] ] + 1 changed = 1 if ( rank [ bonds [ i ] [ 1 ] ] == cur_rank and rank [ bonds [ i ] [ 0 ] ] < 0 ) : rank [ bonds [ i ] [ 0 ] ] = rank [ bonds [ i ] [ 1 ] ] + 1 changed = 1 return rank
|
Description:** Define a list of ranks for each grup of atoms or cluster in assign
which will show which atoms are closer to the group.
| Description : ** Define a list of ranks for each grup of atoms or cluster in assign which will show which atoms are closer to the group .
"""
    |
    **Description:** Define a list of ranks for each grup of atoms or cluster in assign
    which will show which atoms are closer to the group.
    As small is the number of the rank as close to the atom we are making the rank from it will be.


    **Input:**
      - bonds: Ligand connectivity
      - assign: List of atoms with numbers assigned in order to cluster them
      - atom_num: number of the atom to calculate the rank respect to.
    **Output:**
      - Rank: list of numbers for each grup of atoms or cluster in assign
            which will show which atoms are closer to the group.

    E.g.

    Rank From number 1:

    Start: [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
      
    Middle: [0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] (look for the closest atoms)
      
    Final: [0, 0, 0, 1, 2, 3, 4, 3, 2, 3, 4, 5, 5, 3, 4, 5, 4, 6, 6, 6] As small is the number as close to atom number 2 is positioned on the ligand.
    
    """ # assigns atom_num a rank of zero # do until all are assigned #the loop is over ranks # print(cur_rank) #while we haven't assigned any atoms #bonds is a list of pairs of atoms that are bonded
bonds
assign
atom_num