├── .travis.yml ├── 2hhb.inp ├── README.md ├── LICENSE └── illustrate.f /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: required 3 | before_install: 4 | - sudo apt-get install gfortran 5 | 6 | script: 7 | - gfortran illustrate.f -o illustrate 8 | - ./illustrate < 2hhb.inp -------------------------------------------------------------------------------- /2hhb.inp: -------------------------------------------------------------------------------- 1 | read 2 | 2hhb.pdb 3 | HETATM-----HOH-- 0,9999, 0.5,0.5,0.5, 0.0 4 | ATOM -H-------- 0,9999, 0.5,0.5,0.5, 0.0 5 | ATOM H--------- 0,9999, 0.5,0.5,0.5, 0.0 6 | ATOM -C-------A 0,9999, 1.0,0.6,0.6, 1.6 7 | ATOM -S-------A 0,9999, 1.0,0.5,0.5, 1.8 8 | ATOM ---------A 0,9999, 1.0,0.5,0.5, 1.5 9 | ATOM -C-------C 0,9999, 1.0,0.6,0.6, 1.6 10 | ATOM -S-------C 0,9999, 1.0,0.5,0.5, 1.8 11 | ATOM ---------C 0,9999, 1.0,0.5,0.5, 1.5 12 | ATOM -C-------- 0,9999, 1.0,0.8,0.6, 1.6 13 | ATOM -S-------- 0,9999, 1.0,0.7,0.5, 1.8 14 | ATOM ---------- 0,9999, 1.0,0.7,0.5, 1.5 15 | HETATMFE---HEM-- 0,9999, 1.0,0.8,0.0, 1.8 16 | HETATM-C---HEM-- 0,9999, 1.0,0.3,0.3, 1.6 17 | HETATM-----HEM-- 0,9999, 1.0,0.1,0.1, 1.5 18 | END 19 | center 20 | auto 21 | trans 22 | 0.,0.,0. 23 | scale 24 | 12.0 25 | zrot 26 | 90. 27 | wor 28 | 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 29 | 1,0.0023,2.0,1.0,0.2 30 | -30,-30 31 | illustrate 32 | 3.0,10.0,4,0.0,5.0 33 | 3.0,10.0 34 | 3.0,8.0,6000. 35 | calculate 36 | 2hhb.pnm 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://api.travis-ci.org/ccsb-scripps/Illustrate.svg?branch=master)](https://api.travis-ci.org/ccsb-scripps/Illustrate.svg?branch=master) 2 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 3 | 4 | **I L L U S T R A T E** 5 | 6 | Biomolecular Illustration 7 | copyright 2019 David S Goodsell 8 | 9 | Licensed under the Apache License, Version 2.0 (the "License") you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License 10 | 11 | This work was supported in part by Damon Runyon-Walter Winchell Cancer Research Fund Fellowship DRG 972, the US National Institutes of Health R01-GM120604 and the kind support of the RCSB Protein Data Bank. 12 | DS Goodsell & AJ Olson (1992) "Molecular Illustration in Black and White" JMolGraphics 10, 235-240. 13 | April 2019 Simplified and released with only non-photorealistic rendering 14 | 15 | **COMPILING AND RUNNING** 16 | 17 | Compile the fortran code: 18 | 19 | gfortran illustrate.f -o illustrate 20 | 21 | Run the program: 22 | 23 | illustrate < command_file 24 | 25 | Command file is read from unit 5 (standard in), and a bunch of diagnostic stuff is written to unit 6 (standard out) 26 | 27 | **COMMAND FILE FORMAT** 28 | 29 | The command file has command cards (read, center, world, calculate, etc), followed by parameter cards needed for each command. Please issue command cards in this order: 30 | 1. `read` — reads coordinates and selection/rendering parameters 31 | 2. `center, translate, xrot, yrot, zrot, scale` commands, in any order 32 | 3. `world` — defines rendering parameter 33 | 4. `illustrate` — defines illustration parameters 34 | 5. `calculate` — renders the image and writes ppm file 35 | 36 | This program has many idiosyncracies and almost no error checking (beware…postdoc code from the 90s!) 37 | 38 | Selection/rendering cards in the “read” command are read sequentially until one without “ATOM” or “HETATM” is found. Atoms are compared to cards in order, and if a match is found, the atom is assigned those parameters. This process provides a lot of flexibility with very few cards, if you’re clever about the order of cards and the use of wildcards. Any number of rotation cards may be added, and they are concatenated when added. This means they are effectively applied last to first, so if you’re progressively refining an orientation, add new rotations to the top of the list. Rotations are applied first, then centering, and finally translation. This ensures that the molecule is always centered in the view. Use the translation if you want it offset. Origin at upper left, +x down, +y left to right, +z towards viewer, molecules clipped at z=0 39 | 40 | **ABOUT THE OUTLINES** 41 | 42 | Outlines are created by calculating the local derivative of the z-value using a variety of kernels, then providing a range of values of these derivatives that will be given shades of gray and black. Outlines may be drawn based on the contours and outer shape of the molecule, between subunits, and based on the differences in the residue number in chains. 43 | 44 | **SAMPLE COMMAND FILE** 45 | 46 | for PDB entry 2hhb (Hemoglobin) 47 | 48 | read #READ command 49 | 2hhb.pdb #PDB format coordinate file 50 | HETATM-----HOH-- 0,9999, 0.5,0.5,0.5, 0.0 #selection/rendering cards 51 | ATOM -H-------- 0,9999, 0.5,0.5,0.5, 0.0 # omits hydrogens 52 | ATOM H--------- 0,9999, 0.5,0.5,0.5, 0.0 # omits hydrogens with long atom names 53 | ATOM -C-------A 0,9999, 1.0,0.6,0.6, 1.6 # draws carbon atoms in chain A, pink 54 | ATOM -S-------A 0,9999, 1.0,0.5,0.5, 1.8 55 | ATOM ---------A 0,9999, 1.0,0.5,0.5, 1.5 # draws the rest of chain A atoms 56 | ATOM -C-------C 0,9999, 1.0,0.6,0.6, 1.6 # similarly for chain C 57 | ATOM -S-------C 0,9999, 1.0,0.5,0.5, 1.8 58 | ATOM ---------C 0,9999, 1.0,0.5,0.5, 1.5 59 | ATOM -C-------- 0,9999, 1.0,0.8,0.6, 1.6 # draws remaining protein carbons, light orange 60 | ATOM -S-------- 0,9999, 1.0,0.7,0.5, 1.8 61 | ATOM ---------- 0,9999, 1.0,0.7,0.5, 1.5 62 | HETATMFE---HEM-- 0,9999, 1.0,0.8,0.0, 1.8 # draws heme iron, yellow 63 | HETATM-C---HEM-- 0,9999, 1.0,0.3,0.3, 1.6 64 | HETATM-----HEM-- 0,9999, 1.0,0.1,0.1, 1.5 65 | END #end of READ command 66 | center #CENTER command 67 | auto #use autocentering 68 | trans #TRANSLATION command 69 | 0.,0.,0. #x,y,z for translation 70 | scale #SCALE command 71 | 12.0 #scale value (pixels/A) 72 | zrot #ROTATION command 73 | 90. #rotation angle (deg) 74 | wor #WORLD command (rendering parameters) 75 | 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 #rgbback, rgbfog, fogparams 76 | 1,0.0023,2.0,1.0,0.2 #soft shadow parameters 77 | -30,-30 #image size with autosizing 78 | illustrate #ILLUSTRATION command 79 | 3.0,10.0,4,0.0,5.0 #contour outlines 80 | 3.0,10.0 #subunit outlines 81 | 3.0,8.0,6000. #residue outlines 82 | calculate #CALCULATE command 83 | 2hhb.pnm #image file name in ppm 84 | 85 | 86 | 87 | **COMMAND CARDS** 88 | 89 | READ command 90 | 91 | PDB filename 92 | 93 | Selection/rendering cards 94 | 95 | record name (A6) “ATOM “ or “HETATM”, matched with columns 1-6 of PDB file 96 | 97 | atom descriptor (A10) matched with columns 13-22 of PDB file, “-” is a wildcard 98 | 99 | residue range low, high (integer) 100 | 101 | color r,g,b (3 real) 0.0-1.0 102 | 103 | radius (real) angstrom, value of 0.0 will omit the atom 104 | 105 | -------------------------------------------------------------------- 106 | CENTER command 107 | 108 | centering type (a3) 109 | “aut” (auto) will autocenter with no clipping 110 | 111 | “cen” (center) will center on max/min coordinates in xyz 112 | 113 | -------------------------------------------------------------------- 114 | TRANSLATE command 115 | 116 | translation vector x,y,z (3 real) translation in Angstroms 117 | 118 | -------------------------------------------------------------------- 119 | XROT, YROT, ZROT commands 120 | 121 | rotation angle (real) rotation angle in degrees 122 | 123 | -------------------------------------------------------------------- 124 | SCALE command 125 | 126 | scale value (real) pixels/Angstrom 127 | 128 | -------------------------------------------------------------------- 129 | WORLD command 130 | 131 | Background and fog parameters 132 | 133 | rback r,g,b (3 real) color of background (0.0-1.0) 134 | 135 | rfog r,g,b (3 real) color of fog (0.0-1.0) 136 | 137 | pfogh, pfogl (2 real) fractional transparency of fog at front and back of molecule 138 | 139 | (0.0-1.0, 1.0=no fog) 140 | 141 | Soft shadow parameters 142 | 143 | icone (integer) 0=no shadows, 1=shadows 144 | 145 | pcone (real) fractional shadowing around each atom 146 | 147 | larger=darker (0.0-1.0, typically 0.0023) 148 | 149 | coneangle (real) angle of shadowing around each atom 150 | 151 | larger=tighter region (0.0-1.0, typically 2.0) 152 | 153 | rcone (real) shadowing only applied if z-difference greater than this value 154 | 155 | (Angstroms, typically 1.0) 156 | 157 | pshadowmax (real) maximal shadowing amount 158 | 159 | smaller=darker (0.0-1.0, typically 0.7) 160 | 161 | -------------------------------------------------------------------- 162 | ILLUSTRATE command 163 | 164 | Contour outline parameters 165 | 166 | l_low, l_high (2 real) thresholds for gray to black 167 | 168 | typically values from about 3.0-20.0, best values for typical atomic illustrations: 3.0, 10.0 169 | 170 | ikernel (integer) kernel for derivative calculation (1,2,3,4 smoothest=4) 171 | 172 | l_diff_min, l_diff_max (2 integer) range of z-difference used for derivative (Angstroms) 173 | 174 | 0.0,1.0 gives outlines around every atom 175 | 176 | 0.0,1000.0 gives only outline around molecule 177 | 178 | 0.0,5.0 is typical 179 | 180 | Subunit outline parameters 181 | 182 | r_low, r_high (2 real) thresholds for gray to black (typically ~ 3.0-20.0) 183 | 184 | Residue outline parameters 185 | 186 | g_low, g_high (2 real) thresholds for gray to black (typically ~ 3.0-20.0) 187 | 188 | resdiff (real) difference in residue numbers to draw outlines 189 | 190 | -------------------------------------------------------------------- 191 | CALCULATE command 192 | 193 | Filename for PPM format file 194 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /illustrate.f: -------------------------------------------------------------------------------- 1 | C ****************************** 2 | C I L L U S T R A T E 3 | C Biomolecular Illustration 4 | C ****************************** 5 | C copyright 2019 David S Goodsell 6 | C 7 | C Licensed under the Apache License, Version 2.0 (the "License"); 8 | C you may not use this file except in compliance with the License. 9 | C You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 10 | C Unless required by applicable law or agreed to in writing, software 11 | C distributed under the License is distributed on an "AS IS" BASIS, 12 | C WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | C See the License for the specific language governing permissions and 14 | C limitations under the License 15 | C 16 | C This work was supported by Damon Runyon-Walter Winchell Cancer Research Fund Fellowship DRG 972, 17 | C the US National Institutes of Health R01-GM120604 and the kind support of the RCSB Protein Data Bank. 18 | C 19 | C-------------------------------------------------------------------- 20 | C 21 | C DS Goodsell & AJ Olson (1992) "Molecular Illustration in Black and White" JMolGraphics 10, 235-240. 22 | C April 2019 -- Simplified and released with only non-photorealistic rendering 23 | C 24 | C-------------------------------------------------------------------- 25 | C compile: gfortran illustrate.f -o illustrate 26 | C run: illustrate < command_file 27 | C 28 | C Command file is read from unit 5 29 | C Command file has command cards, followed by parameter cards 30 | C Idiosyncracies (warning, postdoc code): 31 | C *** must issue command cards in this order 32 | C *** any number of rotation cards may be added, and they are concatenated when added 33 | C this means they are effectively applied last to first 34 | C so if you're progressively refining a position, add new rotations to the top of the list 35 | C *** origin at upper left, +x down, +y left to right, +z towards viewer, molecules clipped at z=0 36 | C 37 | C read #READ command 38 | C 2hhb.pdb #PDB format coordinate file 39 | C HETATM-----HOH-- 0,9999, 0.5,0.5,0.5, 0.0 #selection/rendering cards 40 | C ATOM -H-------- 0,9999, 0.5,0.5,0.5, 0.0 41 | C ATOM H--------- 0,9999, 0.5,0.5,0.5, 0.0 42 | C ATOM -C-------A 0,9999, 1.0,0.6,0.6, 1.6 43 | C ATOM -S-------A 0,9999, 1.0,0.5,0.5, 1.8 44 | C ATOM ---------A 0,9999, 1.0,0.5,0.5, 1.5 45 | C ATOM -C-------C 0,9999, 1.0,0.6,0.6, 1.6 46 | C ATOM -S-------C 0,9999, 1.0,0.5,0.5, 1.8 47 | C ATOM ---------C 0,9999, 1.0,0.5,0.5, 1.5 48 | C ATOM -C-------- 0,9999, 1.0,0.8,0.6, 1.6 49 | C ATOM -S-------- 0,9999, 1.0,0.7,0.5, 1.8 50 | C ATOM ---------- 0,9999, 1.0,0.7,0.5, 1.5 51 | C HETATMFE---HEM-- 0,9999, 1.0,0.8,0.0, 1.8 52 | C HETATM-C---HEM-- 0,9999, 1.0,0.3,0.3, 1.6 53 | C HETATM-----HEM-- 0,9999, 1.0,0.1,0.1, 1.5 54 | C END #end of READ commad 55 | C center #CENTER command 56 | C auto #use autocentering (typical) 57 | C trans #TRANSLATION command 58 | C 0.,0.,0. #x,y,z for translation 59 | C scale #SCALE command 60 | C 12.0 #scale value (pixels/Angstrom) 61 | C zrot #ROTATION command 62 | C 90. #rotation angle (deg) 63 | C wor #WORLD rendering parameter 64 | C 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 #rgb background, rgb fog, fractional opacity of fog front & back 65 | C 1,0.0023,2.0,1.0,0.2 #soft shadow parameters 66 | C -30,-30 #image size, negative for autosizing with padding 67 | C illustrate #ILLUSTRATION command 68 | C 3.0,10.0,4,0.0,5.0 #contour outlines 69 | C 3.0,10.0 #subunit outlines 70 | C 3.0,8.0,6000. #residue outlines 71 | C calculate #CALCULATE command 72 | C 2hhb.pnm #image file name in ppm format 73 | C 74 | C-------------------------------------------------------------------- 75 | c ***** OUTPUT SCAN LINE ***** 76 | integer*4 scanline(9000) 77 | c ***** FRAME BUFFER WITH COLORS ***** 78 | real*4 pix(-10:3008,-10:3008,4) 79 | c ***** FRAME BUFFER CONTAINING THE z HEIGHT ***** 80 | real*4 zpix(-10:3008,-10:3008) 81 | c ***** FRAME BUFFER CONTAINING THE ATOM NUMBER ***** 82 | integer*4 atom(-10:3008,-10:3008) 83 | integer*4 bio(-10:3008,-10:3008) 84 | integer*4 n,ia 85 | c ***** SHADING MAPS FOR THE EIGHT ATOM TYPES ***** 86 | real*4 sphdat(0:32000,3) 87 | integer*4 numpix 88 | c ***** PHONG SHADING PARAMETERS ****** 89 | real*4 colortype(0:1000,3) 90 | real*4 rback(3),rfog(3) 91 | c ***** ATOMIC INFORMATION ***** 92 | real*4 coord(3,350000) 93 | integer*4 type(350000),res(0:350000),su(0:350000) 94 | real*4 radtype(1000) 95 | character chain,chainlast 96 | c ***** transformation matrices ***** 97 | real*4 matrixin(4,4),rm(4,4) 98 | c ***** biological unit stuff ***** 99 | real*4 biomat(4,4,500) 100 | integer*4 nbiochain,nbiomat 101 | character biochain(500) 102 | c ***** STUFF FOR OUTLINES ***** 103 | real*4 l_opacity,l_opacity_ave,g_opacity,opacity 104 | real*4 l(-1:1,-1:1),g 105 | real*4 l_low,l_high,g_low,g_high 106 | real*4 l_diff_min, l_diff_max 107 | c ***** Conical shadows ***** 108 | real*4 rtable(-51:51,-51:51),coneangle,pcone,rcone 109 | c ***** ETC. ***** 110 | real*4 x,y,z,rx,ry,rz,xp,yp,zp,d 111 | real*4 xn,yn,zn,ci,xs,xy,xz,cs 112 | character*3 comcode(10),command 113 | character*80 filename,inputfile 114 | integer*4 ixsize,iysize, idepth 115 | integer*4 ix,iy,iz 116 | integer illustrationflag 117 | c ***** stuff for reading atoms 118 | integer*4 resrange(2,1000),inptype(1000),inpsu(1000) 119 | character*6 atomdescriptor(1000) 120 | character*10 descriptor(1000) 121 | character*80 instring 122 | c-------------------------------------------------------------------- 123 | c ***** Initialize a few things ***** 124 | c-------------------------------------------------------------------- 125 | rscale=1. 126 | 127 | illustrationflag=0 128 | 129 | data comcode/'rea','tra','xro','yro','zro','sca','cen', 130 | & 'wor','cal','ill'/ 131 | 132 | call clearmatrix(rm) 133 | l_low=1. 134 | l_high=10. 135 | g_low=350000. 136 | g_high=21000. 137 | xshmax=4000 138 | yshmax=4000 139 | su(0)=9999 140 | res(0)=9999 141 | xtran=0. 142 | ytran=0. 143 | ztran=0. 144 | l_diff_max=50. 145 | l_diff_min=1. 146 | ixsize=0 147 | iysize=0 148 | do i=1,3 149 | do j=1,4 150 | do k=1,500 151 | biomat(i,j,k)=0. 152 | if (i.eq.j) biomat(i,j,k)=1. 153 | enddo 154 | enddo 155 | enddo 156 | c ********************* READ CONTROL CARDS *************************** 157 | 10 read (5,101,end=999) command 158 | icommand=10 159 | do icount=1,10 160 | 100 if (command.eq.comcode(icount)) icommand=icount 161 | enddo 162 | goto (1,2,3,4,5,6,7,8,111,12),icommand 163 | write (6,102) ' ***** invalid control card read: ', 164 | & command, ' ***** ' 165 | goto 10 166 | 101 format (a3) 167 | 102 format (a35,a3,a7) 168 | c-------------------------------------------------------------------- 169 | c *** read and classify atoms *** 170 | c 171 | 1 continue 172 | read(5,113) inputfile 173 | open(1,file=inputfile,form='formatted',status='old') 174 | c --- read atom descriptors --- 175 | c param: atom descriptor cards 176 | c ATOM -CA--ALA-A 0,9999,0.5,0.5,0.5,1.6 177 | c ^^^^^^ ATOM or HETATM, matched with columns 1-6 of PDB record 178 | c ^^^^^^^^^^ compared to columns 13-22 of PDB record 179 | c "-" is a wildcard 180 | c ^^^^^^ residue number range 181 | c ^^^^^^^^^^^ r,g,b (0.-1.) 182 | c ^^^ radius (Angstrom) 183 | c cards are read in order, and if there is a match, the atom is assigned that type 184 | c cards are read until one is found without "ATOM " or "HETATM" 185 | c 186 | ndes=0 187 | c --- default 50% gray --- 188 | do i=0,1000 189 | do j=1,3 190 | colortype(i,j)=.5 191 | enddo 192 | enddo 193 | 7020 read(5,7100) instring 194 | if (instring(1:3).eq.'END') goto 7030 195 | ndes=ndes+1 196 | read(instring,21) atomdescriptor(ndes),descriptor(ndes) 197 | read(instring(18:80),*) (resrange(i,ndes),i=1,2), 198 | & rr,rg,rb,rad 199 | colortype(ndes,1)=rr 200 | colortype(ndes,2)=rg 201 | colortype(ndes,3)=rb 202 | radtype(ndes)=rad 203 | goto 7020 204 | 7030 write(6,*) ' atom descriptors: ',ndes 205 | do i=1,ndes 206 | write(6,*) "type, color, radius ",i,(colortype(i,j),j=1,3), 207 | & radtype(i) 208 | enddo 209 | 21 format(a6,a10) 210 | c --- read atoms and classify --- 211 | n=0 212 | nsu=0 213 | chain=" " 214 | nbiomat=0 215 | nbiochain=0 216 | 7040 read(1,7100,end=7009) instring 217 | if (instring(1:5).eq."MODEL") nsu=nsu+1 218 | 219 | if (instring(12:25).eq."BIOMOLECULE: 1") then 220 | 8010 read(1,7100) instring 221 | if ((instring(1:10).eq."REMARK 350").and. 222 | & (instring(35:40).eq."CHAINS")) then 223 | ich=43 224 | 8020 if (instring(ich:ich).ne." ") then 225 | nbiochain=nbiochain+1 226 | biochain(nbiochain)=instring(ich:ich) 227 | ich=ich+3 228 | goto 8020 229 | else 230 | continue 231 | endif 232 | write(6,*) "Chains in Biological Assembly" 233 | do i=1,nbiochain 234 | write(6,*) i,biochain(i) 235 | enddo 236 | write(6,*) 237 | goto 8010 238 | endif 239 | if (instring(14:19).eq."BIOMT1") then 240 | nbiomat=nbiomat+1 241 | read(instring(20:80),*) ib,(biomat(1,j,nbiomat),j=1,4) 242 | 8030 format(23x,5f10.6,f15.5) 243 | endif 244 | if (instring(14:19).eq."BIOMT2") then 245 | c read(instring,8030) (biomat(2,j,nbiomat),j=1,4) 246 | read(instring(20:80),*) ib,(biomat(2,j,nbiomat),j=1,4) 247 | endif 248 | if (instring(14:19).eq."BIOMT3") then 249 | c read(instring,8030) (biomat(3,j,nbiomat),j=1,4) 250 | read(instring(20:80),*) ib,(biomat(3,j,nbiomat),j=1,4) 251 | endif 252 | if (instring(14:19).eq." ") then 253 | write(6,*) "Number of BIOMT ",nbiomat 254 | do ibio=1,nbiomat 255 | do im=1,3 256 | write(6,*) "BIOMAT ",ibio,(biomat(im,j,ibio),j=1,4) 257 | enddo 258 | enddo 259 | goto 8099 260 | endif 261 | goto 8010 262 | 263 | endif 264 | c --- end of BIOMAT 265 | 8099 continue 266 | 267 | if ((instring(1:4).ne.'ATOM').and. 268 | & (instring(1:6).ne.'HETATM')) goto 7040 269 | 270 | read(instring,200) ires 271 | do ides=1,ndes 272 | 273 | if (instring(1:6).ne.atomdescriptor(ides)(1:6)) goto 7050 274 | 275 | do ia=1,10 276 | if (descriptor(ides)(ia:ia).eq.'-') goto 7060 277 | if (instring(12+ia:12+ia).ne.descriptor(ides)(ia:ia)) goto 7050 278 | 7060 continue 279 | enddo 280 | 281 | if ((ires.lt.resrange(1,ides)).or. 282 | & (ires.gt.resrange(2,ides))) goto 7050 283 | 284 | if (radtype(ides).eq.0) goto 7040 285 | 286 | c --- check if chain is in biological assembly 287 | if (nbiochain.ne.0) then 288 | ibioflag=0 289 | do ibio=1,nbiochain 290 | if (instring(22:22).eq.biochain(ibio)) ibioflag=1 291 | enddo 292 | if (ibioflag.eq.0) goto 7040 293 | endif 294 | 295 | c --- found an atom to save --- 296 | n=n+1 297 | read(instring,300) (coord(i,n),i=1,3) 298 | type(n)=ides 299 | C --- assign subunits automatically --- 300 | chain=instring(22:22) 301 | if (chain.ne.chainlast) then 302 | nsu=nsu+1 303 | chainlast=chain 304 | endif 305 | su(n)=nsu 306 | res(n)=ires 307 | 308 | C --- apply biomat --- 309 | cif (nbiomat.gt.0) then 310 | crx=coord(1,n) 311 | cry=coord(2,n) 312 | crz=coord(3,n) 313 | cdo imat=1,nbiomat 314 | csu(n+imat)=su(n) 315 | cres(n+imat)=res(n) 316 | ctype(n+imat)=ides 317 | ccoord(1,n+imat)=rx*biomat(1,1,imat)+ 318 | c & ry*biomat(1,2,imat)+ 319 | c & rz*biomat(1,3,imat)+ 320 | c & biomat(1,4,imat) 321 | ccoord(2,n+imat)=rx*biomat(2,1,imat)+ 322 | c & ry*biomat(2,2,imat)+ 323 | c & rz*biomat(2,3,imat)+ 324 | c & biomat(2,4,imat) 325 | ccoord(3,n+imat)=rx*biomat(3,1,imat)+ 326 | c & ry*biomat(3,2,imat)+ 327 | c & rz*biomat(3,3,imat)+ 328 | c & biomat(3,4,imat) 329 | cenddo 330 | cn=n+nbiomat 331 | cendif 332 | 333 | goto 7040 334 | 7050 continue 335 | enddo 336 | goto 7040 337 | c --- done reading atoms --- 338 | 7009 write(6,*)' atoms read: ', n, ' from: ',inputfile 339 | write(6,*) " number of subunits: ",nsu 340 | write(6,*)' ' 341 | 7100 format(a80) 342 | 200 format(22x,i4) 343 | 300 format(30x,3f8.3) 344 | goto 10 345 | c-------------------------------------------------------------------- 346 | c TRANSLATION 347 | 2 continue 348 | read(5,*) xtrani,ytrani,ztrani 349 | xtran=xtran+xtrani 350 | ytran=ytran+ytrani 351 | ztran=ztran+ztrani 352 | write(6,*) 'translation vector : ',xtran,ytran,ztran 353 | write(6,*) 354 | goto 10 355 | c-------------------------------------------------------------------- 356 | c Z ROTATION 357 | 5 call clearmatrix(matrixin) 358 | read(5,*) angle 359 | write(6,*) 'z rotation : ',angle 360 | c --minus sign is because original rotations were left-handed! (warning: postdoc code) 361 | angle=-angle*3.141592/180. 362 | matrixin(1,1)=cos(angle) 363 | matrixin(1,2)=-sin(angle) 364 | matrixin(2,1)=sin(angle) 365 | matrixin(2,2)=cos(angle) 366 | call catenate(rm,matrixin) 367 | goto 10 368 | c-------------------------------------------------------------------- 369 | c Y ROTATION 370 | 4 call clearmatrix(matrixin) 371 | read(5,*) angle 372 | write(6,*) 'y rotation : ',angle 373 | angle=-angle*3.141592/180. 374 | matrixin(1,1)=cos(angle) 375 | matrixin(1,3)=sin(angle) 376 | matrixin(3,1)=-sin(angle) 377 | matrixin(3,3)=cos(angle) 378 | call catenate(rm,matrixin) 379 | goto 10 380 | c-------------------------------------------------------------------- 381 | c X ROTATION 382 | 3 call clearmatrix(matrixin) 383 | read(5,*) angle 384 | write(6,*) 'x rotation : ',angle 385 | angle=-angle*3.141592/180. 386 | matrixin(2,2)=cos(angle) 387 | matrixin(2,3)=-sin(angle) 388 | matrixin(3,2)=sin(angle) 389 | matrixin(3,3)=cos(angle) 390 | call catenate(rm,matrixin) 391 | goto 10 392 | c-------------------------------------------------------------------- 393 | c SCALE 394 | 6 continue 395 | read(5,*) rscalei 396 | rscale=rscale*rscalei 397 | write(6,*) 'scale factor : ',rscale 398 | write(6,*) 399 | goto 10 400 | c-------------------------------------------------------------------- 401 | c CENTERING of coordinates 402 | c three options: CEN(TER) will center on max/min coordinates in x,y,z 403 | c AUT(O-CENTER) will center the rotated coordinates 404 | c in the frame, and place the uppermost atom 405 | c just below the image plane 406 | c (done when image processing begins) 407 | c ROTATIONs are applied before the centering 408 | c TRANSLATIONs are applied after the centering 409 | 7 continue 410 | read(5,101) command 411 | autocenter=0 412 | if (command.eq.'aut') then 413 | autocenter=1 414 | goto 10 415 | endif 416 | 417 | if (command.eq.'cen') then 418 | autocenter=2 419 | goto 10 420 | endif 421 | 422 | goto 10 423 | c-------------------------------------------------------------------- 424 | c WORLD parameters that describe the environment 425 | 8 continue 426 | 427 | c param: rback(3) -- rgb of background, 0.-1. 428 | c param: rfog(3) -- rgb of fog, 0.-1. 429 | c param: pfogh,pfogl -- fractional intensity of fog color at front and back of molecule 430 | read (5,*) (rback(i),i=1,3),(rfog(i),i=1,3),pfogh,pfogl 431 | if (pfogl.lt.0.) then 432 | pfogl=-pfogl 433 | endif 434 | 435 | do i=1,3 436 | if (rback(i).gt.1.) rback(i)=1. 437 | if (rfog(i).gt.1.) rfog(i)=1. 438 | colortype(0,i)=rback(i) 439 | enddo 440 | 441 | if (pfogh.gt.1.) pfogh=1. 442 | if (pfogl.gt.1.) pfogl=1. 443 | 444 | write (6,202) ' background inten. :',(rback(i),i=1,3) 445 | write (6,202) ' fog intensity : ',(rfog(i),i=1,3) 446 | write (6,202) ' upper fog percent :',pfogh*100. 447 | write (6,202) ' lower fog percent :',pfogl*100. 448 | pfogdiff=pfogh-pfogl 449 | 450 | c param: icone -- flag, 0=no soft shadow, other=soft shadow 451 | c param: pcone -- fractional shadowing contribution from each atom (0.0023) 452 | c larger=darker shadow 453 | c param: coneangle -- angle of shadowing around each atom (2.0) 454 | c larger values give tighter shadowed region 455 | c param: rcone -- shadowing applied only if z values of atoms are 456 | c greater than rcone (removes many small shadows in 457 | c creases) (1.0 A) 458 | c param: pshadowmax -- maximal shadowing amount (0.7) smaller=darker shadow 459 | read (5,*) icone,pcone,coneangle,rcone,pshadowmax 460 | if (icone.ne.0) write (6,202) ' draw conical shadows' 461 | 462 | c param: ixsize,iysize -- vertical and horizonal size (pixels) 463 | c negative values are autosized, padded by the value 464 | read(5,*) ixsize,iysize 465 | if (ixsize.gt.3000) ixsize=3000 466 | if (iysize.gt.3000) iysize=3000 467 | write(6,*) 'input value for image size', ixsize,iysize 468 | goto 10 469 | 202 format(1x,a20,1x,8f7.2) 470 | 207 format(/1x,a20/) 471 | c-------------------------------------------------------------------- 472 | c ILLUSTRATION parameters for outlines 473 | 12 continue 474 | illustrationflag=1 475 | 476 | c param: l_low, l_high -- thresholds for drawing contour outlines (3.,8.) 477 | c higher values give fewer outlines 478 | c narrower range gives jaggier outlines 479 | c values are based on the number of pixels in the kernel 480 | c param: ikernel -- kernel for doing derivative, values=1,2,3,4 (4) 481 | c param: l_diff_min, l_diff_max -- range of difference in z-values used for calculation (0.,5. A) 482 | c 0-1 gives outlines around every atom, 0-1000 outlines the whole molecule 483 | c param: r_low, r_high -- thresholds for drawing subunit outlines (3.,8.) 484 | c param: g_low, g_high -- thresholds for drawing residue outlines (3.,8.) 485 | c param: resdiff -- residue outlines drawn for atoms with this difference in residue numbers or greater 486 | 487 | read(5,*) l_low,l_high,ikernel,l_diff_min,l_diff_max 488 | read(5,*) r_low,r_high 489 | read(5,*) g_low,g_high,resdiff 490 | write(6,*) 'illustration parameters' 491 | write(6,*) 'l parameters: ',l_low,l_high 492 | write(6,*) 'g parameters: ',g_low,g_high 493 | goto 10 494 | c-------------------------------------------------------------------- 495 | 111 write (6,207) ' *begin calculation*' 496 | c --- if no BIOMT in file, use biomat 1 == identity matrix 497 | nbiomat=max(nbiomat,1) 498 | c ***** Populate conical shadow table **** 499 | conemax=50. 500 | do i=-51,51 501 | do j=-51,51 502 | rtable(i,j)=sqrt(float(i)**2+float(j)**2) 503 | if (rtable(i,j).gt.conemax) rtable(i,j)=10000. 504 | enddo 505 | enddo 506 | rtable(0,0)=10000. 507 | c ***** SCALE RADII ***** 508 | do i=1,ndes 509 | radtype(i)=radtype(i)*rscale 510 | if (radtype(i).gt.radius_max) radius_max=radtype(i) 511 | 119 enddo 512 | c ***** APPLY AUTOCENTERING and AUTOSIZING, if switched on ***** 513 | if (autocenter.gt.0) then 514 | 515 | xmin=10000. 516 | xmax=-10000. 517 | ymin=10000. 518 | ymax=-10000. 519 | zmin=10000. 520 | zmax=-10000. 521 | 522 | do ia=1,n 523 | do ibio=1,nbiomat 524 | c--apply biomat 525 | rx=coord(1,ia)*biomat(1,1,ibio)+coord(2,ia)*biomat(1,2,ibio)+ 526 | & coord(3,ia)*biomat(1,3,ibio)+biomat(1,4,ibio) 527 | ry=coord(1,ia)*biomat(2,1,ibio)+coord(2,ia)*biomat(2,2,ibio)+ 528 | & coord(3,ia)*biomat(2,3,ibio)+biomat(2,4,ibio) 529 | rz=coord(1,ia)*biomat(3,1,ibio)+coord(2,ia)*biomat(3,2,ibio)+ 530 | & coord(3,ia)*biomat(3,3,ibio)+biomat(3,4,ibio) 531 | 532 | c--apply rotation matrix 533 | rx2=rx*rm(1,1)+ry*rm(2,1)+rz*rm(3,1) 534 | ry2=rx*rm(1,2)+ry*rm(2,2)+rz*rm(3,2) 535 | rz2=rx*rm(1,3)+ry*rm(2,3)+rz*rm(3,3) 536 | xmin=MIN(xmin,rx2) 537 | xmax=MAX(xmax,rx2) 538 | ymin=MIN(ymin,ry2) 539 | ymax=MAX(ymax,ry2) 540 | zmin=MIN(zmin,rz2) 541 | zmax=MAX(zmax,rz2) 542 | 543 | enddo 544 | enddo 545 | 546 | write(6,*) 'min coordinates : ',xmin,ymin,zmin 547 | write(6,*) 'max coordinates : ',xmax,ymax,zmax 548 | xtranc=-xmin-(xmax-xmin)/2. 549 | ytranc=-ymin-(ymax-ymin)/2. 550 | if (autocenter.eq.1) then 551 | ztranc=-zmax-radius_max-1. 552 | write(6,*) 'automating centering' 553 | endif 554 | if (autocenter.eq.2) then 555 | ztranc=-zmin-(zmax-zmin)/2. 556 | write(6,*) 'x,y,z centering' 557 | endif 558 | 559 | write(6,*) 'centering vector : ',xtranc,ytranc,ztranc 560 | 561 | if ((ixsize.le.0).or.(iysize.le.0)) then 562 | write(6,*) 563 | write(6,*) 'applying autosizing' 564 | write(6,*) 'x and y frame width: ',-ixsize,-iysize 565 | ixsize=-2.*ixsize+2.*radius_max+(xmax-xmin)*rscale 566 | iysize=-2.*iysize+2.*radius_max+(ymax-ymin)*rscale 567 | endif 568 | endif 569 | 570 | ixsize=min(ixsize,3000) 571 | iysize=min(iysize,3000) 572 | 573 | c ***** OPEN OUTPUT FILES ***** 574 | ixsize=int(ixsize/2)*2 575 | iysize=int(iysize/2)*2 576 | write(6,*) 'xsize and ysize: ',ixsize,iysize 577 | write(6,*) 578 | read(5,113) filename 579 | write(6,*) "output pnm filename: ",filename 580 | open(8,file=filename,form='formatted') 581 | write(8,1003) "P3" 582 | 1003 format(a2) 583 | write(8,1004) iysize,ixsize 584 | write(8,1004) 255 585 | open(9,file="opacity.pnm",form='formatted') 586 | write(9,1003) "P3" 587 | write(9,1004) iysize,ixsize 588 | write(9,1004) 255 589 | 1004 format(2i5) 590 | 113 format(a80) 591 | c ***** MAP SPHERICAL SURFACES OVER ATOMS ***** 592 | do ix=1,ixsize 593 | do iy=1,iysize 594 | pix(ix,iy,1)=0. 595 | pix(ix,iy,2)=0. 596 | pix(ix,iy,3)=0. 597 | pix(ix,iy,4)=0. 598 | atom(ix,iy)=0 599 | bio(ix,iy)=1 600 | zpix(ix,iy)=-10000. 601 | enddo 602 | enddo 603 | 604 | if (n.gt.0) then 605 | 606 | c ----- create the spherical shading map for atom types ----- 607 | do irad=1,ndes 608 | ic=1 609 | irlim=int(radtype(irad)) 610 | if (irlim.gt.100) then 611 | write(6,*) 'atoms radius * scale > 100' 612 | stop 613 | endif 614 | 615 | do ix=-irlim-1,irlim+1 616 | do iy=-irlim-1,irlim+1 617 | x=float(ix) 618 | y=float(iy) 619 | d=sqrt(x*x+y*y) 620 | if (d.gt.radtype(irad)) goto 350 621 | z=sqrt(radtype(irad)**2-d*d) 622 | sphdat(ic,1)=x 623 | sphdat(ic,2)=y 624 | sphdat(ic,3)=z 625 | ic=ic+1 626 | 350 continue 627 | enddo 628 | 352 enddo 629 | numpix=ic-1 630 | c ----- then map spherical surface over atoms of the proper type ------ 631 | icount=0 632 | 633 | do ia=1,n 634 | 635 | if (type(ia).ne.irad) goto 500 636 | icount=icount+1 637 | do ibio=1,nbiomat 638 | c--apply biomat 639 | rx=coord(1,ia)*biomat(1,1,ibio)+coord(2,ia)*biomat(1,2,ibio)+ 640 | & coord(3,ia)*biomat(1,3,ibio)+biomat(1,4,ibio) 641 | ry=coord(1,ia)*biomat(2,1,ibio)+coord(2,ia)*biomat(2,2,ibio)+ 642 | & coord(3,ia)*biomat(2,3,ibio)+biomat(2,4,ibio) 643 | rz=coord(1,ia)*biomat(3,1,ibio)+coord(2,ia)*biomat(3,2,ibio)+ 644 | & coord(3,ia)*biomat(3,3,ibio)+biomat(3,4,ibio) 645 | 646 | c--apply rotation matrix 647 | rx2=rx*rm(1,1)+ry*rm(2,1)+rz*rm(3,1) 648 | ry2=rx*rm(1,2)+ry*rm(2,2)+rz*rm(3,2) 649 | rz2=rx*rm(1,3)+ry*rm(2,3)+rz*rm(3,3) 650 | 651 | c--apply centering vector 652 | rx2=rx2+xtranc 653 | ry2=ry2+ytranc 654 | rz2=rz2+ztranc 655 | 656 | c--apply translation and scaling 657 | rx2=(rx2+xtran)*rscale 658 | ry2=(ry2+ytran)*rscale 659 | rz2=(rz2+ztran)*rscale 660 | 661 | if (rz2.lt.0.) then 662 | 663 | do ipix=1,numpix 664 | x=sphdat(ipix,1)+rx2+float(ixsize)/2. 665 | y=sphdat(ipix,2)+ry2+float(iysize)/2. 666 | ix=int(x) 667 | iy=int(y) 668 | if ((x.gt.float(ixsize)).or.(x.lt.1.).or. 669 | & (y.gt.float(iysize)).or.(y.lt.1.)) goto 510 670 | z=sphdat(ipix,3)+rz2 671 | if (z.gt.zpix(ix,iy)) then 672 | zpix(ix,iy)=z 673 | atom(ix,iy)=ia 674 | bio(ix,iy)=ibio 675 | endif 676 | 510 continue 677 | enddo 678 | 679 | endif 680 | 681 | c -- ibio loop 682 | enddo 683 | 684 | 500 continue 685 | 686 | c -- ia loop 687 | enddo 688 | 689 | write(6,*) icount,' spheres added of type: ',irad 690 | 691 | c -- irad loop 692 | 340 enddo 693 | 694 | write(6,*) 'shading maps written into depth buffer' 695 | 696 | endif 697 | 698 | c***** CALCULATE SECOND DERIVATIVE OUTLINES ****** 699 | c ---- find maximum and minimum z levels --- 700 | c (note: I use a value of zpix=-10000. to distinguish background) 701 | zpix_max=-100000. 702 | zpix_min=100000. 703 | do ix=1,ixsize 704 | do iy=1,iysize 705 | if (zpix(ix,iy).gt.zpix_max) zpix_max=zpix(ix,iy) 706 | if ((zpix(ix,iy).ne.-10000.).and. 707 | & (zpix(ix,iy).lt.zpix_min)) zpix_min=zpix(ix,iy) 708 | enddo 709 | enddo 710 | zpix_max=min(zpix_max,0.) 711 | zpix_spread=zpix_max-zpix_min 712 | write(6,*) 'zpix_min,zpix_max ',zpix_min,zpix_max 713 | 714 | c ***** PROCESSING OF THE IMAGE BEGINS HERE***** 715 | l_diff_min=l_diff_min*rscale 716 | l_diff_max=l_diff_max*rscale 717 | write(6,*) ' Pixel processing beginning ' 718 | do ix=1,ixsize 719 | do iy=1,iysize 720 | zpix(ix,iy)=min(zpix(ix,iy),0.) 721 | 2009 enddo 722 | 1009 enddo 723 | 724 | do ix=1,ixsize 725 | do iy=1,iysize 726 | 727 | c ***** CONICAL SHADOW TESTING ***** 728 | pconetot=1. 729 | if ((icone.ne.0).and.(atom(ix,iy).ne.0)) then 730 | do i=-50,50,5 731 | do j=-50,50,5 732 | if ((ix+i.gt.0).and.(ix+i.lt.ixsize).and. 733 | & (iy+j.gt.0).and.(iy+j.lt.iysize)) then 734 | rzdiff=zpix(ix+i,iy+j)-zpix(ix,iy) 735 | if (rzdiff.gt.rcone) then 736 | if (rtable(i,j)*coneangle.lt.rzdiff+rcone) then 737 | pconetot=pconetot-pcone 738 | endif 739 | endif 740 | endif 741 | enddo 742 | enddo 743 | pconetot=max(pconetot,pshadowmax) 744 | endif 745 | c ***** CALCULATE THE FOG PERCENTAGE (DEPTH CUEING) ***** 746 | pfh=pfogh-(zpix_max-zpix(ix,iy))/zpix_spread*pfogdiff 747 | if (zpix(ix,iy).lt.zpix_min) pfh=1. 748 | c ***** CALCULATE OUTLINES ***** 749 | g_opacity=0. 750 | l_opacity=0. 751 | if (illustrationflag.ne.0) then 752 | c ***** SUBUNIT OUTLINES ***** 753 | c ---- (this replaces original calculation of first derivatives) 754 | 755 | if ((ix.gt.1).and.(ix.lt.ixsize).and. 756 | & (iy.gt.1).and.(iy.lt.iysize)) then 757 | c --- calculate subunit 'derivatives' --- 758 | g=0. 759 | r=0. 760 | do i=-2,2 761 | do j=-2,2 762 | if (abs(i*j).ne.4) then 763 | if ((su(atom(ix,iy)).ne.su(atom(ix+i,iy+j))).or. 764 | & (bio(ix,iy).ne.bio(ix+i,iy+j))) r=r+1. 765 | if (abs(res(atom(ix,iy))- 766 | & res(atom(ix+i,iy+j))).gt.resdiff) g=g+1. 767 | endif 768 | enddo 769 | enddo 770 | c --- opacities are 1 for completely opaque --- 771 | g_opacity=min((g-g_low)/(g_high-g_low),1.) 772 | r_opacity=min((r-r_low)/(r_high-r_low),1.) 773 | g_opacity=max(g_opacity,r_opacity,0.) 774 | endif 775 | c ***** SECOND DERIVATIVE OUTLINES ***** 776 | if ((ix.gt.2).and.(ix.lt.ixsize-1).and. 777 | & (iy.gt.2).and.(iy.lt.iysize-1)) then 778 | rl=0. 779 | l_opacity_ave=0. 780 | do ixl=-1,1 781 | do iyl=-1,1 782 | ixc=ix+ixl 783 | iyc=iy+iyl 784 | 785 | if (ikernel.eq.1) then 786 | l(ixl,iyl)=abs(1./3. * ( 787 | & -0.8*zpix(ixc-1,iyc-1)-1.*zpix(ixc-1,iyc)-0.8*zpix(ixc-1,iyc+1)- 788 | & 1.0* zpix(ixc,iyc-1)+7.2*zpix(ixc,iyc)-1.0*zpix(ixc,iyc+1)- 789 | & 0.8* zpix(ixc+1,iyc-1)-1.*zpix(ixc+1,iyc)-0.8*zpix(ixc+1,iyc+1) 790 | & )) 791 | endif 792 | 793 | if (ikernel.eq.2) then 794 | l(ixl,iyl)=abs(1./3. * ( 795 | & -0.8*zpix(ixc-1,iyc-1)-1.0*zpix(ixc-1,iyc)-0.8*zpix(ixc-1,iyc+1)- 796 | & 1.0*zpix(ixc,iyc-1)+8.8*zpix(ixc,iyc)-1.0*zpix(ixc,iyc+1)- 797 | & 0.8*zpix(ixc+1,iyc-1)-1.0*zpix(ixc+1,iyc)-0.8*zpix(ixc+1,iyc+1)- 798 | & 0.1*zpix(ixc+2,iyc-1)-0.2*zpix(ixc+2,iyc)-0.1*zpix(ixc+2,iyc+1)- 799 | & 0.1*zpix(ixc-2,iyc-1)-0.2*zpix(ixc-2,iyc)-0.1*zpix(ixc-2,iyc+1)- 800 | & 0.1*zpix(ixc-1,iyc+2)-0.2*zpix(ixc,iyc+2)-0.1*zpix(ixc+1,iyc+2)- 801 | & 0.1*zpix(ixc-1,iyc-2)-0.2*zpix(ixc,iyc-2)-0.1*zpix(ixc+1,iyc-2) 802 | & )) 803 | endif 804 | 805 | if (ikernel.eq.3) then 806 | do i=-1,1 807 | do j=-1,1 808 | rd=abs(zpix(ix,iy)-zpix(ix+i,iy+j)) 809 | if (rd.gt.l_diff_min) then 810 | rd=(rd-l_diff_min)/(l_diff_max-l_diff_min) 811 | l(ixl,iyl)=l(ixl,iyl)+min(rd,1.) 812 | endif 813 | enddo 814 | enddo 815 | endif 816 | 817 | if (ikernel.eq.4) then 818 | do i=-2,2 819 | do j=-2,2 820 | if (abs(i*j).ne.4) then 821 | rd=abs(zpix(ix,iy)-zpix(ix+i,iy+j)) 822 | if (rd.gt.l_diff_min) then 823 | rd=abs(zpix(ix,iy)-zpix(ix+i,iy+j)) 824 | rd=(rd-l_diff_min)/(l_diff_max-l_diff_min) 825 | l(ixl,iyl)=l(ixl,iyl)+min(rd,1.) 826 | endif 827 | endif 828 | enddo 829 | enddo 830 | endif 831 | 832 | l(ixl,iyl)=min((l(ixl,iyl)-l_low)/(l_high-l_low),1.) 833 | l(ixl,iyl)=max(l(ixl,iyl),0.) 834 | if (l(ixl,iyl).gt.0.) rl=rl+1. 835 | l_opacity_ave=l_opacity_ave+l(ixl,iyl) 836 | enddo 837 | enddo 838 | if (rl.ge.6.) then 839 | l_opacity=l_opacity_ave/6. 840 | else 841 | l_opacity=l(0,0) 842 | endif 843 | l_opacity=min(l_opacity,1.) 844 | l_opacity=max(l_opacity,0.) 845 | endif 846 | c ---- combine subunit outlines and derivative outlines ---- 847 | l_opacity=max(l_opacity,g_opacity) 848 | endif 849 | c ***** CALCULATE THE TOTAL PIXEL INTENSITY ***** 850 | ropacity=0. 851 | do icolor=1,3 852 | 853 | rcolor= 854 | & pfh*(pconetot*(colortype(type(atom(ix,iy)),icolor)))+ 855 | & (1.-pfh)*rfog(icolor) 856 | 857 | pix(ix,iy,icolor)=(1.-l_opacity)*rcolor 858 | 859 | c ----calculate pixel opacity 860 | if (type(atom(ix,iy)).ne.0) ropacity=1. 861 | pix(ix,iy,4)=max(ropacity,l_opacity) 862 | 863 | enddo 864 | 865 | enddo 866 | 867 | c ***** output of a scan line ***** 868 | c ----- PPM format ----- 869 | iscan=0 870 | do iout=1,iysize 871 | do ic=1,3 872 | iscan=iscan+1 873 | scanline(iscan)=int(pix(ix,iout,ic)*255.) 874 | scanline(iscan)=min(scanline(iscan),255) 875 | scanline(iscan)=max(scanline(iscan),0) 876 | enddo 877 | enddo 878 | write(8,1002) (scanline(if),if=1,iysize*3) 879 | C -- write opacity 880 | iscan=0 881 | do iout=1,iysize 882 | do ic=1,3 883 | iscan=iscan+1 884 | scanline(iscan)=int(pix(ix,iout,4)*255.) 885 | scanline(iscan)=min(scanline(iscan),255) 886 | scanline(iscan)=max(scanline(iscan),0) 887 | enddo 888 | enddo 889 | write(9,1002) (scanline(if),if=1,iysize*3) 890 | 1002 format(20i4) 891 | c ----- diagnostic ------ 892 | if (int(ix/20)*20.eq.int((float(ix)/20.)*20.)) then 893 | write(6,6669) (int(pix(ix,iyo,1)*9.),iyo=1,iysize,20) 894 | 6669 format(65i1) 895 | endif 896 | 897 | 1000 enddo 898 | 899 | 999 stop 900 | end 901 | c-------------------------------------------------------------------- 902 | subroutine catenate(m1,m2) 903 | real*4 m1(4,4),m2(4,4),m(4,4) 904 | c-------------------------------------------------------------------- 905 | m(1,1)=m1(1,1)*m2(1,1)+m1(2,1)*m2(1,2)+m1(3,1)*m2(1,3)+ 906 | & m1(4,1)*m2(1,4) 907 | m(1,2)=m1(1,2)*m2(1,1)+m1(2,2)*m2(1,2)+m1(3,2)*m2(1,3)+ 908 | & m1(4,2)*m2(1,4) 909 | m(1,3)=m1(1,3)*m2(1,1)+m1(2,3)*m2(1,2)+m1(3,3)*m2(1,3)+ 910 | & m1(4,3)*m2(1,4) 911 | m(1,4)=m1(1,4)*m2(1,1)+m1(2,4)*m2(1,2)+m1(3,4)*m2(1,3)+ 912 | & m1(4,4)*m2(1,4) 913 | m(2,1)=m1(1,1)*m2(2,1)+m1(2,1)*m2(2,2)+m1(3,1)*m2(2,3)+ 914 | & m1(4,1)*m2(2,4) 915 | m(2,2)=m1(1,2)*m2(2,1)+m1(2,2)*m2(2,2)+m1(3,2)*m2(2,3)+ 916 | & m1(4,2)*m2(2,4) 917 | m(2,3)=m1(1,3)*m2(2,1)+m1(2,3)*m2(2,2)+m1(3,3)*m2(2,3)+ 918 | & m1(4,3)*m2(2,4) 919 | m(2,4)=m1(1,4)*m2(2,1)+m1(2,4)*m2(2,2)+m1(3,4)*m2(2,3)+ 920 | & m1(4,4)*m2(2,4) 921 | m(3,1)=m1(1,1)*m2(3,1)+m1(2,1)*m2(3,2)+m1(3,1)*m2(3,3)+ 922 | & m1(4,1)*m2(3,4) 923 | m(3,2)=m1(1,2)*m2(3,1)+m1(2,2)*m2(3,2)+m1(3,2)*m2(3,3)+ 924 | & m1(4,2)*m2(3,4) 925 | m(3,3)=m1(1,3)*m2(3,1)+m1(2,3)*m2(3,2)+m1(3,3)*m2(3,3)+ 926 | & m1(4,3)*m2(3,4) 927 | m(3,4)=m1(1,4)*m2(3,1)+m1(2,4)*m2(3,2)+m1(3,4)*m2(3,3)+ 928 | & m1(4,4)*m2(3,4) 929 | m(4,1)=m1(1,1)*m2(4,1)+m1(2,1)*m2(4,2)+m1(3,1)*m2(4,3)+ 930 | & m1(4,1)*m2(4,4) 931 | m(4,2)=m1(1,2)*m2(4,1)+m1(2,2)*m2(4,2)+m1(3,2)*m2(4,3)+ 932 | & m1(4,2)*m2(4,4) 933 | m(4,3)=m1(1,3)*m2(4,1)+m1(2,3)*m2(4,2)+m1(3,3)*m2(4,3)+ 934 | & m1(4,3)*m2(4,4) 935 | m(4,4)=m1(1,4)*m2(4,1)+m1(2,4)*m2(4,2)+m1(3,4)*m2(4,3)+ 936 | & m1(4,4)*m2(4,4) 937 | do j=1,4 938 | do i=1,4 939 | m1(i,j)=m(i,j) 940 | enddo 941 | enddo 942 | return 943 | end 944 | c-------------------------------------------------------------------- 945 | subroutine clearmatrix(m) 946 | real*4 m(4,4) 947 | c-------------------------------------------------------------------- 948 | do i=1,4 949 | do j=1,4 950 | x=0. 951 | if (i.eq.j) x=1. 952 | 1 m(i,j)=x 953 | enddo 954 | enddo 955 | return 956 | end 957 | --------------------------------------------------------------------------------