예제 #1
0
def tagged_pka_print(tag, s, labels):
    s = "%s %s" % (tag, s)
    s = s.replace('\n', '\n%s ' % tag)
    for label in labels:
        s = s.replace(label, '\033[31m%s\033[30m' % label)
    pka_print(s)
    return
예제 #2
0
    def protonate_protein(self, protein):
        """ Will protonate all atoms in the protein """

        pka_print('----- Protontion started -----')
        # Remove all currently present hydrogen atoms
        self.remove_all_hydrogen_atoms_from_protein(protein)
     
        # make bonds
        self.my_bond_maker.find_bonds_for_protein(protein)

        # set charges
        self.set_charges(protein)
        
        # protonate all atom
        non_H_atoms = []
        for chain in protein.chains:
            for residue in chain.residues:
                 if residue.resName.replace(' ','') not in ['N+','C-']:
                     for atom in residue.atoms:
                         non_H_atoms.append(atom)

        for atom in non_H_atoms:
            # if atom.resNumb ==35: #######################
            self.protonate_atom(atom)
            

        # fix hydrogen names
        self.set_proton_names(non_H_atoms)
                    
        return
예제 #3
0
def tagged_pka_print(tag, s, labels):
    s = "%s %s"%(tag,s)
    s = s.replace('\n','\n%s '%tag)
    for label in labels:
        s = s.replace(label, '\033[31m%s\033[30m'%label)
    pka_print(s)
    return
예제 #4
0
def printAlignment(names=None, alignment=None):
    """
    printing out alignment
    """
    str = \
"""
sequence alignment:
                        1         2         3         4         5         6         7         8         9        10
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
               .........|.........|.........|.........|.........|.........|.........|.........|.........|.........|
"""
    str = str[:-1]
    pka_print(str)
    for key1 in alignment.keys():
        for key2 in alignment[key1].keys():
            str = "    %s 100 %s 0" % (key2, "%")
            index = 0
            for code in alignment[key1][key2]['sequence']:
                index += 1
                if index % 100 == 0:
                    str += "\n               "
                str += "%s" % (code)
            pka_print(str)

        #pka_print(alignment[key])

    return
예제 #5
0
def printAlignment(names=None, alignment=None):
    """
    printing out alignment
    """
    str = \
"""
sequence alignment:
                        1         2         3         4         5         6         7         8         9        10
               1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
               .........|.........|.........|.........|.........|.........|.........|.........|.........|.........|
"""
    str = str[:-1]
    pka_print(str)
    for key1 in alignment.keys():
      for key2 in alignment[key1].keys():
        str = "    %s 100 %s 0" % (key2, "%")
        index = 0
        for code in alignment[key1][key2]['sequence']:
          index += 1
          if index%100 == 0:
            str += "\n               "
          str += "%s" % (code)
        pka_print(str)

      #pka_print(alignment[key])

    return
예제 #6
0
    def protonate_protein(self, protein):
        """ Will protonate all atoms in the protein """

        pka_print('----- Protontion started -----')
        # Remove all currently present hydrogen atoms
        self.remove_all_hydrogen_atoms_from_protein(protein)

        # make bonds
        self.my_bond_maker.find_bonds_for_protein(protein)

        # set charges
        self.set_charges(protein)

        # protonate all atom
        non_H_atoms = []
        for chain in protein.chains:
            for residue in chain.residues:
                if residue.resName.replace(' ', '') not in ['N+', 'C-']:
                    for atom in residue.atoms:
                        non_H_atoms.append(atom)

        for atom in non_H_atoms:
            # if atom.resNumb ==35: #######################
            self.protonate_atom(atom)

        # fix hydrogen names
        self.set_proton_names(non_H_atoms)

        return
예제 #7
0
def compareFoldingContributions(target=None, template=None, options=None):
    """
    1. check if pKa values are calculated
    2. calculate contributions to dG_fold
    3. read alignment
    4. calculate the difference
    5. printout sorted result
    """
    from mutate import readAlignmentFiles

    # checking that pKa values are available
    checkDonePKA(target, template)

    # reading alignment files
    alignment = readAlignmentFiles(filenames=options.alignment, mesophile=target.name, options=options)
    names = makeNameList(name=target.name, alignment=alignment, options=options)
    pka_print(names)
    printAlignment(names=names, alignment=alignment)

    # setup contribution differences
    positions = makeFoldingEnergyDifferences(target, template, alignment, names=names, options=options)

    # print out contribution differences
    printFoldingEnergyDifferences(positions, names=names, template=template, options=options)

    # print out suggested mutations
    suggestMutations(positions, names=names, template=template, options=options)

    return  None
예제 #8
0
    def protonate_ligand(self, ligand):
        """ Will protonate all atoms in the ligand """

        #pka_print('----- Protonation started -----')
        # Remove all currently present hydrogen atoms
        self.remove_all_hydrogen_atoms_from_ligand(ligand)

        pka_print(ligand)

        # make bonds
        self.my_bond_maker.find_bonds_for_ligand(ligand)

        # set charges
        self.set_ligand_charges(ligand)

        # protonate all atoms
        atoms = []
        for atom in ligand.atoms:
            if atom.type == 'atom':
                atoms.append(atom)
        for atom in atoms:
            self.protonate_atom(atom)
  
        # fix hydrogen names
        self.set_proton_names(ligand.atoms)
                    
        return
예제 #9
0
def printResidues(residue_list):
    """
    Prints out determinant information for debugging
    """
    pka_print("  --- debug residue list --- ")
    for residue in residue_list:
        residue.printLabel()
예제 #10
0
    def set_charges(self, protein, standard_protonation_states = 1):
        if standard_protonation_states:
            # set side chain charges
            for chain in protein.chains:
                for residue in chain.residues:
                    for atom in residue.atoms:
                        key = '%3s-%s'%(atom.resName, atom.name)
                        if key in list(self.standard_charges.keys()):
                            atom.charge = self.standard_charges[key]
                            #pka_print('Charge', atom, atom.charge)

            # set n-terminal charges
            for chain in protein.chains:
                for residue in chain.residues:
                    if residue.resName.replace(' ','') == 'N+':
                        for atom in residue.atoms:
                            if atom.name == 'N':
                                atom.charge = self.standard_charges['NTERM']
                                #pka_print('Charge', atom, atom.charge)

            # set c-terminal charges
            for chain in protein.chains:
                for residue in chain.residues:
                    if residue.resName.replace(' ','') == 'C-':
                        for atom in residue.atoms:
                            if atom.name in self.my_bond_maker.terminal_oxygen_names: 
                                atom.charge = self.standard_charges['CTERM']
                                #pka_print('Charge', atom, atom.charge)

        else:
            pka_print('Custom protonation state choosen - don\'t know what to do')

        return
