[Chimera-users] Realign sequences

Eric Pettersen pett at cgl.ucsf.edu
Mon Nov 14 15:43:07 PST 2022


Oh yeah, it's even worse that I thought. The problem is that the realignment job executes in the background, so your script continues on while the job is still running, so therefore you are getting the original association info.  Unlike ChimeraX, there is no way to tell computeRealignment() to not return until the job finishes.

The only option that occurs to me is for you to monitor the job to see when it finishes.  Before you call computeRealignment(), do this:

from chimera.tasks import manager
mgr = manager()
num_jobs = mgr.active_task_count() # should be zero unless your script is running other jobs

...call computeRealignment()

from time import sleep
while mgr.active_task_count() == num_jobs + 1:
	sleep(1)

...save association info

--Eric

> On Nov 14, 2022, at 3:16 PM, Hernando J Sosa via Chimera-users <chimera-users at cgl.ucsf.edu> wrote:
> 
> Hi Eric
> 
> Using the following argument works:
> 
> mav.computeRealignment("ClustalOmegaService", ("-i", "-o"),'--full')
> 
> However, saving the corresponding association file using: 
> 
> mav.saveAssocInfo('myassocfile.txt') 
> 
> I get  a file different from the one I get using the Multialign Viewer window menu
> MultialignViewer->File->Save Assoc Info...
> 
> The saveAssocInfo  statement is after the computeRealignment statement but perhaps for some reason I'm getting the association file corresponding to the first alignment ???
> 
> 
> Thanks for any help on this issue.
> 
> Best
> 
> Hernando
> 
> 
> 
> ___________________________________
> Hernando Sosa                                                           
> Dept. of Biochemistry
> Albert Einstein College of Medicine
> 1300 Morris Park Av.
> Bronx NY 10461
> phone (718) 430-3456
> emai:  hernando.sosa at einsteinmed. <mailto:hernando.sosa at einsteinmed.org>edu
> ___________________________________
> 
> 
> 
> From: Chimera-users <chimera-users-bounces at cgl.ucsf.edu <mailto:chimera-users-bounces at cgl.ucsf.edu>> on behalf of Hernando J Sosa via Chimera-users <chimera-users at cgl.ucsf.edu <mailto:chimera-users at cgl.ucsf.edu>>
> Sent: Monday, November 14, 2022 4:25 PM
> To: chimera-users at cgl.ucsf.edu <mailto:chimera-users at cgl.ucsf.edu> List <chimera-users at cgl.ucsf.edu <mailto:chimera-users at cgl.ucsf.edu>>
> Subject: Re: [Chimera-users] Realign sequences
>  
> CAUTION: This email comes from an external source; the attachments and/or links may compromise our secure environment. Do not open or click on suspicious emails. Please click on the “Phish Alert” button on the top right of the Outlook dashboard to report any suspicious emails.
> Thanks Eric,
> 
> I will try first with the computeRealignment() method.  Both alignments algorithms seem to work so I'll try Crustal-Omega first. Most likely will have more questions coming. 
> 
> Eventually we'll try chimera-X which indeed seems like an easier route. However, the problem is that this script is part of a library of scripts and functions that we have built over the years for Chimera (in python 2.7).  Translating all to python 3.0 and the different environment of ChimeraX may be more difficult and time consuming at this time. 
> 
> Thanks again,
> 
> Hernando
> 
> From: Eric Pettersen <pett at cgl.ucsf.edu <mailto:pett at cgl.ucsf.edu>>
> Sent: Monday, November 14, 2022 3:04 PM
> To: Hernando J Sosa <hernando.sosa at einsteinmed.edu <mailto:hernando.sosa at einsteinmed.edu>>
> Cc: Chimera <chimera-users at cgl.ucsf.edu <mailto:chimera-users at cgl.ucsf.edu>>
> Subject: Re: [Chimera-users] Realign sequences
>  
> CAUTION: This email comes from an external source; the attachments and/or links may compromise our secure environment. Do not open or click on suspicious emails. Please click on the “Phish Alert” button on the top right of the Outlook dashboard to report any suspicious emails.
> 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 <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.rbvi.ucsf.edu%2Fchimerax%2Fdocs%2Fuser%2Fcommands%2Fsequence.html%23align&data=05%7C01%7Chernando.sosa%40einsteinmed.edu%7C0387de7384a0405b5e3508dac6874fcf%7C9c01f0fd65e040c089a82dfd51e62025%7C0%7C0%7C638040582449460272%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=vl8cURst3fUY3WPANch2WRbsKiGHq6V0ZV6knnI1Viw%3D&reserved=0> 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 at cgl.ucsf.edu <mailto:chimera-users at 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 at cgl.ucsf.edu <mailto:Chimera-users at cgl.ucsf.edu>
>> Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-users <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.rbvi.ucsf.edu%2Fmailman%2Flistinfo%2Fchimera-users&data=05%7C01%7Chernando.sosa%40einsteinmed.edu%7C0387de7384a0405b5e3508dac6874fcf%7C9c01f0fd65e040c089a82dfd51e62025%7C0%7C0%7C638040582449460272%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=tM0pGELY860WCJEx6KUo7af7CEpGNo3kUpoftgPjDcM%3D&reserved=0>
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu <mailto:Chimera-users at cgl.ucsf.edu>
> Manage subscription: https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-users <https://www.rbvi.ucsf.edu/mailman/listinfo/chimera-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimera-users/attachments/20221114/b62aff7a/attachment.html>


More information about the Chimera-users mailing list