Esempio n. 1
0
def parameter_antigen_experiment(experiment, dockingGroups, fileNames):
    """ Prepare the antigens for use in OptMAVEn
        Modify the residue permisson and parameter them 
        Output all the information to a "Antigen.txt"
    """
    # Loop through the docking groups
    for dockingGroup in dockingGroups:
        # Go through each molecule
        for molID in dockingGroup:
            # Get that Molecule
            molecule = experiment[molID[0]][molID[1]]
            # Modify its Residues' permissions so that all Atoms will be output
            for residue in molecule:
                residue.permission = "FIXED"
            #Parameterize the Molecule
            ROTAMERS.parameterize(molecule, experiment)
            # Get the energy calculation - ready text
            contents = format(molecule, "energy")
            # Put those contents in a file
            #fileName = "Antigen_" + str(molID[0] + str(molID[1]) + ".txt"
            fileName = "Antigen.txt"
            f = open(fileName, "a")
            f.write(contents)
            f.close()
            # Store that file name so it can be deleted later
            fileNames.append(fileName)
Esempio n. 2
0
def appropriateness(experiment, nonbonded = True):
    """Check for force field and implicit solvation information validity"""
    # Make a list of the Molecules
    molecules = []
    for data in experiment["Molecules"]:
        # This shouldn't be the case, but the function is being written so it
        # can be used as a generic checker, in which case "Molecules" would just
        # be a list of Molecules
        if isinstance(data, MOLECULES.Molecule):
            molecules.append(data)
        # the normal format is a list with the 3rd entry being a Molecule
        else:
            molecules.append(data[2])
    # Add missing Atoms, depending on the Force Field
    if experiment["Force Field"] == "CHARMM":
        try:
            CHARMM.Missing_Atoms(molecules, experiment)
        except CHARMM.CHARMM_Error as error:
            text = "There was an error when CHARMM was tested:\n" + str(error)
            raise ExperimentError(text)
    # If the force field isn't supported
    else:
        text = "The " + str(experiment["Force Field"]) + " is not supported by "
        text += "the appropriateness function"
        raise ExperimentError(text)
    # Try to parameterize the system
    if nonbonded:
        try:
            ROTAMERS.parameterize(molecules, experiment)
        except ROTAMERS.RotamerError as error:
            text = "There was an error when attempting to assign non-bonded "
            text += "energy parameters:\n" + str(error)
            raise ExperimentError(text)
    # Return the list of Molecule structures
    return molecules
def appropriateness(experiment, nonbonded=True, isOptcdr=False):
    """Check for force field and implicit solvation information validity"""
    # Make a list of the Molecules
    molecules = []
    for data in experiment["Molecules"]:
        # This shouldn't be the case, but the function is being written so it
        # can be used as a generic checker, in which case "Molecules" would just
        # be a list of Molecules
        if isinstance(data, MOLECULES.Molecule):
            molecules.append(data)
        # the normal format is a list with the 3rd entry being a Molecule
        else:
            molecules.append(data[2])
    # Repeat the procedure for the framework molecules if the procedure is
    # OptCDR
    if isOptcdr:
        # Make a list of the Molecules
        frameworks = []
        # Check information for the light and heavy chains
        for chain in ['light', 'heavy']:
            # Determine if a framework for this chain was specified
            if chain in experiment["Optcdr Frameworks"]:
                for data in experiment["Optcdr Frameworks"][chain]:
                    # Check for a list of Molecules
                    if isinstance(data, MOLECULES.Molecule):
                        frameworks.append(data)
                    # Otherwise choose the 3rd element from the list, which is a
                    # Molecule
                    else:
                        frameworks.append(data[2])
        # Add the framework Molecules to the existing Molecules
        molecules.extend(frameworks)
    # Add missing Atoms, depending on the Force Field
    if experiment["Force Field"] == "CHARMM":
        try:
            CHARMM.Missing_Atoms(molecules, experiment)
        except CHARMM.CHARMM_Error as error:
            text = "There was an error when CHARMM was tested:\n" + str(error)
            raise ExperimentError(text)
    # If the force field isn't supported
    else:
        text = "The " + str(
            experiment["Force Field"]) + " is not supported by "
        text += "the appropriateness function"
        raise ExperimentError(text)
    # Try to parameterize the system
    if nonbonded:
        try:
            ROTAMERS.parameterize(molecules, experiment)
        except ROTAMERS.RotamerError as error:
            text = "There was an error when attempting to assign non-bonded "
            text += "energy parameters:\n" + str(error)
            raise ExperimentError(text)
    # Return the list of Molecule structures if this is the standard use of the
    # function
    if not isOptcdr:
        return molecules
    # Otherwise return the framework Molecule structures
    else:
        return frameworks
def create_static_structures(experiment, movingMolecules, fileNames):
    """Create the structures that don't move during docking."""
    # First, determine what Design Groups have structures that move during
    # docking
    designNumbers = []
    for molID in movingMolecules:
        if molID[0] not in designNumbers:
            designNumbers.append(molID[0])
    # Assemble the constant portions of each of those complexes
    for gn in designNumbers:
        # Store the contents of all of the Molecules in this list
        contents = ''
        # Loop through the Molecules in this Design Group
        for molecule in experiment[gn]:
            # If this Molecule moves during docking, don't consider it
            if [gn, molecule.name] in movingMolecules:
                continue
            # Set each Residue's permission to FIXED so all atoms are output
            for residue in molecule:
                residue.permission = "FIXED"
            # Parameterize the Molecule
            ROTAMERS.parameterize(molecule, experiment)
            # Add its contents to contents
            contents += format(molecule, "energy")
        # Write these contents to a file, even if they're empty
        fileName = "constant" + str(gn) + ".txt"
        f = open(fileName, "w")
        f.write(contents)
        f.close()
        # Store the file name so it can be deleted later
        fileNames.append(fileName)
def create_moving_structures(experiment, dockingGroups, fileNames):
    """Create the structures that move during docking."""
    # Start creating the docking_information.txt file's data with this string
    information = str(len(dockingGroups)) + "\n"
    # Store each molecule that moves during docking in this list
    movingMolecules = []
    # Loop through the docking groups
    for dockingGroup in dockingGroups:
        # Inlcude the number of Molecules in this docking group
        information += str(len(dockingGroup)) + "\n"
        # Go through each molecule
        for molID in dockingGroup:
            # Get that Molecule
            molecule = experiment[molID[0]][molID[1]]
            # Modify its Residues' permissions so that all Atoms will be output
            for residue in molecule:
                residue.permission = "FIXED"
            # Parameterize the Molecule
            ROTAMERS.parameterize(molecule, experiment)
            # Get the energy calculation - ready text
            contents = format(molecule, "energy")
            # Put those contents in a file
            fileName = "docking_" + str(molID[0]) + str(molID[1]) + ".txt"
            f = open(fileName, "w")
            f.write(contents)
            f.close()
            # Store that file name so it can be deleted later
            fileNames.append(fileName)
            # Store this Molecule in the moving Molecules list
            movingMolecules.append(molID)
            # Update information with data about this Molecule
            information += fileName + " " + str(molID[0]) + "\n"
    # Return what needs to be returned
    return information, movingMolecules
def create_static_structures(experiment, movingMolecules, fileNames):
    """Create the structures that don't move during docking."""
    # First, determine what Design Groups have structures that move during
    # docking
    designNumbers = []
    for molID in movingMolecules:
        if molID[0] not in designNumbers:
            designNumbers.append(molID[0])
    # Assemble the constant portions of each of those complexes
    for gn in designNumbers:
        # Store the contents of all of the Molecules in this list
        contents = ''
        # Loop through the Molecules in this Design Group
        for molecule in experiment[gn]:
            # If this Molecule moves during docking, don't consider it
            if [gn, molecule.name] in movingMolecules:
                continue
            # Set each Residue's permission to FIXED so all atoms are output
            for residue in molecule:
                residue.permission = "FIXED"
            # Parameterize the Molecule
            ROTAMERS.parameterize(molecule, experiment)
            # Add its contents to contents
            contents += format(molecule, "energy")
        # Write these contents to a file, even if they're empty
        fileName = "constant" + str(gn) + ".txt"
        f = open(fileName, "w")
        f.write(contents)
        f.close()
        # Store the file name so it can be deleted later
        fileNames.append(fileName)
def create_moving_structures(experiment, dockingGroups, fileNames):
    """Create the structures that move during docking."""
    # Start creating the docking_information.txt file's data with this string
    information = str(len(dockingGroups)) + "\n"
    # Store each molecule that moves during docking in this list
    movingMolecules = []
    # Loop through the docking groups
    for dockingGroup in dockingGroups:
        # Inlcude the number of Molecules in this docking group
        information += str(len(dockingGroup)) + "\n"
        # Go through each molecule
        for molID in dockingGroup:
            # Get that Molecule
            molecule = experiment[molID[0]][molID[1]]
            # Modify its Residues' permissions so that all Atoms will be output
            for residue in molecule:
                residue.permission = "FIXED"
            # Parameterize the Molecule
            ROTAMERS.parameterize(molecule, experiment)
            # Get the energy calculation - ready text
            contents = format(molecule, "energy")
            # Put those contents in a file
            fileName = "docking_" + str(molID[0]) + str(molID[1]) + ".txt"
            f = open(fileName, "w")
            f.write(contents)
            f.close()
            # Store that file name so it can be deleted later
            fileNames.append(fileName)
            # Store this Molecule in the moving Molecules list
            movingMolecules.append(molID)
            # Update information with data about this Molecule
            information += fileName + " " + str(molID[0]) + "\n"
    # Return what needs to be returned
    return information, movingMolecules
Esempio n. 8
0
def parameter_output_antigen_normal(antigen, outFile="Antigen.txt"):
    """ Parameter the antigen molecule and output the antigen to the Antigen.txt     """
    #Missing_Atoms(antigen)
    for residue in antigen:
        #residue.permission = "FIXED"
        ROTAMERS.parameterize_Residue(residue)
    # Get the energy calculation - ready text
    contents = format(antigen, "energy")
    # Put those contents in a file
    #outFile = "Antigen.txt"
    f = open(outFile, "w")
    f.write(contents)
    f.close()
