{"id":1532,"date":"2021-04-08T12:49:50","date_gmt":"2021-04-08T03:49:50","guid":{"rendered":"https:\/\/mitsudo.net\/?p=1532"},"modified":"2021-06-21T09:17:13","modified_gmt":"2021-06-21T00:17:13","slug":"building-a-crystal-structure-analysis-environment-on-a-mac","status":"publish","type":"post","link":"https:\/\/mitsudo.net\/en\/building-a-crystal-structure-analysis-environment-on-a-mac\/","title":{"rendered":"Building a Crystal Structure Analysis Environment on a Mac"},"content":{"rendered":"<h2>Crystal Structure Analysis on Mac<\/h2>\n<p><strong>X-ray crystallography<\/strong> is one of the most direct methods to know the structure of molecules. Nowadays, data analysis of crystal structure can be done free of charge (for non-commercial use) on an individual&#8217;s PC. <!--more-->Among the various analysis software available, <strong>Olex2<\/strong> is one of the most popular software now. <strong>Olex2<\/strong> is freeware and has a beautiful screen, and thankfully <span class=\"marker-halfPink\">there is also a Mac version<\/span>. Here is shown how to install <strong>Olex2<\/strong> for Mac.<\/p>\n<figure id=\"attachment_695\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/06\/27ca339219b4a8f6f72eb7e7adc42dc1-300x300.png\" alt=\"\" width=\"300\" height=\"300\" class=\"wp-image-695 size-medium\" \/><figcaption class=\"wp-caption-text\">ORTEP diagram displayed by Olex2<\/figcaption><\/figure>\n<h3>How Olex2 works<\/h3>\n<p><span class=\"marker-halfPink\"><strong>Olex2<\/strong> is used in combination with <strong>SHELX<\/strong> and <strong>PLATON<\/strong>.<\/span>\u00a0 The analysis is performed on <strong>Olex2<\/strong>, and the actual crystal structure analysis is done by <strong>SHELX<\/strong>. <strong>PLATON<\/strong> help us to do miscellaneous things.<\/p>\n<h3>Requirements<\/h3>\n<p>To install <strong>Olex2<\/strong>, <strong>Homebrew<\/strong>, <strong>Xquartz<\/strong>, <strong>iTerm2<\/strong> (or normal terminal), and <strong>zsh<\/strong> (or bash) are required. If you use Catalina or later, <strong>zsh<\/strong> is the default shell.<\/p>\n\r\n\t\t\t<div class=\"sitecard\">\r\n\t\t\t\t<div class=\"sitecard__subtitle\">Related Article<\/div>\r\n\t\t\t\t<div class=\"sitecard__contents\">\r\n\t\t\t\t\t<div class=\"heading heading-secondary\"><a href=\"https:\/\/mitsudo.net\/en\/mac-homebrew\/\" target=\"_blank\">Mac with Homebrew for Organic Chemists (for Intel Mac)<\/a><\/div>\r\n\t\t\t\t\t<p class=\"phrase phrase-tertiary\">Homebrew (A Package Manager for Mac)\r\nFor organic chemists, Homebrew is a very useful software, although it is not as es[\u2026]<\/p>\r\n\t\t\t\t<\/div>\r\n\t\t\t\t<div class=\"eyecatch eyecatch-11\"><a class=\"eyecatch__link eyecatch__link-maskzoom\" href=\"https:\/\/mitsudo.net\/en\/mac-homebrew\/\" target=\"_blank\"><img decoding=\"async\" width=\"375\" height=\"232\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/05\/mac-459196_1280-375x232.jpg\" class=\"attachment-icatch375 size-icatch375 wp-post-image\" alt=\"\" \/><\/a><\/div>\r\n\t\t\t<\/div>\n<h2>Installation of SHELX<\/h2>\n<p>You can download <strong>SHELX<\/strong> from <a href=\"http:\/\/shelx.uni-goettingen.de\/index.php\" target=\"_blank\" rel=\"noopener noreferrer\">The SHELX homepage<\/a>. After you register, you will receive a password for the download.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/06\/SHELX_regist-and-downloads-1024x339.png\" alt=\"\" width=\"1024\" height=\"339\" class=\"alignnone size-large wp-image-696\" \/><\/p>\n<p>From the download page, download <span class=\"marker-halfPink\">a set of files with the <strong>.bz2<\/strong> extension in the mac folder<\/span>. If you are doing small molecule analysis, be sure to download <strong>shelxt.bz2<\/strong>, <strong>shelxl.bz2<\/strong>, and <strong>ciftab.bz2<\/strong>. Download them to a folder (for example, in <strong>temp<\/strong> folder) in your download folder (<strong>~\/Downloads<\/strong>).<\/p>\n<p>Next, open <strong>iTerm2<\/strong>, move to the <strong>temp<\/strong> folder, and extract the <strong>bz2<\/strong> files.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ cd ~\/Downloads\/temp  #move to the temp folder\r\n$ bunzip2 *.bz2  #extract all the bz2 files\r\n<\/code><\/pre>\n<\/div>\n<p>Next, grant all users execute permissions to the extracted programs.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>\r\n$ chmod ugo+x shelxt  #Grant execute permissions for all users\r\n$ chmod ugo+x shelxl\r\n$ chmod ugo+x ciftab\r\n$ chmod ugo+x &lt;other extracted files&gt;<\/code><\/pre>\n<\/div>\n<p><span class=\"marker-halfPink\">Move all these unzipped files to <strong>\/usr\/local\/bin<\/strong>.<\/span><\/p>\n<p>Restart <strong>iTerm2<\/strong> and use the <strong>which<\/strong> command to confirm that the path is valid. If the output looks like the following, you have succeeded.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ which shelxl #enter this command\r\n\/usr\/local\/bin\/shexl<\/code><\/pre>\n<\/div>\n<h2>Installation of PLATON<\/h2>\n<h3>Requirements<\/h3>\n<p>To install <strong>PLATON<\/strong>, <strong>gfortran<\/strong> is required. Check whether the <strong>gfortran<\/strong> command is available or not on <strong>iTerm2<\/strong>.<strong><br \/>\n<\/strong><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ which gfortran  #enter this command\r\n\/usr\/local\/bin\/gfortran  #if installed, you see this answer\r\ngfortran not found  #if not installed, you see this answer\r\n\r\n<\/code><\/pre>\n<\/div>\n<p><span class=\"marker-halfPink\">If you see <strong>\/usr\/local\/bin\/gfortran<\/strong>, gfortran has been installed.<\/span><\/p>\n<p><span class=\"marker-halfBlue\">If the message &#8220;<strong>gfortran not found<\/strong>&#8221; is displayed, <strong>gfortran<\/strong> is not installed<\/span>, so install it from <strong>Homebrew<\/strong>. <strong>gfortran<\/strong> is built into <strong>gcc<\/strong>, so install <strong>gcc<\/strong>.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ brew install gcc  #If gfortran is not available, install gcc.<\/code><\/pre>\n<\/div>\n<h3>Installation of PLATON<\/h3>\n<p><strong>PLATON<\/strong> is installed according to the <a href=\"http:\/\/www.platonsoft.nl\/xraysoft\/Mac-OSX\/platon\/Platon_installation_on_a_Mac.pdf\" target=\"_blank\" rel=\"noopener\">manual<\/a> (pdf) on the <a href=\"http:\/\/www.platonsoft.nl\/platon\/\" target=\"_blank\" rel=\"noopener\">platon website<\/a>. (Some changes have been made.)<\/p>\n<p>Download <strong>platon.tar.gz<\/strong> from the <a href=\"http:\/\/www.platonsoft.nl\/xraysoft\/unix\/\" target=\"_blank\" rel=\"noopener\">platon download site<\/a> to your download folder (~\/Downloads). Unzip it and compile it.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ cd ~\/Downloads  #move to the download folder\r\n$ tar zxvf platon.tar.gz  #extract the files\r\n$ cd platon  #move to the platon folder \r\n$ gunzip *.gz  #extract all the files\r\n$ gfortran -o platon platon.f xdrvr.c -L\/opt\/X11\/lib -lX11 -I\/opt\/X11\/include #compile the file \"platon\"<\/code><\/pre>\n<\/div>\n<p>The compilation by <strong>gfortran<\/strong> will take a while.<\/p>\n<ul>\n<li><span class=\"marker-halfBlue\">In <strong>Mojave<\/strong>, you may get an error message &#8220;stdio.h is not present&#8221;<\/span>. In that case, type the following command and execute <strong>macOS_SDK_headers_for_macOS_10.14.pkg<\/strong> in the opened folder. After that, execute the above gfortran command again.<\/li>\n<\/ul>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ open \/Library\/Developer\/CommandLineTools\/Packages\/<\/code><\/pre>\n<\/div>\n<ul>\n<li><span class=\"marker-halfPink\">In <strong>Catalina<\/strong>, you can compile by the following command.<br \/>\n<\/span>(Thanks Prof. Makoto Yamashita in Nagoya University for this information)<\/li>\n<\/ul>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ gfortran -o platon platon.f xdrvr.c -I\/opt\/X11\/include -L\/opt\/X11\/lib -lX11 --sysroot=\/Library\/Developer\/CommandLineTools\/SDKs\/MacOSX10.15.sdk<\/code><\/pre>\n<\/div>\n<ul>\n<li><span class=\"marker-halfPink\">In <strong><span class=\"marker-halfPink\">Big<\/span> Sur<\/strong> <strong>(IntelMac)<\/strong>, you can compile by the following command.<\/span><br \/>\n&#8220;The number part of &#8220;11.1.sdk&#8221; may depend on the OS version. If you type &#8220;MacOSX11&#8221; and press the Tab key, the rest of the text will be completed.<\/li>\n<li><span class=\"marker-halfPink\">In <strong>Big Sur (M1 Mac),<\/strong> you can also compile by the following command.<br \/>\n<\/span>In some case, you see an error &#8220;Class AMSupportURLConnectionDelegate is implemented in both ?? ~&#8221;, but in most cases, you do not need to worry about this, especially when the generated <strong>platon<\/strong> is working.<br \/>\n(Thank Prof. Ami Saito in the University of Tokyo for the information.)<\/li>\n<\/ul>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ gfortran -o platon platon.f xdrvr.c -I\/opt\/X11\/include -L\/opt\/X11\/lib -lX11 --sysroot=\/Library\/Developer\/CommandLineTools\/SDKs\/MacOSX11.1.sdk<\/code><\/pre>\n<\/div>\n<p>After compilation, a file &#8220;<strong>platon<\/strong>&#8221; will be generated. Copy this file and <strong>check.def<\/strong> into \/usr\/local\/bin with the following command.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ cp platon \/usr\/local\/bin\/. #copy the file \"platon\" to \/usr\/local\/bin\/. Do not forget the period at the end\r\n$ cp check.def \/usr\/local\/bin\/.\r\n$ chmod -R 755 \/usr\/local\/bin\/platon #change the permissions of the file \"platon\" to make it executable.\r\n$ chmod -R 755 \/usr\/local\/bin\/check.def #change the permissions of the file \"check.def\" to make it executable.<\/code><\/pre>\n<\/div>\n<h3>Settings for PLATON<\/h3>\n<p>Set the location of <strong>check.def<\/strong> in the environment variable <strong>CHECKDEF<\/strong>, which is used in the VALIDATION of cif files. The varible is set to the XQuartz shell. If you have not changed the shell, it should be <strong>bash<\/strong> (or <strong>zsh<\/strong> for Catalina and later), so set it to <strong>.bashrc<\/strong> (or <strong>.zshrc<\/strong> for Catalina and later). Recent Macs do not have a bash configuration files, <strong>.bashrc<\/strong>, or <strong>.bash_profile<\/strong>, so you will start by creating them (for Catalina or later, it is not necessary to create <strong>.bashrc<\/strong> and <strong>.bash_profile<\/strong>).<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ cd  #move to the home folder\r\n$ touch .bash_profile  #make .bash_profile\r\n$ touch .bashrc  #make .bashrc<\/code><\/pre>\n<\/div>\n<p>Write the following into <strong>.bash_profile<\/strong> (not required for Catalina and later).<br \/>\nFiles that begin with a &#8220;. &#8221; (period) is a hidden file and cannot be seen from the Finder. So, It is easy to open from an editor such as VSCode or vim.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>if [ -f ~\/.bashrc ] ; then\r\n. ~\/.bashrc\r\nfi<\/code><\/pre>\n<\/div>\n<p>Write the following contents in <strong>.bashrc<\/strong>. (After Catalina, it is written in <strong>.zshrc<\/strong>)<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>export CHECKDEF='\/usr\/local\/bin\/check.def'<\/code><\/pre>\n<\/div>\n<h2>Installation of Olex2<\/h2>\n<h3>Installation of Olex2<\/h3>\n<p>Download and install the most recent Olex2 from the Olex2 website, <a href=\"https:\/\/www.olexsys.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">OlexSys<\/a>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/06\/Installation_Notes___OlexSys.png\" alt=\"\" width=\"899\" height=\"263\" class=\"alignnone size-full wp-image-1360\" \/><\/p>\n<h3>Settings for Olex2<\/h3>\n<p>You will need to specify the paths for <strong>SHELX<\/strong> and <strong>PLATON<\/strong>. Start <strong>Olex2<\/strong>, click &#8220;Settings&#8221; in &#8220;Home&#8221; to expand it, and enter <strong>\/usr\/local\/bin<\/strong> in the <strong>PATH:<\/strong> field that appears.<\/p>\n<figure id=\"attachment_707\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/06\/olex2-settings.png\" alt=\"\" width=\"553\" height=\"331\" class=\"wp-image-707 size-full\" \/><figcaption class=\"wp-caption-text\">Click <strong>Settings<\/strong><\/figcaption><\/figure>\n<figure id=\"attachment_709\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/06\/Olex2-path.png\" alt=\"\" width=\"546\" height=\"205\" class=\"wp-image-709 size-full\" \/><figcaption class=\"wp-caption-text\">enter <strong>\/usr\/local\/bin<\/strong> in <strong>PATH:<\/strong><\/figcaption><\/figure>\n<p>Then reboot. If the path is recognized successfully, the <strong>PTON<\/strong> button will appear in the icon field. Click on it to start <strong>PLATON<\/strong>. <strong>SHELX<\/strong> will also be recognized, and you will be able to select <strong>SHELXT<\/strong> in <strong>Solve<\/strong> and <strong>SHELXL<\/strong> in Least Squares (<strong>LS<\/strong>).<\/p>\n<figure id=\"attachment_708\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"https:\/\/mitsudo.net\/wp-content\/uploads\/2020\/06\/Olex2-platon.png\" alt=\"\" width=\"262\" height=\"40\" class=\"wp-image-708 size-full\" \/><figcaption class=\"wp-caption-text\">Click the PTON button to start PLATON<\/figcaption><\/figure>\n<ul>\n<li><span class=\"marker-halfBlue\">If <strong>Olex2<\/strong> is too slow<br \/>\n<\/span><strong><\/strong>If <strong>Olex2<\/strong> is running slowly, <span class=\"marker-halfPink\">try reducing the number of lines displayed in [Tools]-[Settings]-[Lines of Text]<\/span>. The more you reduce the number of lines displayed, the more it will run.<\/li>\n<li>If <strong>PLATON<\/strong> does not work<br \/>\nFirst, from the command line, use the <strong style=\"font-family: Lato, \u6e38\u30b4\u30b7\u30c3\u30af\u4f53, 'Yu Gothic', YuGothic, '\u30d2\u30e9\u30ae\u30ce\u89d2\u30b4\u30b7\u30c3\u30af Pro', 'Hiragino Kaku Gothic Pro', \u30e1\u30a4\u30ea\u30aa, Meiryo, '\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af', 'MS PGothic', sans-serif; font-size: 1.4rem;\">which<\/strong><span style=\"font-family: Lato, \u6e38\u30b4\u30b7\u30c3\u30af\u4f53, 'Yu Gothic', YuGothic, '\u30d2\u30e9\u30ae\u30ce\u89d2\u30b4\u30b7\u30c3\u30af Pro', 'Hiragino Kaku Gothic Pro', \u30e1\u30a4\u30ea\u30aa, Meiryo, '\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af', 'MS PGothic', sans-serif; font-size: 1.4rem;\"> command to make sure that the path to <\/span><strong style=\"font-family: Lato, \u6e38\u30b4\u30b7\u30c3\u30af\u4f53, 'Yu Gothic', YuGothic, '\u30d2\u30e9\u30ae\u30ce\u89d2\u30b4\u30b7\u30c3\u30af Pro', 'Hiragino Kaku Gothic Pro', \u30e1\u30a4\u30ea\u30aa, Meiryo, '\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af', 'MS PGothic', sans-serif; font-size: 1.4rem;\">platon<\/strong><span style=\"font-family: Lato, \u6e38\u30b4\u30b7\u30c3\u30af\u4f53, 'Yu Gothic', YuGothic, '\u30d2\u30e9\u30ae\u30ce\u89d2\u30b4\u30b7\u30c3\u30af Pro', 'Hiragino Kaku Gothic Pro', \u30e1\u30a4\u30ea\u30aa, Meiryo, '\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af', 'MS PGothic', sans-serif; font-size: 1.4rem;\"> is passed.<\/span><\/li>\n<\/ul>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ which platon\u00a0 # check where platon is\r\n\/usr\/local\/bin\/platon\u00a0 #If it looks like this, it's OK.<\/code><\/pre>\n<\/div>\n<p>If you see &#8220;platon not found&#8221;, it means <strong>platon<\/strong> has not been copied to \/usr\/local\/bin, or you do not have permission to run it (permission setting failed).<\/p>\n<p>After confirming that the path to platon has been successfully passed, try to run platon from the command line.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-bash\" data-lang=\"Zsh\"><code>$ platon<\/code><\/pre>\n<\/div>\n<p>If <strong>platon<\/strong> starts, it is OK. If you get an error and <strong>platon<\/strong> does not start, you will need to re-install <strong>platon<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Crystal Structure Analysis on Mac X-ray crystallography is one of the most direct methods to know the structure of molecules. Nowadays, data analysis of crystal structure can be done free of charge (f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":695,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/mitsudo.net\/?p=690","footnotes":""},"categories":[26],"tags":[31,25,33,32],"class_list":["post-1532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chem-with-mac","tag-chemistry","tag-mac","tag-olex2","tag-x-ray","en-US"],"_links":{"self":[{"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/posts\/1532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/comments?post=1532"}],"version-history":[{"count":21,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/posts\/1532\/revisions"}],"predecessor-version":[{"id":1636,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/posts\/1532\/revisions\/1636"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/media\/695"}],"wp:attachment":[{"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/media?parent=1532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/categories?post=1532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitsudo.net\/wp-json\/wp\/v2\/tags?post=1532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}