TheoChem-VU / TCutility

Utility functions/classes for the TheoCheM programs
https://theochem-vu.github.io/TCutility/
MIT License
6 stars 0 forks source link

Add Remove Specific Coordinates from IRC XYZ-file #301

Open ToriGijzen opened 3 months ago

ToriGijzen commented 3 months ago

Sometimes you want to remove specific atoms/molecules of the already runned IRC to perform, for instance, a pyfrag on the same geometries but without specific atoms/molecules for deeper analysis.

For example, in my research I want to remove the benzene molecule of each frame to perform a pyfrag with the LA-sub complex in the same geometry they will adopt when benzene is present. Yuman already wrote a script:

import os

files = [ ('/Users/Tori/Dropbox/Work/Research/Friedel-Crafts/Data Alkylation/Manuscript effect Bulk/Me/IRCfor_MeCl-AlCl3.ams.amv', [5, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]), ]

for file, atomnumbers in files: with open(file) as origamv: lines = origamv.readlines()

with open(os.path.split(file)[0] + '/molecule.xyz', 'w+') as out:
    for i, line in enumerate(lines):
        if line.startswith('Geometry'):
            current_atom_index = 0
            continue

        current_atom_index += 1
        if current_atom_index in atomnumbers:
            continue
        else:
            out.write(line)