Esempio n. 9
0
def distance_setting(experiment, group):
    """Modify Residue freedoms and permissions based on distances"""
    # Only do this if the packing method is 'Distance'
    if experiment["Packing Method"] == "Distance":
        # Make a list of the Residue freedoms that are acceptable
        freedoms = ["RESTRAINED"]
        if experiment["Packing Selection"] == "FREE":
            freedoms.append("FREE")
        # Get all of the heavy Atoms in the docking selection
        atoms = []
        for molecule in group:
            for residue in molecule:
                if residue.freedom in freedoms:
                    for atom in residue:
                        if not ROTAMERS.is_hydrogen(atom):
                            atoms.append(atom)
        # Modify permissions in Design Molecules
        for molecule in group:
            if not molecule.design:
                continue
            for residue in molecule:
                # If the Residue already has settings, skip it
                if residue.freedom != "FIXED":
                    continue
                # Determine if it is sufficiently close
                close = False
                for atom in residue:
                    # Only consider heavy atoms
                    if ROTAMERS.is_hydrogen(atom):
                        continue
                    for atom2 in atoms:
                        dis = MOLECULES.calculate_distance(atom, atom2)
                        if dis <= experiment["Packing Cutoff"]:
                            close = True
                            break
                    if close:
                        break
                # If the Residue is close to the Packing selection, repack it
                if close:
                    residue.freedom = "FREE"
                    residue.permission = "ISOMER"
Esempio n. 10
0
def appropriateness(experiment, nonbonded=True):
    """Check for force field and implicit solvation information validity"""
    # Make a list of the Molecules
    molecules = []
    for data in experiment["Molecules"]:
        # This shouldn't be the case, but the function is being written so it
        # can be used as a generic checker, in which case "Molecules" would just
        # be a list of Molecules
        if isinstance(data, MOLECULES.Molecule):
            molecules.append(data)
        # the normal format is a list with the 3rd entry being a Molecule
        else:
            molecules.append(data[2])
    # Add missing Atoms, depending on the Force Field
    if experiment["Force Field"] == "CHARMM":
        try:
            CHARMM.Missing_Atoms(molecules, experiment)
        except CHARMM.CHARMM_Error as error:
            text = "There was an error when CHARMM was tested:\n" + str(error)
            raise ExperimentError(text)
    # If the force field isn't supported
    else:
        text = "The " + str(
            experiment["Force Field"]) + " is not supported by "
        text += "the appropriateness function"
        raise ExperimentError(text)
    # Try to parameterize the system
    if nonbonded:
        try:
            ROTAMERS.parameterize(molecules, experiment)
        except ROTAMERS.RotamerError as error:
            text = "There was an error when attempting to assign non-bonded "
            text += "energy parameters:\n" + str(error)
            raise ExperimentError(text)
    # Return the list of Molecule structures
    return molecules
Esempio n. 11
0
def prepare_MAPs_parts(experiment={}):
    """Get the MAPs parts ready for use in OptMAVEn"""
    # Determine which domains to use
    domains = []
    if "OptMAVEn Domains" not in experiment:
        domains.extend(["H", "K", "L"])
    else:
        if "Heavy" in experiment["OptMAVEn Domains"]:
            domains.append("H")
        if "Light" in experiment["OptMAVEn Domains"]:
            domains.extend(["K", "L"])
    # Store the names of the files made by this function
    fileNames = []
    # Write out the types of domains being designed
    text = ''
    for d in domains:
        text += d + " "
    f = open("domains.txt", "w")
    f.write(text[:-1])
    f.close()
    fileNames.append("domains.txt")
    # Get file format and force field information
    if "Force Field" in experiment:
        ff1 = experiment["Force Field"]
    else:
        ff1 = defaultField
    if "File Format" in experiment:
        ff2 = experiment["File Format"]
    else:
        ff2 = defaultFormat
    # Go through those domains and the regions of structure
    for D in domains:
        for R in ["V", "CDR3", "J"]:
            # Store the text of the formatted structures here
            text = ''
            # Access the MAPs parts
            path = InstallFolder + "databases/MAPs/" + D + R + "/"
            # Loop through possible number options
            for i in range(1, 501):
                name = path + D + R + "_" + str(i) + ".pdb"
                try:
                    f = open(name, "r")
                except IOError:
                    # If the file couldn't be opened, we're out of parts
                    break
                # Read in the part
                lines = f.readlines()
                f.close()
                # Make a Molecule out of it
                part = MOLECULES.Molecule(lines, None, None, D, True, ff1, ff2)
                # parameterize the part
                ROTAMERS.parameterize(part, experiment)
                # Modify its parameters
                modify_parameters(part)
                # Get the formatted text, listing the rotamer number as i
                for residue in part:
                    text += format(residue, "all - " + str(i))
            # Write the formatted text of this file to a folder
            f = open(D + R + ".txt", "w")
            f.write(text)
            f.close()
            # Store the file name
            fileNames.append(D + R + ".txt")
    # Return the names of the files
    return fileNames