예제 #11
0
def printResidues(residue_list):
    """
    Prints out determinant information for debugging
    """
    pka_print("  --- debug residue list --- ")
    for residue in residue_list:
        residue.printLabel()
예제 #12
0
def printCooArgAtomDistances(residue_coo, residue_arg):
    """
    printing out all COO and ARG distances for debugging, picking closest + runner-up
    """
    for atom_coo in residue_coo.makeDeterminantAtomList(residue_arg.resName):
      for atom_arg in residue_arg.makeDeterminantAtomList(residue_coo.resName):
        distance = calculate.InterAtomDistance(atom_coo, atom_arg)
        pka_print("%3s %3s %6.2lf" % (atom_coo.name, atom_arg.name, distance))
예제 #13
0
    def add_protons(self, atom):
        # decide which method to use
        #pka_print('PROTONATING',atom)
        if atom.steric_number in list(self.protonation_methods.keys()):
            self.protonation_methods[atom.steric_number](atom)
        else:
            pka_print('Warning: Do not have a method for protonating',atom,'(steric number: %d)'%atom.steric_number)

        return
예제 #14
0
def printBackBoneAtoms(list):
    """
    Prints out determinant information for debugging
    """
    pka_print("  --- debug back-bone atom list --- ")
    for atoms in list:
        label1 = "%s%4d%2s" % (atoms[0].resName, atoms[0].resNumb, atoms[0].chainID)
        label2 = "%s%4d%2s" % (atoms[1].resName, atoms[1].resNumb, atoms[1].chainID)
        pka_print("%s - %s" % (label1, label2))
예제 #15
0
    def set_bond_distance(self, a, element):
        d = 1.0
        if element in list(self.bond_lengths.keys()):
            d = self.bond_lengths[element]
        else:
            pka_print('WARNING: Bond length for %s not found, using the standard value of %f'%(element, d))

        a = a.rescale(d)

        return a
예제 #16
0
def printCooArgAtomDistances(residue_coo, residue_arg):
    """
    printing out all COO and ARG distances for debugging, picking closest + runner-up
    """
    for atom_coo in residue_coo.makeDeterminantAtomList(residue_arg.resName):
        for atom_arg in residue_arg.makeDeterminantAtomList(
                residue_coo.resName):
            distance = calculate.InterAtomDistance(atom_coo, atom_arg)
            pka_print("%3s %3s %6.2lf" %
                      (atom_coo.name, atom_arg.name, distance))
예제 #17
0
def printBackBoneAtoms(list):
    """
    Prints out determinant information for debugging
    """
    pka_print("  --- debug back-bone atom list --- ")
    for atoms in list:
        label1 = "%s%4d%2s" % (atoms[0].resName, atoms[0].resNumb,
                               atoms[0].chainID)
        label2 = "%s%4d%2s" % (atoms[1].resName, atoms[1].resNumb,
                               atoms[1].chainID)
        pka_print("%s - %s" % (label1, label2))
예제 #18
0
def bracketingPI(protein, bracket=[0.0, 14.0]):
    """
    Calculates the pI using 'bracketing'
    """
    iter = 0
    pI = [0., 0.]
    Q_min = [0., 0.]
    Q_max = [0., 0.]
    pI_min = [bracket[0], bracket[0]]
    pI_max = [bracket[1], bracket[1]]
    Q_min[0], Q_min[1] = protein.calculateCharge(0.00)
    Q_max[0], Q_max[1] = protein.calculateCharge(14.00)
    while True:
        pI[0] = random.uniform(pI_min[0], pI_max[0])
        pI[1] = random.uniform(pI_min[1], pI_max[1])
        Q = []
        Q.append(protein.calculateCharge(pI[0]))
        Q.append(protein.calculateCharge(pI[1]))
        # folded structure
        if Q[0][0] > 0.00:
            pI_min[0] = pI[0]
            Q_min[0] = Q[0][0]
        else:
            pI_max[0] = pI[0]
            Q_max[0] = Q[0][0]
        if True:
            if Q[1][0] > 0.00 and Q[1][0] < Q_min[0]:
                pI_min[0] = pI[1]
                Q_min[0] = Q[1][0]
            elif Q[1][0] < 0.00 and Q[1][0] > Q_max[0]:
                pI_max[0] = pI[1]
                Q_max[0] = Q[1][0]
        # unfolded structure
        if Q[1][1] > 0.00:
            pI_min[1] = pI[1]
            Q_min[1] = Q[1][1]
        else:
            pI_max[1] = pI[1]
            Q_max[1] = Q[1][1]
        if True:
            if Q[0][1] > 0.00 and Q[0][1] < Q_min[1]:
                pI_min[1] = pI[0]
                Q_min[1] = Q[0][1]
            elif Q[0][1] < 0.00 and Q[0][1] > Q_max[1]:
                pI_max[1] = pI[0]
                Q_max[1] = Q[0][1]
        iter += 1
        pka_print("%4d protein = %6.2lf [%6.2lf%6.2lf] [%6.2lf%6.2lf]" %
                  (iter, pI[0], Q_min[0], Q_max[0], pI_min[0], pI_max[0]))
        if Q_min[0] <  0.005 and Q_min[1] <  0.005 and \
           Q_max[0] > -0.005 and Q_max[1] > -0.005:
            break

    return pI[0], pI[1]
예제 #19
0
    def set_ligand_charges(self, ligand, standard_protonation_states = 1):
        if standard_protonation_states:
            for atom in ligand.atoms:
                #pka_print('Charge before', atom, atom.charge)
                if atom.name in list(self.sybyl_charges.keys()):
                    atom.charge = self.sybyl_charges[atom.name]
                    #pka_print('Charge', atom, atom.charge)

        else:
            pka_print('Custom protonation state choosen - don\'t know what to do')
        
        return
예제 #20
0
def get_interaction(residue1, residue2, include_side_chain_hbs = True):
    determinants = residue1.determinants[2]
    if include_side_chain_hbs:
        determinants = residue1.determinants[0] + residue1.determinants[2]

    interaction_energy = 0.0    
    for det in determinants:
        if residue2.label == det.label:
            interaction_energy += det.value

    pka_print(' '.join((str(residue1), str(residue2), str(interaction_energy))))   

    return interaction_energy
