{"id":10413,"date":"2023-10-02T11:16:14","date_gmt":"2023-10-02T10:16:14","guid":{"rendered":"https:\/\/www.blopig.com\/blog\/?p=10413"},"modified":"2023-10-02T11:16:16","modified_gmt":"2023-10-02T10:16:16","slug":"tips-tricks-with-pymol","status":"publish","type":"post","link":"https:\/\/www.blopig.com\/blog\/2023\/10\/tips-tricks-with-pymol\/","title":{"rendered":"Tips &amp; tricks with PyMOL"},"content":{"rendered":"\n<p class=\"has-text-align-justify\">I have been using PyMOL, a molecular visualisation program, throughout my PhD and wanted to share some of the things I&#8217;ve learned.<br><\/p>\n\n\n\n<p class=\"has-text-align-justify\"><strong>1. Installation<\/strong><br><br>Open source PyMOL can be installed using conda: <code>conda install -c conda-forge pymol-open-source<\/code>. It does not watermark figures and has full functionality, as far as I have been able to tell.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"has-text-align-justify\"><strong>2. Documentation<\/strong><br><br>You can find documentation for PyMOL online (<a href=\"https:\/\/pymol.org\/dokuwiki\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/pymol.org\/dokuwiki\/<\/a>), which can be very helpful, although is not entirely complete.<br><\/p>\n\n\n\n<p><strong>3. Some of my favourite PyMOL commands\/selections<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Standard commands: <a rel=\"noreferrer noopener\" href=\"https:\/\/pymolwiki.org\/index.php\/Fetch\" target=\"_blank\">fetch<\/a>, <a href=\"https:\/\/pymolwiki.org\/index.php\/Load\" target=\"_blank\" rel=\"noreferrer noopener\">load<\/a>, <a href=\"https:\/\/pymolwiki.org\/index.php\/Show\" target=\"_blank\" rel=\"noreferrer noopener\">show<\/a>, <a href=\"https:\/\/pymolwiki.org\/index.php\/Hide\" target=\"_blank\" rel=\"noreferrer noopener\">hide<\/a>, <a href=\"https:\/\/pymolwiki.org\/index.php\/Select\" target=\"_blank\" rel=\"noreferrer noopener\">select<\/a>, <a href=\"https:\/\/pymolwiki.org\/index.php\/Create\" target=\"_blank\" rel=\"noreferrer noopener\">create<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pymol.org\/dokuwiki\/doku.php?id=selection:within\" target=\"_blank\" rel=\"noreferrer noopener\">within<\/a>: Select\/show\/color\/etc. objects within a distance from another object. This is great, for example, to visualise binding sites.<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/pymolwiki.org\/index.php\/Ray\" target=\"_blank\">ray<\/a>: Ray trace your images for higher resolution. You can specify the resolution \u2013\u00a0I usually go for <code>ray 2000, 2000<\/code>.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.pymolwiki.org\/index.php\/Color\" target=\"_blank\" rel=\"noreferrer noopener\">color<\/a> \/ <a href=\"https:\/\/pymolwiki.org\/index.php\/Set_Color\" target=\"_blank\" rel=\"noreferrer noopener\">set_color<\/a>: These commands allow you to use personalised colors<\/li>\n\n\n\n<li>distance: Find the distance between two selections. You can <a href=\"https:\/\/pymol.org\/dokuwiki\/doku.php?id=setting:dash\" target=\"_blank\" rel=\"noreferrer noopener\">format the dashed line<\/a> with e.g., dash_color and dash_radius.<\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/pymolwiki.org\/index.php\/Align\" target=\"_blank\">align<\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/pymolwiki.org\/index.php\/Super\" target=\"_blank\">super<\/a>: Align two selections; the former command takes sequence into account, while the latter does not.<br><\/li>\n<\/ul>\n\n\n\n<p><strong>4. Playing around with visualisations<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pymolwiki.org\/index.php\/Ray#Modes\" target=\"_blank\" rel=\"noreferrer noopener\">ray_trace_mode<\/a>: There are three ray trace modes, which can be used for fun visualisations. Mode 1 is standard, 2 is black outline, 3 is quantised colour + black outline.<\/li>\n\n\n\n<li><a href=\"https:\/\/pymolwiki.org\/index.php\/Cartoon\" target=\"_blank\" rel=\"noreferrer noopener\">cartoon<\/a>: you can change the style of the protein backbone, for example to a &#8216;tube&#8217; format.<\/li>\n\n\n\n<li>Check out some more ideas: <a rel=\"noreferrer noopener\" href=\"https:\/\/pymolwiki.org\/index.php\/Gallery\" target=\"_blank\">https:\/\/pymolwiki.org\/index.php\/Gallery<\/a>\u00a0and\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.blopig.com\/blog\/2021\/01\/making-pretty-pictures-with-pymol\/\" target=\"_blank\">https:\/\/www.blopig.com\/blog\/2021\/01\/making-pretty-pictures-with-pymol\/<\/a><br><\/li>\n<\/ul>\n\n\n\n<p><strong>5. Pymol scripts<\/strong><br><br>You can create .pml scripts with PyMOL commands and run these in PyMOL. For example, pml_script.pml:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>load 3w2d.pdb\nselect Ab, chain H + chain L\nselect Ag, chain A\n\nhide\nshow cartoon, Ab + Ag\ncolor blue, Ab\ncolor red, Ag<\/code><\/pre>\n\n\n\n<p><br>In the command line, you can run: <code>pymol pml_script.pml<\/code>.<br><br>To run this script without opening the PyMOL GUI: <code>pymol -c <code>pml_script.pml<\/code><\/code><\/p>\n\n\n\n<p><strong>6. Python + PyMOL scripts<\/strong><br><br>PyMOL is compatible with Python! This is incredibly helpful when using PyMOL iteratively, such as for distance or rmsd calculations. There are a few ways Python + PyMOL scripts can be written\/executed, but I typically use the following:<br><br>py_script.py:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\nabs = pd.read_csv(\"antibody_pdbs.csv\")\n\nfor ind, row in abs.iterrows():\n\u00a0 \u00a0 cmd.load(row&#091;\"pdb_path\"])\n\u00a0 \u00a0 cmd.create(\"ab\", f\"chain {row&#091;'Hchain']} + chain {row&#091;'Lchain']}\")\n\u00a0 \u00a0 print(\"cdrh3_anchor_dist:\", cmd.distance(\"ab &amp; resi 105 &amp; name CA\", \"ab &amp; resi 117 &amp; name CA\"))\n\u00a0 \u00a0 cmd.reinitialize()<\/code><\/pre>\n\n\n\n<p><br>In the command line, you can run: <code>pymol py_script.py<\/code>.<br><br>Again, to run this script without opening the PyMOL GUI: <code>pymol -c <code>py_script.py<\/code><\/code><br><br>You can see more, e.g., at\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.blopig.com\/blog\/2020\/11\/using-python-in-pymol\/\" target=\"_blank\">https:\/\/www.blopig.com\/blog\/2020\/11\/using-python-in-pymol\/<\/a>.<br><\/p>\n\n\n\n<p><strong>8. .pymolrc<\/strong><br><br>You can specify default settings in a .pymolrc file in your home directory (~\/.pymolrc). Some of the key settings in my .pymolrc file (which I adapted from Prof Phill Stansfeld\u00a0\u2013 thanks!) include:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>viewport 800, 800\nbg white # background to white\nset orthoscopic, 1 # perspective\nset two_sided_lighting, 1 # illuminate inside and outside of surfaces\nset antialias = 1 # smooths jagged edges in ray tracing\nset ray_shadow,0 # no shadow\nset ray_trace_mode = 1 # default ray trace mode\nspace cmyk # cmyk color space<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have been using PyMOL, a molecular visualisation program, throughout my PhD and wanted to share some of the things I&#8217;ve learned. 1. Installation Open source PyMOL can be installed using conda: conda install -c conda-forge pymol-open-source. It does not watermark figures and has full functionality, as far as I have been able to tell.<\/p>\n","protected":false},"author":78,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","wikipediapreview_detectlinks":true,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[351],"tags":[729,132],"ppma_author":[484],"class_list":["post-10413","post","type-post","status-publish","format-standard","hentry","category-molecular-visualization","tag-molecular-visualization","tag-pymol"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"authors":[{"term_id":484,"user_id":78,"is_guest":0,"slug":"alissa","display_name":"Alissa Hummer","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/65ab670c32312147bd0e263ed45bf1216bc05ec0fe26e475a8c139455701c5ae?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/10413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/comments?post=10413"}],"version-history":[{"count":5,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/10413\/revisions"}],"predecessor-version":[{"id":10435,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/10413\/revisions\/10435"}],"wp:attachment":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/media?parent=10413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/categories?post=10413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/tags?post=10413"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=10413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}