def reset(self, **kwargs): dir = 'protein_data/short_valid' protein_name = np.random.choice(os.listdir(dir)) if self.start_distance > self.best_distance: self.write_best_conformation(self.best_distance) if self.validation: self.name = protein_name dir = 'protein_data/short_valid' else: self.name = protein_name dir = 'protein_data/short_valid' self.target_protein_pose = pose_from_pdb(os.path.join(dir, self.name)) self.prev_residues_angle_distane = {} self.protein_pose = pose_from_sequence( self.target_protein_pose.sequence()) for i in range(1, self.target_protein_pose.total_residue()): self.prev_residues_angle_distane[i * 2] = self.get_residue_distance( 0, i) self.prev_residues_angle_distane[i * 2 + 1] = self.get_residue_distance( 1, i) if not self.shuffle: self.protein_pose = pose_from_sequence( self.target_protein_pose.sequence()) else: self.scramble_pose(self.protein_pose) self.move_counter = 0 self.reward = 0.0 self.prev_ca_rmsd = None self.achieved_goal_counter = 0 self.current_residue = 1 self.best_distance = self._get_ca_metric(self.protein_pose, self.target_protein_pose) self.start_distance = self._get_ca_metric(self.protein_pose, self.target_protein_pose) self.best_energy = self.scorefxn(self.protein_pose) self.start_energy = self.scorefxn(self.protein_pose) self.prev_energy = self.scorefxn(self.protein_pose) self.encoded_residue_sequence = self._encode_residues( self.target_protein_pose.sequence()) self.residue_mask = self.create_residue_mask( self.target_protein_pose.sequence()) self.save_best_matches() return self._get_state()
def compare_openmm_energy_pyrosetta_score(cgmodel): from cg_openmm.src.cg_mm_tools.cg_openmm import build_mm_simulation """ Given a cgmodel class object, this function determines if PyRosetta and OpenMM give the same score/energy with identical model settings. Parameters ---------- cgmodel: Coarse grained model class object. """ build_params_files(cgmodel) pyrosetta.init() pyrosetta_sequence = ''.join([str('['+str(monomer['monomer_name'])+']') for monomer in cgmodel.sequence]) # Build a PyRosetta pose pose = pyrosetta.pose_from_sequence(pyrosetta_sequence) # Define a PyRosetta scoring function scorefxn = build_scorefxn(cgmodel) # get the PyRosetta score score = scorefxn.show(pose) # Build an OpenMM simulation object so that we can calculate the energy using a simulation Context() simulation = build_mm_simulation(cgmodel.topology, cgmodel.system, cgmodel.positions, temperature=temperature, simulation_time_step=simulation_time_step, total_simulation_time=total_simulation_time, output_pdb=output_pdb, output_data=output_data, print_frequency=print_frequency) # Obtain a state for our simulation context energy = simulation.context.getState(getEnergy=True).getPotentialEnergy() print("The PyRosetta score is: "+str(score)+"\n") print("The OpenMM potential energy is: "+str(energy)+"\n") return
def test_mm_twist(): # Set CG1-CG1-CG1-CG1 torsion cg_pyrosetta.change_parameters.changeTorsionParameters( {'CG2 CG1 CG1 CG2': [10, 6, 35]}) # Build 1-1 CG model pose = pyrosetta.pose_from_sequence( 'X[CG31:CGLower]X[CG31]X[CG31]X[CG31]X[CG31]X[CG31]X[CG31]X[CG31:CGUpper]' ) # Randomize torsion in backbone randomize = cg_pyrosetta.CG_movers.randomizeBackBone(pose) randomize.apply(pose) # Scorefunction w/o mm_twist scorefunction = pyrosetta.ScoreFunction() scorefunction.set_weight(pyrosetta.rosetta.core.scoring.fa_atr, 1) scorefunction.set_weight(pyrosetta.rosetta.core.scoring.fa_rep, 1) # Scorefunction w/ mm_twist scorefunction_mm = pyrosetta.ScoreFunction() scorefunction_mm.set_weight(pyrosetta.rosetta.core.scoring.fa_atr, 1) scorefunction_mm.set_weight(pyrosetta.rosetta.core.scoring.fa_rep, 1) scorefunction_mm.set_weight(pyrosetta.rosetta.core.scoring.mm_twist, 1) print(scorefunction(pose)) print(scorefunction_mm(pose)) assert not math.isclose(scorefunction(pose), scorefunction_mm(pose))
def submain(args_phi_psi=False, args_seq=False, args_name='render'): with open(args_phi_psi, 'r') as phi_psi: args_phi_psi = phi_psi.readlines() torsion_space_iterable = args_phi_psi PhiPsi = [] if args_seq: if os.path.isfile(args_seq): with open(args_seq, 'r') as seq: args_seq = seq.readlines() args_seq = [line for line in args_seq if len(line)] if len(args_seq) == 1: args_seq = args_seq[0].strip() Seq = list(args_seq) else: Seq = [] try: assert len(torsion_space_iterable) == len(Seq) except: print('Sequence and torison iteratable must be same length\n', Seq, len(Seq), torsion_space_iterable, len(torsion_space_iterable)) sys.exit() # 1st loop through backbone for i, element in enumerate(torsion_space_iterable): element = element.strip() angles = tuple(float(a) for a in element.split()) if len(angles) == 2: phi, psi = angles omega = 180 else: assert len(angles) == 3 phi, psi, omega = angles PhiPsi.append((phi, psi, omega)) if not args_seq: Seq.append(AminoAcid) assert len(PhiPsi) == len(Seq) try: pyrosetta except NameError: import pyrosetta pyrosetta.init() render_pose = pyrosetta.pose_from_sequence(''.join(Seq)) for i, torsion_angles in enumerate(PhiPsi): phi, psi, omega = torsion_angles p = i + 1 render_pose.set_phi(p, phi) render_pose.set_psi(p, psi) render_pose.set_omega(p, omega) render_pose.dump_pdb('%s.pdb' % args_name)
def build_cgmodel(rosetta_scoring): # Set values for the parameters in our coarse grained model: polymer_length = 2 backbone_lengths = [1] sidechain_lengths = [1] sidechain_positions = [0] include_bond_forces = False # NOTE: By default bonds are constrained to their equilibrium lengths, even when this variable is set to False, unless 'constrain_bonds'=False constrain_bonds = True include_bond_angle_forces = False include_nonbonded_forces = True include_torsion_forces = False # Particle properties mass = 100.0 * unit.amu masses = {'backbone_bead_masses': mass, 'sidechain_bead_masses': mass} bond_length = 1.0 * unit.angstrom bond_lengths = { 'bb_bb_bond_length': bond_length, 'bb_sc_bond_length': bond_length, 'sc_sc_bond_length': bond_length } bond_force_constant = 0.0 * unit.kilocalorie_per_mole / unit.nanometer / unit.nanometer bond_force_constants = { 'bb_bb_bond_k': bond_force_constant, 'bb_sc_bond_k': bond_force_constant, 'sc_sc_bond_k': bond_force_constant } r_min = bond_length sigma = r_min / (2.0**(1 / 6)) sigmas = {'bb_sigma': sigma, 'sc_sigma': sigma} epsilon = 0.2 * unit.kilocalorie_per_mole epsilons = {'bb_eps': epsilon, 'sc_eps': epsilon} exclusions = True # Get positions from a local PDB file written by PyRosetta, and modified (by hand) to have a geometry where the nonbonded interactions are easy to evaluate cgmodel = CGModel(polymer_length=polymer_length, backbone_lengths=backbone_lengths, sidechain_lengths=sidechain_lengths, sidechain_positions=sidechain_positions, masses=masses, sigmas=sigmas, epsilons=epsilons, bond_lengths=bond_lengths, include_nonbonded_forces=include_nonbonded_forces, include_bond_forces=include_bond_forces, include_bond_angle_forces=include_bond_angle_forces, include_torsion_forces=include_torsion_forces, rosetta_scoring=rosetta_scoring, exclusions=exclusions, constrain_bonds=constrain_bonds) pyrosetta_sequence = ''.join([ str('X[' + str(monomer['monomer_name']) + ']') for monomer in cgmodel.sequence ]) pose = pyrosetta.pose_from_sequence(pyrosetta_sequence) pose.dump_pdb("test_pyrosetta.pdb") cgmodel.positions = PDBFile("test_pyrosetta.pdb").getPositions() cgmodel.topology = build_topology(cgmodel) return (cgmodel, pose)
def create_pose(seq='DAYAQWLKDGGPSSGRPPPS'): pose = pyrosetta.pose_from_sequence(seq) # set given initial conditions for res in range(1, pose.total_residue() + 1): pose.set_phi(res, -150) pose.set_psi(res, 150) pose.set_omega(res, 180) return pose
def test_setBBBL(): pose = pyrosetta.pose_from_sequence( 'X[CG11x3:CGLower]X[CG11x3]X[CG11x3][CG11x3:CGUpper]') set_bbbl = cg_pyrosetta.CG_movers.setBondLengths(pose, { "BB1 BB2": 20.3, "BB2 BB3": 20.3, "BB1 BB3": 20.3, }) set_bbbl.apply(pose) for atom1, atom2 in set_bbbl.bb_bonds[1:-1]: assert pose.conformation().bond_length(atom1, atom2) == 20.3
def reset(self): pdb_id = self.chain_id.split('_')[0] npy_file = os.path.join(self.chains_dir, pdb_id, self.chain_id + '.npy') state = np.load(npy_file) seq_string = self._get_seq_string() self.pose = pyrosetta.pose_from_sequence(seq_string) self._set_pose(state) return state
def bh(eaObj, initcfg): # Create references to variables in ini file eaObj.genN = int(initcfg['nGen']) eaObj.pdbid = initcfg['protein'] eaObj.proteinPath = initcfg['path'] # 3 different initialization states # The protein can be instantiated through 3 different file types: # .fasta, .pdb, or a sequence file. if initcfg['initState'] == 'extended': eaObj.sequence = seq_from_fasta( eaObj.proteinPath + "{0}/{0}.fasta".format(eaObj.pdbid)) eaObj.initialPose = pose_from_sequence(eaObj.sequence) elif initcfg['initState'] == 'pdb': eaObj.initialPose = pose_from_pdb(eaObj.proteinPath + "{0}/{0}.pdb".format(eaObj.pdbid)) elif initcfg['initState'] == 'sequence': eaObj.sequence = initcfg['sequence'] eaObj.initialPose = pose_from_sequence(eaObj.sequence) else: raise Exception("Unrecognized initState!") eaObj.seqLen = eaObj.initialPose.size()
def initialize_pose_from_rama(sequence): """ args: : sequence (str) - The primary structure of the pose returns: : (pyrosetta.Pose) """ pose = pyrosetta.pose_from_sequence(sequence) mover = pyrosetta.rosetta.protocols.backbone_movers.RandomizeByRamaPrePro() mover.apply(pose) return pose
def compare_openmm_energy_pyrosetta_score(cgmodel, mm=False): """ Given a cgmodel class object, this function determines if PyRosetta and OpenMM give the same score/energy with identical model settings. Parameters ---------- cgmodel: Coarse grained model class object. """ pyrosetta_sequence = ''.join([ str('X[' + str(monomer['monomer_name']) + ']') for monomer in cgmodel.sequence ]) # Build a PyRosetta pose pose = pyrosetta.pose_from_sequence(pyrosetta_sequence) # Write the pose to a PDB file file_name = "init.pdb" pose.dump_pdb(file_name) # Reformat the PDBFile for OpenMM compatibility (add inter-residue bonds) cgmodel.positions = PDBFile(file_name).getPositions() write_pdbfile_without_topology(cgmodel, file_name) cgmodel = read_pdbfile(cgmodel, file_name) # Define a PyRosetta scoring function scorefxn = build_scorefxn(cgmodel, mm=mm) # Get the PyRosetta score score = scorefxn(pose) # Get the cg_openmm energy energy = get_mm_energy(cgmodel.topology, cgmodel.system, cgmodel.positions).in_units_of( unit.kilocalorie_per_mole) # Obtain a state for our simulation context print("The PyRosetta score is: " + str(score)) print("The OpenMM potential energy is: " + str(energy)) file = open("energies.dat", "w") file.write("The nonbonded interaction list is: " + str(cgmodel.nonbonded_interaction_list) + "\n") file.write("The distances between these particles are: " + str([ distance(cgmodel.positions[interaction[0]], cgmodel.positions[ interaction[1]]) for interaction in cgmodel.nonbonded_interaction_list ])) file.write("The PyRosetta score is: " + str(score) + "\n") file.write("The OpenMM potential energy is: " + str(energy) + "\n") file.close() return
def test_CGSmallAngleMover(): pymol = pyrosetta.PyMOLMover() pose = pyrosetta.pose_from_sequence( 'X[CG11x3:CGLower]X[CG11x3]X[CG11x3][CG11x3:CGUpper]') conf = pose.conformation() small_mover = cg_pyrosetta.CG_movers.CGSmallAngleMover(pose) # print(small_mover.bond_angles) assert len(small_mover.bond_angles) != 0 pymol.apply(pose) for angle in small_mover.bond_angles: print("Changing Angle:", angle[0], angle[1], angle[2]) old_angle = conf.bond_angle(angle[0], angle[1], angle[2]) conf.set_bond_angle(angle[0], angle[1], angle[2], old_angle + 10 * np.pi / 180) pymol.apply(pose) assert conf.bond_angle(angle[0], angle[1], angle[2]) == pytest.approx(old_angle + 10 * np.pi / 180)
def buildProtein(sequence, outdir, start_idx=1): from htmd.builder.preparation import proteinPrepare from htmd.ui import Molecule, amber import sys sys.path.append( "/home/pablo/PyRosetta4.Release.python36.linux.release-197") import pyrosetta pyrosetta.init() pose = pyrosetta.pose_from_sequence(sequence, 'fa_standard') pose.dump_pdb('/tmp/test.pdb') mol = Molecule('/tmp/test.pdb') mol = proteinPrepare(mol) mol.resid = mol.resid + start_idx mol.set('segid', 'P1') mol.filter('backbone') _ = amber.build(mol, outdir=outdir, ionize=False # , caps=None ) return outdir + '/structure.prmtop'
def main(): pyrosetta.init() for id, c in enumerate(RESIDUE_LETTERS): atom_count = None chi_count = None try: pose = pyrosetta.pose_from_sequence(c, 'fa_standard') residue = pose.residue(1) atom_count = pose.residue(1).natoms() chi_count = len(residue.chi()) except Exception as e: print('Error processing {}: {}'.format(c, e)) ATOM_COUNT[id] = atom_count CHI_COUNT[id] = chi_count print('Max atom count: {}'.format(max(ATOM_COUNT))) print('Max chi angles count: {}'.format(max(CHI_COUNT)))
def testCGSmallAngleMover(): pose = pyrosetta.pose_from_sequence( 'X[CG11x3:CGLower]X[CG11x3]X[CG11x3][CG11x3:CGUpper]') x_old = pose.xyz(pyrosetta.AtomID(1, pose.size())).x y_old = pose.xyz(pyrosetta.AtomID(1, pose.size())).y z_old = pose.xyz(pyrosetta.AtomID(1, pose.size())).z small_angle_mover = cg_pyrosetta.CG_movers.CGSmallAngleMover(pose) for _ in range(200): small_angle_mover.apply(pose) x_new = pose.xyz(pyrosetta.AtomID(1, pose.size())).x y_new = pose.xyz(pyrosetta.AtomID(1, pose.size())).y z_new = pose.xyz(pyrosetta.AtomID(1, pose.size())).z assert x_new != x_old assert y_new != y_old assert z_new != z_old
def compare_openmm_energy_pyrosetta_score(cgmodel): """ Given a cgmodel class object, this function determines if PyRosetta and OpenMM give the same score/energy with identical model settings. Parameters ---------- cgmodel: Coarse grained model class object. """ #build_params_files(cgmodel) pyrosetta.init() pyrosetta_sequence = ''.join([ str('X[' + str(monomer['monomer_name']) + ']') for monomer in cgmodel.sequence ]) # Build a PyRosetta pose pose = pyrosetta.pose_from_sequence(pyrosetta_sequence) # Define a PyRosetta scoring function pose.dump_pdb("test_pyrosetta.pdb") scorefxn = build_scorefxn(cgmodel) cgmodel.positions = PDBFile("test_pyrosetta.pdb").getPositions() cgmodel.topology = build_topology(cgmodel) write_pdbfile_without_topology(cgmodel, "test_foldamers.pdb") # get the PyRosetta score score = scorefxn(pose) # Build an OpenMM simulation object so that we can calculate the energy using a simulation Context() temperature = 300.0 * unit.kelvin simulation = build_mm_simulation(cgmodel.topology, cgmodel.system, cgmodel.positions, temperature=temperature, simulation_time_step=5.0 * unit.femtosecond) # Obtain a state for our simulation context energy = simulation.context.getState(getEnergy=True).getPotentialEnergy() print("The PyRosetta score is: " + str(score) + "\n") print("The OpenMM potential energy is: " + str(energy) + "\n") return
def extract_results(X_test, Z_test, generative): global NUM_NUCLEOTIDES, FINAL_RESULTS_CSV, TYPE_NUCLEOTIDES headers = ("Sequence", "Degrees", "Score DB", "Score Generated") with open(FINAL_RESULTS_CSV, "w", newline="", encoding="utf-8") as csvfile: writer = csv.writer(csvfile) writer.writerow(headers) gen_imgs = generative.predict(X_test) for i in range(1, len(X_test)): pose_new = Pose() sequence = "" muestra = X_test[i] for no in range(0, NUM_NUCLEOTIDES): if muestra[0, no] == 1: sequence = sequence + "A[ADE]" elif muestra[1, no] == 1: sequence = sequence + "G[GUA]" elif muestra[2, no] == 1: sequence = sequence + "C[CYT]" elif muestra[3, no] == 1: sequence = sequence + "T[THY]" pose_new = pose_from_sequence(sequence) data = [] gen_img = gen_imgs[i] for k in range(0, NUM_NUCLEOTIDES): data.append(gen_img[0, k, 0]) pose_new.set_gamma(k + 1, gen_img[0, k, 0]) data.append(gen_img[1, k, 0]) pose_new.set_epsilon(k + 1, gen_img[1, k, 0]) data.append(gen_img[2, k, 0]) pose_new.set_delta(k + 1, gen_img[2, k, 0]) data.append(gen_img[3, k, 0]) pose_new.set_chi(k + 1, gen_img[3, k, 0]) data.append(gen_img[4, k, 0]) pose_new.set_zeta(k + 1, gen_img[4, k, 0]) score = scorefxn(pose_new) table = [sequence, data, Z_test[i], score] with open(FINAL_RESULTS_CSV, "a", newline="", encoding="utf-8") as csvfile: writer = csv.writer(csvfile) writer.writerow(table)
def test_randomizeBB(): pose = pyrosetta.pose_from_sequence( 'X[CG11x3:CGLower]X[CG11x3]X[CG11x3][CG11x3:CGUpper]') small = cg_pyrosetta.CG_movers.CGSmallMover(pose) old_angles = [] for atoms in small.dihes: old_angles.append(pose.conformation().torsion_angle( atoms[0], atoms[1], atoms[2], atoms[3])) randomize = cg_pyrosetta.CG_movers.randomizeBackBone(pose) randomize.apply(pose) new_angles = [] for atoms in small.dihes: new_angles.append(pose.conformation().torsion_angle( atoms[0], atoms[1], atoms[2], atoms[3])) bool_array = [ old_angles[i] != new_angles[i] for i in range(len(small.dihes)) ] assert (all(bool_array))
def save_created_figures(epoch, my_generative, X_test): #noise = noise_nucleotides(1) idx = np.random.randint(0, X_test.shape[0], 1) X_test = X_test[idx] gen_img = my_generative.predict(X_test) pose_new = Pose() sequence = "" global NUM_NUCLEOTIDES for no in range(0, NUM_NUCLEOTIDES): if X_test[0, 0, no] == 1: sequence = sequence + "A[ADE]" elif X_test[0, 1, no] == 1: sequence = sequence + "G[GUA]" elif X_test[0, 2, no] == 1: sequence = sequence + "C[CYT]" elif X_test[0, 3, no] == 1: sequence = sequence + "T[THY]" pose_new = pose_from_sequence(sequence) data = [] for k in range(0, NUM_NUCLEOTIDES): data.append(gen_img[0, 0, k, 0]) pose_new.set_gamma(k + 1, gen_img[0, 0, k, 0]) data.append(gen_img[0, 1, k, 0]) pose_new.set_epsilon(k + 1, gen_img[0, 1, k, 0]) data.append(gen_img[0, 2, k, 0]) pose_new.set_delta(k + 1, gen_img[0, 2, k, 0]) data.append(gen_img[0, 3, k, 0]) pose_new.set_chi(k + 1, gen_img[0, 3, k, 0]) data.append(gen_img[0, 4, k, 0]) pose_new.set_zeta(k + 1, gen_img[0, 4, k, 0]) score = scorefxn(pose_new) save_to_csv(sequence, data, score) create_pdb_and_save(pose_new, score, epoch)
def generate_fuzzball_contact_rotamersets(ligand_conformer_path, match_path, match_pose, sfxn, match_residue_map, flag_special_rot=True, custom_taskop=None, rotset_limit=200, contact_method='RMSD', RMSD_limit=1.5, apply_minimization=False, dump_rotamerset_pdb=False, report_stats=False, defined_positions=None): """ Generate rotamers that recapitulate observed fuzzball contacts for each position in a nucleated match :param ligand_conformer_path: path to ligand generated by molfile_to_params.py :param flag_special_rot: If true, flag rotamers as SPECIAL_ROT variants :param custom_taskop: list of task operations to apply to the PackerTask used to generate rotamers :return: viable_rotamers dictionary of rotamers organized by position and residue identity """ sfxn_weights = sfxn.weights() conformer_resnum = match_pose.size( ) # Assumes single ligand appended to end of sequence if contact_method not in ['RMSD', 'matcher']: raise Exception( 'Contact method needs to be one of the following: "RMSD", "matcher"' ) # --- Find and store viable rotamers --- # viable_rotamers = dict() rotamer_stats = dict() # Setting things up is going to mess up the match pose, so use a clone match_pose_clone = match_pose.clone() sfxn(match_pose_clone) # --- Transform match pose clone onto fuzzball conformer --- # """Required for contact coordsets to make sense""" # Get ligand from match, always last residue # todo: select chain X, ligand is always chain X match_pose_size = match_pose_clone.size() match_ligand = match_pose_clone.residue(match_pose_size) # Get match positions if they exist motif_resnums = list() with open(match_path, 'r') as my_match: for line in my_match: if line.startswith('REMARK 666 MATCH TEMPLATE'): motif_resnums.append(int(line.split()[11])) motif_and_ligand_resnums = motif_resnums + [conformer_resnum] # Keep track of match positions and compatible residue identites # match_residue_map = {position: dict() for position in range(1, match_pose.size())} # Assumes one ligand appended to end of sequence # Import conformer from pose fuzzball_ligand_pose = rosetta.core.pose.Pose() rosetta.core.import_pose.pose_from_file(fuzzball_ligand_pose, ligand_conformer_path) fuzzball_ligand = fuzzball_ligand_pose.residue(1) # Calculate rotation/translation by hand using first three atoms of ligand mobile_match = rosetta.numeric.xyzTransform_double_t( match_ligand.xyz(1), match_ligand.xyz(2), match_ligand.xyz(3)) mobile_match_inverse = mobile_match.inverse() target_fuzzball = rosetta.numeric.xyzTransform_double_t( fuzzball_ligand.xyz(1), fuzzball_ligand.xyz(2), fuzzball_ligand.xyz(3)) ligand_rotation = target_fuzzball.R * mobile_match_inverse.R ligand_translation = target_fuzzball.R * mobile_match_inverse.t + target_fuzzball.t # Apply transformation match_pose_clone.apply_transform_Rx_plus_v(ligand_rotation, ligand_translation) match_pose_clone_ligand = match_pose_clone.residue(match_pose_size).clone() # --- All other operations --- # # Mutate all non-motif residues within 10A from ligand to ALA, interferes with RotamerSet generation ligand_residue_selector = rosetta.core.select.residue_selector.ChainSelector( 'X') neighborhood_selector = rosetta.core.select.residue_selector.NeighborhoodResidueSelector( ligand_residue_selector, 10, False) neighborhood_selector_bool = neighborhood_selector.apply(match_pose_clone) neighborhood_residues_resnums = rosetta.core.select.get_residues_from_subset( neighborhood_selector_bool) positions_to_consider = list( set(neighborhood_residues_resnums) - set(motif_and_ligand_resnums)) mutate = rosetta.protocols.simple_moves.MutateResidue() mutate.set_res_name('ALA') for position in positions_to_consider: if match_pose_clone.residue(position).name3() not in [ 'GLY', 'PRO' ] and 'disulfide' not in match_pose_clone.residue(position).name(): mutate.set_target(position) mutate.apply(match_pose_clone) # Build RotamerSets for each extrachi/sample level if dump_rotamerset_pdb: all_rotamersets = rosetta.core.pack.rotamer_set.RotamerSetsFactory.create_rotamer_sets( match_pose_clone) task_factory = rosetta.core.pack.task.TaskFactory() # NATRO positions TaskOp rotamer_candidates_rs = rosetta.core.select.residue_selector.ResidueIndexSelector( ','.join([str(i) for i in match_residue_map.keys()])) natro_rs = rosetta.core.select.residue_selector.NotResidueSelector( rotamer_candidates_rs) natro_op = rosetta.core.pack.task.operation.OperateOnResidueSubset( rosetta.core.pack.task.operation.PreventRepackingRLT(), natro_rs) task_factory.push_back(natro_op) rotamersets_packer_task = task_factory.create_task_and_apply_taskoperations( match_pose_clone) all_rotamersets.set_task(rotamersets_packer_task) # Remove ligand from match_pose_clone before generating rotamers!!! match_pose_clone_apo = match_pose_clone.clone() match_pose_clone_apo.conformation_ptr().delete_residue_slow( match_pose_size) # Define positions where rotamers will be considered if defined_positions: rotamerset_positions = list( set(defined_positions) & set(match_residue_map.keys())) else: rotamerset_positions = list(match_residue_map.keys()) print(f'Rotamerset Positions: {rotamerset_positions}') # Generate rotamers at each position for position in rotamerset_positions: # Prepare minimization if apply_minimization: motif_movemap = rosetta.core.kinematics.MoveMap() motif_movemap.set_chi(position, True) minimize_motif = rosetta.protocols.minimization_packing.MinMover() minimize_motif.movemap(motif_movemap) minimize_motif.score_function(sfxn) minimize_motif.min_type('lbfgs_armijo') minimize_motif.tolerance(1e-6) # Prepare infrastructure rotamer_stats[position] = dict() if dump_rotamerset_pdb: current_rotamerset = rosetta.core.pack.rotamer_set.RotamerSetFactory.create_rotamer_set( match_pose_clone) # Keep rotamers that are compatible with minimal binding motif for contact_residue in match_residue_map[position]: # print(f'Considering position {position}: {contact_residue}') position_rotamer_list = list() possible_contact_geometries = match_residue_map[position][ contact_residue] # --- Prepare viable rotamers for each position --- # # Define packertask using neighborhood_selector packer_task = rosetta.core.pack.task.TaskFactory.create_packer_task( match_pose_clone_apo) packer_task.initialize_from_command_line() # Get boolean vector for packable positions and apply to packer task packable_positions = rosetta.utility.vector1_bool() packable_position_list = [ True if i == position else False for i in range(1, match_pose_clone_apo.size()) ] for bool_value in packable_position_list: packable_positions.append(bool_value) packer_task.restrict_to_residues(packable_positions) # Only build rotamers for residues with Hbond donors/acceptors restrict_CAAs = rosetta.core.pack.task.operation.RestrictAbsentCanonicalAAS( position, rosetta.utility.vector1_bool(20)) restrict_CAAs.keep_aas(contact_residue) restrict_CAAs.apply(match_pose_clone_apo, packer_task) packer_neighbor_graph = rosetta.core.pack.create_packer_graph( match_pose_clone_apo, sfxn, packer_task) match_rotamer_set = rosetta.core.pack.rotamer_set.RotamerSetFactory.create_rotamer_set( match_pose_clone_apo) match_rotamer_set.set_resid(position) match_rotamer_set.build_rotamers(match_pose_clone_apo, sfxn, packer_task, packer_neighbor_graph, use_neighbor_context=False) if match_rotamer_set.num_rotamers( ) <= 1 and match_rotamer_set.rotamer(1).name1() != contact_residue: continue print( f'Position {position} ResidueType {contact_residue} - comparing {match_rotamer_set.num_rotamers()} rotamers against {len(possible_contact_geometries)} contact modes' ) rotamer_stats[position][contact_residue] = dict() rotamer_stats[position][contact_residue][ 'num_rotamers'] = match_rotamer_set.num_rotamers() rotamer_info = list() rotamers_accepted = 0 # --- Evaluate Rotamers --- # for rotamer in range(1, match_rotamer_set.num_rotamers() + 1): # Place residue before applying to pose!!!! # Rotamers need to be transformed back onto the backbone of the input pdb!!! trail_rotamer = match_rotamer_set.rotamer(rotamer) trail_rotamer.place(match_pose_clone.residue(position), match_pose_clone.conformation_ptr()) match_pose_clone.replace_residue(position, trail_rotamer, False) pose_trial_rotamer = match_pose_clone.residue(position) # Evaluate RMSD to possible_contact_geometries contact_RMSDs = list() dof_errors = list() sad_atom_in_rotamer = False for contact_mode in possible_contact_geometries: # REFERENCE: contact_info = [current_motif_coord_list, [float(a) for a in dof_tuple], constraint_atoms_dict['residue']['atom_names'], constraint_atoms_dict['ligand']['atom_names']] current_motif_coord_list = contact_mode[0] contact_dofs = contact_mode[1] residue_matchatoms = contact_mode[2] ligand_matchatoms = contact_mode[3] # Skip rotamer if contact is mediated by a backbone atom... if residue_matchatoms[0] in ['C', 'CA', 'N', 'O']: continue # Get contact atom coords using atom names try: rotamer_contact_coords = [ list(match_pose_clone.residue(position).xyz(atom)) for atom in residue_matchatoms ] # If distance is off, don't even bother... residue_contactatom = pose_trial_rotamer.xyz( residue_matchatoms[0]) ligand_contactatom = match_pose_clone_ligand.xyz( ligand_matchatoms[0]) atom_displacement = ligand_contactatom - residue_contactatom if atom_displacement.norm() > 4: # print(f'Contact is {atom_displacement.norm()}A, continuing...') continue residue_atomid_list = [ pose_trial_rotamer.xyz(atom) for atom in residue_matchatoms ] ligand_atomid_list = [ match_pose_clone_ligand.xyz(atom) for atom in ligand_matchatoms ] # Res1 - ligand, Res2 - residue # 'angle_A' is the angle Res1:Atom2 - Res1:Atom1 - Res2:Atom1 angle_A = rosetta.numeric.angle_degrees_double( ligand_atomid_list[1], ligand_atomid_list[0], residue_atomid_list[0]) # 'angle_B' is the angle Res1:Atom1 - Res2:Atom1 - Res2:Atom2 angle_B = rosetta.numeric.angle_degrees_double( ligand_atomid_list[0], residue_atomid_list[0], residue_atomid_list[1]) # 'torsion_A' is the dihedral Res1:Atom3 - Res1:Atom2 - Res1:Atom1 - Res2:Atom1 torsion_A = rosetta.numeric.dihedral_degrees_double( ligand_atomid_list[2], ligand_atomid_list[1], ligand_atomid_list[0], residue_atomid_list[0]) # 'torsion_AB' is the dihedral Res1:Atom2 - Res1:Atom1 - Res2:Atom1 - Res2:Atom2 torsion_AB = rosetta.numeric.dihedral_degrees_double( ligand_atomid_list[1], ligand_atomid_list[0], residue_atomid_list[0], residue_atomid_list[1]) # 'torsion_B' is the dihedral Res1:Atom1 - Res2:Atom1 - Res2:Atom2 - Res2:Atom3 torsion_B = rosetta.numeric.dihedral_degrees_double( ligand_atomid_list[0], residue_atomid_list[0], residue_atomid_list[1], residue_atomid_list[2]) rotamer_dofs = [ angle_A, angle_B, torsion_A, torsion_AB, torsion_B ] except Exception as e: print(e, residue_matchatoms, ligand_matchatoms) # print(f'Skipping {contact_mode[0]}: contains sad atom.') sad_atom_in_rotamer = True break # todo: Edge condition at 0/360... dof_difference_list = [ abs(ideal - measured) for ideal, measured in zip( contact_dofs[1:], rotamer_dofs) ] # print('contact_dofs:', contact_dofs) # print('rotamer_dofs:', rotamer_dofs) # print('DOF DIFFERENCE LIST:', dof_difference_list) dof_errors.append(max(dof_difference_list)) contact_RMSDs.append( prody.calcRMSD(np.asarray(current_motif_coord_list), np.asarray(rotamer_contact_coords))) if len(dof_errors) == 0: continue if sad_atom_in_rotamer: continue # Continue if current rotamer does not have <{RMSD_limit}A RMSD with any contact mode if contact_method == 'RMSD' and min(contact_RMSDs, default=666) > RMSD_limit: rotamer_info.append((contact_RMSDs, None, None)) continue # Only continue if a contact mode exists where max angle/torsion DOF error < 10 degrees if contact_method == 'matcher' and min(dof_errors) > 15: continue # Apply minimization to rotamer-ligand interaction before deciding to accept if apply_minimization: minimize_motif.apply(match_pose_clone) # Evaluate possible clashes (fa_rep) with motif residues and ligand sfxn(match_pose_clone) edges = match_pose_clone.energies().energy_graph() motif_fa_rep = list() for motif in motif_and_ligand_resnums: current_edge = edges.find_energy_edge(position, motif) if current_edge is not None: current_edge.fill_energy_map() motif_fa_rep.append( current_edge[rosetta.core.scoring.fa_rep]) # Get score for current rotamer against ligand current_edge = edges.find_energy_edge(position, conformer_resnum) rotamer_ligand_reu = current_edge.dot( sfxn_weights) if current_edge is not None else 0 if all([ min(motif_fa_rep, default=666) < 20, rotamer_ligand_reu <= 20 ]): if flag_special_rot: current_rsd_type_ptr = match_pose_clone.residue_type_ptr( position) new_rsd_type_mutable = rosetta.core.chemical.MutableResidueType( current_rsd_type_ptr) new_rsd_type_mutable.add_variant_type( rosetta.core.chemical.SPECIAL_ROT) new_rsd_type = rosetta.core.chemical.ResidueType.make( new_rsd_type_mutable) rosetta.core.pose.replace_pose_residue_copying_existing_coordinates( match_pose_clone, position, new_rsd_type) # Place residue before applying to pose!!!! # Rotamers need to be transformed back onto the backbone of the input pdb!!! new_rotamer = match_pose_clone.residue(position).clone() new_rotamer.place(match_pose.residue(position), match_pose.conformation_ptr()) position_rotamer_list.append( (rotamer_ligand_reu, new_rotamer)) rotamers_accepted += 1 if dump_rotamerset_pdb: current_rotamerset.add_rotamer(new_rotamer) rotamer_info.append( (max(dof_errors), max(motif_fa_rep, default=0), rotamer_ligand_reu)) print( f'{rotamers_accepted} of {match_rotamer_set.num_rotamers()} rotamers accepted' ) rotamer_stats[position][contact_residue][ 'rotamer_info'] = rotamer_info rotamer_stats[position][contact_residue][ 'rotamers_accepted'] = rotamers_accepted if len(position_rotamer_list) > 0: position_rotamer_list_selected = sorted( position_rotamer_list, key=lambda x: x[0])[:rotset_limit] position_rotamer_list = [ rot[1] for rot in position_rotamer_list_selected ] if position not in viable_rotamers.keys(): viable_rotamers[position] = dict() viable_rotamers[position][ contact_residue] = position_rotamer_list if dump_rotamerset_pdb: current_moltresid = all_rotamersets.resid_2_moltenres(position) all_rotamersets.set_explicit_rotamers(current_moltresid, current_rotamerset) if dump_rotamerset_pdb: current_extrachi = len([ rosetta.basic.options.get_boolean_option(f'packing:ex{i}') for i in range(1, 5) if rosetta.basic.options.get_boolean_option(f'packing:ex{i}') is True ]) current_sample_level = rosetta.basic.options.get_integer_option( f'packing:ex{current_extrachi}:level') if current_extrachi <= 2 and current_sample_level <= 3: match_name = os.path.normpath(os.path.basename(match_path)) # todo: figure out why this doesn't work... problem with CONECT records... # all_rotamersets.dump_pdb(match_pose_clone, f"{match_name.split('.')[0]}-extrachi_{current_extrachi}-sampling_{current_sample_level}.pdb") all_rotamers_pose = pyrosetta.pose_from_sequence('A') for position in match_residue_map.keys(): position_rotset = all_rotamersets.rotamer_set_for_residue( position) for rot in range(1, position_rotset.num_rotamers() + 1): all_rotamers_pose.append_residue_by_jump( position_rotset.rotamer(rot), 1) all_rotamers_pose.dump_pdb( f"{match_name.split('.')[0]}-extrachi_{current_extrachi}-sampling_{current_sample_level}.pdb" ) if report_stats: return viable_rotamers, rotamer_stats else: return viable_rotamers
import pyrosetta.rosetta as rosetta pyrosetta.init( extra_options="-constant_seed" ) # WARNING: option '-constant_seed' is for testing only! MAKE SURE TO REMOVE IT IN PRODUCTION RUNS!!!!! import os os.chdir('.test.output') print(pyrosetta.version()) pose = rosetta.core.import_pose.pose_from_file("../test/data/test_in.pdb") scorefxn = rosetta.core.scoring.get_score_function() scorefxn(pose) pose2 = pyrosetta.pose_from_sequence("ARNDCEQGHILKMFPSTWYV", 'fa_standard') scorefxn = rosetta.core.scoring.get_score_function() scorefxn(pose2) pose3 = pyrosetta.pose_from_sequence("DSEEKFLRRIGRFGYGYGPYE", 'centroid') # Creating standard centroid score function and scoring scorefxn = rosetta.core.scoring.ScoreFunctionFactory.create_score_function( 'score3') scorefxn(pose3) pose_fs = pyrosetta.pose_from_sequence("DSEEKFLRRIGRFGYGYGPYE") pose_fs.delete_polymer_residue( 2) # Testing that attached PDB info have right size...
#!/usr/bin/env python # :noTabs=true: from __future__ import print_function import rosetta, pyrosetta pyrosetta.init( extra_options="-constant_seed" ) # WARNING: option '-constant_seed' is for testing only! MAKE SURE TO REMOVE IT IN PRODUCTION RUNS!!!!! import os os.chdir('.test.output') pose = pyrosetta.pose_from_sequence('EVAAAVAT') pymol = pyrosetta.PyMOLMover() pymol.apply(pose) scorefxn = pyrosetta.get_fa_scorefxn( ) # rosetta.create_score_function('standard') scorefxn(pose) pymol.send_energy(pose) #pymol.send_energy(pose, label=True) DEPRECATED: needed to be ported to C++ version #pymol.send_colors(pose, {}, default_color="orange") pymol.send_colors(pose, rosetta.std.map_int_int(), default_color=rosetta.protocols.moves.XC_orange)
def pose(): return(pyrosetta.pose_from_sequence('X[CG11]X[CG11]X[CG11]X[CG11]X[CG11]'))
import pyrosetta as pr import configparser as cp import math import random # *************** # Initial setup * # *************** pr.init() # Read configuration file conf = cp.ConfigParser() conf.read("configs/generation.ini") # Read fasta file and generate a pose from the sequence pose = pr.pose_from_sequence( io.get_sequence_from_fasta(conf['init']['fastaPath'])) # Native pose native_pose = pr.pose_from_pdb(conf['init']['pdbPath']) # Convert the pose to coarse-grained representation switch = pr.SwitchResidueTypeSetMover("centroid") switch.apply(pose) switch.apply(native_pose) # Create score function for evaluation score4_function = pr.create_score_function("score3", "score4L") score4_function.set_weight(pr.rosetta.core.scoring.rama, 1) population_size = int(conf['init']['population'])
os.chdir('.test.output') print(pyrosetta.version()) pose = rosetta.core.import_pose.pose_from_file("../test/data/test_in.pdb") scorefxn = rosetta.core.scoring.get_score_function() scorefxn(pose) pose2 = rosetta.core.pose.Pose() pyrosetta.make_pose_from_sequence(pose2, "ARNDCEQGHILKMFPSTWYV", 'fa_standard') scorefxn = rosetta.core.scoring.get_score_function() scorefxn(pose2) pose3 = Pose() pyrosetta.make_pose_from_sequence(pose3, "DSEEKFLRRIGRFGYGYGPYE", 'centroid') # Creating standard centroid score function and scoring scorefxn = rosetta.core.scoring.ScoreFunctionFactory.create_score_function( 'score3') scorefxn(pose3) pose_fs = pyrosetta.pose_from_sequence("DSEEKFLRRIGRFGYGYGPYE") pose_fs.delete_polymer_residue( 2) # Testing that attached PDB info have right size... import pyrosetta.toolbox pyrosetta.toolbox.pose_from_rcsb('1brs')
def __init__(self, sequence, BBB_angle=120, BBBB_dihe=180, file_name='outputs/traj.pdb', energy_graph_output=False): """ folding object used for easily implementing different movers into a single folding algorithm. Arguments --------- sequence : str Sequence of CG residues BBB_angle : float Desired angle of all B-B-B angles. Generalizes to all backbone models (not working) BBBB_angle : float Desired dihedral of all B-B-B-B torsion angles. Generalizes to all backbone models (not working) """ # Build CG model and set desired initial angles self.pose = pyrosetta.pose_from_sequence(sequence, auto_termini=False) self.energy_graph_output = energy_graph_output # self.pose = self.set_BBB_angles(self.pose, BBB_angle) # self.pose = self.set_BBBB_dihe(self.pose, BBBB_dihe) # PyMOL mover, if wanting to visualize self.pymol = pyrosetta.PyMOLMover() self.pymol.apply(self.pose) # randomizer = CG_movers.randomizeBackBone(self.pose) # randomizer.apply(self.pose) self.pymol.apply(self.pose) # Building PDBTrajWriter object, used for writing multiple structures # to a single file self.PDB_writer = pyrosetta.rosetta.protocols.canonical_sampling.PDBTrajectoryRecorder( ) # self.PDB_writer.apply(self.pose) # write initial structure self.PDB_writer.file_name('outputs/traj.pdb') self.PDB_writer.stride(100) # Define scorefunction terms self.scorefxn = pyrosetta.ScoreFunction() self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_rep, 1) self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_atr, 1) self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_intra_atr, 1) self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.fa_intra_rep, 1) self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_twist, 1) self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_bend, 1) # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_inter_rep, 1) # segfaults beware! # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_inter_atr, 1) # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_intra_rep, 1) # self.scorefxn.set_weight(pyrosetta.rosetta.core.scoring.mm_lj_intra_atr, 1) # Build standard CG 1-1 movers self.small = CG_movers.CGSmallMover(self.pose) # self.shear = CG_movers.CGShearMover(self.pose) self.small_angle = CG_movers.CGSmallAngleMover(self.pose) # Build minimization movers self.mini = pyrosetta.rosetta.protocols.minimization_packing.MinMover() self.mini.min_type('lbfgs_armijo_nonmonotone') self.movemap = pyrosetta.MoveMap() self.mini.score_function(self.scorefxn) # for atom in self.small_angle.bb_atoms: # self.movemap.set(pyrosetta.rosetta.core.id.DOF_ID(atom , pyrosetta.rosetta.core.id.THETA), True) self.movemap.set_bb_true_range(1, self.pose.size()) self.mini.movemap(self.movemap) # Build MC object + Trial Mover (empty for now) self.mc = pyrosetta.MonteCarlo(self.pose, self.scorefxn, 1) self.trial_mc = pyrosetta.TrialMover() # Building variable to store various folding algorithms self.folding_protocols = {} # Adding a default mover self.build_fold_alg('default') self.add_folding_move('default', pyrosetta.RepeatMover(self.small, 10)) # self.add_folding_move('default', pyrosetta.RepeatMover(self.shear, 10)) self.add_folding_move('default', pyrosetta.RepeatMover(self.mini, 10))
if random.randint(PHI, PSI) == PHI: torsion = pose.phi(res) a = random.gauss(torsion, 25) pose.set_phi(res, a) else: torsion = pose.psi(res) a = random.gauss(torsion, 25) pose.set_psi(res, a) # initialize pose objects last_pose = Pose() low_pose = Pose() # create poly-A chain and set all peptide bonds to trans p = pose_from_sequence("AAAAAAAAAA", "fa_standard") for res in range(1, p.total_residue() + 1): p.set_omega(res, 180) # use the PyMOLMover to echo this structure to PyMOL pmm = PyMOLMover() pmm.apply(p) # set score function to include Van der Wals and H-bonds only score = ScoreFunction() score.set_weight(fa_atr, 0.8) score.set_weight(fa_rep, 0.44) score.set_weight(hbond_sr_bb, 1.17) # initialize low score objects low_pose.assign(p)
frag_description = "\n" while offset < 3: phi, psi, omega, description = fragment[offset] frag_description += description + "\n" pose.set_phi(position + offset, phi) pose.set_psi(position + offset, psi) pose.set_omega(position + offset, omega) offset += 1 return frag_description seq = 'MIKVTVTNSFFEVTGHAPDKTLCASVSLLTQHVANFLKAEKKAKIKKESGYLKVKFEELENCEVKVLAAMVRSLKELEQKFPSQIRVEVIDNGS' three_mer_file = '../Projects/homework/homework_folding/structure_prediction/1S12/1S12.200.3mers' nine_mer_file = '../Projects/homework/homework_folding/structure_prediction/1S12/1S12.200.9mers' fragments = angles_from_file(three_mer_file) pose = pyrosetta.pose_from_sequence(seq) pmm = pyrosetta.PyMOLMover() pmm.apply(pose) accepted = 0 rejected = 0 scorefxn = pyrosetta.teaching.get_fa_scorefxn() score = scorefxn(pose) best_score = score best_pose = pyrosetta.pose_from_sequence(seq) best_pose.assign(pose) new_pose = pyrosetta.pose_from_sequence(seq)
#!/usr/bin/env python # :noTabs=true: # -*- coding: utf-8 -*- # (c) Copyright Rosetta Commons Member Institutions. # (c) This file is part of the Rosetta software suite and is made available under license. # (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. # (c) For more information, see http://www.rosettacommons.org. Questions about this can be # (c) addressed to University of Washington CoMotion, email: [email protected]. ## @file T201_Scoring_pre_talaris.py ## @brief Test to trigger creation of database/rotamer/bbdep02.May.sortlib.Dunbrack02.lib.bin ## @brief binaries on windows. ## @author Sergey Lyskov from __future__ import print_function import pyrosetta from pyrosetta import rosetta pyrosetta.init( extra_options="-restore_pre_talaris_2013_behavior" ) # trigger generation of database/rotamer/bbdep02.May.sortlib.Dunbrack02.lib.bin pose2 = pyrosetta.pose_from_sequence("ARNDCEQGHILKMFPSTWYV", 'fa_standard') scorefxn = rosetta.core.scoring.get_score_function() scorefxn(pose2)
mass = unit.Quantity(10.0, unit.amu) sigma = unit.Quantity(2.4, unit.angstrom) bond_length = unit.Quantity(1.0, unit.angstrom) epsilon = unit.Quantity(0.5, unit.kilocalorie_per_mole) # charge = unit.Quantity(0.0,unit.elementary_charge) # Define PDB files to test our PDB writing ability openmm_pdb_file = 'test_1_1_openmm.pdb' rosetta_pdb_file = 'test_1_1_rosetta.pdb' # Build a coarse grained model cgmodel = basic_cgmodel(polymer_length=polymer_length, backbone_length=backbone_length, sidechain_length=sidechain_length, sidechain_positions=sidechain_positions, mass=mass, bond_length=bond_length, sigma=sigma, epsilon=epsilon) # write_pdbfile_without_topology(cgmodel,openmm_pdb_file) pyrosetta_sequence = ''.join([str('['+str(monomer['monomer_name'])+']') for monomer in cgmodel.sequence]) # Compare OpenMM and PyRosetta energies # (This function is also where we initialize new residue/monomer # types in the PyRosetta database.) compare_openmm_energy_pyrosetta_score(cgmodel) pose_from_sequence = pyrosetta.pose_from_sequence(pyrosetta_sequence, 'coarse_grain') # Test our ability to write a PDB file using our pose and new residue type sets. pyrosetta.rosetta.core.io.pdb.dump_pdb(pose, rosetta_pdb_file) # Test our ability to read a pose from the PDB file we wrote pose_from_pdb = pyrosetta.pose_from_pdb(rosetta_pdb_file) # Define scorefunction terms pyrosetta_scorefxn = build_scorefxn(cgmodel) # Compare poses built from a PDB file and from the polymer sequence compare_pose_scores(pyrosetta_scorefxn, pose_from_pdb, pose_from_sequence, compare_pdb_sequence=True) exit()