예제 #21
0
    def trigonal(self, atom):
        pka_print('TRIGONAL - %d bonded atoms' % (len(atom.bonded_atoms)))
        rot_angle = math.radians(120.0)

        c = multi_vector(atom1=atom)

        # 0 bonds
        if len(atom.bonded_atoms) == 0:
            pass

        # 1 bond
        if len(atom.bonded_atoms) == 1 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first one
            a = multi_vector(atom1=atom, atom2=atom.bonded_atoms[0])
            # use plane of bonded trigonal atom - e.g. arg
            if atom.bonded_atoms[0].steric_number == 3 and len(
                    atom.bonded_atoms[0].bonded_atoms) > 1:
                # use other atoms bonded to the neighbour to establish the plane, if possible
                other_atom_indices = []
                for i in range(len(atom.bonded_atoms[0].bonded_atoms)):
                    if atom.bonded_atoms[0].bonded_atoms[i] != atom:
                        other_atom_indices.append(i)

                if len(other_atom_indices) < 2:
                    other_atom_indices = [0, 1]

                axis = multi_vector(
                    atom1=atom.bonded_atoms[0],
                    atom2=atom.bonded_atoms[0].bonded_atoms[
                        other_atom_indices[0]])**multi_vector(
                            atom1=atom.bonded_atoms[0],
                            atom2=atom.bonded_atoms[0].bonded_atoms[
                                other_atom_indices[1]])
            else:
                axis = a.orthogonal()

            a = rotate_multi_vector_around_an_axis(rot_angle, axis, a)
            a = self.set_bond_distance(a, atom.get_element())
            self.add_proton(atom, c + a)

        # 2 bonds
        if len(atom.bonded_atoms) == 2 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first two
            a = multi_vector(atom1=atom, atom2=atom.bonded_atoms[1])
            b = multi_vector(atom1=atom, atom2=atom.bonded_atoms[0])
            axis = b**a
            new_a = rotate_multi_vector_around_an_axis(rot_angle, axis, a)
            new_a = self.set_bond_distance(new_a, atom.get_element())
            self.add_proton(atom, c + new_a)

        return
예제 #22
0
def get_interaction(residue1, residue2, include_side_chain_hbs=True):
    determinants = residue1.determinants[2]
    if include_side_chain_hbs:
        determinants = residue1.determinants[0] + residue1.determinants[2]

    interaction_energy = 0.0
    for det in determinants:
        if residue2.label == det.label:
            interaction_energy += det.value

    pka_print(' '.join(
        (str(residue1), str(residue2), str(interaction_energy))))

    return interaction_energy
예제 #23
0
    def tetrahedral(self, atom):
        pka_print('TETRAHEDRAL - %d bonded atoms' % (len(atom.bonded_atoms)))
        rot_angle = math.radians(109.5)

        # sanity check
        # if atom.number_of_protons_to_add + len(atom.bonded_atoms) != 4:
        # print 'Error: Attempting tetrahedral structure with %d bonds'%(atom.number_of_protons_to_add +
        #                                                                len(atom.bonded_atoms))

        c = multi_vector(atom1=atom)

        # 0 bonds
        if len(atom.bonded_atoms) == 0:
            pass

        # 1 bond
        if len(atom.bonded_atoms) == 1 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first one
            a = multi_vector(atom1=atom, atom2=atom.bonded_atoms[0])
            axis = a.orthogonal()
            a = rotate_multi_vector_around_an_axis(rot_angle, axis, a)
            a = self.set_bond_distance(a, atom.get_element())
            self.add_proton(atom, c + a)

        # 2 bonds
        if len(atom.bonded_atoms) == 2 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first two
            a = multi_vector(atom1=atom, atom2=atom.bonded_atoms[1])
            axis = multi_vector(atom1=atom.bonded_atoms[0], atom2=atom)
            new_a = rotate_multi_vector_around_an_axis(math.radians(120), axis,
                                                       a)
            new_a = self.set_bond_distance(new_a, atom.get_element())
            self.add_proton(atom, c + new_a)

        # 3 bonds
        if len(atom.bonded_atoms) == 3 and atom.number_of_protons_to_add > 0:
            a = multi_vector(atom1=atom, atom2=atom.bonded_atoms[2])
            axis = multi_vector(atom1=atom.bonded_atoms[0], atom2=atom)
            b = multi_vector(atom1=atom, atom2=atom.bonded_atoms[1])
            cross = b**axis
            angle = math.radians(120)
            if angle_degrees(cross.vectors[0], a.vectors[0]) < 90:
                angle = -angle
            new_a = rotate_multi_vector_around_an_axis(angle, axis, a)
            new_a = self.set_bond_distance(new_a, atom.get_element())
            self.add_proton(atom, c + new_a)

        return
예제 #24
0
    def trigonal(self, atom):
        pka_print('TRIGONAL - %d bonded atoms'%(len(atom.bonded_atoms))) 
        rot_angle = math.radians(120.0)

        c = multi_vector(atom1 = atom)

        # 0 bonds
        if len(atom.bonded_atoms) == 0:
            pass
        
        # 1 bond
        if len(atom.bonded_atoms) == 1 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first one
            a = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[0])
            # use plane of bonded trigonal atom - e.g. arg
            if atom.bonded_atoms[0].steric_number == 3 and len(atom.bonded_atoms[0].bonded_atoms)>1:
                # use other atoms bonded to the neighbour to establish the plane, if possible
                other_atom_indices = []
                for i in range(len(atom.bonded_atoms[0].bonded_atoms)):
                    if atom.bonded_atoms[0].bonded_atoms[i] != atom:
                        other_atom_indices.append(i)

                if len(other_atom_indices)<2:
                    other_atom_indices = [0,1]

                axis = multi_vector(atom1 = atom.bonded_atoms[0], 
                              atom2 = atom.bonded_atoms[0].bonded_atoms[other_atom_indices[0]]
                              )**multi_vector(atom1 = atom.bonded_atoms[0], 
                                              atom2 = atom.bonded_atoms[0].bonded_atoms[other_atom_indices[1]])
            else:
                axis = a.orthogonal()

            a = rotate_multi_vector_around_an_axis(rot_angle, axis, a)
            a = self.set_bond_distance(a, atom.get_element())
            self.add_proton(atom, c+a)

        # 2 bonds
        if len(atom.bonded_atoms) == 2 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first two 
            a = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[1])
            b = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[0])
            axis = b**a
            new_a = rotate_multi_vector_around_an_axis(rot_angle, axis, a)
            new_a = self.set_bond_distance(new_a, atom.get_element())
            self.add_proton(atom, c+new_a)


        return
