{"id":3808,"date":"2018-01-16T15:43:37","date_gmt":"2018-01-16T15:43:37","guid":{"rendered":"http:\/\/www.blopig.com\/blog\/?p=3808"},"modified":"2018-01-16T15:43:37","modified_gmt":"2018-01-16T15:43:37","slug":"crystallographic-programming-super-short-tour-of-the-cctbx","status":"publish","type":"post","link":"https:\/\/www.blopig.com\/blog\/2018\/01\/crystallographic-programming-super-short-tour-of-the-cctbx\/","title":{"rendered":"Crystallographic programming:  Super short tour of the cctbx"},"content":{"rendered":"<p>Two of the leading packages in crystallography are <a href=\"http:\/\/phenix-online.org\/\">Phenix<\/a> and <a href=\"http:\/\/www.ccp4.ac.uk\/\">CCP4<\/a>. For most practicing crystallographers they will interact via with these to progress a single crystallographic data-set from diffraction images, through integration, merging, phasing, model building and hopefully deposition.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-3809\" src=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2018\/01\/gui_main.png?resize=625%2C471&#038;ssl=1\" alt=\"\" width=\"625\" height=\"471\" srcset=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2018\/01\/gui_main.png?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2018\/01\/gui_main.png?resize=300%2C226&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2018\/01\/gui_main.png?resize=768%2C579&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2018\/01\/gui_main.png?resize=624%2C470&amp;ssl=1 624w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p><iframe loading=\"lazy\" title=\"CCP4i2 quick start tutorial\" width=\"625\" height=\"469\" src=\"https:\/\/www.youtube.com\/embed\/fB7BRVzBURg?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>However, if you want to develop crystallographic software, you will likely need to decide on a framework to build upon. <a href=\"http:\/\/phenix-online.org\/\">Phenix<\/a> is built on the comprehensive <a href=\"http:\/\/cctbx.sourceforge.net\/\">cctbx library,<\/a> whereas CCP4 programs are typically standlone, although common crystallographic libraries such as <a href=\"http:\/\/www.ysbl.york.ac.uk\/~cowtan\/clipper\/doc\/\">clipper<\/a> and cctbx are utilised.<\/p>\n<p>CCTBX is written mainly in python, with core crystallographic functionality written in C++. My usual starting place for understanding functionality is through the <a href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/iotbx\/iotbx.pdb.html\">pdb parser tutorial<\/a>. This introduces the concept of a hierarchy, a iterative way to represent a macromolecule:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">from iotbx.pdb import hierarchy\r\npdb_in = hierarchy.input(file_name=\"model.pdb\")\r\nfor chain in pdb_in.hierarchy.only_model().chains() :\r\n  for residue_group in chain.residue_groups() :\r\n    for atom_group in residue_group.atom_groups() :\r\n      for atom in atom_group.atoms() :\r\n        if (atom.element.strip().upper() == \"ZN\") :\r\n          atom_group.remove_atom(atom)\r\n      if (atom_group.atoms_size() == 0) :\r\n        residue_group.remove_atom_group(atom_group)\r\n    if (residue_group.atom_groups_size() == 0) :\r\n      chain.remove_residue_group(residue_group)\r\nf = open(\"model_Zn_free.pdb\", \"w\")\r\nf.write(pdb_in.hierarchy.as_pdb_string(\r\n  crystal_symmetry=pdb_in.input.crystal_symmetry()))\r\nf.close()<\/pre>\n<p>Although there are many ways to parse a pdb file, the <a href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/iotbx\/iotbx.pdb.html\">introduction to iotbx.pdb<\/a>, gives a view of how xray structure data can be associated to the model. The tour of the cctbx can be helpful starting place, especially for understanding how the python and c++ functionality interact through boost and the <code class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">scitbx.array_family.flex.\u00a0<\/code>Unfortunately, documentation on cctbx tends to vary in quality and quantity throughout the modules:<\/p>\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/libtbx\/index.html\">libtbx &#8211; low-level utilities and infrastructure for CCTBX<\/a><\/li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/boost_adaptbx\/index.html\">boost_adaptbx &#8211; wrappers for Boost functionality<\/a><\/li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/iotbx\/index.html\">iotbx &#8211; file readers and writers<\/a><\/li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/scitbx\/index.html\">scitbx &#8211; general-purpose scientific programming infrastructure<\/a><\/li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/cctbx\/cctbx.html\">cctbx &#8211; core crystallographic objects and functions<\/a><\/li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"https:\/\/cci.lbl.gov\/cctbx_docs\/mmtbx\/mmtbx.html\">mmtbx &#8211; macromolecular crystallography<\/a><\/li>\n<\/ul>\n<p>Other components of the library include ways to simulate crystallographic data through <a href=\"https:\/\/github.com\/cctbx\/cctbx_project\/tree\/master\/simtbx\">simtbx<\/a>,\u00a0 and tools for <a href=\"http:\/\/viper.lbl.gov\/cctbx.xfel\/index.php\/Main_Page\">processing xfel data.<\/a><\/p>\n<p>As the library is open source, github hosted <a href=\"https:\/\/github.com\/cctbx\/cctbx_project\">source code<\/a> allows exploration of previously written routines, which can be very helpful for understanding the inner workings of the library. Note that there are also bulletin boards for <a href=\"http:\/\/www.phenix-online.org\/mailman\/listinfo\/phenixbb\">users<\/a> and <a href=\"http:\/\/www.phenix-online.org\/mailman\/listinfo\/cctbxbb\">developers<\/a> of phenix and cctbx respectively. A few <a href=\"http:\/\/www.phenix-online.org\/pipermail\/cctbxbb\/2015-January\/001042.html\">tutorials<\/a> can also be found.<\/p>\n<p>Hopefully this post will give someone other than me a reminder of where to find resources to get started developing within CCTBX.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Two of the leading packages in crystallography are Phenix and CCP4. For most practicing crystallographers they will interact via with these to progress a single crystallographic data-set from diffraction images, through integration, merging, phasing, model building and hopefully deposition. However, if you want to develop crystallographic software, you will likely need to decide on a [&hellip;]<\/p>\n","protected":false},"author":39,"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":[29,14,30],"tags":[],"ppma_author":[526],"class_list":["post-3808","post","type-post","status-publish","format-standard","hentry","category-code","category-howto","category-links"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"authors":[{"term_id":526,"user_id":39,"is_guest":0,"slug":"elliot","display_name":"Elliot Nelson","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/b8663b2e53fd00e5778a17f165ee97f39587795f8345606ad0fa95e68655f409?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\/3808","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\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/comments?post=3808"}],"version-history":[{"count":8,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/3808\/revisions"}],"predecessor-version":[{"id":3817,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/3808\/revisions\/3817"}],"wp:attachment":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/media?parent=3808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/categories?post=3808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/tags?post=3808"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=3808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}