Package: rdkit-to-params
RDKit to paramsCreate or modify Rosetta params files (topology files) from scratch, RDKit mols or another params file.InstallationTo install from pip type:pip install rdkit-to-paramsTo install the latest version (probably the same) from GitHubpip install git+https://github.com/matteoferla/rdkit_to_paramsRDKit and PyRosetta are optional module, but most of the useful functionality comes from the former.
To install rdkit,conda install -c conda-forge rdkitorapt-getorpip install rdkit-pypi.
To install PyRosetta you need to get a licence (free for academic use) and install it.
One option for installation without visiting the Rosetta Commons site is:pip install pyrosetta_help; PYROSETTA_USERNAME='👾👾👾' PYROSETTA_PASSWORD='👾👾👾' install_pyrosettaRationaleThis is a fresh rewrite ofmol_to_params.py. For three reasons:I cannot share my 2to3 port and modd  ed module-version ofmol_to_params.pydue to licence.I want to modifyparamsfiles and more as opposed to use a standalone script.RDKit does not savemol2files, yet knows about atom names and Gasteiger-Massilli charges and more...It sounds mad, but did not actually take too long.WebsiteFor a web app using this seehttps://direvo.mutanalyst.com/params.
For the code running the website, see:templatesviewsRoundtripNative amino acid params files can be found in the Rosetta folderrosetta/main/database/chemical/residue_type_sets/fa_standard/residue_types/l-caaLet's do a roundtrip changing an atomname:import pyrosetta
pyrosetta.init(extra_options='-mute all') # required for test
from rdkit_to_params import Params

p = Params.load('PHE.params')
p.IO_STRING[0].name3 = 'PHX'
p.IO_STRING[0].name1 = 'Z'
p.AA = 'UNK'  #If it's not one of the twenty (plus extras), UNK!
del p.ROTAMER_AA[0]
p.rename_atom(' CB ', ' CX ') # this renames
p.dump('fake.params')
p.test().dump_pdb('test.pdb')p.test()returns a pyrosetta pose. The static methodparams_to_pose('something.params', name3)accepts a params fileimport nglview
pose = Params.params_to_pose('some_topology_I_found.params', name3)
view = nglview.show_rosetta(pose)
viewFrom mol objectRequirementsFor the sake of sanity,EmbedMolecule,Chem.AddHs(mol)or any other operation is assumed to have been done beforehand.
And that the user is going to doChem.MolToPDBFile(params.mol)orChem.MolToPDBBlock(params.mol)or use the bound methods ofParams,dump_pdbanddump_pdb_conf(see below).The molecule should preferably benotKekulised.
3letter name of residue is either from the title row (_Name) if a 3letter word or from the PDBInfo or 'LIG'.Dummy atom (*/R) is assumed to be a CONNECT —ligand only atm.Here is a conversion to an amino acid from a SMILES (quickest way):import pyrosetta
pyrosetta.init(extra_options='-mute all')
from rdkit_to_params import Params
p = Params.from_smiles('*C(=O)C(Cc1ccccc1)[NH]*', #recognised as amino acid.
        name='PHX', #optional.
        atomnames={3: 'CZ'} #optional, rando atom name as see in previous edit
        )