예제 #25
0
    def tetrahedral(self, atom):
        pka_print('TETRAHEDRAL - %d bonded atoms'%(len(atom.bonded_atoms))) 
        rot_angle = math.radians(109.5)

        # sanity check
        # if atom.number_of_protons_to_add + len(atom.bonded_atoms) != 4:
        # print 'Error: Attempting tetrahedral structure with %d bonds'%(atom.number_of_protons_to_add + 
        #                                                                len(atom.bonded_atoms))
        
        c = multi_vector(atom1 = atom)

        # 0 bonds
        if len(atom.bonded_atoms) == 0:
            pass
        
        # 1 bond
        if len(atom.bonded_atoms) == 1 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first one
            a = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[0])
            axis = a.orthogonal()
            a = rotate_multi_vector_around_an_axis(rot_angle, axis, a)
            a = self.set_bond_distance(a, atom.get_element())
            self.add_proton(atom, c+a)

        # 2 bonds
        if len(atom.bonded_atoms) == 2 and atom.number_of_protons_to_add > 0:
            # Add another atom with the right angle to the first two 
            a = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[1])
            axis = multi_vector(atom1 = atom.bonded_atoms[0],atom2 = atom)
            new_a = rotate_multi_vector_around_an_axis(math.radians(120), axis, a)
            new_a = self.set_bond_distance(new_a, atom.get_element())
            self.add_proton(atom, c+new_a)

        # 3 bonds
        if len(atom.bonded_atoms) == 3 and atom.number_of_protons_to_add > 0:
            a = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[2])
            axis = multi_vector(atom1 = atom.bonded_atoms[0],atom2 = atom)
            b = multi_vector(atom1 = atom, atom2 = atom.bonded_atoms[1])
            cross = b**axis
            angle = math.radians(120)
            if angle_degrees(cross.vectors[0],a.vectors[0]) < 90:
                angle = -angle
            new_a = rotate_multi_vector_around_an_axis(angle, axis, a)
            new_a = self.set_bond_distance(new_a, atom.get_element())
            self.add_proton(atom, c+new_a)

      
        return
예제 #26
0
def TmProfile(protein,
              reference="neutral",
              grid=[0., 14., 0.1],
              Tm=None,
              Tms=None,
              ref=None,
              options=None):
    """
    Calculates the folding profile
    """
    Nres = 0
    for chain in protein.chains:
        Nres += len(chain.residues)
    dS = 0.0173 * Nres
    pH_ref = 5.0
    dG_ref = protein.calculateFoldingEnergy(pH_ref, reference=reference)
    if ref == None:
        Tm_ref = 0.00
        if Tms == None:
            Tm_list = [Tm]
        else:
            Tm_list = Tms
        number_of_Tms = float(len(Tm_list))
        ave_diff = 1.0
        while abs(ave_diff) > 0.005:
            ave_diff = 0.00
            for pH, Tm in Tm_list:
                dG = protein.calculateFoldingEnergy(pH, reference=reference)
                dTm = -4.187 * (dG - dG_ref) / dS
                Tm_calc = Tm_ref + dTm
                ave_diff += (Tm_calc - Tm) / number_of_Tms
                #Tm_ref -= (Tm_old+dTm - Tm)/(2*number_of_Tms)
            Tm_ref -= ave_diff
            #pka_print("%6.2lf %6.2lf %6.2lf" % (Tm_ref, ave_diff, Tm_ref - Tm_old))
    else:
        dTm_ref = -4.187 * (dG_ref - ref[2]) / dS
        Tm_ref = ref[1] + dTm_ref

    pka_print("ref = %6.2lf%6.2lf%6.2lf" % (pH_ref, Tm_ref, dG_ref))
    profile = []
    pH, end, increment = grid
    while pH <= end:
        dG = protein.calculateFoldingEnergy(pH, reference=reference)
        dTm = -4.187 * (dG - dG_ref) / dS
        profile.append([pH, Tm_ref + dTm])
        pH += increment

    return profile
예제 #27
0
def radialVolumeDesolvation(residue, atoms, version, options=None):
    """
    calculates the desolvation according to the ScaledRadialVolumeModel
    """
    if residue.label == "BKB  50 A":
      pka_print("found %s [%6.3lf%6.3lf%6.3lf]!" % (residue.label, residue.x, residue.y, residue.z))
      pka_print("buried_cutoff_sqr = %s!" % (version.buried_cutoff_sqr))
      pka_print("desolv_cutoff_sqr = %s!" % (version.desolv_cutoff_sqr))
    scale_factor = 0.8527*1.36  # temporary weight for printing out contributions
    residue.Nlocl = 0
    residue.Nmass = 0
    residue.Elocl = 0.00
    dV            = 0.00
    volume        = 0.00
    min_distance_4th = pow(2.75, 4)
    for chainID in atoms.keys():
      for key in atoms[chainID]["keys"]:
        for atom in atoms[chainID][key]:
          if atom.element != "H":
            if atom.resNumb != residue.resNumb or atom.chainID != residue.chainID:
                # selecting atom type
                if   atom.name in ["C", "CA"]:
                  atomtype = "C"
                elif atom.name in ["N", "NE1", "NE2", "ND1", "ND2", "NZ", "NE", "NH1", "NH2"]:
                  atomtype = "N"
                elif atom.name in ["O", "OD1", "OD2", "OE1", "OE2", "OH", "OG", "OG1", "OXT"]:
                  atomtype = "O"
                elif atom.name in ["S", "SD", "SG"]:
                  atomtype = "S"
                else:
                  atomtype = "C4"
                dV = version.desolvationVolume[atomtype]
                # calculating distance (atom - residue)
                dX = atom.x - residue.x
                dY = atom.y - residue.y
                dZ = atom.z - residue.z
                distance_sqr = dX*dX + dY*dY + dZ*dZ
                if  distance_sqr < version.desolv_cutoff_sqr:
                  dV_inc  = dV/max(min_distance_4th, distance_sqr*distance_sqr)
                  volume += dV_inc
                  if residue.label in ["ASP   8 a", "ASP  10 a", "GLU 172 a", "ASP  92 a", "GLU  66 a"]:
                    # test printout
                    distance = max(2.75, math.sqrt(distance_sqr))
                    if distance < 20.0:
                      str  = "%6.2lf %8.4lf" % (distance, residue.Q * version.desolvationPrefactor * max(0.00, dV_inc)*scale_factor)
                      str += " %s" % (atomtype)
                      #str += " %s" % (residue.label)
                      pka_print(str)
                if distance_sqr < version.buried_cutoff_sqr:
                  residue.Nmass += 1
                  residue.Vmass += dV
    weight = version.calculateWeight(residue.Nmass)
    scale_factor = 1.0 - (1.0 - version.desolvationSurfaceScalingFactor)*(1.0 - weight)
    residue.buried = weight
    residue.Emass = residue.Q * version.desolvationPrefactor * max(0.00, volume-version.desolvationAllowance) * scale_factor

    return 0.00, 0.00, 0.00, 0.00
예제 #28
0
    def protonateBackBone(self, residue, C, O):
        """
        Protonates an atom, X1, given a direction (X2 -> X3) [X1, X2, X3]
        """
        N = residue.getAtom(name='N')

        if C == None and O == None:
          """ do nothing, first residue """
        elif N == None:
          pka_print( "could not find N atom in '%s' (protonateBackBone())" % (residue.label) ); sys.exit(9)
        elif residue.resName == "PRO":
          """ do nothing, proline doesn't have a proton """
        else:
          H = self.protonateDirection(atoms=[N, O, C])
          residue.atoms.append(H)

        return  residue.getAtom(name='C'), residue.getAtom(name='O')
