
Hi, I'm attempting to use a python script to save the names of each residue in a protein The code I have is as follows: import chimerax, sys from chimerax.core.commands import run cwd = (str(sys.argv[0][:-17])) prot = "/A" run(session, "open 3GDM") run(session, "save " + str(cwd) + "/script_content/sasa/name.defattr " + str(prot) + " & protein attrName r:name format defattr") The command being input into the command line of ChimeraX by the script is as follows: "save [file path]/name.defattr /A & protein attrName r:name format defattr" I've also tried using: "save [file path]/name.defattr attrName r:name format defattr models /A & protein" However, both commands give me a file with all the residues and all the names contained within the model rather than just the chain I'm interested in. Could you advise on how I can better use this command to save a file with the residue positions and corresponding amino acid for each residue from a single chain only? I've attached the resultant file to this email. Kind regards, David

Apologies I attached the wrong file, I've attached the correct file to this email. Kind regards, David ________________________________ From: David Leeming Sent: 04 May 2021 12:06 To: chimerax-users@cgl.ucsf.edu <chimerax-users@cgl.ucsf.edu> Subject: Saving name attribute Hi, I'm attempting to use a python script to save the names of each residue in a protein The code I have is as follows: import chimerax, sys from chimerax.core.commands import run cwd = (str(sys.argv[0][:-17])) prot = "/A" run(session, "open 3GDM") run(session, "save " + str(cwd) + "/script_content/sasa/name.defattr " + str(prot) + " & protein attrName r:name format defattr") The command being input into the command line of ChimeraX by the script is as follows: "save [file path]/name.defattr /A & protein attrName r:name format defattr" I've also tried using: "save [file path]/name.defattr attrName r:name format defattr models /A & protein" However, both commands give me a file with all the residues and all the names contained within the model rather than just the chain I'm interested in. Could you advise on how I can better use this command to save a file with the residue positions and corresponding amino acid for each residue from a single chain only? I've attached the resultant file to this email. Kind regards, David

Hi David, I can't advise on Python specifically, but I can see from the documentation that the save attribute command does not take an atomspec directly (namely the "/A & protein" that you included): <https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes> You can limit the scope to specific models with the "models" option, and/or to selected atoms only with the "selectedOnly" option. So to limit to a specific chain you would need to select it, and then use the "selectedOnly" option. For example: open 3eeb sel /A & protein save chainAnames.defattr attrName r:name format defattr selectedOnly true ~select Probably would be best to try the commands out in the command line to make sure that they work before putting them into your python script. I hope this helps, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On May 4, 2021, at 4:06 AM, David Leeming <david.leeming@student.manchester.ac.uk> wrote:
Hi, I'm attempting to use a python script to save the names of each residue in a protein The code I have is as follows: import chimerax, sys from chimerax.core.commands import run cwd = (str(sys.argv[0][:-17])) prot = "/A" run(session, "open 3GDM") run(session, "save " + str(cwd) + "/script_content/sasa/name.defattr " + str(prot) + " & protein attrName r:name format defattr")
The command being input into the command line of ChimeraX by the script is as follows: "save [file path]/name.defattr /A & protein attrName r:name format defattr"
I've also tried using: "save [file path]/name.defattr attrName r:name format defattr models /A & protein"
However, both commands give me a file with all the residues and all the names contained within the model rather than just the chain I'm interested in.
Could you advise on how I can better use this command to save a file with the residue positions and corresponding amino acid for each residue from a single chain only?
I've attached the resultant file to this email. Kind regards, David <name.defattr>

Hi Elaine, Thanks so much for your advice! Works perfectly now I really appreciated the response! Kind regards, David Get Outlook for Android<https://aka.ms/AAb9ysg> ________________________________ From: Elaine Meng <meng@cgl.ucsf.edu> Sent: Tuesday, 4 May 2021, 16:31 To: David Leeming Cc: chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Saving name attribute Hi David, I can't advise on Python specifically, but I can see from the documentation that the save attribute command does not take an atomspec directly (namely the "/A & protein" that you included): <https://rbvi.ucsf.edu/chimerax/docs/user/commands/save.html#attributes> You can limit the scope to specific models with the "models" option, and/or to selected atoms only with the "selectedOnly" option. So to limit to a specific chain you would need to select it, and then use the "selectedOnly" option. For example: open 3eeb sel /A & protein save chainAnames.defattr attrName r:name format defattr selectedOnly true ~select Probably would be best to try the commands out in the command line to make sure that they work before putting them into your python script. I hope this helps, Elaine ----- Elaine C. Meng, Ph.D. UCSF Chimera(X) team Department of Pharmaceutical Chemistry University of California, San Francisco
On May 4, 2021, at 4:06 AM, David Leeming <david.leeming@student.manchester.ac.uk> wrote:
Hi, I'm attempting to use a python script to save the names of each residue in a protein The code I have is as follows: import chimerax, sys from chimerax.core.commands import run cwd = (str(sys.argv[0][:-17])) prot = "/A" run(session, "open 3GDM") run(session, "save " + str(cwd) + "/script_content/sasa/name.defattr " + str(prot) + " & protein attrName r:name format defattr")
The command being input into the command line of ChimeraX by the script is as follows: "save [file path]/name.defattr /A & protein attrName r:name format defattr"
I've also tried using: "save [file path]/name.defattr attrName r:name format defattr models /A & protein"
However, both commands give me a file with all the residues and all the names contained within the model rather than just the chain I'm interested in.
Could you advise on how I can better use this command to save a file with the residue positions and corresponding amino acid for each residue from a single chain only?
I've attached the resultant file to this email. Kind regards, David <name.defattr>
participants (2)
-
David Leeming
-
Elaine Meng