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> 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> 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 == (1,)), None)
m2 = next((m for m in session.models if m.id == (2,)), None)

if m1 is None or m2 is None:
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(f"Deleted chains: {', '.join(unmatched)}")
else:
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
To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu
Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/