Skip to content

Refactor: Modularize mol3D class into a package with I/O, geometry, and vectorized methods#538

Open
sniderg wants to merge 3 commits into
hjkgrp:mainfrom
sniderg:refactor-modularize-mol3d
Open

Refactor: Modularize mol3D class into a package with I/O, geometry, and vectorized methods#538
sniderg wants to merge 3 commits into
hjkgrp:mainfrom
sniderg:refactor-modularize-mol3d

Conversation

@sniderg
Copy link
Copy Markdown
Contributor

@sniderg sniderg commented Mar 27, 2026

Converts

  • mol3D.py→ mol3D/package with
    core.py, io.py, geometry.py

  • Extracts 20+ I/O methods and geometric transforms into mixin classes

  • Vectorizes centermass, centersym, adds get_coords_matrix()/ get_mass_vector()

  • Fixes writemol2 bug: missing bond_count increment when bond orders present

  • Full backward compatibility — zero import changes needed

import re
import sys
import time
import tempfile
s = xyzstring.split('\n')
try:
s.remove('')
except ValueError:
s = filename.split('\n')
try:
s.remove('')
except ValueError:
with open(filename, 'w') as f:
f.write(mol_contents)

def writemol2(self, filename, writestring=False, ignoreX=False, force=False):
Comment on lines +728 to +734
def writemol2_bodict(
self,
ignore_dummy_atoms=True,
write_bond_orders=True,
return_string=True,
output_file=None
):
Comment on lines +924 to +926
def writexyz(self, filename, symbsonly=True, ignoreX=False,
ordering=False, writestring=False, withgraph=False,
specialheader=False, no_tabs=False):
@rolan701
Copy link
Copy Markdown
Contributor

Hi, this is a good idea. I am a bit swamped so I am unsure when I can get around to fixing it for the tests, if you get time let me know. In the meantime I will let the pull stand as I don't want to close it yet since I think this is a good approach for a class as dense as mol3D.

Best,

  • Roland

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants