def run_extension(routines, outroot, options):
    """
        Print a list of contacts.

        Parameters
            routines:  A link to the routines object
            outroot:   The root of the output name
            options:   options object 
    """
    outname = outroot + ".con"
    outfile = open(outname, "w")

    # Initialize - set nearby cells, donors/acceptors

    cellsize = int(DIST_CUTOFF + 1.0 + 1.0)
    protein = routines.protein
    routines.setDonorsAndAcceptors()
    routines.cells = Cells(cellsize)
    routines.cells.assignCells(protein)

    for thisatom in protein.getAtoms():
        # Grab the list of thisatoms
        if not thisatom.hdonor:
            continue
        thisatomhs = []
        for bond in thisatom.bonds:
            if bond.isHydrogen():
                thisatomhs.append(bond)
        if thisatomhs == []:
            continue

        # For each thisatom, grab all thatatomeptors

        count = 0
        closeatoms = routines.cells.getNearCells(thisatom)
        for thatatom in closeatoms:
            if (thisatom.residue == thatatom.residue):
                continue  # comment this out to include interresidue contacts
            if (thatatom.isHydrogen()):
                continue
            thisdist = distance(thisatom.getCoords(), thatatom.getCoords())
            if (thisdist <= DIST_CUTOFF):
                count = count + 1
                thisBstring = 'S'
                thatBstring = 'S'
                hscore = 0.0
                if (thisatom.hdonor & thatatom.hacceptor):
                    hscore = 1.0
                if (thisatom.hacceptor & thatatom.hdonor):
                    hscore = 1.0
                if (thisatom.isBackbone()):
                    thisBstring = 'B'
                if (thatatom.isBackbone()):
                    thatBstring = 'B'
                outfile.write("%4d %4d %-4s (%4d  ) %s     %-4s<>%4d %-4s (%4d  ) %s     %-4s D=%6.2f  H-ene=%6.2f  Sym=  (%s-%s)\n" % \
                  (count, thisatom.residue.resSeq,thisatom.residue.name,thisatom.residue.resSeq, thisatom.residue.chainID,thisatom.name,thatatom.residue.resSeq,thatatom.residue.name,thatatom.residue.resSeq, thatatom.residue.chainID,thatatom.name, thisdist, hscore, thisBstring, thatBstring))

    routines.write("\n")
    outfile.close()
Example #2
0
def run_extension(routines, outroot, options):
    """
        Print a list of contacts.

        Parameters
            routines:  A link to the routines object
            outroot:   The root of the output name
            options:   options object 
    """
    outname = outroot + ".con"
    outfile = open(outname, "w")

    # Initialize - set nearby cells, donors/acceptors
    
    cellsize = int(DIST_CUTOFF + 1.0 + 1.0) 
    protein = routines.protein
    routines.setDonorsAndAcceptors()
    routines.cells = Cells(cellsize)
    routines.cells.assignCells(protein)

    for thisatom in protein.getAtoms():
        # Grab the list of thisatoms
        if not thisatom.hdonor: 
            continue
        thisatomhs = []
        for bond in thisatom.bonds:
            if bond.isHydrogen(): 
                thisatomhs.append(bond)
        if thisatomhs == []: 
            continue

        # For each thisatom, grab all thatatomeptors
            
        count = 0
        closeatoms = routines.cells.getNearCells(thisatom)
        for thatatom in closeatoms:
            if (thisatom.residue == thatatom.residue): 
                continue  # comment this out to include interresidue contacts
            if (thatatom.isHydrogen()): 
                continue
            thisdist = distance(thisatom.getCoords(), thatatom.getCoords())
            if (thisdist <= DIST_CUTOFF): 
                count = count+1
                thisBstring='S'
                thatBstring='S'
                hscore= 0.0
                if (thisatom.hdonor & thatatom.hacceptor): 
                    hscore = 1.0
                if (thisatom.hacceptor & thatatom.hdonor): 
                    hscore = 1.0
                if (thisatom.isBackbone()): 
                    thisBstring='B'
                if (thatatom.isBackbone()): 
                    thatBstring='B'
                outfile.write("%4d %4d %-4s (%4d  ) %s     %-4s<>%4d %-4s (%4d  ) %s     %-4s D=%6.2f  H-ene=%6.2f  Sym=  (%s-%s)\n" % \
                  (count, thisatom.residue.resSeq,thisatom.residue.name,thisatom.residue.resSeq, thisatom.residue.chainID,thisatom.name,thatatom.residue.resSeq,thatatom.residue.name,thatatom.residue.resSeq, thatatom.residue.chainID,thatatom.name, thisdist, hscore, thisBstring, thatBstring)) 

    routines.write("\n")
    outfile.close()