print(p.is_aminoacid()) # True
p.dump('fake.params')
p.test().dump_pdb('test.pdb')
Chem.MolToPDBFile(mol, 'ref.pdb')Here is a conversion to a ligand the circuitous way, just for fun:import pyrosetta
pyrosetta.init(extra_options='-mute all')
# note that pyrosetta needs to be started before rdkit.
from rdkit_to_params import Params
# make the molecule in RDKit or chemdraw or download it or whatever.
mol = Chem.MolFromSmiles('NC(C(=O)O)Cc1ccccc1')
mol = AllChem.AddHs(mol)
AllChem.EmbedMolecule(mol)
AllChem.MMFFOptimizeMolecule(mol)
# add names to the mol beforehand
Params.add_names(mol, names=['N', 'CA', 'C', 'O', 'OXT', 'CB'], name='PHZ')
# parameterise
p = Params.from_mol(mol, name='PHZ')
p.test().dump_pdb('test.pdb')
Chem.MolToPDBFile('ref.pdb')The class methodadd_namesis based upon atom index
(which is derived from the SMILES or sdf/mol file unless atoms have been replaced).
The instance methodrename_by_substructureaccepts a substructure and a list of atom names in the order they are in the substructure.Note that conformer generation is not fully automatic and is not done by default.# make your conformers as you desire
AllChem.EmbedMultipleConfs(mol, numConfs=10) # or whatever you choose. This is a somewhat important decision.
AllChem.AlignMolConformers(mol) # I do not know if the conformers need to be aligned for Rosetta
# params time!
p = Params.from_mol(mol, name='LIG') 
p.dump_pdb_conf('LIG_conf.pdb')
p.PDB_ROTAMERS.append('LIG_conf.pdb')
p.dump('my_params.params')Notedump_pdbanddump_pdb_confwill save the molecule(s) without the dummy atoms, to stop this addstripped=False.From SMILES stringThe above is actually a bit convoluted for example purposes asParams.from_smiles, accepts a SMILES string.From SMILES string and PDB for namesIn some cases one has a PDB file with a ligand that needs parameterising.
Assuming one has also the smiles of the ligand (PubChem has an super easy search), one can dop = Params.from_smiles_w_pdbfile(pdb_file, smiles, 'XXX') # the name has to match.The smiles does not need to match full. It can contain more atoms or even one*(CONNECT).
The smiles gets parameterised. So be suse to add correct charges properly —hydrogens are added.
It could be used for scaffold hopping, but if position matters so much,
you may be interested inFragmenstein.For more seeautogenerated documentation. Sphinx with markdown cannot deal with typehinting,
so checking the code might be clearer.RenameA key part is the atom names ——this can happen at . The following renaming methods are present:p.rename(???): "overloaded" method that directs to the othersp.rename_from_str('XX,YY,ZZ')orp.rename_from_str('0:XX,3:YY')p.rename_from_list(['XX','YY', 'ZZ'])p.rename_from_dict({0:'XX',3:'YY'})p.rename_from_template(Chem.Mol)p.rename_by_substructure(Chem.Mol, ['XX','YY', 'ZZ'])where the list is the atom idx in substructureNote,retype_by_namedoes not have all these options (only atomname -> Rosetta atomtype).The class methodadd_namessimply uses these, but returns a molDIYIf you have two mol objects from whatever routes, the basic operation is:p = Params.load_mol(mol, generic=False, name='LIG')
p.rename_from_template(template) # or whatever middle step

p.convert_mol()Note thatconvert_molshould be called once and is already called in the twofrom_XXXclassmethods.p = Params.from_mol(...)
p.convert_mol() # No!!!
p.mol # is the mol...
p2 = Params.load_mol(p.mol)
p2.convert_mol() # YesConstraintsThe selfstanding classConstraintsis for generating constraint files, which are a must with covalent attachments
in order to stop janky topologies.
The class is instantiated with a pair of SMILES, each with at least a real atom and with one attachment point,
the first is the ligand and the second is its peptide target. The names of the heavy atoms and the Rosetta residue "numbers".from rdkit_to_params import Constraints
c = Constraints(smiles=('*C(=N)', '*SC'), names= ['*', 'CX', 'NY', '*', 'SG', 'CB'], ligand_res= '1B', target_res='145A')
c.dump('con.con')
# individual strings can be accessed
c.atom_pair_constraint
c.angle_constraint
c.dihedral_constaint
c.custom_constaint # if you want to add your own before `str`, `.dumps`, `.dump`.Do note that to make covalent links work in Rosetta, NGL and a few other places you need a LINK record, here is a f-string
for it:f'LINK        {target_atom: >4} {target_resn: >3} {p_chain[:1]} {target_resi: >3}                '+\
f'{ligand_atom: >4} {ligand_resn: >3} {ligand_chain[:1]} {ligand_resi: >3}     1555   1555  1.8\n'This is not to be confused with CCP4 REFMAC'sLINKR, which are however easy to covert.
Alternatively, you can add it after importing the pose,cf.pose.residue(lig_pos).connect_map.Bond orderIt is worth mentioning that the bond order specified in the topology file in theBOND_ORDERlines is mostly ignored
and the bond order is derived from the rosetta types that get assigned.
To extract and correct a ligand, consider the following# pose to string
buffer = pyrosetta.rosetta.std.stringbuf()
pose.dump_pdb(pyrosetta.rosetta.std.ostream(buffer))
pdbblock = buffer.str()
# get the residue
mol = Chem.MolFromPDBBlock(pdbblock, proximityBonding=False, removeHs=False)
ligand = Chem.SplitMolByPDBResidues(mol, whiteList=[params.NAME])[params.NAME]
# fix bond order
template = AllChem.DeleteSubstructs(params.mol, Chem.MolFromSmiles('*'))
AllChem.AssignBondOrdersFromTemplate(template, ligand)Amino acidsA*C(=O)C([*:3])[NH]*molecule, where R3 is whatever sidechain is automatically converted into an amino acid.
Omitting the hydrogen on the amine is fine (implicit), so*C(=O)C([*:3])N*is also automatically accepted.
Likewise, a secondary amine like in proline,*C(=O)C1CCCN1*, is automatically determined to be an amino acid.
Omitting the double bond of the carboxyl will result in a hydroxyl backbones amino acid, which will behave likeC=[OH+]for properties, but without the partial charge.
The criterion for an amino acid is if the substracture*NCC(~O)*is matched (see_aminoacid_override).However,C(=O)C([*:3])[NH]will be parsed as[CH](=O)C([*:3])[NH], i.e. with a radical amine and an aldehyde.Here is an example of making a sequence with a custom residue (without writing to file):importnglviewasnvfromrdkit_to_paramsimportParamsimportpyrosetta# make paramsp=Params.from_smiles('CCCCC(N*)C(*)=O',name='NLE')p.PROPERTIES.append('ALIPHATIC')p.PROPERTIES.append('HYDROPHOBIC')# p.test() would test it in isolation.# add to posepose=pyrosetta.Pose()rst=p.add_residuetype(pose)pyrosetta.rosetta.core.pose.make_pose_from_sequence(pose,'AX[NLE]A',rst)# relax and showscorefxn=pyrosetta.get_fa_scorefxn()relax=pyrosetta.rosetta.protocols.relax.FastRelax(scorefxn,15)relax.apply(pose)nv.show_rosetta(pose)GreekIn the amino acid case, the class attributegreekificationchanges the atomnames to CB, CD2 etc.
It is by defaultTrue. It is called duringfix_mol, a step inload_mol/load_smiles,
so should be safe for rename methods.OptionalsInstalling RDKit with conda is easy (conda install rdkit).
With apt-get likewise (sudo apt-get install python3-rdkit  librdkit1 rdkit-data).
With brew idem (brew install rdkit --with-python3).
But there is always a system where one needs to compile it from source, which is a pain. Hence why it is optional.
For example, I have never tried installing it on a Windows.Pyrosetta is optional because it has a non-standard installation.Terminal capsTo make a cap, there is a quick way:p = Params.from_smiles('*NCC', name='CAP', atomnames={1: ' N  ', 2: ' CA '})
p.make_C_terminal_cap(mainchain_atoms=['N', 'CA'])

