Converts a pro residue to a hydroxypro residue.

    All metadata associated with the original pro will be lost i.e. tags.
    As a consequence, it is advisable to relabel all atoms in the structure
    in order to make them contiguous.

    Parameters
    ----------
    pro: ampal.Residue
        The proline residue to be mutated to hydroxyproline.

    Examples
    --------
    We can create a collagen model using isambard and convert every third
    residue to hydroxyproline:

    >>> import isambard
    >>> col = isambard.specifications.CoiledCoil.tropocollagen(aa=21)
    >>> col.pack_new_sequences(['GPPGPPGPPGPPGPPGPPGPP']*3)
    >>> to_convert = [
    ...     res for (i, res) in enumerate(col.get_monomers())
    ...     if not (i + 1) % 3]
    >>> for pro in to_convert:
    ...     isambard.ampal.non_canonical.convert_pro_to_hyp(pro)
    >>> col.sequences
    ['GPXGPXGPXGPXGPXGPXGPX', 'GPXGPXGPXGPXGPXGPXGPX', 'GPXGPXGPXGPXGPXGPXGPX']

def convert_pro_to_hyp(pro):
    """Converts a pro residue to a hydroxypro residue.

    All metadata associated with the original pro will be lost i.e. tags.
    As a consequence, it is advisable to relabel all atoms in the structure
    in order to make them contiguous.

    Parameters
    ----------
    pro: ampal.Residue
        The proline residue to be mutated to hydroxyproline.

    Examples
    --------
    We can create a collagen model using isambard and convert every third
    residue to hydroxyproline:

    >>> import isambard
    >>> col = isambard.specifications.CoiledCoil.tropocollagen(aa=21)
    >>> col.pack_new_sequences(['GPPGPPGPPGPPGPPGPPGPP']*3)
    >>> to_convert = [
    ...     res for (i, res) in enumerate(col.get_monomers())
    ...     if not (i + 1) % 3]
    >>> for pro in to_convert:
    ...     isambard.ampal.non_canonical.convert_pro_to_hyp(pro)
    >>> col.sequences
    ['GPXGPXGPXGPXGPXGPXGPX', 'GPXGPXGPXGPXGPXGPXGPX', 'GPXGPXGPXGPXGPXGPXGPX']
    """
    with open(str(REF_PATH / 'hydroxyproline_ref_1bkv_0_6.pickle'), 'rb') as inf:
        hyp_ref = pickle.load(inf)
    align_nab(hyp_ref, pro)
    to_remove = ['CB', 'CG', 'CD']
    for (label, atom) in pro.atoms.items():
        if atom.element == 'H':
            to_remove.append(label)
    for label in to_remove:
        del pro.atoms[label]
    for key, val in hyp_ref.atoms.items():
        if key not in pro.atoms.keys():
            pro.atoms[key] = val
    pro.mol_code = 'HYP'
    pro.mol_letter = 'X'
    pro.is_hetero = True
    pro.tags = {}
    pro.states = {'A': pro.atoms}
    pro.active_state = 'A'
    for atom in pro.get_atoms():
        atom.ampal_parent = pro
        atom.tags = {'bfactor': 1.0, 'charge': ' ',
                     'occupancy': 1.0, 'state': 'A'}
    return