예제 #29
0
def bracketingPI(protein, bracket=[0.0, 14.0]):
    """
    Calculates the pI using 'bracketing'
    """
    iter = 0
    pI     = [0., 0.]
    Q_min  = [0., 0.]; Q_max  = [0., 0.]
    pI_min = [bracket[0], bracket[0]]; pI_max = [bracket[1], bracket[1]]
    Q_min[0], Q_min[1] = protein.calculateCharge( 0.00)
    Q_max[0], Q_max[1] = protein.calculateCharge(14.00)
    while True:
      pI[0] = random.uniform(pI_min[0], pI_max[0])
      pI[1] = random.uniform(pI_min[1], pI_max[1])
      Q = []
      Q.append(protein.calculateCharge(pI[0]))
      Q.append(protein.calculateCharge(pI[1]))
      # folded structure
      if Q[0][0] > 0.00:
        pI_min[0] = pI[0]; Q_min[0] = Q[0][0]
      else:
        pI_max[0] = pI[0]; Q_max[0] = Q[0][0]
      if True:
        if Q[1][0] > 0.00 and Q[1][0] < Q_min[0]:
          pI_min[0] = pI[1]; Q_min[0] = Q[1][0]
        elif Q[1][0] < 0.00 and Q[1][0] > Q_max[0]:
          pI_max[0] = pI[1]; Q_max[0] = Q[1][0]
      # unfolded structure
      if Q[1][1] > 0.00:
        pI_min[1] = pI[1]; Q_min[1] = Q[1][1]
      else:
        pI_max[1] = pI[1]; Q_max[1] = Q[1][1]
      if True:
        if Q[0][1] > 0.00 and Q[0][1] < Q_min[1]:
          pI_min[1] = pI[0]; Q_min[1] = Q[0][1]
        elif Q[0][1] < 0.00 and Q[0][1] > Q_max[1]:
          pI_max[1] = pI[0]; Q_max[1] = Q[0][1]
      iter += 1
      pka_print("%4d protein = %6.2lf [%6.2lf%6.2lf] [%6.2lf%6.2lf]" % (iter, pI[0], Q_min[0], Q_max[0], pI_min[0], pI_max[0]))
      if Q_min[0] <  0.005 and Q_min[1] <  0.005 and \
         Q_max[0] > -0.005 and Q_max[1] > -0.005:
        break

    return pI[0], pI[1]
예제 #30
0
def compareFoldingContributions(target=None, template=None, options=None):
    """
    1. check if pKa values are calculated
    2. calculate contributions to dG_fold
    3. read alignment
    4. calculate the difference
    5. printout sorted result
    """
    from mutate import readAlignmentFiles

    # checking that pKa values are available
    checkDonePKA(target, template)

    # reading alignment files
    alignment = readAlignmentFiles(filenames=options.alignment,
                                   mesophile=target.name,
                                   options=options)
    names = makeNameList(name=target.name,
                         alignment=alignment,
                         options=options)
    pka_print(names)
    printAlignment(names=names, alignment=alignment)

    # setup contribution differences
    positions = makeFoldingEnergyDifferences(target,
                                             template,
                                             alignment,
                                             names=names,
                                             options=options)

    # print out contribution differences
    printFoldingEnergyDifferences(positions,
                                  names=names,
                                  template=template,
                                  options=options)

    # print out suggested mutations
    suggestMutations(positions,
                     names=names,
                     template=template,
                     options=options)

    return None
예제 #31
0
def interactionMatrix(interaction):
    """
    printing out all information in resInfo
    """
    keys = ["COO", "CYS", "TYR", "HIS", "N+ ", "LYS", "ARG", "ROH", "AMD", "TRP"]

    pka_print("interaction matrix:")
    for key1 in keys:
      str = "%6s:" % (key1)
      for key2 in keys:
        do_pair, iterative = interaction[key1][key2]
        if   do_pair == True and iterative == True:
          str += "%3s" % ("I")
        elif do_pair == True and iterative == False:
          str += "%3s" % ("N")
        else:
          str += "%3s" % ("-")

      pka_print(str)
예제 #32
0
def pI(protein, pI=7.0, options=None):
    """
    Calculates the iso electric point
    """
    pI_pro = pI - 0.50
    pI_mod = pI + 0.50
    Q1_pro, Q1_mod = protein.calculateCharge(pI_pro)
    Q2_pro, Q2_mod = protein.calculateCharge(pI_mod)
    iter = 0

    while abs(Q1_pro) > 0.005 and abs(Q2_mod) > 0.005:
        if iter == 50:
            pka_print(
                "pI iterations did not converge after %d iterations %s, switching to bracketing"
                % (iter, protein.name))
            pI_pro, pI_mod = bracketingPI(protein)
            break
        else:
            iter += 1
        if abs(pI_pro - pI_mod) < 0.010:
            shift_pro = random.random() * 0.02 - 0.01
            shift_mod = random.random() * 0.02 - 0.01
            shift = (shift_pro - shift_mod)
            pI_pro += shift_pro
            pI_mod += shift_mod
        Q1_pro, Q1_mod = protein.calculateCharge(pI_pro)
        Q2_pro, Q2_mod = protein.calculateCharge(pI_mod)
        k1 = (Q1_pro - Q2_pro) / (pI_pro - pI_mod)
        k2 = (Q2_mod - Q1_mod) / (pI_mod - pI_pro)
        shift = -Q1_pro / k1
        if abs(shift) > 4.0:
            shift = shift / abs(shift)
        pI_pro += shift
        shift = -Q2_mod / k2
        if abs(shift) > 4.0:
            shift = shift / abs(shift)
        pI_mod += shift
        #pka_print("%4d%8.3lf%8.3lf" % (iter, pI_pro, pI_mod))
    #if options.verbose == True:
    #  pka_print("%10d pI iterations" % (iter))

    return pI_pro, pI_mod
예제 #33
0
def main():
    """
    Simple check on the corresponding atoms-dictionary
    """

    corresponding_atoms = makeCorrespondingAtomNames()

    resNames = residueList("standard")

    for resName1 in resNames:
        for resName2 in resNames:
            str = "%s %s \n" % (resName1, resName2)
            for i in range(len(corresponding_atoms[resName1][resName2])):
                name1, name2 = corresponding_atoms[resName1][resName2][i]
                str += " %-3s %-3s" % (name1, name2)
                name1, name2 = corresponding_atoms[resName2][resName1][i]
                str += "%-5s %-3s %-3s\n" % (" ", name1, name2)
            pka_print(str)
            if resName1 == resName2:
                break
