def OptzymeGroups(experiment): """Describe the objectives and Molecule present in the system""" # Validate the Optzyme Groups error = VALIDATE.OptzymeGroups(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the text here text = "\nThe Optzyme Groups\n" # Go through the groups for group in experiment["Optzyme Groups"]: RHS = group[1].capitalize() + " " + group[0].capitalize() if group[0].capitalize() == "Kcat": RHS += " with a weight of " + str(group[2]) for i in range(len(group[3])): RHS += " using " if group[3][i][0] == "improve": RHS += "TSA Molecules:" else: RHS += "ground Molecules:" for mol in group[3][i][1:]: RHS += " " + mol if len(group[3]) == 2 and i == 0: RHS += " and" text += standard_format("Optzyme Group", RHS) return text
def Molecules(experiment): """Describe the Molecules being used in an experiment""" # Validate the Molecules error = VALIDATE.Molecules(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the text here text = "\nThe Molecules used in the experiment\n" # Go through the Molecules for data in experiment["Molecules"]: # Create the LHS of the text LHS = "Molecule" # And the RHS RHS = "Molecule " # If the Molecule's name is a blank, use '_' if data[1] == ' ': RHS += "_" else: RHS += data[1] RHS += " from file " + data[0] + " is " if data[2].design: RHS += "Design Molecule " else: RHS += "Target Molecule " RHS += data[2].name # Add this to the text text += standard_format(LHS, RHS) # Add text listing Dimers, if there are any text += Dimers(experiment) return text
def load_Experiment_Details(): """Try to load the Experiment_Details.txt file""" # Store the information from the file here data = {} # Try to open the file try: f = open("Experiment_Details.txt", "r") except IOError: text = "There is no Experiment Details file" raise FUNCTIONS.IPRO_IOError(text) # Go through the contents of the file for line in f: # Get the index of the first ':'. If there isn't one, skip this line try: i = line.index(':') except ValueError: continue # Split the line on that value attribute = line[:i].strip() info = line[i + 1:].strip() # Store the attribute in data, as appropriate # If this is the first instance of this attribute occuring, store it as # a string if attribute not in data: data[attribute] = info else: # if the current value is a string, change it to a list if isinstance(data[attribute], str): data[attribute] = [data[attribute]] # Store the new information in the list data[attribute].append(info) # close the file and return the data f.close() return data
def rotamer_info(experiment): """Describe how to use rotamers""" # Validate the rotamer information error = VALIDATE.rotamer_info(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store formatted text here text = "\nHow to use rotamers\n" # Go through the attributes for name in ['Rotamer Library', 'Rotamer Window', 'Max Rotamer Number', \ 'Packing Cutoff', 'Packing Method', 'Packing Selection']: text += standard_format(name, experiment[name]) return text
def IPRO_info(experiment): """Provide a description of how IPRO should be run""" # Validate the IPRO information error = VALIDATE.IPRO_info(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the formatted text here text = "\nHow to run IPRO\n" # Go through the attributes for name in ['IPRO Iterations', "IPRO Annealing Temperature", \ "Annealing Sharing", "Energy Calculation"]: text += standard_format(name, experiment[name]) return text
def Restraints(experiment): """Create text describing the 4 types of structure restraints""" # Validate the restraints that exist error = VALIDATE.Restraints(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the formatted text here text = '' # Add the text for each type of restraint text += fixedAtoms(experiment) text += position_restraints(experiment) text += distance_restraints(experiment) text += dihedral_restraints(experiment) return text
def DesignGroups(experiment): """Describe what Molecules are simultaneously present in the system""" # Validate the Design Groups error = VALIDATE.DesignGroups(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the text here text = "\nThe Design Groups\n" # Go through the groups for group in experiment["Design Groups"]: RHS = group[0].capitalize() + " binding to Molecules:" for i in range(1, len(group)): RHS += " " + group[i] text += standard_format("Design Group", RHS) return text
def basic_info(experiment, data): """Load the basic information into the Experiment""" # Store any generated errors here errors = '' # Go through the basic pieces of information for the experiment for attribute in ['User', 'Type', 'Name', 'File Format', 'Force Field', \ 'Folder']: errors += standard_load(attribute, experiment, data, "string") # Make sure the Folder is valid if errors == '': if os.getcwd() + "/" != experiment["Folder"]: errors += "\nThe Experiment is not located in this folder:\n" errors += experiment["Folder"] if errors != '': raise FUNCTIONS.IPRO_IOError(errors)
def docking_info(experiment): """Create text describing how to run docking""" # Validate the docking information error = VALIDATE.docking_info(experiment) # If there's a problem, raise an error if error != '': raise FUNCTIONS.IPRO_IOError(error) # STore the text here text = "\nHow to run Docking\n" # Go through the attributes for attribute in ['Docking Frequency', 'Docking Iterations', \ 'Docking SD Movements', 'Docking SD Rotations', 'Docking Start Temp', \ 'Docking End Temp']: text += standard_format(attribute, experiment[attribute]) return text
def PermittedKinds(experiment): """Specific limits on how Residues may mutate""" # Validate the permitted kinds error = VALIDATE.PermittedKinds(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the formatted text here text = '' if "Permitted Kinds" in experiment and experiment["Permitted Kinds"] != {}: # Create a header for the information text += "\nPermitted Kinds of Amino Acid Mutations\n" # Get the Molecule names mns = list(experiment["Permitted Kinds"].keys()) mns.sort() # Go through the Molecules for mn in mns: # Get the Residue names rns = list(experiment["Permitted Kinds"][mn].keys()) # Sort the Residue names manually # Ironically, the first step is to sort them automatically rns.sort() # Now sort them manually sorted = False while not sorted: sorted = True for i in range(len(rns) - 1): try: n1 = int(rns[i]) except ValueError: n1 = int(rns[i][:-1]) try: n2 = int(rns[i + 1]) except ValueError: n2 = int(rns[i + 1][:-1]) # If appropriate, reverse the order of the entries if n2 < n1: temp = rns[i] rns[i] = rns[i + 1] rns[i + 1] = temp sorted = False # Output the information about each Residue for rn in rns: RHS = 'Residue ' + rn + " in Molecule " + mn + ":" for aa in experiment["Permitted Kinds"][mn][rn]: RHS += " " + aa text += standard_format("Permitted Kinds", RHS) return text
def position_restraints(experiment): """Describe position restraints""" # Error checking is done in the restraints function. Store the text here text = '' # If there are position restraints if "Restraints" in experiment and "Position" in experiment["Restraints"]: # go through the restraints for restraint in experiment["Restraints"]["Position"]: # Create the text RHS = "" if restraint[3] == 'all': RHS += "All Atoms in " else: RHS += "Atom " + restraint[3] + " in " if restraint[2] == "all": RHS += "all Residues in " else: RHS += "Residue " + restraint[2] + " in " if restraint[1] == 'all': RHS += "all Molecules in " else: RHS += "Molecule " + restraint[1] + " in " if restraint[0] == 'all': RHS += "all Design Groups" else: RHS += "Design Group " + str(restraint[0]) # Have a different method for each force field if experiment["Force Field"] == "CHARMM": RHS += ", using a force constant of " RHS += format(restraint[4], '.3f') + ", to " if len(restraint) == 6: RHS += "Design Group " + str(restraint[5]) elif restraint[3] == 'all': RHS += "their initial positions" else: RHS += "its initial position" else: text = "The I/O OUTPUT position restraints function does not " text += 'support the ' + str(experiment["Force Field"]) text += " force field." raise FUNCTIONS.IPRO_IOError(text) # Store the information in the text text += standard_format("Position Restraint", RHS) # If there are position restraints, modify the text if text != '': text = "\nRestraints on Atom Positions\n" + text return text
def OptCDR_info(experiment): """Provide a description of how OptCDR should be run""" # Validate the OptCDR information error = VALIDATE.OptCDR_info(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the formatted text here text = "\nHow to run OptCDR\n" # Output the home OptCDR directory text += standard_format('Home Directory', experiment['Optcdr Path']) # If it is a path within the home OptCDR directory, save the path relative # to the home directory for LHS, name in zip(['Canonical Folder', 'Clash File', 'Position File', \ 'Cluster Folder'], ['Optcdr Canonical Path', \ 'Optcdr Clash Path', 'Optcdr Gaussian Path', \ 'Optcdr Cluster Folder']): value = experiment[name].replace(experiment['Optcdr Path'], '') text += standard_format(LHS, value) # Go through the other attributes for name in [ 'Optcdr Chains', 'Optcdr Positions', 'Optcdr Libraries', 'Optcdr Usage Patterns' ]: text += standard_format(name, experiment[name]) # Since the 'OptCDR Rotations' attribute is a dictionary, split the data # by molecule name for mn in experiment['Optcdr Rotations']: LHS = "Antigen Rotation: " RHS = experiment['Optcdr Rotations'][mn].capitalize() + " in Molecule" RHS += " " + mn + "\n" # Add this to the existing text text += standard_format(LHS, RHS) # Similarly, split the 'OptCDR Frameworks' dictionary by the chain type for chain in experiment['Optcdr Frameworks']: LHS = chain.capitalize() + " Framework: " RHS = "MOLECULE " # If the Molecule's name is a blank space, use an underscore if experiment['Optcdr Frameworks'][chain][1] == ' ': RHS += "_" else: RHS += experiment['Optcdr Frameworks'][chain][1] RHS += " from file " + experiment['Optcdr Frameworks'][chain][0] RHS += " is Design Molecule " RHS += experiment['Optcdr Frameworks'][chain][2].name # Add this to the text text += standard_format(LHS, RHS) return text
def refinement_info(experiment): """Create text describing how to run structure refinements""" # Validate the refinement information error = VALIDATE.refinement_info(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the formatted text here text = "\nHow to do Structure Refinements\n" # Go through the attributes for name in ['Do Refinement', 'Refinement Iterations', \ 'Ensemble Number']: # If this is a mutator experiment, skip the do refinement attribute if "Type" in experiment and experiment["Type"] == "Mutator" and name \ == "Do Refinement": continue text += standard_format(name, experiment[name]) return text
def Dimers(experiment): """If there are Dimers in an experiment, list them""" # Validate the Dimer information error = VALIDATE.Dimers(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the text here text = '' # Go through the dimers if "Dimers" in experiment: for pair in experiment["Dimers"]: RHS = "Molecules " + pair[0] + " and " + pair[1] text += standard_format("Dimers", RHS) # If there is Dimer information, give a heading if text != '': text = "\nMolecules that are Dimers\n" + text return text
def Mutants(experiment): """List the mutations of each mutant""" # Validate the mutants error = VALIDATE.Mutants(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the text here text = "\nMutants\n" # Go through the mutants for i, mutant in enumerate(experiment["Mutants"]): # Go through the mutations for mutation in mutant: RHS = "Mutant " + str(i + 1) + ": Mutate Residue " RHS += mutation[1] + " in Molecule " + mutation[0] + " to " RHS += mutation[2] text += standard_format("Mutation", RHS) return text
def CHARMM_info(experiment): """Create formatted text describing how to use CHARMM.""" # Store the formatted text here text = '' # Only do this if the Experiment is using the CHARMM force field if experiment["Force Field"] == "CHARMM": # Validate the force field information error = VALIDATE.CHARMM_info(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(text) # Give the text an appropriate header text = "\nHow to use CHARMM\n" # Since the information is all correct, loop through the attributes for name in ['CHARMM Topology Files', 'CHARMM Parameter Files', \ 'CHARMM Energy Terms', 'CHARMM Iterations', 'Lj Phi']: # Include each piece of information text += standard_format(name, experiment[name]) return text
def solvation_info(experiment): """Provide information about how to use implicit solvation""" # Validate the information error = VALIDATE.solvation_info(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the formatted text here text = "\nHow to use Implicit Solvation\n" # Go through the variables one at a time... text += standard_format("Use Solvation", experiment["Use Solvation"]) # If solvation is being used, say the type if experiment["Use Solvation"]: text += standard_format("Solvation Type", \ experiment["Solvation Type"]) # If LK solvation is being used, list those file if experiment["Solvation Type"] == "Lazaridis-Karplus": text += standard_format("LK Solvation Files", \ experiment["LK Solvation Files"]) return text
def basic_info(experiment): """Check that the Experiment has all basic information.""" # Store any generated errors here errors = '' # Loop through the attributes for name in ['User', 'Type', 'Name', 'File Format', 'Force Field','Folder']: # If the attribute is missing if name not in experiment: text += "\nThe " + name + " attribute is missing." else: # If it's not missing, check its value try: CHECK.basic_info(name, experiment[name]) except FUNCTIONS.IPRO_IOError as error: errors += str(error) # Unlike in other validation functions, if there is a problem with basic # information the experiment should immediately die instead of searching for # other errors if errors != '': raise FUNCTIONS.IPRO_IOError(errors[1:])
def DesignPositions(experiment): """List what Residues are permitted to mutate""" # Validate the Design Positions error = VALIDATE.DesignPositions(experiment) if error != '': raise FUNCTIONS.IPRO_IOError(error) # Store the text here text = '' # If this isn't an OptMAVEn or OptCDR experiment, list the Design Positions if "Type" in experiment and experiment["Type"] in ['OptMAVEn', 'OptCDR']: pass else: text += "\nResidues that are Permitted to Mutate\n" # Go through the Molecules for mn in experiment["Design Positions"]: # Go through the Residues for rn in experiment["Design Positions"][mn]: # Create the RHS RHS = "Residue " + rn + " in Molecule " + mn text += standard_format("Design Position", RHS) return text
def distance_restraints(experiment): """Create text describing distance restraints""" # Error checking is done in the restraints function. Store the distance # restraints here text = '' # If there are restraints if "Restraints" in experiment and "Distance" in experiment["Restraints"]: # Go through the restraints for restraint in experiment["Restraints"]["Distance"]: # Start creating the RHS RHS = "Between " # List the two atoms for i in range(1, 3): RHS += "Atom " + restraint[i][2] + " in Residue " + \ restraint[i][1] + " in Molecule " + restraint[i][0] if i == 1: RHS += " and " # Say the Design Group if restraint[0] == 'all': RHS += " in all Design Groups" else: RHS += " in Design Group " + str(restraint[0]) # Have a different method for the remaining values based on force # field if experiment["Force Field"] == "CHARMM": names = ['KMIN', 'RMIN', 'KMAX', 'RMAX', 'FMAX'] for j in range(len(names)): RHS += " " + names[j] + ": " + format( restraint[3 + j], '.3f') else: text = "The I/O OUTPUT distance restraints function does not " text += "support the " + experiment[ "Force Field"] + " force field" raise FUNCTIONS.IPRO_IOError(text) # Include the text text += standard_format("Distance Restraint", RHS) # If text was created if text != '': text = "\nRestraints on Atom-Atom distances\n" + text return text
def dihedral_restraints(experiment): """Create text describing dihedral angle restraints""" # Error checking is done in the restraints function. Store the text here text = '' # If there are restraints if "Restraints" in experiment and "Dihedral" in experiment["Restraints"]: # Go through them for restraint in experiment["Restraints"]["Dihedral"]: # Start creating this restraint RHS = "Between " for i in range(1, 5): if i == 4: RHS += "and " RHS += "Atom " + restraint[i][2] + " in Residue " RHS += restraint[i][1] + " in Molecule " + restraint[i][0] if i != 4: RHS += ", " # Say the Design Group if restraint[0] == 'all': RHS += " in all Design Groups" else: RHS += " in Design Group " + str(restraint[0]) # Have a different method for the remaining terms based on force # field if experiment["Force Field"] == "CHARMM": RHS += " using a force constant of " + format( restraint[5], '.3f') RHS += " to a minimum angle of " + format(restraint[6], '.3f') else: text = "The I/O OUTPUT dihedral restraints function does not " text += "support the " + experiment[ "Force Field"] + " force field." raise FUNCTIONS.IPRO_IOError(text) # Add the restraint to the text text += standard_format("Dihedral Restraint", RHS) # If there are restraints, give htem a header if text != '': text = "\nRestraints on Dihedral Angles\n" + text return text
def Molecules(experiment, data): """Load the information about which Molecules are being used""" # Store errors here errors = '' # If there is no Molecule information if "Molecule" not in data: errors += "\nThere is no Molecule information" else: # If the information is a string, change it to a list if isinstance(data["Molecule"], str): data["Molecule"] = [data["Molecule"]] # Store the Molecules in this list molecules = [] # Go through each entry in that list for line in data["Molecule"]: # Split the line on whitespace items = line.split() # The line should be organized as follows # Molecule mn1 from file fn is DESIGN Molecule mn2 # 0 1 2 3 4 5 6 7 8 if len(items) != 9: errors += "\nThe following is not a properly formatted Molecule" errors += " declaration:\n" + line continue # Get the information mn1 = items[1] fn = items[4] ds = items[6] if ds.lower() == "design": design = True elif ds.lower() == "target": design = False else: errors += "\n" + ds + " is not a declaration of a Molecule's " \ + "Design status." continue mn2 = items[8] # Try to load the relevant Molecule. Generate its expected name fileName = "Molecule" + mn2 if experiment["File Format"] == "PDB": fileName += ".pdb" else: text = "The LOADING Molecules function does not support the " text += experiment["File Format"] + " file format." raise FUNCTIONS.IPRO_IOError(text) # Load the Molecule try: f = CHECK.for_file(fileName, "./", True) except FUNCTIONS.IPRO_IOError as error: errors += str(error) continue lines = f.readlines() f.close() # Try to make a Molecule try: molecule = MOLECULES.Molecule(lines, None, None, mn2, design, \ experiment['Force Field'], experiment['File Format']) except MOLECULES.MoleculeError as error: errors += str(error) continue # Store the molecule in the list molecules.append([fn, mn1, molecule]) # Store the Molecules in the Experiment try: experiment["Molecules"] = molecules except IPRO_Error as error: errors += str(error) return errors
def OptCDR_frameworks(experiment, data): """Load the specific frameworks specified within OptCDR""" # Store the errors here errors = '' # If there is no framework information, store an empty dictionary if "Heavy Framework" not in data and "Light Framework" not in data: experiment["Optcdr Frameworks"] = {} else: # Store the framework information in this dictionary frameworks = {} # Go through the specifications for kind in ["Heavy", "Light"]: # If this kind of framework is not specified, skip it name = kind + " Framework" if name not in data: continue # Otherwise, store the information # If the information is a string, change it to a list if isinstance(data[name], str): data[name] = [data[name]] # Store the Molecules in this list molecules = [] # Go through each entry in the data for line in data[name]: # Split the line on whitespace items = line.split() # The line should be organized as follows # Molecule mn1 from file fn is DESIGN Molecule mn2 # 0 1 2 3 4 5 6 7 8 if len(items) != 9: errors += "\nThe following is not a properly formatted " errors += "Molecule for framework specification:\n" + line continue # Get the information mn1 = items[1] fn = items[4] ds = items[6] if ds.lower() == "design": design = True elif ds.lower() == "target": design = False else: errors += "\n" + ds + " is not a declaration of a " + \ "Molecule's Design status for framework specification." mn2 = items[8] # Try to load the relevant Molecule. Generate its expected name fileName = "Molecule" + mn2 if experiment["File Format"] == "PDB": fileName += ".pdb" else: text = "The LOADING Molecules function does not support " +\ "the " + experiment["File Format"] + " file format." raise FUNCTIONS.IPRO_IOError(text) # Load the Molecule try: f = CHECK.for_file(fileName, "./", True) except FUNCTIONS.IPRO_IOError as error: errors += str(error) continue lines = f.readlines() f.close() # Try to make a Molecule try: molecule = MOLECULES.Molecule(lines, None, None, mn2, \ design, experiment["Force Field"], \ experiment["File Format"]) except MOLECULES.MoleculeError as error: errors += str(error) # Store the molecule in the list molecules.append([fn, mn1, molecule, 'Antibody']) # Store the molecules in the framework dictionary try: frameworks[kind.lower()] = molecules except IPRO_Error as error: errors += str(error) # Store the framework dictionary in the experiment experiment["Optcdr Frameworks"] = frameworks return errors
def position_restraints(experiment, data): """Load information restraining Atom positions""" # Store errors here errors = '' # This information does not have to exist if "Position Restraint" in data: # Make sure it is a list if isinstance(data["Position Restraint"], str): data["Position Restraint"] = [data["Position Restraint"]] # Store the restraints in this list restraints = [] # Go through each line for line in data["Position Restraint"]: # The line formatting depends on the force field, so here are the # options # CHARMM # Atom an in Residue rn in Molecule mn in Design Group gn, using a # force constant of fn, to Design Group gn2 # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 # 14 15 16 17 18 19 20 21 # Currently there are no other force fields # For most options, can say 'all (Atoms) in' instead of (Atom) an in # Can also say 'its initial position' instead of 'Design Group gn2' items = line.split() if experiment["Force Field"] == "CHARMM": if len(items) != 22: errors += "\nThe following line is not a valid CHARMM " errors += "position restraint specification:\n" + line continue # If the force field isn't supported else: text = "The LOADING position restraints function does not " text += "support the " + experiment["Force Field"] + " force " text += 'field' raise FUNCTIONS.IPRO_IOError(text) # Get the Molecule information if items[0].lower() == 'all': an = 'all' else: an = items[1] if items[3].lower() == 'all': rn = 'all' else: rn = items[4] if items[6] == 'all': mn = 'all' else: mn = items[7] if items[9] == 'all': gn = 'all' else: try: gn = int(items[11][:-1]) except ValueError: errors += "\nThe following is not a validly formatted " errors += "position restraint:\n" + line continue # Put that in a restraint restraint = [gn, mn, rn, an] # Have a different method based on force field if experiment["Force Field"] == "CHARMM": # Store the force constant try: restraint.append(float(items[17][:-1])) except ValueError: errors += "\nThe following line doesn't contain a force " errors += "constant:\n" + line continue # Determine if the restraint is to a particular position or its # initial position if items[19].capitalize() == "Design": try: restraint.append(int(items[21])) except ValueError: errors += "\nThe following position restraint isn't " errors += "formatted properly:\n" + line continue # Store the restraint restraints.append(restraint) # Check the restraints try: CHECK.position_restraints(restraints, experiment) # Store the restraint if "Restraints" not in experiment: experiment["Restraints"] = {} experiment["Restraints"]["Position"] = restraints # If there was an error checking the restraints, show that except FUNCTIONS.IPRO_IOError as error: errors += str(error) return errors
def distance_restraints(experiment, data): """Load the information about restraints on the distances between Atoms""" # Store errors here errors = '' # There doesn't have to be this information if "Distance Restraint" in data: # Make sure it is a list if isinstance(data["Distance Restraint"], str): data["Distance Restraint"] = [data["Distance Restraint"]] # Store the restraints in this list restraints = [] # Go through the lines of text for line in data["Distance Restraint"]: # The formatting is dependent on the force field # CHARMM # Between Atom an1 in Residue rn1 in Molecule mn1 and Atom an2 in # Residue rn2 in Molecule mn2 in Design Group gn KMIN: N1 RMIN: N2 # KMAX: N3 RMAX: N4 FMAX: N5 # 0 1 2 3 4 5 6 7 8 9 10 11 12 # 13 14 15 16 17 18 19 20 21 22 23 24 25 # 26 27 28 29 30 31 # There are currently no other force fields items = line.split() if experiment["Force Field"] == "CHARMM": if len(items) != 32: errors += "\nThe following is not a valid CHARMM distance " errors += "restraint specification:\n" + line continue else: text = "The LOADING distance restraints function does not " text += "support the " + experiment["Force Field"] text += " force field." raise FUNCTIONS.IPRO_IOError(text) # Start assembling the information if items[19].lower() == 'all': gn = 'all' else: try: gn = int(items[21]) except ValueError: errors += "\nThe following is not a validly formatted " errors += "distance restraint:\n" + line continue restraint = [gn, [items[8], items[5], items[2]], [items[17], \ items[14], items[11]]] # Store the remaining information based on the force field if experiment["Force Field"] == "CHARMM": problem = False for i in [23, 25, 27, 29, 31]: try: restraint.append(float(items[i])) except ValueError: errors += "\nThe following is not a validly formatted " errors += "CHARMM distance restraint:\n" + line problem = True break if problem: continue # Store the restraint restraints.append(restraint) # Check the restraints try: CHECK.distance_restraints(restraints, experiment) if "Restraints" not in experiment: experiment["Restraints"] = {} experiment["Restraints"]["Distance"] = restraints # If there was an error, store that information except FUNCTIONS.IPRO_IOError as error: errors += str(error) return errors
def dihedral_restraints(experiment, data): """Load the information about dihedral angle restraints""" # Store errors here errors = '' # There doesn't have to be any restraints if "Dihedral Restraint" in experiment: # Make sure it is a list if isinstance(data["Dihedral Restraint"], str): data["Dihedral Restraint"] = [data["Dihedral Restraint"]] # Store the restraints in this list restraints = [] # Go through the lines for line in data["Dihedral Restraint"]: # CHARMM formatting (this is long because there are 4 Atom # specifications) # Between Atom an1 in Residue rn1 in Molecule mn1, Atom an2 in # Residue rn2 in Molecule mn2, Atom an3 in Residue rn3 in Molecule # mn3, and Atom an4 in Residue rn4 in Molecule mn4 in Design Group # gn using a force constant of N1 to a minimum angle of N2 # 0 1 2 3 4 5 6 7 8 9 10 11 # 12 13 14 15 16 17 18 19 20 21 22 23 # 24 25 26 27 28 29 30 31 32 33 34 35 36 # 37 38 39 40 41 42 43 44 45 46 47 48 49 items = line.split() if experiment["Force Field"] == "CHARMM": if len(items) != 50: errors += "\nThe following is not a validly formatted " errors += "CHARMM Dihedral Restraint:\n" + line continue else: text = "The LOADING dihedral restraints function does not " text += "support the " + experiment["Force Field"] text += " force field." raise FUNCTIONS.IPRO_IOError(text) # Get the Design Group specification if items[35].lower() == 'all': gn = 'all' else: try: gn = int(items[37]) except ValueError: errors += "\nThe following is not a validly formatted " errors += "dihedral restraint:\n" + line continue # Store the information restraint = [gn, [items[8][:-1], items[5], items[2]], \ [items[16][:-1], items[13], items[10]], \ [items[24][:-1], items[21], items[18]], \ [items[33], items[30], items[27]]] # Store the remaining information based on force field if experiment["Force Field"] == "CHARMM": problem = False for i in [43, 49]: try: restraint.append(float(items[i])) except ValueError: errors += "\nThe following is not a validly formatted " errors += "dihedral restraint:\n" + line problem = True break if problem: continue # Store the restraint restraints.append(restraint) # Check and store the restraints try: CHECK.dihedral_restraints(restraints, experiment) if "Restraints" not in experiment: experiment["Restraints"] = {} experiment["Restraints"]["Dihedral"] = restraints # If there was a problem, store that error except FUNCTIONS.IPRO_IOError as error: errors += str(error) return errors