Vilseck-Lab / msld-py-prep

msld-py-prep scripts for creating a multiple topology model for Multisite Lambda Dynamics in CHARMM
5 stars 0 forks source link

rename_atoms.py doesn't work with mol2 files from smiles strings with a formal charge. #6

Open RyanLeeHayes opened 4 months ago

RyanLeeHayes commented 4 months ago

When I construct a mol2 file using openbabel from a smiles string with a formal charge in it, I get a charge section in my mol2 file:

@<TRIPOS>UNITY_ATOM_ATTR
7 1
charge 1

in between the ATOM and BOND sections of the mol2 file. This breaks rename_atoms.py. There is a simple fix for this. Change line 23 of rename atoms from

while line[0:13] != '@<TRIPOS>BOND':

to

while line[0:9] != '@<TRIPOS>':

Then if some other TRIPOS section happens before the bond section, the script won't crash. Sorry to post this as an issue instead of an email, I'm working on learning to do coding stuff of github the right way.

clbrooksiii commented 4 months ago

The atoms, bond, charge, etc sections don’t need an order as it’s parsed. ----------------------------------------------------------------------Charles L. Brooks III (he/him)Cyrus Levinthal Distinguished University Professor   of Chemistry and BiophysicsWarner-Lambert/Parke-Davis Professor   of ChemistryProfessor of BiophysicsDirector of the Biophysics ProgramNorth American Editor-in-Chief of     Journal of Computational ChemistryDepartment of Chemistry, Biophysics ProgramPresident of the Protein Society (2017-2020) 930 N. University AveUniversity of MichiganAnn Arbor, MI 48109Phone: 734/647-6682Fax:     734/647-1604Phone: 734/763-6444 (Biophysics Office)Brooks LabJournal of Computational ChemistryProtein SocietyNicholas O'HairAdministrative Assistant & JCC Editorial AssistantPhone: 734/763-2353Email: @. MoingBiophysics Executive @. me on twitter: https://twitter.com/CharlesLBrooks----------------------------------------------------------------------On Mar 1, 2024, at 2:16 AM, Ryan Hayes @.> wrote: When I construct a mol2 file using openbabel from a smiles string with a formal charge in it, I get a charge section in my mol2 file: @UNITY_ATOM_ATTR 7 1 charge 1 in between the ATOM and BOND sections of the mol2 file. This breaks rename_atoms.py. There is a simple fix for this. Change line 23 of rename atoms from while line[0:13] != @.': to while line[0:9] != '@': Then if some other TRIPOS section happens before the bond section, the script won't crash. Sorry to post this as an issue instead of an email, I'm working on learning to do coding stuff of github the right way.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

RyanLeeHayes commented 4 months ago

As the script functions now, it starts reading atoms once it find the tripos atom section, and stops reading atom once it finds the tripos bond section. If there is another tripos section in between atoms and bonds, it crashes because it tries to interpret tripos as an integer because it doesn't realize the atom section is over.