예제 #1
0
 def __init__(self, routines, outfile, options):
     self.pairEnergyResults = {}
     self.combinationCount = 0
     self.totalCombinations = 0
     self.options = options
     self.output = extensions.extOutputHelper(routines, outfile)
     self.routines = routines
예제 #2
0
 def __init__(self, routines, outfile, options):
     self.pairEnergyResults = {}
     self.combinationCount = 0
     self.totalCombinations = 0
     self.options = options
     self.output = extensions.extOutputHelper(routines, outfile)
     self.routines = routines
예제 #3
0
def create_rama_output(routines, outfile, outputtype='rama'):

    routines.write("\nPrinting %s angles for each residue...\n" %
                   (outputtype if outputtype != 'rama' else 'phi and psi'))
    verboseHeader = "Residue        %s\n" % (outputtype.capitalize(
    ) if outputtype != 'rama' else 'Phi          Psi')
    routines.write(verboseHeader)
    routines.write('-' * len(verboseHeader) + '\n')

    output = extensions.extOutputHelper(routines, outfile)

    # Initialize some variables

    protein = routines.protein

    for residue in protein.getResidues():
        if residue.hasAtom("N"):
            ncoords = residue.getAtom("N").getCoords()
        else:
            continue

        if residue.hasAtom("CA"):
            cacoords = residue.getAtom("CA").getCoords()
        else:
            continue

        if residue.hasAtom("C"):
            ccoords = residue.getAtom("C").getCoords()
        else:
            continue

        try:
            if residue.peptideN != None:
                pepncoords = residue.peptideN.getCoords()
            else:
                continue

            if residue.peptideC != None:
                pepccoords = residue.peptideC.getCoords()
            else:
                continue
        except AttributeError:  # Non amino acids
            continue

        output.write(str(residue))

        if outputtype in ('rama', 'phi'):
            phi = getDihedral(pepccoords, ncoords, cacoords, ccoords)
            output.write("\t%.4f" % phi)

        if outputtype in ('rama', 'psi'):
            psi = getDihedral(ncoords, cacoords, ccoords, pepncoords)
            output.write("\t%.4f" % psi)

        output.write('\n')

    routines.write("\n")
예제 #4
0
파일: rama.py 프로젝트: ASCM/apbs-pdb2pqr
def create_rama_output(routines, outfile, outputtype='rama'):

    routines.write("\nPrinting %s angles for each residue...\n" % (outputtype if outputtype != 'rama' else 'phi and psi'))
    verboseHeader = "Residue        %s\n"  % (outputtype.capitalize() if outputtype != 'rama' else 'Phi          Psi')
    routines.write(verboseHeader)
    routines.write('-' * len(verboseHeader) + '\n')
    
    output = extensions.extOutputHelper(routines, outfile)

    # Initialize some variables

    protein = routines.protein

    for residue in protein.getResidues():
        if residue.hasAtom("N"): 
            ncoords = residue.getAtom("N").getCoords()
        else: 
            continue

        if residue.hasAtom("CA"): 
            cacoords = residue.getAtom("CA").getCoords()
        else: 
            continue

        if residue.hasAtom("C"): 
            ccoords = residue.getAtom("C").getCoords()
        else: 
            continue

        try:
            if residue.peptideN != None:
                pepncoords = residue.peptideN.getCoords()
            else: 
                continue

            if residue.peptideC != None:
                pepccoords = residue.peptideC.getCoords()
            else: 
                continue
        except AttributeError: # Non amino acids
            continue

        output.write(str(residue))
        
        if outputtype in ('rama', 'phi'):
            phi = getDihedral(pepccoords, ncoords, cacoords, ccoords)
            output.write("\t%.4f" % phi)
            
        if outputtype in ('rama', 'psi'):
            psi = getDihedral(ncoords, cacoords, ccoords, pepncoords)
            output.write("\t%.4f" % psi)
            
        output.write('\n')

    routines.write("\n")
예제 #5
0
def create_summary_output(routines, outfile):
    """
    Output the interaction energy between each possible residue pair.
    """
    routines.write("Printing protein summary...\n")

    output = extensions.extOutputHelper(routines, outfile)

    output.write(routines.protein.getSummary() + '\n')

    for residue in routines.protein.getResidues():
        output.write(str(residue) + '\n')
예제 #6
0
def create_summary_output(routines, outfile):
    """
    Output the interaction energy between each possible residue pair.
    """
    routines.write("Printing protein summary...\n")
    
    output = extensions.extOutputHelper(routines, outfile)
    
    output.write(routines.protein.getSummary() + '\n')
    
    for residue in routines.protein.getResidues():
        output.write(str(residue)+'\n')