예제 #34
0
def main():
    """
    Simple check on the corresponding atoms-dictionary
    """

    corresponding_atoms = makeCorrespondingAtomNames()

    resNames = residueList("standard")

    for resName1 in resNames:
      for resName2 in resNames:
        str = "%s %s \n" % (resName1, resName2)
        for i in range(len(corresponding_atoms[resName1][resName2])):
          name1, name2 = corresponding_atoms[resName1][resName2][i]
          str += " %-3s %-3s" % (name1, name2)
          name1, name2 = corresponding_atoms[resName2][resName1][i]
          str += "%-5s %-3s %-3s\n" % (" ", name1, name2)
        pka_print(str)
        if resName1 == resName2:
          break
예제 #35
0
def TmProfile(protein, reference="neutral", grid=[0., 14., 0.1], Tm=None, Tms=None, ref=None, options=None):
    """
    Calculates the folding profile
    """
    Nres = 0
    for chain in protein.chains:
      Nres += len(chain.residues)
    dS = 0.0173*Nres
    pH_ref = 5.0; dG_ref = protein.calculateFoldingEnergy(pH_ref, reference=reference)
    if ref == None:
      Tm_ref = 0.00
      if Tms == None:
        Tm_list = [Tm]
      else:
        Tm_list = Tms
      number_of_Tms = float(len(Tm_list))
      ave_diff = 1.0
      while abs(ave_diff) > 0.005:
        ave_diff = 0.00
        for pH, Tm in Tm_list:
          dG = protein.calculateFoldingEnergy(pH, reference=reference)
          dTm = -4.187*(dG - dG_ref)/dS
          Tm_calc = Tm_ref+dTm
          ave_diff += (Tm_calc - Tm)/number_of_Tms
          #Tm_ref -= (Tm_old+dTm - Tm)/(2*number_of_Tms)
        Tm_ref -= ave_diff
        #pka_print("%6.2lf %6.2lf %6.2lf" % (Tm_ref, ave_diff, Tm_ref - Tm_old))
    else:
      dTm_ref = -4.187*(dG_ref - ref[2])/dS
      Tm_ref = ref[1] + dTm_ref

    pka_print("ref = %6.2lf%6.2lf%6.2lf" % (pH_ref, Tm_ref, dG_ref))
    profile = []
    pH, end, increment = grid
    while pH <= end:
      dG = protein.calculateFoldingEnergy(pH, reference=reference)
      dTm = -4.187*(dG - dG_ref)/dS
      profile.append([pH, Tm_ref+dTm])
      pH += increment

    return profile
예제 #36
0
def interactionMatrix(interaction):
    """
    printing out all information in resInfo
    """
    keys = [
        "COO", "CYS", "TYR", "HIS", "N+ ", "LYS", "ARG", "ROH", "AMD", "TRP"
    ]

    pka_print("interaction matrix:")
    for key1 in keys:
        str = "%6s:" % (key1)
        for key2 in keys:
            do_pair, iterative = interaction[key1][key2]
            if do_pair == True and iterative == True:
                str += "%3s" % ("I")
            elif do_pair == True and iterative == False:
                str += "%3s" % ("N")
            else:
                str += "%3s" % ("-")

        pka_print(str)
예제 #37
0
    def protonate_ligand(self, ligand):
        """ Will protonate all atoms in the ligand """

        pka_print('----- Protontion started -----')
        # Remove all currently present hydrogen atoms
        self.remove_all_hydrogen_atoms_from_ligand(ligand)

        pka_print(ligand)

        # make bonds
        self.my_bond_maker.find_bonds_for_ligand(ligand)

        #import sys
        #sys.exit(0)

        # set charges
        self.set_ligand_charges(ligand)


        pka_print('PROTONATING')
        # protonate all atoms
        atoms = []
        for atom in ligand.atoms:
            if not atom.get_element() in self.ions:
                atoms.append(atom)
        for atom in atoms:
            self.protonate_atom(atom)
  
        # fix hydrogen names
        self.set_proton_names(ligand.atoms)
                    

        return
예제 #38
0
def swap_interactions(residue1,
                      residue2,
                      include_side_chain_hbs=True,
                      verbose=True):

    if verbose:
        pka_print(' ' + '-' * 113)
        tagged_pka_print(' Original|', residue1.getDeterminantString(),
                         [residue1.label, residue2.label])
        tagged_pka_print(' Original|', residue2.getDeterminantString(),
                         [residue1.label, residue2.label])

    # swap the interactions!
    transfer_determinant(residue1.determinants[2], residue2.determinants[2],
                         residue1.label, residue2.label)
    if include_side_chain_hbs:
        transfer_determinant(residue1.determinants[0],
                             residue2.determinants[0], residue1.label,
                             residue2.label)

    #re-calculate pKa values
    residue1.calculateTotalPKA()
    residue2.calculateTotalPKA()

    if verbose:
        tagged_pka_print(' Swapped |', residue1.getDeterminantString(),
                         [residue1.label, residue2.label])
        tagged_pka_print(' Swapped |', residue2.getDeterminantString(),
                         [residue1.label, residue2.label])
        pka_print(' ' + '=' * 113)
        pka_print('')
    return
예제 #39
0
def pI(protein, pI=7.0, options=None):
    """
    Calculates the iso electric point
    """
    pI_pro = pI - 0.50
    pI_mod = pI + 0.50
    Q1_pro, Q1_mod = protein.calculateCharge(pI_pro)
    Q2_pro, Q2_mod = protein.calculateCharge(pI_mod)
    iter = 0

    while abs(Q1_pro) > 0.005 and abs(Q2_mod) > 0.005:
      if iter == 50:
        pka_print("pI iterations did not converge after %d iterations %s, switching to bracketing" % (iter, protein.name))
        pI_pro, pI_mod = bracketingPI(protein)
        break
      else:
        iter += 1
      if abs(pI_pro - pI_mod) < 0.010:
        shift_pro = random.random()*0.02 - 0.01
        shift_mod = random.random()*0.02 - 0.01
        shift = (shift_pro-shift_mod)
        pI_pro += shift_pro
        pI_mod += shift_mod
      Q1_pro, Q1_mod = protein.calculateCharge(pI_pro)
      Q2_pro, Q2_mod = protein.calculateCharge(pI_mod)
      k1 = (Q1_pro - Q2_pro)/(pI_pro - pI_mod)
      k2 = (Q2_mod - Q1_mod)/(pI_mod - pI_pro)
      shift = -Q1_pro/k1
      if abs(shift) > 4.0:
        shift = shift/abs(shift)
      pI_pro += shift
      shift = -Q2_mod/k2
      if abs(shift) > 4.0:
        shift = shift/abs(shift)
      pI_mod += shift
      #pka_print("%4d%8.3lf%8.3lf" % (iter, pI_pro, pI_mod))
    #if options.verbose == True:
    #  pka_print("%10d pI iterations" % (iter))

    return pI_pro, pI_mod