p = Params.from_smiles('*C(=O)C', name='CAP', atomnames={1: ' C  ', 2: ' O  ', 3: ' CA '})
p.make_N_terminal_cap(mainchain_atoms=['C', 'CA'])These methods also acceptconnection_idx, which is the Fortran-style index of the connection that will become a LOWER/UPPER.
i.e. if the cap is further connected but not as a polymer, say*NCC*.Do note:.test()does not work on a terminal cap and will segfaultmainchain_atomswill change Rosetta atom-types only if the name matchesThe code accepts only cases with 3 or more atoms (so a*=Ocap is a no go and requires virtual atoms added manually)Caveat: I do not know many things!ChemicalI suspect I am doing stuff weirdly and I am meant to create ligands viapyrosetta.rosetta.core.chemicaland not via params files...
If this is so let me know. I don't mind knowing I made a mistake!Edit: it is indeed possible, but it is far from trivial/sane. The classpyrosetta.rosetta.core.chemical.MutableResidueTypecan be operated upon by various
other classes such aspyrosetta.rosetta.core.chemical.SetAtomicCharge.
A mutable residue type can be converted to a regular residue type via.make().GenericI like this generic atom type business, but I am not sure how to use them in RL.from_mol(mol, generic=True)will make generic atom types.
I made several guesses with the classic atom types and I am sure many things are wrong...Rings and cis-transCUT_BONDis implemented, but I am not sure it does anything.CHIentries cannot work across a cut bond,
even when undeclared, so is likely redudant.ADD_RINGis not implemented in thefrom_molconversion as I think it's an old command.Does a cis-trans tautomer bond (sayC(=O)-C=O) gets aCHIentry? I am assuming no, but not sure.NotesThere are some other things to pay attention to:Atom names are 4-letters. It is always safer to add the spaces yourself if assigning them.CHI struggles with rings, so currentlyC1CCCCC1CCChas only one CHI (C7, C8, C9, H10), even if (C6, C7, C8, C9) most probably counts.To DoI have not coded yet, because I forgot:an auto-assignment ofNBR_ATOMandNBR_RADIUSforfrom_mol.add rotamer line infrom_molchange option to override starting atom.tweak the logic ofNAMEafter some thinking.output constrain file for the CONNECT atom.make a better webpage to do the conversion from mol/sdf/pdb/SMILESThefrom_molclass method recognises*[NH]CC(~O)*and assigns it as a backbone properly.
However,Chem.MolFromSmiles('*[NH]CC(~O)*')cannot be embedded, so is a bit of a horrible one for users to use.
Throughout the code, dummy atoms (*/R) are changed to carbons or chlorines and then changed back.
Cystathionine and similar twinned amino acids are the problem as I cannot simply make an amino acid backbone be recognised,
however if protonated as is the case[NH1]C[CH0](=O).
Maybe theCC(=O)NCC(=O)NCoption may be a better choice after all.FootnoteTo save a ResidueType in PyRosetta to a params file, the command is:pyrosetta.rosetta.core.chemical.write_topology_file(residuetype,'foo.params')# noqaLegal DisclaimerThe author, Matteo Ferla, is not affiliated with either Rosetta or RDKit.