<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:2088913088;
        mso-list-template-ids:-1;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Thank you all for the input.</p>
<p class="MsoNormal">I will use HTML file to address this issue (thanks a lot Eric!).</p>
<p class="MsoNormal">Regards,</p>
<p class="MsoNormal">Shubham</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">
Mail</a> for Windows</p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Eric Pettersen <pett@cgl.ucsf.edu><br>
<b>Sent:</b> Tuesday, May 24, 2022 8:55:09 PM<br>
<b>To:</b> Shubham Devesh Ramgoolam <sdramgoolam@uwaterloo.ca><br>
<b>Cc:</b> chimerax-users@cgl.ucsf.edu <chimerax-users@cgl.ucsf.edu><br>
<b>Subject:</b> Re: [chimerax-users] Executing a script in chimerax python shell for an interactive session</font>
<div> </div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">
<div dir="auto" class="" style="word-wrap:break-word; line-break:after-white-space">
Hi Shubham,
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>As far as I know, there is no way to get the Shell tool to start up with a script executing in it.  I think what you need to do is have the script do all the heavy lifting.  For one
 thing, it can get the path of the session file with code like this:</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>from chimera.ui.open_save import OpenDialogWithMessage</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>dialog = OpenDialogWithMessage(message="Choose the session file containing the structure to be analyzed", caption="Open Session")</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>session_format = session.data_formats["ChimeraX session"]</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>dialog.setNameFilter(session.data_formats.qt_file_filter(session_format))</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>paths = dialog.selectedFiles()</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>if not paths:</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span># user cancelled dialog</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>from chimerax.core.errors import CancelOperation</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>raise CancelOperation("script cancelled by user")</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>session_path = paths[0]</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span># probably use an "open" command to open the session</div>
<div class=""><br class="">
</div>
<div class="">You would do a similar thing for the residues text file, except you probably would skip the setNameFilter() call since there is no particular suffix you are looking for.</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>So the tricky part is getting residue-pair choices from the user interactively.  In an ideal world you would use Qt to create a dialog with a list of residue pairs in it, and clicking
 on an item in the list would visualize the pair.  That's the approach I would use since I am familiar with Qt, but if you aren't then that's a pretty big learning curve for what you want to accomplish.  Nonetheless, if that's what you'd like to do, just let
 me know and I'll provide some pointers.</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>Alternatively, a simpler approach is to leverage the fact that ChimeraX supports special HTML links that execute commands.  So you would write out an HTML file with a link for every
 residue pair and the user could click on links to visualize the corresponding pair.  The file would have a bunch of lines like:</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span><a href="cxcmd:sel :14,27; view sel">Residues 14 and 27</a></div>
<div class=""><br class="">
</div>
<div class="">or whatever commands you wanted to execute when the link is clicked, plus any other HTML you wanted to put in it.  You would then just use the "open" command to open the HTML file and it will show up in a window.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">--Eric</div>
<div class=""><br class="">
</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>Eric Pettersen</div>
<div class=""><span class="x_Apple-tab-span" style="white-space:pre"></span>UCSF Computer Graphics Lab</div>
<div class=""><br class="">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On May 22, 2022, at 10:51 PM, Shubham Devesh Ramgoolam via ChimeraX-users <<a href="mailto:chimerax-users@cgl.ucsf.edu" class="">chimerax-users@cgl.ucsf.edu</a>> wrote:</div>
<br class="x_Apple-interchange-newline">
<div class="">
<div class="x_WordSection1" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Hi all,</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
I hope you are doing well.</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
I have a python script that allows the user to visualize specific residue pairs.</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Here is an overview of how the script functions:</div>
<ul type="disc" class="" style="margin-bottom:0in; margin-top:0in">
<li class="x_MsoListParagraph" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Ask the user to input the path of a .cxs file (created previously) and a text file containing the pairs to be visualized</li><li class="x_MsoListParagraph" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Print the names of the pairs along a uniquely assigned number</li><li class="x_MsoListParagraph" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Ask the user to input a number in order to visualize the pair assigned to it</li></ul>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
 </div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
To run the script currently, I have to do the following: i)Open chimerax ii)Show the shell iii) Call the script from the shell</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
 </div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Now, is it possible to include some codes in the script that would allow me to just open chimerax, click on File -> Open -> this script, and then the shell would show up and the execution would continue there?</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
 </div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Right now, if I ran the script using File -> Open -> this script, I would get this error:</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Traceback (most recent call last):<br class="">
File "C:/Users/Shubham/Desktop/this_script.py", line 8, in<span class="x_Apple-converted-space"> </span><br class="">
session_path = input('Enter file (.cxs) to be visualized with path: \n')<br class="">
RuntimeError: input(): lost sys.stdin<span class="x_Apple-converted-space"> </span></div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
 </div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Regards,</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Shubham</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
 </div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
Sent from<span class="x_Apple-converted-space"> </span><a href="https://go.microsoft.com/fwlink/?LinkId=550986" class="" style="color:blue; text-decoration:underline">Mail</a><span class="x_Apple-converted-space"> </span>for Windows</div>
<div class="" style="margin:0in; font-size:11pt; font-family:Calibri,sans-serif">
 </div>
</div>
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important">ChimeraX-users
 mailing list</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<a href="mailto:ChimeraX-users@cgl.ucsf.edu" class="" style="color:blue; text-decoration:underline; font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">ChimeraX-users@cgl.ucsf.edu</a><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important">Manage
 subscription:</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<a href="https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users" class="" style="color:blue; text-decoration:underline; font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</body>
</html>