예제 #40
0
def printFoldingEnergyDifferences(positions,
                                  names=None,
                                  template=None,
                                  options=None):
    """
    making an array with folding energy differences and related information
    """
    pka_print("\n the most stabilizing differences: (kcal/mol)")
    pka_print("-" * 64)
    sorted_positions = sortAccordingToMin(positions, key=names[1])

    i_position = 0
    for position in sorted_positions:
        target_label = position[names[0]]['label']
        template_label = position[names[1]]['label']
        difference = position[names[1]]['difference']
        str = "%5d    %s   ->   %s  %6.2lf   " % (i_position, target_label,
                                                  template_label, difference)
        if difference < -0.50:
            str += suggestMutation(positions=positions,
                                   label=template_label,
                                   names=names,
                                   template=template,
                                   options=options)
        pka_print(str)
        i_position += 1

    return
예제 #41
0
    def protonate_ligand(self, ligand):
        """ Will protonate all atoms in the ligand """

        pka_print('----- Protontion started -----')
        # Remove all currently present hydrogen atoms
        self.remove_all_hydrogen_atoms_from_ligand(ligand)

        pka_print(ligand)

        # make bonds
        self.my_bond_maker.find_bonds_for_ligand(ligand)

        #import sys
        #sys.exit(0)

        # set charges
        self.set_ligand_charges(ligand)

        pka_print('PROTONATING')
        # protonate all atoms
        atoms = []
        for atom in ligand.atoms:
            if not atom.get_element() in self.ions:
                atoms.append(atom)
        for atom in atoms:
            self.protonate_atom(atom)

        # fix hydrogen names
        self.set_proton_names(ligand.atoms)

        return
예제 #42
0
    def add_proton(self, atom, position):
        residue = atom.residue
        #pka_print(residue)
        # Create the new proton
        new_H = pdb.Atom()
        new_H.setProperty(numb=None,
                          name='H',
                          resName=atom.resName,
                          chainID=atom.chainID,
                          resNumb=atom.resNumb,
                          x=None,
                          y=None,
                          z=None,
                          occ=None,
                          beta=None)
        new_H.element = 'H'

        pka_print(position)
        # set all the configurations
        for i in range(len(position.keys)):
            #print ('adding',position.keys[i],position.vectors[i])
            new_H.configurations[position.keys[i]] = [
                position.vectors[i].x, position.vectors[i].y,
                position.vectors[i].z
            ]
        new_H.setConfiguration(position.keys[0])

        new_H.bonded_atoms = []
        new_H.charge = 0
        new_H.steric_number = 0
        new_H.number_of_lone_pairs = 0
        new_H.number_of_protons_to_add = 0
        new_H.number_of_pi_electrons_in_double_and_triple_bonds = 0

        residue.atoms.append(new_H)
        atom.bonded_atoms.append(new_H)
        atom.number_of_protons_to_add -= 1
        pka_print('added', new_H, 'to', atom)
        return
예제 #43
0
    def add_proton(self, atom, position):
        residue = atom.residue
        #pka_print(residue)
        # Create the new proton
        new_H = pdb.Atom()
        new_H.setProperty(numb    = None, 
                          name    = 'H', 
                          resName = atom.resName, 
                          chainID = atom.chainID,
                          resNumb = atom.resNumb,
                          x       = None,
                          y       = None,
                          z       = None,
                          occ     = None,
                          beta    = None)
        new_H.element = 'H'


        pka_print(position)
        # set all the configurations
        for i in range(len(position.keys)):
            #print ('adding',position.keys[i],position.vectors[i])
            new_H.configurations[position.keys[i]] = [position.vectors[i].x, 
                                                      position.vectors[i].y, 
                                                      position.vectors[i].z]
        new_H.setConfiguration(position.keys[0])

        new_H.bonded_atoms = []
        new_H.charge = 0
        new_H.steric_number = 0
        new_H.number_of_lone_pairs = 0
        new_H.number_of_protons_to_add = 0
        new_H.number_of_pi_electrons_in_double_and_triple_bonds = 0
        
        residue.atoms.append(new_H)
        atom.bonded_atoms.append(new_H)
        atom.number_of_protons_to_add -=1
        pka_print('added',new_H, 'to',atom)
        return
예제 #44
0
def printAlignment(alignment):
    """
    Prints out alignment information for debugging
    """
    for key in alignment.keys():
      pka_print( " --- %s ---" % (key) )
      for key2 in alignment[key].keys():
        pka_print("%s %5d%2s" % (alignment[key][key2]["name"], alignment[key][key2]["resNumb"], alignment[key][key2]["chainID"]))
        pka_print("%s\n" % (alignment[key][key2]["sequence"]))
예제 #45
0
def printResInfo(resInfo):
    """
    printing out all information in resInfo
    """
    pka_print("in resInfo:")
    for key1 in resInfo.keys():
        pka_print(" --- %s ---" % (key1))
        for key2 in resInfo[key1].keys():
            pka_print(key2, resInfo[key1][key2])
예제 #46
0
def printResInfo(resInfo):
    """
    printing out all information in resInfo
    """
    pka_print("in resInfo:")
    for key1 in resInfo.keys():
      pka_print(" --- %s ---" % (key1))
      for key2 in resInfo[key1].keys():
        pka_print(key2, resInfo[key1][key2])
예제 #47
0
    def protonate(self, protein=None):
        """
        protonate a given protein
        """
        C = None; O = None

        for chain in protein.chains:
          C = None; O = None
          for residue in chain.residues:
            if residue.type == "amino-acid":
              C, O = self.protonateBackBone(residue, C, O)
              if   residue.resType == "AMD":
                self.protonateAMD(residue)
              elif residue.resType == "TRP":
                self.protonateTRP(residue)
              elif residue.resType == "HIS":
                self.protonateHIS(residue)
              elif residue.resType == "ARG":
                self.protonateARG(residue)
              elif residue.resName in self.protonate_residues:
                pka_print("no protocol to protonate '%s' in 'old-scheme'" % (residue.label))
                sys.exit(8)

        return
예제 #48
0
def makeFoldingEnergyDifferences(target,
                                 template,
                                 alignment,
                                 names=None,
                                 options=None):
    """
    making an array with folding energy differences and related information
    """
    number_of_positions = len(
        alignment[template.name][template.name]['sequence'])

    # setting up the list of sequence positions, initiated with dictionary
    positions = [{
        target.name: {},
        template.name: {}
    } for position in range(number_of_positions)]

    # setting residue labels and contributions to sequence positions
    for protein in [target, template]:
        i_position = 0
        for chain in protein.chains:
            for residue in chain.residues:
                while alignment[template.name][
                        protein.name]['sequence'][i_position] in ["-", "?"]:
                    position = positions[i_position]
                    position[protein.name]['label'] = "   gap   "
                    position[protein.name]['contribution'] = 0.00
                    i_position += 1
                if residue.resName == "N+ ":
                    position = positions[0]
                else:
                    position = positions[i_position]
                    i_position += 1
                position[protein.name]['label'] = residue.label
                position[protein.name][
                    'contribution'] = residue.calculateFoldingEnergy(
                        options=options)

    # filling position differences
    pka_print("\n unsorted contributions to the folding energy: (kcal/mol)")
    pka_print("-" * 64)
    i_position = 0
    for position in positions:
        str = "%5d  " % (i_position)
        for name in names:
            position[name]['difference'] = position[name][
                'contribution'] - position[names[0]]['contribution']
            str += "  %s" % (position[name]['label'])
            str += " %6.2lf" % (position[name]['contribution'])
            str += "    "
        pka_print(str)
        i_position += 1

    return positions