Example #3
0
def run_extension(routines, outroot, options):
    """
        Print a list of salt bridges.

        Parameters
            routines:  A link to the routines object
            outroot:   The root of the output name
            options:   options object 
    """
    outname = outroot + ".salt"
    outfile = open(outname, "w")

    routines.write("Printing salt bridge list...\n")

    # Define the potential salt bridge atoms here (the current lists are for the AMBER
    # forcefield and are not necessarily exhaustive).
    posresList = ["LYS","ARG","HIP"]
    negresList = ["GLU","ASP","CYM"]
    posatomList = ["NE","NH1","NH2","NZ","ND1","NE2",]
    negatomList = ["SG","OE1","OE2","OD1","OD2"]

    # Initialize - set nearby cells
    # The cell size adds one for the salt bridge distance, and rounds up
    
    cellsize = int(DIST_CUTOFF + 1.0 + 1.0) 
    protein = routines.protein
    routines.cells = Cells(cellsize)
    routines.cells.assignCells(protein)

    # Loop over all the atoms
    for cation in protein.getAtoms():
        # check that we've found a cation
        if cation.residue.name == "NMET":
            print "YES NMET"
        if cation.residue.name not in posresList: 
            continue
        elif cation.name not in posatomList: 
                continue
        # For each cation, grab all potential anions in nearby cells
        closeatoms = routines.cells.getNearCells(cation)
        for anion in closeatoms:
            if cation.residue.name == anion.residue.name: 
                continue
            if anion.residue.name not in negresList: 
                continue
            elif anion.name not in negatomList: 
                    continue
            # Do distance check
            dist = distance(cation.getCoords(), anion.getCoords())
            if dist > DIST_CUTOFF: 
                continue
            #routines.write("Cation: %s %s\tAnion: %s %s\tsaltdist: %.2f\n" % \
            #          (cation.residue, cation.name, anion.residue, anion.name, dist)) 
            outfile.write("Cation: %s %s\tAnion: %s %s\tsaltdist: %.2f\n" % \
                      (cation.residue, cation.name, anion.residue, anion.name, dist))
    #routines.write("\n")
    outfile.close()
Example #4
0
def run_extension(routines, outroot, options):
    """
        Print a list of salt bridges.

        Parameters
            routines:  A link to the routines object
            outroot:   The root of the output name
            options:   options object 
    """
    outname = outroot + ".salt"
    outfile = open(outname, "w")

    routines.write("Printing salt bridge list...\n")

    # Define the potential salt bridge atoms here (the current lists are for the AMBER
    # forcefield and are not necessarily exhaustive).
    posresList = ["LYS", "ARG", "HIP"]
    negresList = ["GLU", "ASP", "CYM"]
    posatomList = [
        "NE",
        "NH1",
        "NH2",
        "NZ",
        "ND1",
        "NE2",
    ]
    negatomList = ["SG", "OE1", "OE2", "OD1", "OD2"]

    # Initialize - set nearby cells
    # The cell size adds one for the salt bridge distance, and rounds up

    cellsize = int(DIST_CUTOFF + 1.0 + 1.0)
    protein = routines.protein
    routines.cells = Cells(cellsize)
    routines.cells.assignCells(protein)

    # Loop over all the atoms
    for cation in protein.getAtoms():
        # check that we've found a cation
        if cation.residue.name == "NMET":
            print("YES NMET")
        if cation.residue.name not in posresList:
            continue
        elif cation.name not in posatomList:
            continue
        # For each cation, grab all potential anions in nearby cells
        closeatoms = routines.cells.getNearCells(cation)
        for anion in closeatoms:
            if cation.residue.name == anion.residue.name:
                continue
            if anion.residue.name not in negresList:
                continue
            elif anion.name not in negatomList:
                continue
            # Do distance check
            dist = distance(cation.getCoords(), anion.getCoords())
            if dist > DIST_CUTOFF:
                continue
            #routines.write("Cation: %s %s\tAnion: %s %s\tsaltdist: %.2f\n" % \
            #          (cation.residue, cation.name, anion.residue, anion.name, dist))
            outfile.write("Cation: %s %s\tAnion: %s %s\tsaltdist: %.2f\n" % \
                      (cation.residue, cation.name, anion.residue, anion.name, dist))
    #routines.write("\n")
    outfile.close()
Example #5
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")