Hi Hernando,
So the first thing I want to say is that this is about a thousand times easier in ChimeraX, because the "seq align" command in ChimeraX does this directly.
At any rate, you would use the computeRealignment() method rather than the realign() method (the latter is for when you already have the realigned sequence in hand).  Getting the right argument values will be somewhat challenging.  Depending on what realignment method you want to use, you will need to look at either Muscle.py or ClustalOmega.py in the MultAlignViewer folder to find the appropriate values.  In particular, look at the return value of the get() method in those files.  It returns a (service name, in/out flag strings, option strings) tuple.  Those correspond directly to the serviceName, inOutFlags, and options arguments of the computeRealignment() method.  You will need to look at the lines above the return statement to find the strings that compose the options value.  Lastly, if you are use Muscle realignment you will have to specify "reordersSequence=True" to the computeRealignment() call.
Good luck! :-)

--Eric

Eric Pettersen
UCSF Computer Graphics Lab

On Nov 12, 2022, at 4:01 PM, Hernando J Sosa via Chimera-users <chimera-users@cgl.ucsf.edu> wrote:


Is there a way to realign sequences already in a multialign window within a python script?  
I want to do this because the first alignment dome using matchmaker in many cases contains mismatches to the aligned structures. Using the realign option in the menu fixes the problem but I want to do this within a script. 

I have code that creates the alignment window and then retrieves the instance:

from chimera.extension import manager
from MultAlignViewer.MAViewer import MAViewer

runCommand('mm #0 #1 show true')
mavs = [inst for inst in manager.instances if isinstance(inst, MAViewer)]
mymav = mavs[-1]

I tried then to do something like
mymav.realign()

However, I don't  know what parameters to put in the realign function, or whether this is the right function to use or whether there is a better way to do this.

Any help would be appreciated

Thanks

Hernando


_______________________________________________
Chimera-users mailing list: Chimera-users@cgl.ucsf.edu
Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-users