예제 #7
0
def create_resinter_output(routines, outfile, options, 
                           residue_combinations=False,
                           all_residue_combinations=False):
    """
    Output the interaction energy between each possible residue pair.
    """
    routines.write("Printing residue interaction energies...\n")
    
    output = extensions.extOutputHelper(routines, outfile)
    
    if residue_combinations or all_residue_combinations:
        write_all_residue_interaction_energies_combinations(routines, output, options, 
                                                            all_residue_combinations=all_residue_combinations)
    else:
        save_residue_interaction_energies(routines.protein.getResidues(), output)
예제 #8
0
def create_resinter_output(routines,
                           outfile,
                           options,
                           residue_combinations=False,
                           all_residue_combinations=False):
    """
    Output the interaction energy between each possible residue pair.
    """
    routines.write("Printing residue interaction energies...\n")

    output = extensions.extOutputHelper(routines, outfile)

    if residue_combinations or all_residue_combinations:
        write_all_residue_interaction_energies_combinations(
            routines,
            output,
            options,
            all_residue_combinations=all_residue_combinations)
    else:
        save_residue_interaction_energies(routines.protein.getResidues(),
                                          output)
예제 #9
0
def create_hbond_output(routines, outfile, whatif=False, 
                                           angleCutoff=ANGLE_CUTOFF, 
                                           distanceCutoff=DIST_CUTOFF, 
                                           oldDistanceMethod=False):

    routines.write("Printing hydrogen bond list...\n")
    
    output = extensions.extOutputHelper(routines, outfile)
    
    cellsize = int(distanceCutoff + 1.0 + 1.0) 
    protein = routines.protein
    routines.setDonorsAndAcceptors()
    routines.cells = Cells(cellsize)
    routines.cells.assignCells(protein)

    for donor in protein.getAtoms():

        # Grab the list of donors
        if not donor.hdonor: 
            continue
        donorhs = []
        for bond in donor.bonds:
            if bond.isHydrogen(): 
                donorhs.append(bond)
        if donorhs == []: 
            continue

        # For each donor, grab all acceptors
        closeatoms = routines.cells.getNearCells(donor)
        for acc in closeatoms:
            if not acc.hacceptor: 
                continue
            if donor.residue == acc.residue: 
                continue
            
            #TODO: do we need to do this for plain hbond stuff?
            if whatif and (donor.residue.chainID == acc.residue.chainID): 
                continue
            
            # Do new style distance check
            if not oldDistanceMethod:
                dist = distance(donor.getCoords(), acc.getCoords())
                if dist > distanceCutoff:
                    continue
            
            for donorh in donorhs:

                # Do old style distance check       
                if oldDistanceMethod:
                    dist = distance(donorh.getCoords(), acc.getCoords())
                    if dist > distanceCutoff: 
                        continue
                    
                # Do angle check
                angle = getAngle(acc.getCoords(), donor.getCoords(), donorh.getCoords())
                if angle > angleCutoff: 
                    continue
                
                if whatif:
                    if (donor.tempFactor > 60.0): 
                        continue
                    if (acc.tempFactor > 60.0): 
                        continue
                    
                    thisBstring='B' if donor.isBackbone() else 'S'
                    thatBstring='B' if acc.isBackbone() else 'S'

                    score= (1.7/dist) * cos(angle * 3.142 / 180.0)
                    output.write(_residueString(donor.residue, donor.name))
                    output.write('-> ')
                    output.write(_residueString(acc.residue, acc.name))
                    output.write('Sym=   1 Val= %6.3lf  DA=%6.2f  DHA=%6.2f (%s-%s)\n' % 
                                 (score, dist, angle, thisBstring, thatBstring))
#                    outfile.write("%4d %-4s (%4d  ) %s     %-4s-> %4d %-4s (%4d  ) %s     %-4sSym=   1 Val= %6.3lf  DA=%6.2f  DHA=%6.2f (%s-%s)\n" % \
#                      (donor.residue.resSeq,donor.residue.name,donor.residue.resSeq, donor.residue.chainID,donor.name,acc.residue.resSeq,acc.residue.name,acc.residue.resSeq, acc.residue.chainID,acc.name, score, dist, angle, thisBstring, thatBstring)) 

                else:
                    s = "Donor: %s %s\tAcceptor: %s %s\tdist: %.2f\tAngle: %.2f\n" % \
                        (donor.residue, donor.name, acc.residue, acc.name, dist, angle)
                    output.write(s) 
                    
    routines.write("\n")