How to match atoms

Lets say we have computed the ESP charges for a molecule and we want to transfer these charges onto all copies of that molecule within a crystal structure. This can be done manually if there are a few atoms, but becomes intractable with more complexity. So the next step is writing a script. A simple script approach is to loop over the atoms in each molecule and transfer the charges that way. But this assumes that the atoms in the crystal molecules occur in the same order that they do in the ESP structure. That is not alwasy the case.

The best solution is to use the pattern finding tool in the script. The attached script does just that and includes example structures to try it on. Try it out! It can be used for other things too.