
Hi Enrico, The problem with your first script is that you are using the wrong set operator. You want to delete chains that are in one structure but not both (the '^' operator), but you are subtracting the chains in one structure from the other ('-') which is only half of the chains you need to delete. So, "unmatched = chains1 - chains2" would instead need to be "unmatched = chains1 ^ chains2". As for your second approach, you are checking the RMSD of the first N carbon alphas (N = shorter chain length), which aren't necessarily the atoms matchmaker used. The matchmaker command returns information about which chains it matched and how, as per: https://github.com/RBVI/ChimeraX/blob/a16ed098a17ab4d20c674cd15867fd3e908205.... --Eric
On Apr 29, 2025, at 1:00 AM, Enrico Martinez <jmsstarlight@gmail.com> wrote:
Hi Eric ! Sorry I forgot to copy the executing line. Basically, this script just compare chain IDs and remove unmatched cases which is abit trivial
chains1 = {chain.chain_id for chain in m1.chains} chains2 = {chain.chain_id for chain in m2.chains}
unmatched = chains1 - chains2
In my next version I tried to use matchmaker to compare the structures and remove unmatched chains using the rmsd threshold > 5 A (I calculate rmsd using return np.sqrt(np.mean(np.sum(diff * diff, axis=1)))
I tested it using several pdb pairs but it always entirely removes the second model ..
Many thanks in advance !
Enrico
Il giorno lun 28 apr 2025 alle ore 21:17 Eric Pettersen <pett@cgl.ucsf.edu <mailto:pett@cgl.ucsf.edu>> ha scritto:
Hi Enrico, Your script seems to define a function without actually calling it. You would need a “delete_unmatched_chains(session)” at the end of the script for it to actually do anything.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Apr 26, 2025, at 1:57 AM, Enrico Martinez via ChimeraX-users <chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu>> wrote:
Dear ChimeraX Users,
I am trying to perform a morphing between two cryo-EM structures of the same complex, where one structure has twice the number of chains as the other (PDBs 3J9K and 8Y6Q). However, the larger structure causes an error during morphing.
I have attempted to write a script that aligns the two structures and deletes the unmatched chains from the larger structure. Unfortunately, the script is not working as expected.
from chimerax.core.commands import run
def delete_unmatched_chains(session): # Get models #1 and #2 m1 = next((m for m in session.models if m.id <http://m.id/> == (1,)), None) m2 = next((m for m in session.models if m.id <http://m.id/> == (2,)), None)
if m1 is None or m2 is None: session.logger.info <http://session.logger.info/>("Model #1 or #2 not found.") return
chains1 = {chain.chain_id for chain in m1.chains} chains2 = {chain.chain_id for chain in m2.chains}
unmatched = chains1 - chains2
if unmatched: chain_ids = ",".join(unmatched) # Deleting unmatched chains run(session, f"delete /{chain_ids}") session.logger.info <http://session.logger.info/>(f"Deleted chains: {', '.join(unmatched)}") else: session.logger.info <http://session.logger.info/>("No unmatched chains found.")
Could you please help me or alternatively propose another solution? Any suggestions would be greatly appreciated. Thank you in advance !
Enrico _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu <mailto:chimerax-users-leave@cgl.ucsf.edu> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
<match_delete.py>