예제 #49
0
def printAlignment(alignment):
    """
    Prints out alignment information for debugging
    """
    for key in alignment.keys():
        pka_print(" --- %s ---" % (key))
        for key2 in alignment[key].keys():
            pka_print(
                "%s %5d%2s" %
                (alignment[key][key2]["name"], alignment[key][key2]["resNumb"],
                 alignment[key][key2]["chainID"]))
            pka_print("%s\n" % (alignment[key][key2]["sequence"]))
예제 #50
0
def suggestMutations(positions, names=None, template=None, options=None):
    """
    making an array with folding energy differences and related information
    """

    pka_print("\n suggesting mutations")
    pka_print("-" * 64)
    sorted_positions = sortAccordingToMin(positions, key=names[1])

    number = 0
    weight = None
    for position in sorted_positions:
        target_label = position[names[0]]['label']
        template_label = position[names[1]]['label']
        if position[names[1]]['difference'] > -0.5:
            break
        elif target_label == "   gap   " or template_label == "   gap   ":
            """ do nothing """
        elif target_label[:3] in ["C- ", "N+ "
                                  ] or template_label[:3] in ["C- ", "N+ "]:
            """ do nothing """
        else:
            number += 1
            roman = int2roman(number)
            determinant_labels = []
            mutation = makeMutationAddendum(target=target_label,
                                            template=template_label)
            #1. get residue
            residue = template.getResidue(label=template_label)
            #2. get determinants
            for determinants in [
                    residue.determinants[0], residue.determinants[2]
            ]:
                for determinant in determinants:
                    if determinant.label not in determinant_labels:
                        determinant_labels.append(determinant.label)
            #3. set together mutation
            weight = residue.buried
            for determinant_label in determinant_labels:
                target_label = getCorrespondingResidueLabel(
                    positions, key=names[1], label=determinant_label)
                if target_label != "   gap   " and target_label[:3] not in [
                        "C- ", "N+ "
                ]:
                    mutation += "/%s" % (makeMutationAddendum(
                        target=target_label, template=determinant_label))
                    residue = template.getResidue(label=determinant_label)
                    weight += residue.buried
            weight = int(100. * weight / (len(determinant_labels) + 1))
            pka_print(" %-5s %3d%2s   %s" % (roman, weight, "%", mutation))

    return
예제 #51
0
def checkDonePKA(target=None, template=None, alignment=None, options=None):
    """
    check if pKa values have been calculated for target and template
    """
    if target.status['done pka'] == False:
      pka_print("please calculate pKa values for target %s before comparing" % (target.name))
    if template.status['done pka'] == False:
      pka_print("please calculate pKa values for template %s before comparing" % (template.name))

    if target.status['done pka'] == True and template.status['done pka'] == True:
      if False:
        pka_print("target = %s, template = %s : pKas done" % (target.name, template.name))
    else:
      sys.exit(8)

    return
예제 #52
0
def makeFoldingEnergyDifferences(target, template, alignment, names=None, options=None):
    """
    making an array with folding energy differences and related information
    """
    number_of_positions = len(alignment[template.name][template.name]['sequence'])

    # setting up the list of sequence positions, initiated with dictionary
    positions = [{target.name: {}, template.name: {}} for position in range(number_of_positions)]

    # setting residue labels and contributions to sequence positions
    for protein in [target, template]:
      i_position = 0
      for chain in protein.chains:
        for residue in chain.residues:
          while alignment[template.name][protein.name]['sequence'][i_position] in ["-", "?"]:
            position = positions[i_position]
            position[protein.name]['label']        = "   gap   "
            position[protein.name]['contribution'] = 0.00
            i_position += 1
          if residue.resName == "N+ ":
            position = positions[0]
          else:
            position = positions[i_position]
            i_position += 1
          position[protein.name]['label']        = residue.label
          position[protein.name]['contribution'] = residue.calculateFoldingEnergy(options=options)

    # filling position differences
    pka_print("\n unsorted contributions to the folding energy: (kcal/mol)")
    pka_print("-"*64)
    i_position = 0
    for position in positions:
      str  = "%5d  " % (i_position)
      for name in names:
        position[name]['difference'] = position[name]['contribution'] - position[names[0]]['contribution']
        str += "  %s" % (position[name]['label'])
        str += " %6.2lf" % (position[name]['contribution'])
        str += "    "
      pka_print(str)
      i_position += 1


    return  positions
예제 #53
0
def suggestMutations(positions, names=None, template=None, options=None):
    """
    making an array with folding energy differences and related information
    """

    pka_print("\n suggesting mutations")
    pka_print("-"*64)
    sorted_positions = sortAccordingToMin(positions, key=names[1])

    number = 0; weight = None
    for position in sorted_positions:
      target_label   = position[names[0]]['label']
      template_label = position[names[1]]['label']
      if   position[names[1]]['difference'] > -0.5:
        break
      elif target_label == "   gap   " or template_label == "   gap   ":
        """ do nothing """
      elif target_label[:3] in ["C- ", "N+ "] or template_label[:3] in ["C- ", "N+ "]:
        """ do nothing """
      else:
        number +=1; roman = int2roman(number)
        determinant_labels = []
        mutation = makeMutationAddendum(target=target_label, template=template_label)
        #1. get residue
        residue = template.getResidue(label=template_label)
        #2. get determinants
        for determinants in [residue.determinants[0], residue.determinants[2]]:
          for determinant in determinants:
            if determinant.label not in determinant_labels:
              determinant_labels.append(determinant.label)
        #3. set together mutation
        weight = residue.buried
        for determinant_label in determinant_labels:
          target_label = getCorrespondingResidueLabel(positions, key=names[1], label=determinant_label)
          if target_label != "   gap   " and target_label[:3] not in ["C- ", "N+ "]:
            mutation += "/%s" % (makeMutationAddendum(target=target_label, template=determinant_label))
            residue = template.getResidue(label=determinant_label)
            weight += residue.buried
        weight = int( 100.*weight/(len(determinant_labels) + 1) )
        pka_print(" %-5s %3d%2s   %s" % (roman, weight, "%", mutation))

    return