├── .gitignore ├── LICENSE ├── README.rst ├── doc └── manual.pdf ├── examples ├── lie │ ├── lie.log │ └── lie.vmd ├── md │ ├── com.dcd │ ├── com.psf │ ├── lig.dcd │ └── lig.psf ├── mmpbsa │ ├── mmpbsa.log │ └── mmpbsa.vmd └── toppar │ ├── lig.str │ ├── par_all22_prot.prm │ ├── par_all36_cgenff.prm │ └── toppar_water_ions_namd.str ├── image └── logo.png ├── patch └── topoatoms.tcl └── src ├── cafe.tcl ├── cafe_lie.tcl ├── cafe_mmpbsa.tcl ├── cafe_tools.tcl ├── par_all22_prot.inp └── pkgIndex.tcl /.gitignore: -------------------------------------------------------------------------------- 1 | # Vim 2 | .sw[po] 3 | *~ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. image:: image/logo.png 2 | :align: center 3 | 4 | 5 | Introduction 6 | ----------------------------------- 7 | 8 | CaFE (Calculation of Free Energy) is a VMD plugin for binding affinity 9 | prediction using end-point free energy methods. 10 | 11 | 12 | Availability & Implementation 13 | ----------------------------------- 14 | 15 | You can use CaFE on all major platforms. 16 | 17 | * Source code: https://github.com/HuiLiuCode/CaFE_Plugin 18 | 19 | 20 | Documentation 21 | ----------------------------------- 22 | 23 | * Manual: https://github.com/HuiLiuCode/CaFE_Plugin/tree/master/doc/manual.pdf 24 | 25 | 26 | Installation 27 | ----------------------------------- 28 | 29 | Please see the user manual for details about installation. 30 | 31 | 32 | License 33 | ----------------------------------- 34 | 35 | CaFE is freely available under the GNU General Public License. See LICENSE 36 | for more details. 37 | 38 | 39 | -------------------------------------------------------------------------------- /doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuiLiuCode/CaFE_Plugin/f89b4834600d59e5453912b02f65860d3b93eb19/doc/manual.pdf -------------------------------------------------------------------------------- /examples/lie/lie.log: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------ 2 | Title Frames Mean SD 3 | ------------------------------------------------------------ 4 | Bound: 5 | Vdw: 10 -27.3237 5.6244 6 | Elec: 10 -209.0961 8.8321 7 | ------------------------------------------------------------ 8 | Free: 9 | Vdw: 10 -10.4081 5.0517 10 | Elec: 10 -179.7855 24.6240 11 | ------------------------------------------------------------ 12 | Delta: 13 | Vdw: -16.9156 14 | Elec: -29.3107 15 | ------------------------------------------------------------ 16 | Final: (alpha=0.18, beta=0.5, gamma=0.0) 17 | Total: -17.7002 18 | ------------------------------------------------------------ 19 | * All energy values are in kcal/mol 20 | -------------------------------------------------------------------------------- /examples/lie/lie.vmd: -------------------------------------------------------------------------------- 1 | package require cafe 1.0 2 | 3 | lie -top_bound ../md/com.psf \ 4 | -trj_bound ../md/com.dcd \ 5 | -top_free ../md/lig.psf \ 6 | -trj_free ../md/lig.dcd \ 7 | -out lie.log \ 8 | -par ../toppar/par_all22_prot.prm \ 9 | -par ../toppar/par_all36_cgenff.prm \ 10 | -par ../toppar/toppar_water_ions_namd.str \ 11 | -par ../toppar/lig.str \ 12 | -lig_bound "segname LIG" \ 13 | -lig_free "segname LIG" \ 14 | -first_bound 0 \ 15 | -last_bound -1 \ 16 | -stride_bound 1 \ 17 | -first_free 0 \ 18 | -last_free -1 \ 19 | -stride_free 1 \ 20 | -alpha 0.18 \ 21 | -beta 0.5 \ 22 | -gamma 0.0 23 | 24 | quit 25 | -------------------------------------------------------------------------------- /examples/md/com.dcd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuiLiuCode/CaFE_Plugin/f89b4834600d59e5453912b02f65860d3b93eb19/examples/md/com.dcd -------------------------------------------------------------------------------- /examples/md/lig.dcd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuiLiuCode/CaFE_Plugin/f89b4834600d59e5453912b02f65860d3b93eb19/examples/md/lig.dcd -------------------------------------------------------------------------------- /examples/mmpbsa/mmpbsa.log: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------ 2 | Title Frames Mean SD 3 | ------------------------------------------------------------ 4 | Complex: 5 | Elec: 10 -2821.2704 58.4307 6 | Vdw: 10 -444.8378 11.3031 7 | PB: 10 -2317.9230 42.6444 8 | SA: 10 45.9417 0.7205 9 | Gas: 10 -3266.1082 53.8282 10 | Sol: 10 -2271.9813 42.6820 11 | Pol: 10 -5139.1933 22.0353 12 | Npol: 10 -398.8961 11.3803 13 | Total: 10 -5538.0895 16.9873 14 | ------------------------------------------------------------ 15 | Receptor: 16 | Elec: 10 -2561.0975 55.1617 17 | Vdw: 10 -418.6449 10.4660 18 | PB: 10 -2398.6264 43.3459 19 | SA: 10 46.7564 0.7313 20 | Gas: 10 -2979.7424 53.6086 21 | Sol: 10 -2351.8700 43.2930 22 | Pol: 10 -4959.7238 19.5022 23 | Npol: 10 -371.8885 10.4023 24 | Total: 10 -5331.6123 16.2879 25 | ------------------------------------------------------------ 26 | Ligand: 27 | Elec: 10 -77.5529 1.9237 28 | Vdw: 10 -0.7546 1.0947 29 | PB: 10 -110.5977 1.0760 30 | SA: 10 3.2411 0.0308 31 | Gas: 10 -78.3075 1.7447 32 | Sol: 10 -107.3567 1.0639 33 | Pol: 10 -188.1506 1.4657 34 | Npol: 10 2.4865 1.1046 35 | Total: 10 -185.6641 1.2205 36 | ------------------------------------------------------------ 37 | Delta: 38 | Elec: 10 -182.6200 11.9746 39 | Vdw: 10 -25.4383 4.5632 40 | PB: 10 191.3011 8.7708 41 | SA: 10 -4.0558 0.0472 42 | Gas: 10 -208.0583 10.9846 43 | Sol: 10 187.2453 8.7741 44 | Pol: 10 8.6811 4.3386 45 | Npol: 10 -29.4941 4.5348 46 | Total: 10 -20.8130 3.4564 47 | ------------------------------------------------------------ 48 | * All energy values are in kcal/mol 49 | -------------------------------------------------------------------------------- /examples/mmpbsa/mmpbsa.vmd: -------------------------------------------------------------------------------- 1 | package require cafe 1.0 2 | 3 | mmpbsa -top ../md/com.psf \ 4 | -trj ../md/com.dcd \ 5 | -out mmpbsa.log \ 6 | -par ../toppar/par_all22_prot.prm \ 7 | -par ../toppar/par_all36_cgenff.prm \ 8 | -par ../toppar/toppar_water_ions_namd.str \ 9 | -par ../toppar/lig.str \ 10 | -com "segname PRO LIG" \ 11 | -rec "segname PRO" \ 12 | -lig "segname LIG" \ 13 | -first 0 \ 14 | -last -1 \ 15 | -stride 1 \ 16 | -mm 1 \ 17 | -pb 2 \ 18 | -pb_exe apbs \ 19 | -pb_rad mparse \ 20 | -pb_bcfl mdh \ 21 | -pb_chgm spl2 \ 22 | -sa 1 \ 23 | -sa_rad mparse \ 24 | -sa_gamma 0.00542 \ 25 | -sa_beta 0.92 26 | 27 | quit 28 | -------------------------------------------------------------------------------- /examples/toppar/lig.str: -------------------------------------------------------------------------------- 1 | * Toppar stream file generated by 2 | * CHARMM General Force Field (CGenFF) program version 0.9.7.1 beta 3 | * For use with CGenFF version 2b8 4 | * 5 | 6 | read rtf card append 7 | * Topologies generated by 8 | * CHARMM General Force Field (CGenFF) program version 0.9.7.1 beta 9 | * 10 | 36 1 11 | 12 | ! "penalty" is the highest penalty score of the associated parameters. 13 | ! Penalties lower than 10 indicate the analogy is fair; penalties between 10 14 | ! and 50 mean some basic validation is recommended; penalties higher than 15 | ! 50 indicate poor analogy and mandate extensive validation/optimization. 16 | 17 | RESI BTN -1.000 ! param penalty= 145.500 ; charge penalty= 122.060 18 | GROUP ! CHARGE CH_PENALTY 19 | ATOM C11 CG2O3 0.618 ! 0.000 20 | ATOM O11 OG2D2 -0.758 ! 0.000 21 | ATOM O12 OG2D2 -0.758 ! 0.000 22 | ATOM C10 CG321 -0.281 ! 0.000 23 | ATOM C9 CG321 -0.180 ! 0.075 24 | ATOM C8 CG321 -0.170 ! 4.281 25 | ATOM C7 CG321 -0.186 ! 32.247 26 | ATOM C2 CG3C51 0.026 ! 101.711 27 | ATOM S1 SG311 -0.202 ! 122.060 28 | ATOM C6 CG3C52 -0.089 ! 93.023 29 | ATOM C5 CG3RC1 0.176 ! 48.559 30 | ATOM N1 NG2R53 -0.546 ! 15.573 31 | ATOM C3 CG2R53 0.331 ! 8.657 32 | ATOM O3 OG2D1 -0.427 ! 0.078 33 | ATOM N2 NG2R53 -0.547 ! 15.859 34 | ATOM C4 CG3RC1 0.169 ! 47.170 35 | ATOM H2 HGA2 0.090 ! 0.000 36 | ATOM H3 HGA2 0.090 ! 0.000 37 | ATOM H4 HGA2 0.090 ! 0.000 38 | ATOM H5 HGA2 0.090 ! 0.000 39 | ATOM H6 HGA2 0.090 ! 0.075 40 | ATOM H7 HGA2 0.090 ! 0.075 41 | ATOM H8 HGA2 0.090 ! 2.500 42 | ATOM H9 HGA2 0.090 ! 2.500 43 | ATOM H10 HGA1 0.090 ! 5.636 44 | ATOM H11 HGA2 0.090 ! 5.608 45 | ATOM H12 HGA2 0.090 ! 5.608 46 | ATOM H13 HGA1 0.090 ! 2.713 47 | ATOM H14 HGP1 0.327 ! 7.426 48 | ATOM H15 HGP1 0.327 ! 7.535 49 | ATOM H16 HGA1 0.090 ! 2.713 50 | 51 | BOND C11 O12 52 | BOND C11 C10 53 | BOND C11 O11 54 | BOND C10 C9 55 | BOND C9 C8 56 | BOND C8 C7 57 | BOND C7 C2 58 | BOND C2 C4 59 | BOND C2 S1 60 | BOND S1 C6 61 | BOND C6 C5 62 | BOND C5 C4 63 | BOND C5 N1 64 | BOND N1 C3 65 | BOND C3 O3 66 | BOND C3 N2 67 | BOND N2 C4 68 | BOND C10 H2 69 | BOND C10 H3 70 | BOND C9 H4 71 | BOND C9 H5 72 | BOND C8 H6 73 | BOND C8 H7 74 | BOND C7 H8 75 | BOND C7 H9 76 | BOND C2 H10 77 | BOND C6 H11 78 | BOND C6 H12 79 | BOND C5 H13 80 | BOND N1 H14 81 | BOND N2 H15 82 | BOND C4 H16 83 | IMPR C11 O11 O12 C10 84 | IMPR C3 N1 N2 O3 85 | 86 | END 87 | 88 | read param card flex append 89 | * Parameters generated by analogy by 90 | * CHARMM General Force Field (CGenFF) program version 0.9.7.1 beta 91 | * 92 | 93 | ! Penalties lower than 10 indicate the analogy is fair; penalties between 10 94 | ! and 50 mean some basic validation is recommended; penalties higher than 95 | ! 50 indicate poor analogy and mandate extensive validation/optimization. 96 | 97 | BONDS 98 | CG3C51 SG311 198.00 1.8180 ! BTN , from CG321 SG311, penalty= 65 99 | CG3C52 SG311 198.00 1.8180 ! BTN , from CG321 SG311, penalty= 65 100 | CG3RC1 NG2R53 370.00 1.4500 ! BTN , from CG3C52 NG2R53, penalty= 20 101 | 102 | ANGLES 103 | CG321 CG321 CG3C51 53.35 111.00 8.00 2.56100 ! BTN , from CG321 CG321 CG3RC1, penalty= 1.5 104 | CG321 CG3C51 SG311 58.00 114.50 ! BTN , from CG321 CG321 SG311, penalty= 65 105 | CG3RC1 CG3C51 SG311 110.00 111.00 ! BTN , from CG3C51 CG3C51 NG301, penalty= 112.1 106 | SG311 CG3C51 HGA1 46.10 111.30 ! BTN , from SG311 CG321 HGA2, penalty= 65 107 | CG3RC1 CG3C52 SG311 110.00 111.00 ! BTN , from CG3C51 CG3C51 NG301, penalty= 116.1 108 | SG311 CG3C52 HGA2 46.10 111.30 ! BTN , from SG311 CG321 HGA2, penalty= 65 109 | CG3C51 CG3RC1 NG2R53 70.00 113.70 ! BTN , from CG3C52 CG3RC1 NG2R51, penalty= 9.4 110 | CG3C52 CG3RC1 NG2R53 70.00 113.70 ! BTN , from CG3C52 CG3RC1 NG2R51, penalty= 9 111 | CG3RC1 CG3RC1 NG2R53 70.00 113.70 ! BTN , from CG3RC1 CG3RC1 NG2R51, penalty= 9 112 | NG2R53 CG3RC1 HGA1 59.00 111.00 ! BTN , from NG2R53 CG3C52 HGA2, penalty= 20 113 | CG2R53 NG2R53 CG3RC1 75.00 111.00 ! BTN , from CG2R53 NG2R53 CG3C52, penalty= 1.1 114 | CG3RC1 NG2R53 HGP1 38.00 116.00 ! BTN , from CG3C52 NG2R53 HGP1, penalty= 1.1 115 | CG3C51 SG311 CG3C52 34.00 95.00 ! BTN , from CG321 SG311 CG321, penalty= 20 116 | 117 | DIHEDRALS 118 | NG2R53 CG2R53 NG2R53 CG3RC1 0.5000 2 180.00 ! BTN , from NG2R53 CG2R53 NG2R53 CG311, penalty= 34.4 119 | OG2D1 CG2R53 NG2R53 CG3RC1 2.5900 2 180.00 ! BTN , from OG2D1 CG2R53 NG2R53 CG3C52, penalty= 1.1 120 | CG321 CG321 CG321 CG3C51 0.1500 3 0.00 ! BTN , from CG321 CG321 CG321 CG3RC1, penalty= 1.5 121 | CG3C51 CG321 CG321 HGA2 0.1950 3 0.00 ! BTN , from CG3RC1 CG321 CG321 HGA2, penalty= 1.5 122 | CG321 CG321 CG3C51 CG3RC1 0.1500 3 0.00 ! BTN , from CG321 CG311 CG3C51 CG3RC1, penalty= 4 123 | CG321 CG321 CG3C51 SG311 0.1950 3 0.00 ! BTN , from CG321 CG321 CG321 SG311, penalty= 65 124 | CG321 CG321 CG3C51 HGA1 0.1950 3 0.00 ! BTN , from CG321 CG311 CG3C51 HGA1, penalty= 4 125 | HGA2 CG321 CG3C51 SG311 0.0100 3 0.00 ! BTN , from SG311 CG321 CG321 HGA2, penalty= 65 126 | CG321 CG3C51 CG3RC1 NG2R53 0.5000 2 180.00 ! BTN , from CG321 CG3C51 CG3C51 NG2S3, penalty= 44 127 | SG311 CG3C51 CG3RC1 CG3RC1 0.1500 3 0.00 ! BTN , from CG321 CG3C51 CG3RC1 CG3RC1, penalty= 113 128 | SG311 CG3C51 CG3RC1 NG2R53 0.0000 3 0.00 ! BTN , from NG2R51 CG3C51 CG3C51 OG303, penalty= 145.5 129 | SG311 CG3C51 CG3RC1 HGA1 0.1500 3 0.00 ! BTN , from CG321 CG3C51 CG3RC1 HGA1, penalty= 113 130 | HGA1 CG3C51 CG3RC1 NG2R53 0.1500 3 0.00 ! BTN , from HGA2 CG3C52 CG3RC1 NG2R51, penalty= 13 131 | CG321 CG3C51 SG311 CG3C52 0.2400 1 180.00 ! BTN , from CG321 CG321 SG311 CG321, penalty= 75 132 | CG321 CG3C51 SG311 CG3C52 0.3700 3 0.00 ! BTN , from CG321 CG321 SG311 CG321, penalty= 75 133 | CG3RC1 CG3C51 SG311 CG3C52 0.2400 1 180.00 ! BTN , from CG3C51 CG321 SG311 CG321, penalty= 96.5 134 | CG3RC1 CG3C51 SG311 CG3C52 0.3700 3 0.00 ! BTN , from CG3C51 CG321 SG311 CG321, penalty= 96.5 135 | HGA1 CG3C51 SG311 CG3C52 0.2800 3 0.00 ! BTN , from HGA2 CG321 SG311 CG321, penalty= 75 136 | SG311 CG3C52 CG3RC1 CG3RC1 0.1500 3 0.00 ! BTN , from CG321 CG3C51 CG3RC1 CG3RC1, penalty= 117 137 | SG311 CG3C52 CG3RC1 NG2R53 0.1500 3 0.00 ! BTN , from CG3C52 CG3C52 CG3RC1 NG2R51, penalty= 145 138 | SG311 CG3C52 CG3RC1 HGA1 0.1500 3 0.00 ! BTN , from CG321 CG3C51 CG3RC1 HGA1, penalty= 117 139 | HGA2 CG3C52 CG3RC1 NG2R53 0.1500 3 0.00 ! BTN , from HGA2 CG3C52 CG3RC1 NG2R51, penalty= 9 140 | CG3RC1 CG3C52 SG311 CG3C51 0.2400 1 180.00 ! BTN , from CG3C51 CG321 SG311 CG321, penalty= 96.5 141 | CG3RC1 CG3C52 SG311 CG3C51 0.3700 3 0.00 ! BTN , from CG3C51 CG321 SG311 CG321, penalty= 96.5 142 | HGA2 CG3C52 SG311 CG3C51 0.2800 3 0.00 ! BTN , from HGA2 CG321 SG311 CG321, penalty= 75 143 | CG3C51 CG3RC1 CG3RC1 NG2R53 0.1500 3 0.00 ! BTN , from CG3C52 CG3RC1 CG3RC1 NG2R51, penalty= 9.4 144 | CG3C52 CG3RC1 CG3RC1 NG2R53 0.1500 3 0.00 ! BTN , from CG3C52 CG3RC1 CG3RC1 NG2R51, penalty= 9 145 | NG2R53 CG3RC1 CG3RC1 NG2R53 0.1500 3 0.00 ! BTN , from CG3C52 CG3RC1 CG3RC1 NG2R51, penalty= 81 146 | NG2R53 CG3RC1 CG3RC1 HGA1 0.1500 3 0.00 ! BTN , from NG2R51 CG3RC1 CG3RC1 HGA1, penalty= 9 147 | CG3C51 CG3RC1 NG2R53 CG2R53 2.3100 3 180.00 ! BTN , from CG3C52 CG3C52 NG2R53 CG2R53, penalty= 20.4 148 | CG3C51 CG3RC1 NG2R53 HGP1 0.7600 3 0.00 ! BTN , from CG3C52 CG3C52 NG2R53 HGP1, penalty= 20.4 149 | CG3C52 CG3RC1 NG2R53 CG2R53 2.3100 3 180.00 ! BTN , from CG3C52 CG3C52 NG2R53 CG2R53, penalty= 20 150 | CG3C52 CG3RC1 NG2R53 HGP1 0.7600 3 0.00 ! BTN , from CG3C52 CG3C52 NG2R53 HGP1, penalty= 20 151 | CG3RC1 CG3RC1 NG2R53 CG2R53 1.1000 1 180.00 ! BTN , from CG3RC1 CG3RC1 NG2R51 CG2R53, penalty= 60 152 | CG3RC1 CG3RC1 NG2R53 HGP1 0.7600 3 0.00 ! BTN , from CG3C52 CG3C52 NG2R53 HGP1, penalty= 61.1 153 | HGA1 CG3RC1 NG2R53 CG2R53 0.0000 3 0.00 ! BTN , from HGA2 CG3C52 NG2R53 CG2R53, penalty= 20 154 | HGA1 CG3RC1 NG2R53 HGP1 0.0000 3 180.00 ! BTN , from HGA2 CG3C52 NG2R53 HGP1, penalty= 20 155 | 156 | IMPROPERS 157 | 158 | END 159 | RETURN 160 | -------------------------------------------------------------------------------- /examples/toppar/toppar_water_ions_namd.str: -------------------------------------------------------------------------------- 1 | * Toplogy and parameter information for water and ions. 2 | * 3 | 4 | !Testcase 5 | !test_water_ions.inp 6 | 7 | ! IMPORTANT NOTE: this file contains NBFixes between carboxylates and sodium, 8 | ! which will only apply if the main files containing carboxylate atom types 9 | ! have been read in first! 10 | 11 | !references 12 | ! 13 | !TIP3P water model 14 | ! 15 | !W.L. Jorgensen; J.Chandrasekhar; J.D. Madura; R.W. Impey; 16 | !M.L. Klein; "Comparison of simple potential functions for 17 | !simulating liquid water", J. Chem. Phys. 79 926-935 (1983). 18 | ! 19 | !IONS 20 | ! 21 | !Ions from Roux and coworkers 22 | ! 23 | !Beglov, D. and Roux, B., Finite Representation of an Infinite 24 | !Bulk System: Solvent Boundary Potential for Computer Simulations, 25 | !Journal of Chemical Physics, 1994, 100: 9050-9063 26 | ! 27 | !ZINC 28 | ! 29 | !Stote, R.H. and Karplus, M. Zinc Binding in Proteins and 30 | !Solution: A Simple but Accurate Nonbonded Representation, PROTEINS: 31 | !Structure, Function, and Genetics 23:12-31 (1995) 32 | 33 | read rtf card append 34 | * Topology for water and ions 35 | * 36 | 31 1 37 | 38 | MASS 1 HT 1.00800 H ! TIPS3P WATER HYDROGEN 39 | MASS 2 HX 1.00800 H ! hydroxide hydrogen 40 | MASS 3 OT 15.99940 O ! TIPS3P WATER OXYGEN 41 | MASS 4 OX 15.99940 O ! hydroxide oxygen 42 | MASS 5 LIT 6.94100 LI ! Lithium ion 43 | MASS 6 SOD 22.98977 NA ! Sodium Ion 44 | MASS 7 MG 24.30500 MG ! Magnesium Ion 45 | MASS 8 POT 39.09830 K ! Potassium Ion 46 | MASS 9 CAL 40.08000 CA ! Calcium Ion 47 | MASS 10 RUB 85.46780 RB ! Rubidium Ion 48 | MASS 11 CES 132.90545 CS ! Cesium Ion 49 | MASS 12 BAR 137.32700 BA ! Barium Ion 50 | MASS 13 ZN 65.37000 ZN ! zinc (II) cation 51 | MASS 14 CAD 112.41100 CD ! cadmium (II) cation 52 | MASS 15 CLA 35.45000 CL ! Chloride Ion 53 | 54 | default first none last none 55 | 56 | RESI TIP3 0.000 ! tip3p water model, generate using noangle nodihedral 57 | GROUP 58 | ATOM OH2 OT -0.834 59 | ATOM H1 HT 0.417 60 | ATOM H2 HT 0.417 61 | BOND OH2 H1 OH2 H2 !H1 H2 ! the last bond is needed for shake 62 | ANGLE H1 OH2 H2 ! required 63 | DONOR H1 OH2 64 | DONOR H2 OH2 65 | ACCEPTOR OH2 66 | PATCHING FIRS NONE LAST NONE 67 | 68 | RESI TP3M 0.000 ! "mmff" water model, as an analog of tip3p 69 | GROUP 70 | ATOM OH2 OT -0.834 ! these charges are replaced by the mmff setup 71 | ATOM H1 HT 0.417 ! these charges are replaced by the mmff setup 72 | ATOM H2 HT 0.417 ! these charges are replaced by the mmff setup 73 | BOND OH2 H1 OH2 H2 ! omits the H1-H2 bond, which is needed for shake with tip3p 74 | ANGLE H1 OH2 H2 ! required 75 | DONOR H1 OH2 76 | DONOR H2 OH2 77 | ACCEPTOR OH2 78 | PATCHING FIRS NONE LAST NONE 79 | 80 | RESI OH -1.00 ! hydroxide ion by adm.jr. 81 | GROUP 82 | ATOM O1 OX -1.32 83 | ATOM H1 HX 0.32 84 | BOND O1 H1 85 | DONOR H1 O1 86 | ACCEPTOR O1 87 | 88 | ! Ion parameters from Benoit Roux and Coworkers 89 | ! As of 8/10 new NBFIX terms required 90 | ! 91 | RESI LIT 1.00 ! Lithium Ion 92 | GROUP 93 | ATOM LIT LIT 1.00 94 | PATCHING FIRST NONE LAST NONE 95 | 96 | RESI SOD 1.00 ! Sodium Ion 97 | GROUP 98 | ATOM SOD SOD 1.00 99 | PATCHING FIRST NONE LAST NONE 100 | 101 | RESI MG 2.00 ! Magnesium Ion 102 | GROUP 103 | ATOM MG MG 2.00 104 | PATCHING FIRST NONE LAST NONE 105 | 106 | RESI POT 1.00 ! Potassium Ion 107 | GROUP 108 | ATOM POT POT 1.00 109 | PATCHING FIRST NONE LAST NONE 110 | 111 | RESI CAL 2.00 ! Calcium Ion 112 | GROUP 113 | ATOM CAL CAL 2.00 114 | PATCHING FIRST NONE LAST NONE 115 | 116 | RESI RUB 1.00 ! Rubidium Ion 117 | GROUP 118 | ATOM RUB RUB 1.00 119 | PATCHING FIRST NONE LAST NONE 120 | 121 | RESI CES 1.00 ! Cesium Ion 122 | GROUP 123 | ATOM CES CES 1.00 124 | PATCHING FIRST NONE LAST NONE 125 | 126 | RESI BAR 2.00 ! Barium Ion 127 | GROUP 128 | ATOM BAR BAR 2.00 129 | PATCHING FIRST NONE LAST NONE 130 | 131 | RESI ZN2 2.00 ! Zinc (II) cation, Roland Stote 132 | GROUP 133 | ATOM ZN ZN 2.00 134 | PATCHING FIRST NONE LAST NONE 135 | 136 | RESI CD2 2.00 ! Cadmium (II) cation 137 | GROUP 138 | ATOM CD CAD 2.00 139 | PATCHING FIRST NONE LAST NONE 140 | 141 | RESI CLA -1.00 ! Chloride Ion 142 | GROUP 143 | ATOM CLA CLA -1.00 144 | PATCHING FIRST NONE LAST NONE 145 | 146 | END 147 | 148 | read para card flex append 149 | * Parameters for water and ions 150 | * 151 | 152 | ATOMS 153 | MASS 1 HT 1.00800 ! TIPS3P WATER HYDROGEN 154 | MASS 2 HX 1.00800 ! hydroxide hydrogen 155 | MASS 3 OT 15.99940 ! TIPS3P WATER OXYGEN 156 | MASS 4 OX 15.99940 ! hydroxide oxygen 157 | MASS 5 LIT 6.94100 ! Lithium ion 158 | MASS 6 SOD 22.98977 ! Sodium Ion 159 | MASS 7 MG 24.30500 ! Magnesium Ion 160 | MASS 8 POT 39.09830 ! Potassium Ion 161 | MASS 9 CAL 40.08000 ! Calcium Ion 162 | MASS 10 RUB 85.46780 ! Rubidium Ion 163 | MASS 11 CES 132.90545 ! Cesium Ion 164 | MASS 12 BAR 137.32700 ! Barium Ion 165 | MASS 13 ZN 65.37000 ! zinc (II) cation 166 | MASS 14 CAD 112.41100 ! cadmium (II) cation 167 | MASS 15 CLA 35.45000 ! Chloride Ion 168 | 169 | BONDS 170 | ! 171 | !V(bond) = Kb(b - b0)**2 172 | ! 173 | !Kb: kcal/mole/A**2 174 | !b0: A 175 | ! 176 | !atom type Kb b0 177 | ! 178 | HT HT 0.0 1.5139 ! from TIPS3P geometry (for SHAKE w/PARAM) 179 | HT OT 450.0 0.9572 ! from TIPS3P geometry 180 | OX HX 545.0 0.9700 ! hydroxide ion 181 | 182 | ANGLES 183 | ! 184 | !V(angle) = Ktheta(Theta - Theta0)**2 185 | ! 186 | !V(Urey-Bradley) = Kub(S - S0)**2 187 | ! 188 | !Ktheta: kcal/mole/rad**2 189 | !Theta0: degrees 190 | !Kub: kcal/mole/A**2 (Urey-Bradley) 191 | !S0: A 192 | ! 193 | !atom types Ktheta Theta0 Kub S0 194 | ! 195 | HT OT HT 55.0 104.52 ! FROM TIPS3P GEOMETRY 196 | 197 | DIHEDRALS 198 | ! 199 | !V(dihedral) = Kchi(1 + cos(n(chi) - delta)) 200 | ! 201 | !Kchi: kcal/mole 202 | !n: multiplicity 203 | !delta: degrees 204 | ! 205 | !atom types Kchi n delta 206 | ! 207 | 208 | 209 | ! 210 | IMPROPER 211 | ! 212 | !V(improper) = Kpsi(psi - psi0)**2 213 | ! 214 | !Kpsi: kcal/mole/rad**2 215 | !psi0: degrees 216 | !note that the second column of numbers (0) is ignored 217 | ! 218 | !atom types Kpsi psi0 219 | ! 220 | 221 | NONBONDED nbxmod 5 atom cdiel shift vatom vdistance vswitch - 222 | cutnb 14.0 ctofnb 12.0 ctonnb 10.0 eps 1.0 e14fac 1.0 wmin 1.5 223 | 224 | !TIP3P LJ parameters 225 | HT 0.0 -0.046 0.2245 226 | OT 0.0 -0.1521 1.7682 227 | 228 | !for hydroxide 229 | OX 0.000000 -0.120000 1.700000 ! ALLOW POL ION 230 | ! JG 8/27/89 231 | HX 0.000000 -0.046000 0.224500 ! ALLOW PEP POL SUL ARO ALC 232 | ! same as TIP3P hydrogen, adm jr., 7/20/89 233 | 234 | !ions 235 | LIT 0.0 -0.00233 1.2975 ! Lithium 236 | ! From S Noskov, target ddG(Li-Na) was 23-26.0 kcal/mol (see JPC B, Lamoureux&Roux,2006) 237 | SOD 0.0 -0.0469 1.41075 ! new CHARMM Sodium 238 | ! ddG of -18.6 kcal/mol with K+ from S. Noskov 239 | MG 0.0 -0.0150 1.18500 ! Magnesium 240 | ! B. Roux dA = -441.65 241 | POT 0.0 -0.0870 1.76375 ! Potassium 242 | ! D. Beglovd and B. Roux, dA=-82.36+2.8 = -79.56 kca/mol 243 | CAL 0.0 -0.120 1.367 ! Calcium 244 | ! S. Marchand and B. Roux, dA = -384.8 kcal/mol 245 | RUB 0.0000 -0.15 1.90 ! Rubidium 246 | ! delta A with respect to POT is +6.0 kcal/mol in bulk water 247 | CES 0.0 -0.1900 2.100 ! Cesium 248 | ! delta A with respect to POT is +12.0 kcal/mol 249 | BAR 0.0 -0.150 1.890 ! Barium 250 | ! B. Roux, dA = dA[calcium] + 64.2 kcal/mol 251 | ZN 0.000000 -0.250000 1.090000 ! Zinc 252 | ! RHS March 18, 1990 253 | CAD 0.000000 -0.120000 1.357000 ! Cadmium 254 | ! S. Marchand and B. Roux, from delta delta G 255 | CLA 0.0 -0.150 2.27 ! Chloride 256 | ! D. Beglovd and B. Roux, dA=-83.87+4.46 = -79.40 kcal/mol 257 | 258 | !NBFIX 259 | ! Emin Rmin 260 | ! (kcal/mol) (A) 261 | !SOD CLA -0.083875 3.731 ! From osmotic pressure calibration, J. Phys.Chem.Lett. 1:183-189 262 | !POT CLA -0.114236 4.081 ! From osmotic pressure calibration, J. Phys.Chem.Lett. 1:183-189 263 | !END 264 | 265 | !read para card flex append 266 | !* NBFix between carboxylate and sodium 267 | !* 268 | 269 | ! These NBFixes will only apply if the main files have been read in first!!! 270 | !NBFIX 271 | !SOD OC -0.075020 3.190 ! For prot carboxylate groups 272 | !SOD OCL -0.075020 3.190 ! For lipid carboxylate groups 273 | !SOD OC2D2 -0.075020 3.190 ! For carb carboxylate groups 274 | !SOD OG2D2 -0.075020 3.190 ! For CGenFF carboxylate groups 275 | !END 276 | 277 | return 278 | 279 | -------------------------------------------------------------------------------- /image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HuiLiuCode/CaFE_Plugin/f89b4834600d59e5453912b02f65860d3b93eb19/image/logo.png -------------------------------------------------------------------------------- /patch/topoatoms.tcl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/tclsh 2 | # This file is part of TopoTools, a VMD package to simplify 3 | # manipulating bonds other topology related properties. 4 | # 5 | # Copyright (c) 2009,2010,2011,2012 by Axel Kohlmeyer 6 | # $Id: topoatoms.tcl,v 1.15 2014/08/19 16:45:04 johns Exp $ 7 | 8 | # Return info about atoms 9 | # we list and count only bonds that are entirely within the selection. 10 | proc ::TopoTools::atominfo {infotype sel {flag none}} { 11 | 12 | set atomtypes [lsort -ascii -unique [$sel get type]] 13 | 14 | switch $infotype { 15 | numatoms { return [$sel num] } 16 | numatomtypes { return [llength $atomtypes] } 17 | atomtypenames { return $atomtypes } 18 | default { return "bug? shoot the programmer!"} 19 | } 20 | } 21 | 22 | # guess missing atomic property from periodic table data. numbers are 23 | # taken from the corresponding lists in the molfile plugin header. 24 | # TODO: additional guesses: element-name, mass-element, radius-element, ... 25 | proc ::TopoTools::guessatomdata {sel what from} { 26 | variable elements 27 | variable masses 28 | variable radii 29 | 30 | set selstr [$sel text] 31 | 32 | switch -- "$what-$from" { 33 | lammps-data { 34 | # shortcut for lammps data files 35 | guessatomdata $sel element mass 36 | guessatomdata $sel name element 37 | guessatomdata $sel radius element 38 | } 39 | 40 | element-mass { 41 | foreach a [lsort -real -unique [$sel get mass]] { 42 | set s [atomselect [$sel molid] "mass $a and ( $selstr )"] 43 | $s set element [lindex $elements [ptefrommass $a]] 44 | $s delete 45 | } 46 | } 47 | 48 | element-name { 49 | foreach n [lsort -ascii -unique [$sel get name]] { 50 | set s [atomselect [$sel molid] "name '$n' and ( $selstr )"] 51 | set idx [lsearch -nocase $elements $n] 52 | if { $idx < 0} { 53 | set n [string range $n 0 1] 54 | set idx [lsearch -nocase $elements $n] 55 | if {$idx < 0} { 56 | set n [string range $n 0 0] 57 | set idx [lsearch -nocase $elements $n] 58 | if {$idx < 0} { 59 | set n X 60 | } else { 61 | set n [lindex $elements $idx] 62 | } 63 | } else { 64 | set n [lindex $elements $idx] 65 | } 66 | } else { 67 | set n [lindex $elements $idx] 68 | } 69 | $s set element $n 70 | $s delete 71 | } 72 | } 73 | 74 | element-type { 75 | foreach t [lsort -ascii -unique [$sel get type]] { 76 | set s [atomselect [$sel molid] "type '$t' and ( $selstr )"] 77 | set idx [lsearch -nocase $elements $t] 78 | if { $idx < 0} { 79 | set t [string range $t 0 1] 80 | set idx [lsearch -nocase $elements $t] 81 | if {$idx < 0} { 82 | set t [string range $t 0 0] 83 | set idx [lsearch -nocase $elements $t] 84 | if {$idx < 0} { 85 | set t X 86 | } else { 87 | set t [lindex $elements $idx] 88 | } 89 | } else { 90 | set t [lindex $elements $idx] 91 | } 92 | } else { 93 | set t [lindex $elements $idx] 94 | } 95 | $s set element $t 96 | $s delete 97 | } 98 | } 99 | 100 | mass-element { 101 | foreach e [lsort -ascii -unique [$sel get element]] { 102 | set s [atomselect [$sel molid] "element '$e' and ( $selstr )"] 103 | set idx [lsearch -nocase $elements $e] 104 | set m 0.0 105 | if {$idx >= 0} { 106 | set m [lindex $masses $idx] 107 | } 108 | $s set mass $m 109 | $s delete 110 | } 111 | } 112 | 113 | name-element { 114 | # name is the same as element, only we go all uppercase. 115 | foreach e [lsort -ascii -unique [$sel get element]] { 116 | set s [atomselect [$sel molid] "element '$e' and ( $selstr )"] 117 | $s set name [string toupper $e] 118 | $s delete 119 | } 120 | } 121 | 122 | name-type { 123 | $sel set name [$sel get type] 124 | } 125 | 126 | radius-element { 127 | foreach e [lsort -ascii -unique [$sel get element]] { 128 | set s [atomselect [$sel molid] "element '$e' and ( $selstr )"] 129 | set idx [lsearch $elements $e] 130 | set r 2.0 131 | if {$idx >= 0} { 132 | set r [lindex $radii $idx] 133 | } 134 | $s set radius $r 135 | $s delete 136 | } 137 | } 138 | 139 | type-element { 140 | # type is the same as element, only we go all uppercase. 141 | foreach e [lsort -ascii -unique [$sel get element]] { 142 | set s [atomselect [$sel molid] "element '$e' and ( $selstr )"] 143 | $s set type [string toupper $e] 144 | $s delete 145 | } 146 | } 147 | 148 | type-name { 149 | $sel set type [$sel get name] 150 | } 151 | 152 | default { 153 | vmdcon -err "guessatomdata: guessing '$what' from '$from' not implemented." 154 | vmdcon -err "Available are: element<-mass, element<-name, mass. 20 | ############################################################################ 21 | 22 | package require cafe_mmpbsa 23 | package require cafe_lie 24 | package provide cafe 1.0 25 | 26 | namespace eval ::cafe:: { 27 | namespace export mmpbsa lie 28 | } 29 | 30 | proc mmpbsa { args } { return [eval ::cafe::mmpbsa $args] } 31 | 32 | proc lie { args } { return [eval ::cafe::lie $args] } 33 | 34 | proc ::cafe::mmpbsa { args } { return [eval ::cafe::mmpbsa::mmpbsa $args] } 35 | 36 | proc ::cafe::lie { args } { return [eval ::cafe::lie::lie $args] } 37 | 38 | -------------------------------------------------------------------------------- /src/cafe_lie.tcl: -------------------------------------------------------------------------------- 1 | package provide cafe_lie 1.0 2 | 3 | namespace eval ::cafe::lie:: { 4 | package require cafe_tools 5 | 6 | namespace import ::cafe::tools::* 7 | 8 | # global variables for the package 9 | variable validargs { 10 | -top_bound -trj_bound -top_free -trj_free -top_type -trj_type 11 | -par -out -debug -first_bound -last_bound -stride_bound 12 | -lig_bound -first_free -last_free -stride_free -lig_free -mm_exe 13 | -alpha -beta -gamma 14 | } 15 | 16 | variable topfile "" 17 | variable trjfile { } 18 | variable toptype "auto" 19 | variable trjtype "auto" 20 | variable parfile { } 21 | variable outfile "result.log" 22 | variable debug 0 23 | variable first_bound 0 24 | variable last_bound -1 25 | variable stride_bound 1 26 | variable ligsel_bound "" 27 | variable first_free 0 28 | variable last_free -1 29 | variable stride_free 1 30 | variable ligsel_free "" 31 | variable alpha 0.18 32 | variable beta 0.33 33 | variable gamma 0.0 34 | variable mm_exe "namd2" 35 | } 36 | 37 | # print usage info 38 | proc ::cafe::lie::print_usage { } { 39 | show -info "Usage: lie -top_bound filename -trj_bound filename -top_free filename -trj_free filename \[-args...\]" 40 | show -info "Mandatory arguments:" 41 | show -info " -top_bound " 42 | show -info " -trj_bound " 43 | show -info " -top_free " 44 | show -info " -trj_free " 45 | show -info "Optional arguments:" 46 | show -info " -top_type -- default: auto" 47 | show -info " -trj_type -- default: auto" 48 | show -info " -par -- default: [file join $::env(CAFEDIR) par_all22_prot.inp]" 49 | show -info " -out -- default: result.log" 50 | show -info " -debug -- default: 0" 51 | show -info " -first_bound -- default: 0" 52 | show -info " -last_bound -- default: -1" 53 | show -info " -stride_bound -- default: 1" 54 | show -info " -lig_bound -- default: \"\"" 55 | show -info " -first_free -- default: 0" 56 | show -info " -last_free -- default: -1" 57 | show -info " -stride_free -- default: 1" 58 | show -info " -lig_free -- default: \"\"" 59 | show -info " -mm_exe -- default: \"namd2\"" 60 | show -info " -alpha -- default: 0.18" 61 | show -info " -beta -- default: 0.33" 62 | show -info " -gamma -- default: 0.0" 63 | show "" 64 | } 65 | 66 | proc ::cafe::lie::lie { args } { 67 | variable validargs 68 | 69 | variable topfile_bound 70 | variable trjfile_bound 71 | variable topfile_free 72 | variable trjfile_free 73 | variable toptype 74 | variable trjtype 75 | variable parfile 76 | variable outfile 77 | variable debug 78 | variable first_bound 79 | variable last_bound 80 | variable stride_bound 81 | variable ligsel_bound 82 | variable first_free 83 | variable last_free 84 | variable stride_free 85 | variable ligsel_free 86 | 87 | variable mm_exe 88 | variable alpha 89 | variable beta 90 | variable gamma 91 | 92 | # ********************************************************* 93 | # **************** Do the Preparation Work **************** 94 | # ********************************************************* 95 | show -info "Sanity check" 96 | set start0 [clock seconds] 97 | 98 | # parse the command-line 99 | set nargs [llength $args] 100 | if { !$nargs || $nargs < 8 || [expr $nargs % 2] } { print_usage } 101 | 102 | foreach { key val } $args { 103 | if { [string match -?* $key] } { 104 | switch -nocase -- $key { 105 | -top_bound { 106 | set topfile_bound [check_file $val "top_bound"] 107 | } 108 | -top_free { 109 | set topfile_free [check_file $val "top_free"] 110 | } 111 | -top_type { 112 | set toptype [check_string $val "top_type"] 113 | } 114 | -trj_bound { 115 | lappend trjfile_bound [check_file $val "trj_bound"] 116 | } 117 | -trj_free { 118 | lappend trjfile_free [check_file $val "trj_free"] 119 | } 120 | -trj_type { 121 | set trjtype [check_string $val "trj_type"] 122 | } 123 | -par { 124 | lappend parfile [check_file $val "par"] 125 | } 126 | -out { 127 | set outfile $val 128 | } 129 | -debug { 130 | set debug [check_int $val "debug"] 131 | } 132 | -first_bound { 133 | set first_bound [check_int $val "first_bound"] 134 | } 135 | -last_bound { 136 | set last_bound [check_int $val "last_bound"] 137 | } 138 | -stride_bound { 139 | set stride_bound [check_pos_int $val "stride_bound"] 140 | } 141 | -lig_bound { 142 | set ligsel_bound $val 143 | } 144 | -first_free { 145 | set first_free [check_int $val "first_free"] 146 | } 147 | -last_free { 148 | set last_free [check_int $val "last_free"] 149 | } 150 | -stride_free { 151 | set stride_free [check_pos_int $val "stride_free"] 152 | } 153 | -lig_free { 154 | set ligsel_free $val 155 | } 156 | -mm_exe { 157 | set mm_exe $val 158 | } 159 | -alpha { 160 | set alpha [check_real $val "alpha"] 161 | } 162 | -beta { 163 | set beta [check_real $val "beta"] 164 | } 165 | -gamma { 166 | set gamma [check_real $val "gamma"] 167 | } 168 | default { 169 | if { $key ni $validargs } { 170 | show -err "Found unknown argument '$key'" 171 | } 172 | } 173 | } 174 | } else { 175 | show -err "Found unknown argument '$key'" 176 | } 177 | } 178 | 179 | # check mandatory arguments 180 | if { $topfile_bound eq "" || $topfile_free eq "" } { 181 | show -err "Need topology files for the bound and free states!" 182 | } 183 | 184 | if { ![llength $trjfile_bound] || ![llength $trjfile_free] } { 185 | show -err "Need trajectory files for the bound and free states!" 186 | } 187 | 188 | # check optional arguments 189 | if { ![llength $parfile] } { 190 | lappend parfile [file join $::env(CAFEDIR) "par_all22_prot.inp"] 191 | } 192 | 193 | check_exe $mm_exe "mm_exe" 194 | 195 | foreach name { bound free } topfile [list $topfile_bound $topfile_free] \ 196 | selstr [list $ligsel_bound $ligsel_free] first [list $first_bound $first_free] \ 197 | last [list $last_bound $last_free] stride [list $stride_bound $stride_free] \ 198 | trjfile [list $trjfile_bound $trjfile_free] { 199 | # load topology file 200 | if { $toptype eq "auto" } { 201 | set currmol [mol new $topfile waitfor all] 202 | } else { 203 | set currmol [mol new $topfile type $toptype waitfor all] 204 | } 205 | 206 | set toptype [molinfo $currmol get filetype] 207 | 208 | # check topology type, currently NAMD fully supports AMBER and CHARMM/X-PLOR formats 209 | if { $toptype ne "psf" && $toptype ne "parm" && $toptype ne "parm7" } { 210 | show -err "Currently only AMBER- and CHARMM/X-PLOR-formatted topology files are supported" 211 | } 212 | 213 | # check selections 214 | if { $selstr eq "" } { 215 | show -err "Selection of ligand in the $name state should be specified" 216 | } else { 217 | set sel [atomselect $currmol $selstr] 218 | set natoms [$sel num] 219 | if { !$natoms } { 220 | show -err "Found zero atoms for ligand in the $name state" 221 | } else { 222 | show -info "Found $natoms atoms for ligand in the $name state" 223 | } 224 | $sel delete 225 | } 226 | 227 | # load trajectory 228 | if { $last != -1 && $last < $first } { 229 | show -err "'last' should be not less than 'first'" 230 | } 231 | 232 | foreach f $trjfile { 233 | if { $trjtype eq "auto" } { 234 | mol addfile $f waitfor all 235 | } else { 236 | mol addfile $f type $trjtype waitfor all 237 | } 238 | } 239 | 240 | set old_nframes [molinfo $currmol get numframes] 241 | show -info "Loaded $old_nframes frames for ligand in the $name state" 242 | 243 | # delete unnecessary frames 244 | if { $first > 0 } { 245 | animate delete end [expr $first - 1] $currmol 246 | } 247 | if { $last != -1 && $last < [expr $old_nframes - 1] } { 248 | animate delete beg [expr $last - $first + 1] $currmol 249 | } 250 | 251 | show -info "Generating new trajectory for ligand in the $name state" 252 | 253 | set tmp_trj "_lie_${name}_tmp.dcd" 254 | animate write dcd $tmp_trj waitfor all skip $stride $currmol 255 | 256 | # delete old files and reload the new trajectory to save memory 257 | mol delete $currmol 258 | } 259 | 260 | foreach { d h m s } [timer $start0] { break } 261 | show -info "It took $d days $h hrs $m min $s sec" 262 | 263 | # ***************************************************** 264 | # **************** Do the Calculations **************** 265 | # ***************************************************** 266 | show -info "Calculating the interaction energy" 267 | set start [clock seconds] 268 | 269 | foreach name { bound free } topfile [list $topfile_bound $topfile_free] \ 270 | first [list $first_bound $first_free] stride [list $stride_bound $stride_free] \ 271 | selstr [list $ligsel_bound $ligsel_free] { 272 | set currmol [mol new $topfile type $toptype waitfor all] 273 | 274 | set tmp_trj "_lie_${name}_tmp.dcd" 275 | mol addfile $tmp_trj type dcd waitfor all 276 | show -info "Loaded [molinfo $currmol get numframes] frames for ligand in the $name state" 277 | 278 | set mm_result [calc_mm $currmol $name $selstr $tmp_trj $first $stride $topfile] 279 | if { $name eq "bound" } { 280 | foreach { bound_ele_list bound_vdw_list } $mm_result { break } 281 | } else { 282 | foreach { free_ele_list free_vdw_list } $mm_result { break } 283 | } 284 | } 285 | 286 | foreach { d h m s } [timer $start] { break } 287 | show -info "It took $d days $h hrs $m min $s sec" 288 | 289 | # ***************************************************** 290 | # **************** Generate the Result **************** 291 | # ***************************************************** 292 | show -info "Generating the result" 293 | set start [clock seconds] 294 | 295 | set result [open $outfile w] 296 | 297 | set tfmt " %-6s %15s %15s %15s" 298 | set dfmt " %-6s %15s %15.4f" 299 | set sepline " [string repeat - 60]" 300 | 301 | puts $result $sepline 302 | puts $result [format $tfmt Title Frames Mean SD] 303 | puts $result $sepline 304 | 305 | write_out $result " Bound:" $sepline $bound_vdw_list $bound_ele_list 306 | write_out $result " Free:" $sepline $free_vdw_list $free_ele_list 307 | 308 | foreach { vdw_b - } [calc_stats $bound_vdw_list] { break } 309 | foreach { ele_b - } [calc_stats $bound_ele_list] { break } 310 | foreach { vdw_f - } [calc_stats $free_vdw_list] { break } 311 | foreach { ele_f - } [calc_stats $free_ele_list] { break } 312 | set vdw_d [expr $vdw_b - $vdw_f] 313 | set ele_d [expr $ele_b - $ele_f] 314 | 315 | puts $result " Delta:" 316 | puts $result [format $dfmt "Vdw:" "" $vdw_d] 317 | puts $result [format $dfmt "Elec:" "" $ele_d] 318 | puts $result $sepline 319 | 320 | set vdwsc [expr $alpha*$vdw_d] 321 | set elesc [expr $beta*$ele_d] 322 | set gbind [expr $vdwsc + $elesc + $gamma] 323 | 324 | puts $result " Final: (alpha=$alpha, beta=$beta, gamma=$gamma)" 325 | puts $result [format $dfmt "Total:" "" $gbind] 326 | puts $result $sepline 327 | 328 | puts $result " * All energy values are in kcal/mol" 329 | 330 | close $result 331 | 332 | if { $debug < 2 } { 333 | file delete "_lie_bound_tmp.dcd" 334 | file delete "_lie_free_tmp.dcd" 335 | } 336 | 337 | foreach { d h m s } [timer $start] { break } 338 | show -info "It took $d days $h hrs $m min $s sec" 339 | 340 | foreach { d h m s } [timer $start0] { break } 341 | show -info "Total elapsed time: $d days $h hrs $m min $s sec" 342 | } 343 | 344 | proc ::cafe::lie::write_out { fp title end vdw_list ele_list } { 345 | puts $fp $title 346 | 347 | write_item $fp "Vdw:" $vdw_list 348 | write_item $fp "Elec:" $ele_list 349 | 350 | puts $fp $end 351 | } 352 | 353 | # ###################################################################### 354 | # MM related 355 | # ###################################################################### 356 | proc ::cafe::lie::calc_mm { molid prefix selstr trajname first stride topfile } { 357 | variable debug 358 | 359 | # NOTE: There is a bug in namdEnergy plugin 1.4. It was said that "skip" was 360 | # "number of frames to skip", so given the first frame N, the next one is 361 | # thought to be N + $skip + 1. Unfortunately, when the selection is not 362 | # updated every frame, "animate write" is used there to generate a trajectory. 363 | # However, "animate write" actually uses the "skip" argument the same as a 364 | # "stride". That is to say, if the first frame is N, the next one is actually 365 | # N + $skip. 366 | 367 | set mm_list [run_namd $molid $prefix $selstr $trajname $topfile] 368 | 369 | set ele_list { } 370 | set vdw_list { } 371 | 372 | foreach items $mm_list { 373 | foreach { - - - - ele vdw } $items { break } 374 | lappend ele_list $ele 375 | lappend vdw_list $vdw 376 | } 377 | 378 | if { $debug > 0 } { 379 | set tfmt "#%14s %15s %15s" 380 | set dfmt "%15d %15.4f %15.4f" 381 | set fname ${prefix}_mm.log 382 | set title [format $tfmt Frame Vdw Elec] 383 | set frames { } 384 | 385 | for { set i 0 } { $i < [llength $mm_list] } { incr i } { 386 | lappend frames [expr $first + $i*$stride] 387 | } 388 | 389 | set data { } 390 | lappend data $frames 391 | lappend data $vdw_list 392 | lappend data $ele_list 393 | 394 | write_log $fname $title $dfmt $data 395 | } 396 | 397 | return [list $ele_list $vdw_list] 398 | } 399 | 400 | # calculate MM energy by NAMD 401 | proc ::cafe::lie::run_namd { molid prefix selstr trajname topfile } { 402 | variable mm_exe 403 | variable debug 404 | 405 | write_namd_conf $molid $prefix $selstr $trajname $topfile 406 | exec $mm_exe ${prefix}_mm_tmp.namd > ${prefix}_mm_tmp.log 407 | set result [parse_namd ${prefix}_mm_tmp.log] 408 | if { $debug < 2 } { cleanup ${prefix}_mm } 409 | return $result 410 | } 411 | 412 | # write a NAMD configuration file 413 | # revised from namdenergy1.4 414 | proc ::cafe::lie::write_namd_conf { molid prefix selstr trajname topfile } { 415 | variable toptype 416 | variable parfile 417 | 418 | # write the pair interaction PDB needed for NAMD 419 | set all [atomselect $molid all frame first] 420 | $all set beta 2 421 | set sel [atomselect $molid $selstr frame first] 422 | $sel set beta 1 423 | $sel delete 424 | $all writepdb ${prefix}_mm_tmp.pdb 425 | $all delete 426 | 427 | if { [catch { set namdconf [open ${prefix}_mm_tmp.namd w] } err] } { 428 | show -err "Failed to write NAMD config file: ${prefix}_mm_tmp.namd" 429 | } 430 | 431 | # set up topology and parameters 432 | if { $toptype eq "parm" || $toptype eq "parm7" } { 433 | puts $namdconf "amber on" 434 | puts $namdconf "parmfile $topfile" 435 | puts $namdconf "readexclusions yes" 436 | } else { 437 | puts $namdconf "structure $topfile" 438 | puts $namdconf "paraTypeCharmm on" 439 | foreach pf $parfile { 440 | puts $namdconf "parameters $pf" 441 | } 442 | puts $namdconf "mergeCrossterms yes" 443 | } 444 | 445 | puts $namdconf "numsteps 1" 446 | puts $namdconf "exclude scaled1-4" 447 | if { $toptype eq "parm" || $toptype eq "parm7" } { 448 | puts $namdconf "1-4scaling 0.8333333333333333" 449 | puts $namdconf "scnb 2.0" 450 | } 451 | puts $namdconf "outputname ${prefix}_mm_tmp" 452 | puts $namdconf "temperature 0" 453 | puts $namdconf "COMmotion yes" 454 | puts $namdconf "cutoff 999" 455 | puts $namdconf "dielectric 1" 456 | puts $namdconf "switching off" 457 | 458 | puts $namdconf "pairInteraction on" 459 | puts $namdconf "pairInteractionFile ${prefix}_mm_tmp.pdb" 460 | puts $namdconf "pairInteractionCol B" 461 | puts $namdconf "pairInteractionGroup1 1" 462 | puts $namdconf "pairInteractionGroup2 2" 463 | puts $namdconf "pairInteractionSelf off" 464 | puts $namdconf "coordinates ${prefix}_mm_tmp.pdb" 465 | puts $namdconf "set ts 0" 466 | puts $namdconf "coorfile open dcd $trajname" 467 | puts $namdconf "while \{ \!\[coorfile read\] \} \{" 468 | puts $namdconf " firstTimestep \$ts" 469 | puts $namdconf " run 0" 470 | puts $namdconf " incr ts" 471 | puts $namdconf "\}" 472 | puts $namdconf "coorfile close" 473 | 474 | close $namdconf 475 | } 476 | 477 | -------------------------------------------------------------------------------- /src/cafe_mmpbsa.tcl: -------------------------------------------------------------------------------- 1 | package provide cafe_mmpbsa 1.0 2 | 3 | namespace eval ::cafe::mmpbsa:: { 4 | package require readcharmmpar ;# for ::Pararead::getvdwparam 5 | package require topotools ;# for "topo guessatom" 6 | package require cafe_tools 7 | 8 | namespace import ::cafe::tools::* 9 | 10 | # global variables for the package 11 | # kT/NA = RT = 1.9859 cal/K/mol * 298.15 K = 0.59210 kcal/mol 12 | variable kt2kc 0.592 13 | variable j2cal 0.239 14 | 15 | variable validargs { 16 | -top -trj -top_type -trj_type -par -out -debug -first -last -stride 17 | -com -rec -lig -mm -mm_exe -mm_diel -pb -pb_exe -pb_siz -pb_crg -pb_rad 18 | -pb_indi -pb_exdi -pb_scale -pb_perfil -pb_prbrad -pb_linit -pb_maxc 19 | -pb_bndcon -pb_bcfl -pb_chgm -pb_srfm -pb_swin -pb_sdens -gb 20 | -gb_exdi -gb_ioncon -gb_sa -gb_sagamma -sa -sa_exe -sa_rad -sa_gamma 21 | -sa_beta -sa_prbrad -sa_samples 22 | } 23 | 24 | variable topfile "" 25 | variable trjfile { } 26 | variable toptype "auto" 27 | variable trjtype "auto" 28 | variable parfile { } 29 | variable outfile "result.log" 30 | variable debug 0 31 | variable first 0 32 | variable last -1 33 | variable stride 1 34 | variable comsel "" 35 | variable recsel "" 36 | variable ligsel "" 37 | 38 | variable mm 0 39 | variable mm_exe "namd2" 40 | variable mm_diel 1.0 41 | 42 | variable pb 0 43 | variable pb_exe "delphi77" 44 | variable pb_siz "" 45 | variable pb_crg "" 46 | variable pb_rad "bondi" 47 | variable pb_indi 1.0 48 | variable pb_exdi 80.0 49 | variable pb_scale 2.0 50 | variable pb_perfil 80.0 51 | variable pb_prbrad 1.4 52 | variable pb_linit 1000 53 | variable pb_maxc 0.0001 54 | variable pb_bndcon 4 55 | variable pb_bcfl "sdh" 56 | variable pb_chgm "spl0" 57 | variable pb_srfm "smol" 58 | variable pb_swin 0.3 59 | variable pb_sdens 10.0 60 | 61 | variable gb 0 62 | variable gb_exdi 78.5 63 | variable gb_ioncon 0.0 64 | variable gb_sa 0 65 | variable gb_sagamma 0.005 66 | 67 | variable sa 0 68 | variable sa_exe "apbs" 69 | variable sa_rad "bondi" 70 | variable sa_gamma 0.005 71 | variable sa_beta 0.0 72 | variable sa_prbrad 1.4 73 | variable sa_samples 500 74 | } 75 | 76 | # print usage info 77 | proc ::cafe::mmpbsa::print_usage { } { 78 | show -info "Usage: mmpbsa -top filename -trj filename \[-args...\]" 79 | show -info "Mandatory arguments:" 80 | show -info " -top " 81 | show -info " -trj " 82 | show -info "Optional arguments:" 83 | show -info " -top_type -- default: auto" 84 | show -info " -trj_type -- default: auto" 85 | show -info " -par -- default: [file join $::env(CAFEDIR) par_all22_prot.inp]" 86 | show -info " -out -- default: result.log" 87 | show -info " -debug -- default: 0" 88 | show -info " -first -- default: 0" 89 | show -info " -last -- default: -1" 90 | show -info " -stride -- default: 1" 91 | show -info " -com -- default: \"\"" 92 | show -info " -rec -- default: \"\"" 93 | show -info " -lig -- default: \"\"" 94 | show -info " -mm -- default: 0" 95 | show -info " -mm_exe -- default: \"namd2\"" 96 | show -info " -mm_diel -- default: 1.0" 97 | show -info " -pb -- default: 0" 98 | show -info " -pb_exe -- default: \"delphi77\"" 99 | show -info " -pb_siz -- default: \"\"" 100 | show -info " -pb_crg -- default: \"\"" 101 | show -info " -pb_rad -- default: bondi" 102 | show -info " -pb_indi -- default: 1.0" 103 | show -info " -pb_exdi -- default: 80.0" 104 | show -info " -pb_scale -- default: 2.0" 105 | show -info " -pb_perfil -- default: 80.0" 106 | show -info " -pb_prbrad -- default: 1.4" 107 | show -info " -pb_linit -- default: 1000" 108 | show -info " -pb_maxc -- default: 0.0001" 109 | show -info " -pb_bndcon -- default: 4" 110 | show -info " -pb_bcfl -- default: sdh" 111 | show -info " -pb_chgm -- default: spl0" 112 | show -info " -pb_srfm -- default: smol" 113 | show -info " -pb_swin -- default: 0.3" 114 | show -info " -pb_sdens -- default: 10.0" 115 | show -info " -gb -- default: 0" 116 | show -info " -gb_exdi -- default: 78.5" 117 | show -info " -gb_ioncon -- default: 0.0" 118 | show -info " -gb_sa -- default: 0" 119 | show -info " -gb_sagamma -- default: 0.005" 120 | show -info " -sa -- default: 0" 121 | show -info " -sa_exe -- default: \"apbs\"" 122 | show -info " -sa_rad -- default: bondi" 123 | show -info " -sa_gamma -- default: 0.005" 124 | show -info " -sa_beta -- default: 0.0" 125 | show -info " -sa_prbrad -- default: 1.4" 126 | show -info " -sa_samples -- default: 500" 127 | show "" 128 | } 129 | 130 | proc ::cafe::mmpbsa::mmpbsa { args } { 131 | variable validargs 132 | 133 | variable topfile 134 | variable trjfile 135 | variable toptype 136 | variable trjtype 137 | variable parfile 138 | variable outfile 139 | variable debug 140 | variable first 141 | variable last 142 | variable stride 143 | variable comsel 144 | variable recsel 145 | variable ligsel 146 | 147 | variable mm 148 | variable mm_exe 149 | variable mm_diel 150 | 151 | variable pb 152 | variable pb_exe 153 | variable pb_siz 154 | variable pb_crg 155 | variable pb_rad 156 | variable pb_indi 157 | variable pb_exdi 158 | variable pb_scale 159 | variable pb_perfil 160 | variable pb_prbrad 161 | variable pb_linit 162 | variable pb_maxc 163 | variable pb_bndcon 164 | variable pb_bcfl 165 | variable pb_chgm 166 | variable pb_srfm 167 | variable pb_swin 168 | variable pb_sdens 169 | 170 | variable gb 171 | variable gb_exdi 172 | variable gb_ioncon 173 | variable gb_sa 174 | variable gb_sagamma 175 | 176 | variable sa 177 | variable sa_exe 178 | variable sa_rad 179 | variable sa_gamma 180 | variable sa_beta 181 | variable sa_prbrad 182 | variable sa_samples 183 | 184 | # ********************************************************* 185 | # **************** Do the Preparation Work **************** 186 | # ********************************************************* 187 | show -info "Sanity check" 188 | set start0 [clock seconds] 189 | 190 | # parse the command-line 191 | set nargs [llength $args] 192 | if { !$nargs || $nargs < 4 || [expr $nargs % 2] } { print_usage } 193 | 194 | foreach { key val } $args { 195 | if { [string match -?* $key] } { 196 | switch -nocase -- $key { 197 | -top { 198 | set topfile [check_file $val "top"] 199 | } 200 | -top_type { 201 | set toptype [check_string $val "top_type"] 202 | } 203 | -trj { 204 | lappend trjfile [check_file $val "trj"] 205 | } 206 | -trj_type { 207 | set trjtype [check_string $val "trj_type"] 208 | } 209 | -par { 210 | lappend parfile [check_file $val "par"] 211 | } 212 | -out { 213 | set outfile $val 214 | } 215 | -debug { 216 | set debug [check_int $val "debug"] 217 | } 218 | -first { 219 | set first [check_int $val "first"] 220 | } 221 | -last { 222 | set last [check_int $val "last"] 223 | } 224 | -stride { 225 | set stride [check_pos_int $val "stride"] 226 | } 227 | -com { 228 | set comsel $val 229 | } 230 | -rec { 231 | set recsel $val 232 | } 233 | -lig { 234 | set ligsel $val 235 | } 236 | -mm { 237 | set mm [check_bool $val "mm"] 238 | } 239 | -pb { 240 | set pb [check_nneg_int $val "pb"] 241 | } 242 | -gb { 243 | set gb [check_nneg_int $val "gb"] 244 | } 245 | -sa { 246 | set sa [check_nneg_int $val "sa"] 247 | } 248 | default { 249 | if { $key ni $validargs } { 250 | show -err "Found unknown argument '$key'" 251 | } 252 | } 253 | } 254 | } else { 255 | show -err "Found unknown argument '$key'" 256 | } 257 | } 258 | 259 | if { !$mm && !$pb && !$gb && !$sa } { 260 | show -err "Need a calculation type!" 261 | } 262 | 263 | if { $mm } { 264 | foreach { key val } $args { 265 | switch -nocase -- $key { 266 | -mm_exe { 267 | set mm_exe $val 268 | } 269 | -mm_diel { 270 | set mm_diel [check_pos_real $val "mm_diel"] 271 | } 272 | default { 273 | continue 274 | } 275 | } 276 | } 277 | } 278 | 279 | if { $pb } { 280 | foreach { key val } $args { 281 | switch -nocase -- $key { 282 | -pb_exe { 283 | set pb_exe $val 284 | } 285 | -pb_siz { 286 | set pb_siz [check_file $val "pb_siz"] 287 | } 288 | -pb_crg { 289 | set pb_crg [check_file $val "pb_crg"] 290 | } 291 | -pb_rad { 292 | set pb_rad [check_string $val "pb_rad"] 293 | } 294 | -pb_indi { 295 | set pb_indi [check_pos_real $val "pb_indi"] 296 | } 297 | -pb_exdi { 298 | set pb_exdi [check_pos_real $val "pb_exdi"] 299 | } 300 | -pb_scale { 301 | set pb_scale [check_pos_real $val "pb_scale"] 302 | } 303 | -pb_perfil { 304 | set pb_perfil [check_pos_real $val "pb_perfil"] 305 | if { $pb_perfil > 100 } { 306 | show -err "'pb_perfil' should be less than 100" 307 | } 308 | } 309 | -pb_prbrad { 310 | set pb_prbrad [check_nneg_real $val "pb_prbrad"] 311 | } 312 | -pb_linit { 313 | set pb_linit [check_pos_int $val "pb_linit"] 314 | } 315 | -pb_maxc { 316 | set pb_maxc [check_pos_real $val "pb_maxc"] 317 | } 318 | -pb_bndcon { 319 | set pb_bndcon [check_pos_int $val "pb_bndcon"] 320 | } 321 | -pb_bcfl { 322 | set pb_bcfl [check_string $val "pb_bcfl"] 323 | } 324 | -pb_chgm { 325 | set pb_chgm [check_string $val "pb_chgm"] 326 | } 327 | -pb_srfm { 328 | set pb_srfm [check_string $val "pb_srfm"] 329 | } 330 | -pb_swin { 331 | set pb_swin [check_pos_real $val "pb_swin"] 332 | } 333 | -pb_sdens { 334 | set pb_sdens [check_pos_real $val "pb_sdens"] 335 | } 336 | default { 337 | continue 338 | } 339 | } 340 | } 341 | } 342 | 343 | if { $gb } { 344 | foreach { key val } $args { 345 | switch -nocase -- $key { 346 | -mm_exe { 347 | set mm_exe $val 348 | } 349 | -gb_exdi { 350 | set gb_exdi [check_pos_real $val "gb_exdi"] 351 | } 352 | -gb_ioncon { 353 | set gb_ioncon [check_nneg_real $val "gb_ioncon"] 354 | } 355 | -gb_sa { 356 | set gb_sa [check_bool $val "gb_sa"] 357 | } 358 | -gb_sagamma { 359 | set gb_sagamma [check_real $val "gb_sagamma"] 360 | } 361 | default { 362 | continue 363 | } 364 | } 365 | } 366 | } 367 | 368 | if { $sa } { 369 | foreach { key val } $args { 370 | switch -nocase -- $key { 371 | -sa_exe { 372 | set sa_exe $val 373 | } 374 | -sa_rad { 375 | set sa_rad [check_string $val "sa_rad"] 376 | } 377 | -sa_gamma { 378 | set sa_gamma [check_real $val "sa_gamma"] 379 | } 380 | -sa_beta { 381 | set sa_beta [check_real $val "sa_beta"] 382 | } 383 | -sa_prbrad { 384 | set sa_prbrad [check_pos_real $val "sa_prbrad"] 385 | } 386 | -sa_samples { 387 | set sa_samples [check_pos_int $val "sa_samples"] 388 | } 389 | default { 390 | continue 391 | } 392 | } 393 | } 394 | } 395 | 396 | # check mandatory arguments 397 | if { $topfile eq "" } { 398 | show -err "Need a topology file!" 399 | } 400 | 401 | if { ![llength $trjfile] } { 402 | show -err "Need a trajectory file!" 403 | } 404 | 405 | # check optional arguments 406 | if { ![llength $parfile] } { 407 | lappend parfile [file join $::env(CAFEDIR) "par_all22_prot.inp"] 408 | } 409 | 410 | if { $mm } { check_exe $mm_exe "mm_exe"} 411 | if { $pb } { check_exe $pb_exe "pb_exe"} 412 | if { $gb } { check_exe $mm_exe "mm_exe"} 413 | if { $sa == 2 } { check_exe $sa_exe "sa_exe"} 414 | 415 | if { $pb && $gb } { 416 | show -err "Select only one implicit model at a time." 417 | } 418 | 419 | if { $gb && ($gb_sa && $sa) } { 420 | show -err "Select only one SASA method at a time." 421 | } 422 | 423 | # load topology file 424 | if { $toptype eq "auto" } { 425 | set currmol [mol new $topfile waitfor all] 426 | } else { 427 | set currmol [mol new $topfile type $toptype waitfor all] 428 | } 429 | 430 | set toptype [molinfo $currmol get filetype] 431 | 432 | # check topology type, currently NAMD fully supports AMBER and CHARMM/X-PLOR formats 433 | if { $toptype ne "psf" && $toptype ne "parm" && $toptype ne "parm7" } { 434 | show -err "Currently only AMBER- and CHARMM/X-PLOR-formatted topology files are supported" 435 | } 436 | 437 | # check selections 438 | if { $comsel eq "" } { 439 | show -err "Selection of complex must be specified" 440 | } 441 | 442 | if { ($recsel eq "" && $ligsel ne "") || ($recsel ne "" && $ligsel eq "") } { 443 | show -err "Selections of both receptor and ligand should be specified" 444 | } 445 | 446 | foreach name { complex receptor ligand } selstr [list $comsel $recsel $ligsel] { 447 | if { $selstr ne "" } { 448 | set sel [atomselect $currmol $selstr] 449 | set natoms [$sel num] 450 | if { !$natoms } { 451 | show -err "Found zero atoms for $name" 452 | } else { 453 | show -info "Found $natoms atoms for $name" 454 | } 455 | $sel delete 456 | } 457 | } 458 | 459 | # check radii setting 460 | if { $pb } { 461 | if { $pb_rad eq "charmm" && ![llength $parfile] } { 462 | show -err "Need a CHARMM formatted parameter file for pb_rad charmm" 463 | } elseif { $pb_rad eq "parm7" && ($toptype ne "parm" && $toptype ne "parm7") } { 464 | show -err "Need an AMBER PARM7 file for pb_rad parm7" 465 | } 466 | } 467 | 468 | if { $sa } { 469 | if { $sa_rad eq "charmm" && ![llength $parfile] } { 470 | show -err "Need a CHARMM formatted parameter file for sa_rad charmm" 471 | } elseif { $sa_rad eq "parm7" && ($toptype ne "parm" && $toptype ne "parm7") } { 472 | show -err "Need an AMBER PARM7 file for sa_rad parm7" 473 | } 474 | } 475 | 476 | # load trajectory 477 | if { $last != -1 && $last < $first } { 478 | show -err "'last' should be not less than 'first'" 479 | } 480 | 481 | foreach f $trjfile { 482 | if { $trjtype eq "auto" } { 483 | mol addfile $f waitfor all 484 | } else { 485 | mol addfile $f type $trjtype waitfor all 486 | } 487 | } 488 | 489 | set old_nframes [molinfo $currmol get numframes] 490 | show -info "Loaded $old_nframes frames for complex" 491 | 492 | # delete unnecessary frames 493 | if { $first > 0 } { 494 | animate delete end [expr $first - 1] $currmol 495 | } 496 | if { $last != -1 && $last < [expr $old_nframes - 1] } { 497 | animate delete beg [expr $last - $first + 1] $currmol 498 | } 499 | 500 | show -info "Generating new trajectory for complex" 501 | 502 | set com_trj "_mmpbsa_com_tmp.dcd" 503 | 504 | animate write dcd $com_trj waitfor all skip $stride $currmol 505 | 506 | # delete old files and reload the new trajectory to save memory 507 | mol delete $currmol 508 | 509 | set currmol [mol new $topfile type $toptype waitfor all] 510 | 511 | mol addfile $com_trj type dcd waitfor all 512 | show -info "Loaded [molinfo $currmol get numframes] frames for complex" 513 | 514 | foreach { d h m s } [timer $start0] { break } 515 | show -info "It took $d days $h hrs $m min $s sec" 516 | 517 | # *************************************************************** 518 | # **************** Do the Gas-Phase Calculations **************** 519 | # *************************************************************** 520 | if { $mm } { 521 | show -info "Calculating the MM term" 522 | set start [clock seconds] 523 | 524 | set com_mm_result [calc_mm $currmol com $comsel $com_trj] 525 | foreach { com_ele_list com_vdw_list } $com_mm_result { break } 526 | 527 | if { $recsel ne "" } { 528 | set rec_mm_result [calc_mm $currmol rec $recsel $com_trj] 529 | foreach { rec_ele_list rec_vdw_list } $rec_mm_result { break } 530 | } 531 | 532 | if { $ligsel ne "" } { 533 | set lig_mm_result [calc_mm $currmol lig $ligsel $com_trj] 534 | foreach { lig_ele_list lig_vdw_list } $lig_mm_result { break } 535 | } 536 | 537 | foreach { d h m s } [timer $start] { break } 538 | show -info "It took $d days $h hrs $m min $s sec" 539 | } 540 | 541 | # ********************************************************************* 542 | # **************** Do the Polar Solvation Calculations **************** 543 | # ********************************************************************* 544 | if { $pb } { 545 | show -info "Calculating the PB term" 546 | set start [clock seconds] 547 | 548 | # assign radii 549 | set ar_args "$currmol $pb_rad" 550 | if { $pb_rad eq "charmm" } { 551 | foreach p $parfile { append ar_args " \"$p\"" } 552 | } elseif { $pb_rad eq "parm7" } { 553 | append ar_args " \"$topfile\"" 554 | } 555 | eval assign_radii $ar_args 556 | 557 | set com_pb_list [calc_pb $currmol com $comsel] 558 | 559 | if { $recsel ne "" } { 560 | set rec_pb_list [calc_pb $currmol rec $recsel] 561 | } 562 | 563 | if { $ligsel ne "" } { 564 | set lig_pb_list [calc_pb $currmol lig $ligsel] 565 | } 566 | 567 | foreach { d h m s } [timer $start] { break } 568 | show -info "It took $d days $h hrs $m min $s sec" 569 | } 570 | 571 | # ************************************************************************ 572 | # **************** Do the Nonpolar Solvation Calculations **************** 573 | # ************************************************************************ 574 | if { $sa } { 575 | show -info "Calculating the SA term" 576 | set start [clock seconds] 577 | 578 | # assign radii again 579 | set ar_args "$currmol $sa_rad" 580 | if { $sa_rad eq "charmm" } { 581 | foreach p $parfile { append ar_args " \"$p\"" } 582 | } elseif { $sa_rad eq "parm7" } { 583 | append ar_args " \"$topfile\"" 584 | } 585 | eval assign_radii $ar_args 586 | 587 | set com_sa_list [calc_sa $currmol com $comsel] 588 | 589 | if { $recsel ne "" } { 590 | set rec_sa_list [calc_sa $currmol rec $recsel] 591 | } 592 | 593 | if { $ligsel ne "" } { 594 | set lig_sa_list [calc_sa $currmol lig $ligsel] 595 | } 596 | 597 | foreach { d h m s } [timer $start] { break } 598 | show -info "It took $d days $h hrs $m min $s sec" 599 | } 600 | 601 | # ***************************************************** 602 | # **************** Generate the Result **************** 603 | # ***************************************************** 604 | show -info "Generating the result" 605 | set start [clock seconds] 606 | 607 | set result [open $outfile w] 608 | 609 | set tfmt " %-6s %15s %15s %15s" 610 | set sepline " [string repeat - 60]" 611 | 612 | puts $result $sepline 613 | puts $result [format $tfmt Title Frames Mean SD] 614 | puts $result $sepline 615 | 616 | if { !$mm } { 617 | set com_ele_list { } 618 | set com_vdw_list { } 619 | } 620 | if { !$pb } { 621 | set com_pb_list { } 622 | } 623 | if { !$sa } { 624 | set com_sa_list { } 625 | } 626 | 627 | write_out $result " Complex:" $sepline $com_ele_list $com_vdw_list $com_pb_list $com_sa_list 628 | 629 | if { $recsel ne "" } { 630 | if { !$mm } { 631 | set rec_ele_list { } 632 | set rec_vdw_list { } 633 | } 634 | if { !$pb } { 635 | set rec_pb_list { } 636 | } 637 | if { !$sa } { 638 | set rec_sa_list { } 639 | } 640 | 641 | write_out $result " Receptor:" $sepline $rec_ele_list $rec_vdw_list $rec_pb_list $rec_sa_list 642 | } 643 | 644 | if { $ligsel ne "" } { 645 | if { !$mm } { 646 | set lig_ele_list { } 647 | set lig_vdw_list { } 648 | } 649 | if { !$pb } { 650 | set lig_pb_list { } 651 | } 652 | if { !$sa } { 653 | set lig_sa_list { } 654 | } 655 | 656 | write_out $result " Ligand:" $sepline $lig_ele_list $lig_vdw_list $lig_pb_list $lig_sa_list 657 | } 658 | 659 | if { $comsel ne "" && $recsel ne "" && $ligsel ne "" } { 660 | set del_ele_list [vecsub $com_ele_list [vecadd $rec_ele_list $lig_ele_list]] 661 | 662 | set del_vdw_list [vecsub $com_vdw_list [vecadd $rec_vdw_list $lig_vdw_list]] 663 | 664 | set del_pb_list [vecsub $com_pb_list [vecadd $rec_pb_list $lig_pb_list]] 665 | 666 | set del_sa_list [vecsub $com_sa_list [vecadd $rec_sa_list $lig_sa_list]] 667 | 668 | write_out $result " Delta:" $sepline $del_ele_list $del_vdw_list $del_pb_list $del_sa_list 669 | } 670 | 671 | puts $result " * All energy values are in kcal/mol" 672 | 673 | close $result 674 | 675 | if { $debug < 2 } { file delete $com_trj } 676 | 677 | foreach { d h m s } [timer $start] { break } 678 | show -info "It took $d days $h hrs $m min $s sec" 679 | 680 | foreach { d h m s } [timer $start0] { break } 681 | show -info "Total elapsed time: $d days $h hrs $m min $s sec" 682 | } 683 | 684 | proc ::cafe::mmpbsa::write_out { fp title end ele_list vdw_list pb_list sa_list } { 685 | variable mm 686 | variable pb 687 | variable sa 688 | 689 | puts $fp $title 690 | 691 | if { $mm } { 692 | write_item $fp "Elec:" $ele_list 693 | write_item $fp "Vdw:" $vdw_list 694 | } 695 | 696 | if { $pb } { 697 | write_item $fp "PB:" $pb_list 698 | } 699 | 700 | if { $sa } { 701 | write_item $fp "SA:" $sa_list 702 | } 703 | 704 | if { $mm } { 705 | set gas_list [vecadd $ele_list $vdw_list] 706 | write_item $fp "Gas:" $gas_list 707 | } 708 | 709 | if { $pb && $sa } { 710 | set sol_list [vecadd $pb_list $sa_list] 711 | write_item $fp "Sol:" $sol_list 712 | } 713 | 714 | if { $mm && $pb } { 715 | set pol_list [vecadd $ele_list $pb_list] 716 | write_item $fp "Pol:" $pol_list 717 | } 718 | 719 | if { $mm && $sa } { 720 | set npol_list [vecadd $vdw_list $sa_list] 721 | write_item $fp "Npol:" $npol_list 722 | } 723 | 724 | set tot_list { } 725 | if { $mm } { 726 | set tot_list $gas_list 727 | } 728 | if { $pb } { 729 | if { ![llength $tot_list] } { 730 | set tot_list $pb_list 731 | } else { 732 | set tot_list [vecadd $tot_list $pb_list] 733 | } 734 | } 735 | if { $sa } { 736 | if { ![llength $tot_list] } { 737 | set tot_list $sa_list 738 | } else { 739 | set tot_list [vecadd $tot_list $sa_list] 740 | } 741 | } 742 | write_item $fp "Total:" $tot_list 743 | puts $fp $end 744 | } 745 | 746 | # ###################################################################### 747 | # MM related 748 | # ###################################################################### 749 | proc ::cafe::mmpbsa::calc_mm { molid prefix selstr trajname } { 750 | variable first 751 | variable stride 752 | variable debug 753 | 754 | # NOTE: There is a bug in namdEnergy plugin 1.4. It was said that "skip" was 755 | # "number of frames to skip", so given the first frame N, the next one is 756 | # thought to be N + $skip + 1. Unfortunately, when the selection is not 757 | # updated every frame, "animate write" is used there to generate a trajectory. 758 | # However, "animate write" actually uses the "skip" argument the same as a 759 | # "stride". That is to say, if the first frame is N, the next one is actually 760 | # N + $skip. 761 | 762 | set mm_list [run_namd $molid $prefix $selstr $trajname] 763 | 764 | set ele_list { } 765 | set vdw_list { } 766 | set tot_list { } 767 | 768 | foreach items $mm_list { 769 | foreach { - - - - ele vdw } $items { break } 770 | lappend ele_list $ele 771 | lappend vdw_list $vdw 772 | lappend tot_list [expr $ele + $vdw] 773 | } 774 | 775 | if { $debug > 0 } { 776 | set tfmt "#%14s %15s %15s %15s" 777 | set dfmt "%15d %15.4f %15.4f %15.4f" 778 | set fname ${prefix}_mm.log 779 | set title [format $tfmt Frame Elec Vdw MM] 780 | set frames { } 781 | 782 | for { set i 0 } { $i < [llength $mm_list] } { incr i } { 783 | lappend frames [expr $first + $i*$stride] 784 | } 785 | 786 | set data { } 787 | lappend data $frames 788 | lappend data $ele_list 789 | lappend data $vdw_list 790 | lappend data $tot_list 791 | 792 | write_log $fname $title $dfmt $data 793 | } 794 | 795 | return [list $ele_list $vdw_list] 796 | } 797 | 798 | # calculate MM and/or GB by NAMD 799 | proc ::cafe::mmpbsa::run_namd { molid prefix selstr trajname } { 800 | variable mm_exe 801 | variable debug 802 | 803 | write_namd_conf $molid $prefix $selstr $trajname 804 | exec $mm_exe ${prefix}_mm_tmp.namd > ${prefix}_mm_tmp.log 805 | set result [parse_namd ${prefix}_mm_tmp.log] 806 | if { $debug < 2 } { cleanup ${prefix}_mm } 807 | return $result 808 | } 809 | 810 | # write a NAMD configuration file 811 | # revised from namdenergy1.4 812 | proc ::cafe::mmpbsa::write_namd_conf { molid prefix selstr trajname } { 813 | variable toptype 814 | variable topfile 815 | variable parfile 816 | variable mm_diel 817 | variable gb 818 | variable gb_exdi 819 | variable gb_ioncon 820 | variable gb_sa 821 | variable gb_sagamma 822 | 823 | # write the pair interaction PDB needed for NAMD 824 | set all [atomselect $molid all frame first] 825 | $all set beta 0 826 | set sel [atomselect $molid $selstr frame first] 827 | $sel set beta 1 828 | $sel delete 829 | $all writepdb ${prefix}_mm_tmp.pdb 830 | $all delete 831 | 832 | if { [catch { set namdconf [open ${prefix}_mm_tmp.namd w] } err] } { 833 | show -err "Failed to write NAMD config file: ${prefix}_mm_tmp.namd" 834 | } 835 | 836 | # set up topology and parameters 837 | if { $toptype eq "parm" || $toptype eq "parm7" } { 838 | puts $namdconf "amber on" 839 | puts $namdconf "parmfile $topfile" 840 | puts $namdconf "readexclusions yes" 841 | } else { 842 | puts $namdconf "structure $topfile" 843 | puts $namdconf "paraTypeCharmm on" 844 | foreach pf $parfile { 845 | puts $namdconf "parameters $pf" 846 | } 847 | puts $namdconf "mergeCrossterms yes" 848 | } 849 | 850 | puts $namdconf "numsteps 1" 851 | puts $namdconf "exclude scaled1-4" 852 | if { $toptype eq "parm" || $toptype eq "parm7" } { 853 | puts $namdconf "1-4scaling 0.8333333333333333" 854 | puts $namdconf "scnb 2.0" 855 | } 856 | puts $namdconf "outputname ${prefix}_mm_tmp" 857 | puts $namdconf "temperature 0" 858 | puts $namdconf "COMmotion yes" 859 | puts $namdconf "cutoff 999" 860 | puts $namdconf "dielectric $mm_diel" 861 | puts $namdconf "switching off" 862 | 863 | if { $gb } { 864 | puts $namdconf "GBIS on" 865 | puts $namdconf "solventDielectric $gb_exdi" 866 | puts $namdconf "intrinsicRadiusOffset 0.09" 867 | puts $namdconf "ionConcentration $gb_ioncon" 868 | puts $namdconf "alphaCutoff 999" 869 | if { $gb == 1 } { 870 | puts $namdconf "GBISDelta 1.0" 871 | puts $namdconf "GBISBeta 0.8" 872 | puts $namdconf "GBISGamma 4.85" 873 | } elseif { $gb == 2 } { 874 | puts $namdconf "GBISDelta 0.8" 875 | puts $namdconf "GBISBeta 0.0" 876 | puts $namdconf "GBISGamma 2.90912" 877 | } else { 878 | show -err "Unknown GB method: $gb" 879 | } 880 | if { $gb_sa } { 881 | puts $namdconf "SASA on" 882 | puts $namdconf "surfaceTension $gb_sagamma" 883 | } else { 884 | puts $namdconf "SASA off" 885 | } 886 | } else { 887 | puts $namdconf "GBIS off" 888 | } 889 | 890 | puts $namdconf "pairInteraction on" 891 | puts $namdconf "pairInteractionFile ${prefix}_mm_tmp.pdb" 892 | puts $namdconf "pairInteractionCol B" 893 | puts $namdconf "pairInteractionGroup1 1" 894 | puts $namdconf "pairInteractionSelf on" 895 | puts $namdconf "coordinates ${prefix}_mm_tmp.pdb" 896 | puts $namdconf "set ts 0" 897 | puts $namdconf "coorfile open dcd $trajname" 898 | puts $namdconf "while \{ \!\[coorfile read\] \} \{" 899 | puts $namdconf " firstTimestep \$ts" 900 | puts $namdconf " run 0" 901 | puts $namdconf " incr ts" 902 | puts $namdconf "\}" 903 | puts $namdconf "coorfile close" 904 | 905 | close $namdconf 906 | } 907 | 908 | # ###################################################################### 909 | # PB related 910 | # ###################################################################### 911 | proc ::cafe::mmpbsa::assign_radii { molid type args } { 912 | switch $type { 913 | bondi { assign_radii_bondi $molid } 914 | rowland { assign_radii_rowland $molid } 915 | mparse { assign_radii_parse $molid -mod } 916 | parse { assign_radii_parse $molid -orig } 917 | charmm { eval assign_radii_charmm $molid $args } 918 | roux { assign_radii_roux $molid } 919 | parm7 { assign_radii_parm7 $molid $args } 920 | swanson { assign_radii_swanson $molid } 921 | tan { assign_radii_tan $molid } 922 | yamagishi { assign_radii_yamagishi $molid } 923 | default { show -err "Unknown type of radii: $type" } 924 | } 925 | } 926 | 927 | # **************** General **************** 928 | 929 | # assign Bondi radii (J Phys Chem 1964, 68, 441-452) 930 | proc ::cafe::mmpbsa::assign_radii_bondi { molid } { 931 | # element guessed from mass should be more accurate; however, 932 | # there is a bug in topotools1.5 plugin, line 43: 933 | # "$s set element [lindex $elements [ptefrommass $idx]]" 934 | # should be 935 | # "$s set element [lindex $elements [ptefrommass $a]]" 936 | # so I have to guess from name for now ... 937 | topo guessatom element mass -molid $molid 938 | #topo guessatom element name -molid $molid 939 | topo guessatom radius element -molid $molid 940 | } 941 | 942 | # Rowland and Taylor (J Phys Chem 1996, 100, 7384-7391) 943 | proc ::cafe::mmpbsa::assign_radii_rowland { molid } { 944 | assign_radii_bondi $molid 945 | 946 | [atomselect $molid "element 'H'"] set radius 1.10 947 | [atomselect $molid "element 'C'"] set radius 1.77 948 | [atomselect $molid "element 'N'"] set radius 1.64 949 | [atomselect $molid "element 'O'"] set radius 1.58 950 | [atomselect $molid "element 'F'"] set radius 1.46 951 | [atomselect $molid "element 'S'"] set radius 1.81 952 | [atomselect $molid "element 'Cl'"] set radius 1.76 953 | [atomselect $molid "element 'Br'"] set radius 1.87 954 | [atomselect $molid "element 'I'"] set radius 2.03 955 | } 956 | 957 | # assign PARSE radii (J Phys Chem 1994, 98, 1978-1988) 958 | # atoms not specified here will use default values in VMD 959 | proc ::cafe::mmpbsa::assign_radii_parse { molid { opt "-mod" } } { 960 | # unknown atoms were set to 1.5 in AMBER; however, I set them 961 | # according to either Pauling or the value guessed by VMD 962 | #[atomselect $molid "all"] set radius 1.50 963 | assign_radii_bondi $molid 964 | 965 | [atomselect $molid "element 'H'"] set radius 1.00 966 | [atomselect $molid "element 'C'"] set radius 1.70 967 | [atomselect $molid "element 'O'"] set radius 1.40 968 | [atomselect $molid "element 'N'"] set radius 1.50 969 | [atomselect $molid "element 'S'"] set radius 1.85 970 | 971 | # J Mol Biol 2007, 366, 1475-1496 972 | [atomselect $molid "element 'P'"] set radius 1.9 973 | 974 | # Pauling radii, from which PARSE is derived 975 | [atomselect $molid "element 'F'"] set radius 1.35 976 | [atomselect $molid "element 'Cl'"] set radius 1.80 977 | [atomselect $molid "element 'Br'"] set radius 1.95 978 | [atomselect $molid "element 'I'"] set radius 2.15 979 | 980 | # set CHn = 2.0 and nonpolar H = 0.0 981 | if { $opt == "-orig" } { 982 | return 983 | # the application is wrong for aromatic ring 984 | set hs [atomselect $molid "element 'H' and numbonds = 1"] 985 | set nphlist { } 986 | set chnlist { } 987 | set i 0 988 | 989 | foreach bid [$hs getbonds] { 990 | set batom [atomselect $molid "index $bid"] 991 | if { [$batom get element] eq "C" } { 992 | lappend nphlist $i 993 | lappend chnlist $bid 994 | } 995 | $batom delete 996 | incr i 997 | } 998 | 999 | set ids [$hs get index] 1000 | $hs delete 1001 | foreach i $nphlist { 1002 | [atomselect $molid "index [lindex $ids $i]"] set radius 0.00 1003 | } 1004 | 1005 | foreach i [lsort -unique -integer $chnlist] { 1006 | [atomselect $molid "index $i"] set radius 2.00 1007 | } 1008 | } 1009 | } 1010 | 1011 | # **************** For CHARMM **************** 1012 | 1013 | # assign CHARMM radii based on CHARMM force field parameters 1014 | proc ::cafe::mmpbsa::assign_radii_charmm { molid args } { 1015 | set paramlist { } 1016 | 1017 | foreach f $args { 1018 | lappend paramlist [::Pararead::read_charmm_parameters $f] 1019 | } 1020 | 1021 | set sel [atomselect $molid all] 1022 | set typelist [lsort -uniq [$sel get type]] 1023 | $sel delete 1024 | 1025 | foreach type $typelist { 1026 | set typesel [atomselect $molid "type $type"] 1027 | 1028 | if { [$typesel num] > 0 } { 1029 | foreach par $paramlist { 1030 | set vdwparams [::Pararead::getvdwparam $par $type] 1031 | 1032 | if { [llength $vdwparams] > 1 } { 1033 | set r [expr [lindex $vdwparams 1] * 1.0] 1034 | $typesel set radius $r 1035 | break; 1036 | } 1037 | } 1038 | } 1039 | $typesel delete 1040 | } 1041 | } 1042 | 1043 | # assign modified CHARMM radii developed by Roux and coworkers 1044 | # (J Phys Chem B 1997, 101, 5239-5248 & J Phys Chem B 2002, 106, 11026-11035) 1045 | proc ::cafe::mmpbsa::assign_radii_roux { molid } { 1046 | # **************** General **************** 1047 | assign_radii_bondi $molid 1048 | 1049 | # zero H and set heavy atoms to average default values 1050 | [atomselect $molid "hydrogen"] set radius 0.0 1051 | [atomselect $molid "carbon"] set radius 2.3 1052 | [atomselect $molid "oxygen"] set radius 1.8 1053 | [atomselect $molid "nitrogen"] set radius 2.3 1054 | [atomselect $molid "sulfur"] set radius 2.3 1055 | 1056 | # **************** Protein **************** 1057 | 1058 | # Patches 1059 | # CT3 N-Methylamide C-terminus 1060 | # ACE acetylated N-terminus (ACP for PRO) 1061 | [atomselect $molid "name CAY CAT"] set radius 2.06 1062 | [atomselect $molid "name CY"] set radius 2.04 1063 | [atomselect $molid "name OY"] set radius 1.52 1064 | [atomselect $molid "name NT"] set radius 2.23 1065 | [atomselect $molid "name \"OT.*\""] set radius 1.40 ;# for COO- terminus 1066 | 1067 | # Backbone 1068 | [atomselect $molid "name C"] set radius 2.04 ;# for peptide bond 1069 | [atomselect $molid "name O"] set radius 1.52 ;# for peptide bond 1070 | [atomselect $molid "name N"] set radius 2.23 ;# for peptide bond 1071 | [atomselect $molid "name CA"] set radius 2.86 ;# for all CA except GLY 1072 | [atomselect $molid "resname GLY and name CA"] set radius 2.38 ;# for GLY only 1073 | 1074 | # C 1075 | [atomselect $molid "name CB"] set radius 2.67 ;# for all residues 1076 | [atomselect $molid "name \"CG.*\""] set radius 2.46 ;# for ARG, GLN, ILE, LYS, MET, PHE, THR, TRP, VAL, HSP, HSD 1077 | [atomselect $molid "resname GLU and name CG"] set radius 2.77 ;# for GLU only 1078 | [atomselect $molid "name \"CD.*\""] set radius 2.44 ;# for ARG, ILE, LEU, LYS 1079 | [atomselect $molid "(resname GLN and name CD) or (resname ASN and name CG) or (resname GLU and name CD) or (resname ASP and name CG)"] set radius 1.98 ;# for ASP, GLU, ASN, GLN 1080 | [atomselect $molid "resname PRO and (name CB CG CD)"] set radius 1.98 ;# for PRO only 1081 | [atomselect $molid "(resname TYR and (name \"CE.*\" \"CD.*\" CZ)) or (resname PHE and (name \"CE.*\" \"CD.*\" CZ))"] set radius 2.00 ;# for TYR, PHE rings 1082 | [atomselect $molid "resname TRP and (name \"CE.*\" \"CD.*\" \"CZ.*\" CH2)"] set radius 1.78 ;# for TRP ring only 1083 | [atomselect $molid "name CE"] set radius 2.10 ;# for MET only 1084 | [atomselect $molid "(resname ARG and name CZ) or (resname LYS and name CE)"] set radius 2.80 ;# for ARG, LYS 1085 | #[atomselect $molid "((resname HSD HSP) and name CE1) or ((resname HSD HSP) and name CD2)"] set radius 1.98 ;# for neutral HSD and protonated HSP 1086 | [atomselect $molid "((resname HSD HSP HSE HIS) and name CE1) or ((resname HSD HSP HSE HIS) and name CD2)"] set radius 1.98 ;# for neutral HSD and protonated HSP, and HSE 1087 | 1088 | # O 1089 | [atomselect $molid "(resname GLU ASP) and (name \"OE.*\" \"OD.*\")"] set radius 1.40 ;# for GLU, ASP 1090 | [atomselect $molid "(resname ASN GLN) and (name \"OE.*\" \"OD.*\")"] set radius 1.42 ;# for ASN, GLN 1091 | [atomselect $molid "name \"OG.*\""] set radius 1.64 ;# for SER, THR 1092 | [atomselect $molid "resname TYR and name OH"] set radius 1.85 ;# for TYR only 1093 | [atomselect $molid "resname TIP3 and name OH2"] set radius 2.2 ;# for explicit water molecules 1094 | 1095 | # N 1096 | #[atomselect $molid "resname HSD and (name NE2 ND1)"] set radius 1.80 ;# for neutral HSD 1097 | [atomselect $molid "(resname HSD HSE HIS) and (name NE2 ND1)"] set radius 1.80 ;# for neutral HSD, and HSE 1098 | [atomselect $molid "resname HSP and (name NE2 ND1)"] set radius 2.30 ;# for protonated HSP 1099 | [atomselect $molid "(resname ARG and (name \"NH.*\" NE)) or (resname LYS and name NZ)"] set radius 2.13 ;# for ARG, LYS 1100 | [atomselect $molid "(resname GLN and name NE2) or (resname ASN and name ND2)"] set radius 2.15 ;# for GLN, ASN 1101 | [atomselect $molid "resname TRP and name NE1"] set radius 2.40 ;# for TRP 1102 | 1103 | # S 1104 | [atomselect $molid "name \"S.*\" and (resname MET CYS)"] set radius 2.00 ;# for MET, CYS 1105 | 1106 | # **************** Ions **************** 1107 | 1108 | [atomselect $molid "resname POT"] set radius 2.035 ;# potassium ion K+ 1109 | [atomselect $molid "resname CLA"] set radius 2.035 ;# chloride ion Cl- 1110 | [atomselect $molid "resname SOD"] set radius 1.66 ;# sodium ion Na+ 1111 | 1112 | # Tetramethylamonium (TEA) 1113 | [atomselect $molid "resname TEA and name N"] set radius 2.15 1114 | [atomselect $molid "resname TEA and (name C1 C2 C3 C4)"] set radius 2.30 1115 | [atomselect $molid "resname TEA and (name C5 C6 C7 C8)"] set radius 2.30 1116 | 1117 | # **************** Nucleic acids **************** 1118 | 1119 | # purine base atoms 1120 | [atomselect $molid "resname ADE and name N1"] set radius 1.75 1121 | [atomselect $molid "resname GUA and name N1"] set radius 2.15 1122 | [atomselect $molid "(resname GUA ADE) and name C2"] set radius 2.15 1123 | [atomselect $molid "(resname GUA ADE) and name N3"] set radius 1.69 1124 | [atomselect $molid "(resname GUA ADE) and name C4"] set radius 2.12 1125 | [atomselect $molid "(resname GUA ADE) and name C5"] set radius 2.12 1126 | [atomselect $molid "(resname GUA ADE) and name C6"] set radius 2.12 1127 | [atomselect $molid "(resname GUA ADE) and name N7"] set radius 1.69 1128 | [atomselect $molid "(resname GUA ADE) and name C8"] set radius 2.12 1129 | [atomselect $molid "(resname GUA ADE) and name N9"] set radius 2.13 1130 | [atomselect $molid "resname ADE and name N6"] set radius 2.17 1131 | [atomselect $molid "resname GUA and name O6"] set radius 1.55 1132 | [atomselect $molid "resname GUA and name N2"] set radius 2.12 1133 | [atomselect $molid "(resname GUA ADE) and name C9"] set radius 2.30 1134 | 1135 | # pyrimidine base atoms 1136 | [atomselect $molid "(resname CYT THY URA) and name N1"] set radius 2.20 1137 | [atomselect $molid "(resname CYT THY URA) and name C2"] set radius 2.04 1138 | [atomselect $molid "resname CYT and name N3"] set radius 1.68 1139 | [atomselect $molid "(resname THY URA) and name N3"] set radius 2.20 1140 | [atomselect $molid "(resname CYT THY URA) and name C4"] set radius 2.12 1141 | [atomselect $molid "(resname CYT THY URA) and name C5"] set radius 2.25 1142 | [atomselect $molid "(resname CYT THY URA) and name C6"] set radius 2.25 1143 | [atomselect $molid "(resname CYT THY URA) and name O2"] set radius 1.60 1144 | [atomselect $molid "resname CYT and name N4"] set radius 2.08 1145 | [atomselect $molid "(resname THY URA) and name O4"] set radius 1.60 1146 | [atomselect $molid "resname THY and name C5M"] set radius 2.30 1147 | [atomselect $molid "(resname CYT THY URA) and name C1"] set radius 2.30 1148 | 1149 | # sugar atoms 1150 | [atomselect $molid "name C1'"] set radius 2.57 1151 | [atomselect $molid "name C2'"] set radius 2.70 1152 | [atomselect $molid "name C3'"] set radius 2.73 1153 | [atomselect $molid "name C4'"] set radius 2.50 1154 | [atomselect $molid "name O4'"] set radius 1.55 1155 | [atomselect $molid "name C5'"] set radius 2.57 1156 | [atomselect $molid "name O3'"] set radius 1.65 1157 | [atomselect $molid "name O5'"] set radius 1.65 1158 | [atomselect $molid "name O2'"] set radius 1.75 1159 | 1160 | # add radii for blocking group hydroxyl oxygens 1161 | set oter [atomselect $molid "(name O3' O5') and numbonds = 2"] 1162 | set oterlist { } 1163 | set i 0 1164 | 1165 | foreach bids [$oter getbonds] { 1166 | set batom [atomselect $molid "index [lindex bids 0] or index [lindex bids 1]"] 1167 | set bname [$batom get name] 1168 | if { "H3T" in $bname || "H5T" in $bname } { lappend oterlist $i } 1169 | $batom delete 1170 | incr i 1171 | } 1172 | 1173 | set ids [$oter get index] 1174 | $oter delete 1175 | 1176 | foreach i $oterlist { 1177 | [atomselect $molid "index [lindex $ids $i]"] set radius 1.72 1178 | } 1179 | 1180 | # atoms for sugar2phos 1181 | [atomselect $molid "resname ADE and name O5T"] set radius 1.65 1182 | [atomselect $molid "resname ADE and name C5T"] set radius 2.30 1183 | [atomselect $molid "resname ADE and name P3"] set radius 2.35 1184 | [atomselect $molid "resname ADE and name O1P3"] set radius 1.49 1185 | [atomselect $molid "resname ADE and name O2P3"] set radius 1.49 1186 | [atomselect $molid "resname ADE and name O3T"] set radius 1.65 1187 | [atomselect $molid "resname ADE and name C3T"] set radius 2.30 1188 | 1189 | # phosphate atoms 1190 | [atomselect $molid "(resname GUA ADE CYT THY URA) and name P"] set radius 2.35 1191 | [atomselect $molid "(resname GUA ADE CYT THY URA) and name O1P"] set radius 1.49 1192 | [atomselect $molid "(resname GUA ADE CYT THY URA) and name O2P"] set radius 1.49 1193 | 1194 | # DMPA phosphate atoms, from above radii 1195 | [atomselect $molid "resname DMPA and name P1"] set radius 2.35 1196 | [atomselect $molid "resname DMPA and name O1"] set radius 1.65 1197 | [atomselect $molid "resname DMPA and name O2"] set radius 1.65 1198 | [atomselect $molid "resname DMPA and name O3"] set radius 1.49 1199 | [atomselect $molid "resname DMPA and name O4"] set radius 1.49 1200 | [atomselect $molid "resname DMPA and name C1"] set radius 2.30 1201 | [atomselect $molid "resname DMPA and name C2"] set radius 2.30 1202 | 1203 | # phosphate atoms in ADP or ATP 1204 | [atomselect $molid "name PA PB PG"] set radius 2.35 1205 | [atomselect $molid "(resname ATP and (name O3A O3B)) or (resname ADP and name O3A)"] set radius 1.65 1206 | [atomselect $molid "(name O1A O2A O1B O2B O1G O2G O3G) or (resname ADP and name O3B)"] set radius 1.49 1207 | 1208 | # phosphate atoms in phosphotyrosine 1209 | [atomselect $molid "resname TYR and name P1"] set radius 2.35 1210 | [atomselect $molid "resname TYR and (name O2 O3 O4)"] set radius 1.49 1211 | } 1212 | 1213 | # **************** For AMBER **************** 1214 | 1215 | # assign radii based on a given AMBER PARM7 file 1216 | proc ::cafe::mmpbsa::assign_radii_parm7 { molid args } { 1217 | set rs [parse_parm7 $args] 1218 | [atomselect $molid "all"] set radius $rs 1219 | } 1220 | 1221 | # unfortunately, VMD discards the radii info in a PARM7 file, 1222 | # so I have to re-parse it myself. 1223 | proc ::cafe::mmpbsa::parse_parm7 { fname } { 1224 | if { [catch {set fp [open $fname r]} err] } { 1225 | show -err "Failed to open PARM7 file: $fname" 1226 | } 1227 | 1228 | set natoms 0 1229 | set nr 0 1230 | set rs { } 1231 | 1232 | if { [gets $fp line] < 0 } { 1233 | show -err "Found an empty file: $fname" 1234 | } else { 1235 | if { [string range $line 0 7] ne "%VERSION" } { 1236 | show -err "Unknown or broken PARM7 file: $fname" 1237 | } 1238 | } 1239 | 1240 | while { [gets $fp line] >= 0 } { 1241 | if { [regexp {^%FLAG POINTERS} $line -> s] } { 1242 | # skip the format line 1243 | if { [gets $fp line] < 0 } { break } 1244 | if { [gets $fp line] < 0 } { break } 1245 | set natoms [expr [string range $line 0 7] * 1] 1246 | if { $natoms <= 0 } { break } 1247 | } 1248 | 1249 | if { [regexp {^%FLAG RADII} $line -> s] } { 1250 | # skip the format line 1251 | if { [gets $fp line] < 0 } { break } 1252 | if { $natoms <= 0 } { break } 1253 | set n [expr $natoms / 5] 1254 | set rest [expr $natoms % 5] 1255 | 1256 | for { set i 0 } { $i < $n } { incr i } { 1257 | if { [gets $fp line] < 0 } { break } 1258 | for { set j 0 } { $j < 5 } { incr j } { 1259 | set begin [expr 16 * $j] 1260 | set end [expr $begin + 15] 1261 | lappend rs [expr [string range $line $begin $end] * 1.0] 1262 | incr nr 1263 | } 1264 | } 1265 | 1266 | if { [gets $fp line] < 0 } { break } 1267 | 1268 | for { set j 0 } { $j < $rest } { incr j } { 1269 | set begin [expr 16 * $j] 1270 | set end [expr $begin + 15] 1271 | lappend rs [expr [string range $line $begin $end] * 1.0] 1272 | incr nr 1273 | } 1274 | break 1275 | } 1276 | } 1277 | 1278 | close $fp 1279 | 1280 | # do not use llength 1281 | if { $natoms <= 0 || $nr != $natoms } { 1282 | show -err "Unknown or broken PARM7 file: $fname" 1283 | } 1284 | 1285 | return $rs 1286 | } 1287 | 1288 | # Swanson et al (J Chem Theory Comput 2007, 3, 170-183) 1289 | proc ::cafe::mmpbsa::assign_radii_swanson { molid } { 1290 | show -err "Not implemented yet" 1291 | } 1292 | 1293 | # Tan et al (J Phys Chem B 2006, 110, 18680-18687) 1294 | proc ::cafe::mmpbsa::assign_radii_tan { molid } { 1295 | show -err "Not implemented yet" 1296 | } 1297 | 1298 | # Yamagishi et al (J Comput Chem 2014, 35, 2132-2139) 1299 | proc ::cafe::mmpbsa::assign_radii_yamagishi { molid } { 1300 | show -err "Not implemented yet" 1301 | } 1302 | 1303 | proc ::cafe::mmpbsa::calc_pb { molid prefix selstr } { 1304 | variable pb 1305 | variable kt2kc 1306 | variable j2cal 1307 | variable first 1308 | variable stride 1309 | variable debug 1310 | 1311 | if { $pb == 1 } { 1312 | set pb_list [run_delphi $molid $prefix $selstr] 1313 | set conv $kt2kc 1314 | } elseif { $pb == 2 } { 1315 | set pb_list [run_apbs $molid $prefix $selstr] 1316 | set conv $j2cal 1317 | } else { 1318 | show -err "Unknown PB type" 1319 | } 1320 | 1321 | if { $debug > 0 } { 1322 | set tfmt "#%14s %15s" 1323 | set dfmt "%15d %15.4f" 1324 | set fname ${prefix}_pb.log 1325 | set title [format $tfmt Frame PB] 1326 | set frames { } 1327 | 1328 | for { set i 0 } { $i < [llength $pb_list] } { incr i } { 1329 | lappend frames [expr $first + $i*$stride] 1330 | } 1331 | 1332 | set data { } 1333 | lappend data $frames 1334 | lappend data $pb_list 1335 | 1336 | write_log $fname $title $dfmt $data 1337 | } 1338 | 1339 | set pb_list [vecscale $conv $pb_list] 1340 | 1341 | return $pb_list 1342 | } 1343 | 1344 | # solve PBE by DelPhi 1345 | proc ::cafe::mmpbsa::run_delphi { molid prefix selstr } { 1346 | variable first 1347 | variable stride 1348 | variable pb_exe 1349 | variable pb_siz 1350 | variable pb_crg 1351 | variable pb_indi 1352 | variable pb_exdi 1353 | variable pb_scale 1354 | variable pb_perfil 1355 | variable pb_prbrad 1356 | variable pb_linit 1357 | variable pb_maxc 1358 | variable pb_bndcon 1359 | variable debug 1360 | 1361 | set sel [atomselect $molid $selstr] 1362 | 1363 | set pb_list { } 1364 | 1365 | for { set i 0 } { $i < [molinfo $molid get numframes] } { incr i } { 1366 | molinfo $molid set frame $i 1367 | set iframe [expr $first + $i*$stride] 1368 | 1369 | set tmp_prefix ${prefix}_pb_tmp_${iframe} 1370 | 1371 | if { $pb_siz eq "" || $pb_crg eq "" } { 1372 | # DelPhi cannot read files generated by "animate write pqr" 1373 | set tmp_pqr ${tmp_prefix}.pqr 1374 | write_pqr $sel $tmp_pqr 1375 | } else { 1376 | set tmp_pdb ${tmp_prefix}.pdb 1377 | $sel writepdb $tmp_pdb 1378 | } 1379 | 1380 | foreach { x y z } [measure center $sel] { break } 1381 | 1382 | set pb_out 0.0 1383 | set tmp_prm ${tmp_prefix}.delphi 1384 | set delphiin [open $tmp_prm w] 1385 | 1386 | if { $pb_siz eq "" || $pb_crg eq "" } { 1387 | puts $delphiin "in(modpdb4,file=\"$tmp_pqr\",format=pqr)" 1388 | } else { 1389 | puts $delphiin "in(pdb,file=\"$tmp_pdb\")" 1390 | puts $delphiin "in(siz,file=\"$pb_siz\")" 1391 | puts $delphiin "in(crg,file=\"$pb_crg\")" 1392 | } 1393 | puts $delphiin "acenter($x,$y,$z)" 1394 | puts $delphiin "indi=$pb_indi" 1395 | puts $delphiin "exdi=$pb_exdi" 1396 | puts $delphiin "scale=$pb_scale" 1397 | puts $delphiin "perfil=$pb_perfil" 1398 | puts $delphiin "prbrad=$pb_prbrad" 1399 | puts $delphiin "linit=$pb_linit" 1400 | puts $delphiin "maxc=$pb_maxc" 1401 | puts $delphiin "bndcon=$pb_bndcon" 1402 | puts $delphiin "energy(s,g)" 1403 | 1404 | close $delphiin 1405 | 1406 | if { [file exists ARCDAT] } { file delete ARCDAT } 1407 | 1408 | set tmp_log ${tmp_prefix}.log 1409 | exec $pb_exe $tmp_prm > $tmp_log 1410 | 1411 | # The polar solvation energy is simply C.R.F.Ener(exdi/indi) 1412 | # obtained from the DelPhi log. 1413 | # the unit is kT 1414 | set tmp_out [parse_delphi $tmp_log] 1415 | set pb_out $tmp_out 1416 | lappend pb_list $pb_out 1417 | 1418 | if { $debug < 2 } { cleanup ${prefix}_pb } 1419 | } 1420 | 1421 | $sel delete 1422 | 1423 | if { [file exists ARCDAT] } { file delete ARCDAT } 1424 | 1425 | return $pb_list 1426 | } 1427 | 1428 | # generate a PQR file for DelPhi calculation 1429 | # DelPhi cannot read the PQR written by "animate write pqr" 1430 | proc ::cafe::mmpbsa::write_pqr { sel fname } { 1431 | set fp [open $fname w] 1432 | foreach n [$sel get serial] name [$sel get name] \ 1433 | rname [$sel get resname] rid [$sel get resid] \ 1434 | x [$sel get x] y [$sel get y] z [$sel get z] \ 1435 | q [$sel get charge] r [$sel get radius] { 1436 | set name [format "%-3s" $name] 1437 | puts $fp [format "ATOM %5i %4s %3s %4i %8.3f%8.3f%8.3f %7.4f%7.4f" \ 1438 | $n $name $rname $rid $x $y $z $q $r] 1439 | } 1440 | close $fp 1441 | } 1442 | 1443 | # generate a ligand size file for DelPhi calculation 1444 | proc ::cafe::mmpbsa::write_siz { molid rname fname } { 1445 | set fp [open $fname w] 1446 | puts $fp atom__res_radius_ 1447 | 1448 | set sel [atomselect $molid "resname $rname"] 1449 | 1450 | foreach name [$sel get name] r [$sel get radius] { 1451 | puts $fp [format "%-6s%-4s%7.3f" $name $rname $r] 1452 | } 1453 | 1454 | $sel delete 1455 | 1456 | close $fp 1457 | } 1458 | 1459 | # generate a ligand charge file for DelPhi calculation 1460 | proc ::cafe::mmpbsa::write_crg { molid rname fname } { 1461 | set fp [open $fname w] 1462 | puts $fp atom__resnumbc_charge_ 1463 | 1464 | set sel [atomselect $molid "resname $rname"] 1465 | 1466 | foreach name [$sel get name] q [$sel get charge] { 1467 | puts $fp [format "%-6s%-8s%8.3f" $name $rname $q] 1468 | } 1469 | 1470 | $sel delete 1471 | 1472 | close $fp 1473 | } 1474 | 1475 | # parse a DelPhi output file 1476 | proc ::cafe::mmpbsa::parse_delphi { fname } { 1477 | if { [catch { set fp [open $fname r] } err] } { 1478 | show -err "Failed to open DelPhi output file: $fname" 1479 | } 1480 | 1481 | set found 0 1482 | 1483 | while { [gets $fp line] >= 0 } { 1484 | if { [regexp {^ corrected reaction field energy\s*:(.*)kt} $line -> s] } { 1485 | set s [string trim $s] 1486 | set found 1 1487 | break 1488 | } 1489 | } 1490 | 1491 | close $fp 1492 | 1493 | if { !$found } { 1494 | show -err "Unknown or broken DelPhi output file: $fname" 1495 | } 1496 | 1497 | return $s 1498 | } 1499 | 1500 | # solve PBE by APBS 1501 | proc ::cafe::mmpbsa::run_apbs { molid prefix selstr } { 1502 | variable first 1503 | variable stride 1504 | variable pb_exe 1505 | variable pb_indi 1506 | variable pb_exdi 1507 | variable pb_scale 1508 | variable pb_perfil 1509 | variable pb_prbrad 1510 | variable pb_bcfl 1511 | variable pb_chgm 1512 | variable pb_srfm 1513 | variable pb_swin 1514 | variable pb_sdens 1515 | variable debug 1516 | 1517 | set sel [atomselect $molid $selstr] 1518 | set grid [expr 1.0/$pb_scale] 1519 | set pb_list { } 1520 | 1521 | for { set i 0 } { $i < [molinfo $molid get numframes] } { incr i } { 1522 | molinfo $molid set frame $i 1523 | set iframe [expr $first + $i*$stride] 1524 | 1525 | set tmp_prefix ${prefix}_pb_tmp_${iframe} 1526 | set tmp_pqr ${tmp_prefix}.pqr 1527 | write_pqr $sel $tmp_pqr 1528 | 1529 | set x [$sel get x] 1530 | set y [$sel get y] 1531 | set z [$sel get z] 1532 | set r [$sel get radius] 1533 | 1534 | foreach { xmin xmax } [minmax $x $r] { break } 1535 | foreach { ymin ymax } [minmax $y $r] { break } 1536 | foreach { zmin zmax } [minmax $z $r] { break } 1537 | 1538 | set len [vecsub [list $xmax $ymax $zmax] [list $xmin $ymin $zmin]] 1539 | set dim { } 1540 | set raw [vecscale [expr 100.0/$pb_perfil*$pb_scale] $len] 1541 | 1542 | # calculate optimal numbers of grid points for APBS 1543 | # assuming nlev=4, so n=32*c+1 1544 | foreach x $raw { 1545 | set n [expr entier(ceil($x))] 1546 | set r [expr ($n-1)%32] 1547 | if { $r } { 1548 | set c [expr ($n-1)/32+1] 1549 | set n [expr 32*$c+1 ] 1550 | } 1551 | if { $n < 33 } { 1552 | set n 33 1553 | } 1554 | lappend dim $n 1555 | } 1556 | 1557 | set tmp_prm ${tmp_prefix}.apbs 1558 | set apbsin [open $tmp_prm w] 1559 | 1560 | puts $apbsin "read" 1561 | puts $apbsin " mol pqr $tmp_pqr" 1562 | puts $apbsin "end" 1563 | puts $apbsin "elec name pol" 1564 | puts $apbsin " mg-manual" 1565 | puts $apbsin " mol 1" 1566 | puts $apbsin " dime [lindex $dim 0] [lindex $dim 1] [lindex $dim 2]" 1567 | puts $apbsin " grid $grid $grid $grid" 1568 | puts $apbsin " gcent mol 1" 1569 | puts $apbsin " lpbe" 1570 | puts $apbsin " bcfl $pb_bcfl" 1571 | puts $apbsin " pdie $pb_indi" 1572 | puts $apbsin " sdie $pb_exdi" 1573 | puts $apbsin " chgm $pb_chgm" 1574 | puts $apbsin " srfm $pb_srfm" 1575 | puts $apbsin " srad $pb_prbrad" 1576 | puts $apbsin " swin $pb_swin" 1577 | puts $apbsin " sdens $pb_sdens" 1578 | puts $apbsin " temp 298.15" 1579 | puts $apbsin " calcenergy total" 1580 | puts $apbsin " calcforce no" 1581 | puts $apbsin "end" 1582 | puts $apbsin "elec name ref" 1583 | puts $apbsin " mg-manual" 1584 | puts $apbsin " mol 1" 1585 | puts $apbsin " dime [lindex $dim 0] [lindex $dim 1] [lindex $dim 2]" 1586 | puts $apbsin " grid $grid $grid $grid" 1587 | puts $apbsin " gcent mol 1" 1588 | puts $apbsin " lpbe" 1589 | puts $apbsin " bcfl $pb_bcfl" 1590 | puts $apbsin " pdie $pb_indi" 1591 | puts $apbsin " sdie $pb_indi" 1592 | puts $apbsin " chgm $pb_chgm" 1593 | puts $apbsin " srfm $pb_srfm" 1594 | puts $apbsin " srad $pb_prbrad" 1595 | puts $apbsin " swin $pb_swin" 1596 | puts $apbsin " sdens $pb_sdens" 1597 | puts $apbsin " temp 298.15" 1598 | puts $apbsin " calcenergy total" 1599 | puts $apbsin " calcforce no" 1600 | puts $apbsin "end" 1601 | puts $apbsin "print" 1602 | puts $apbsin " elecEnergy pol - ref" 1603 | puts $apbsin "end" 1604 | puts $apbsin "quit" 1605 | 1606 | close $apbsin 1607 | 1608 | if { [file exists io.mc] } { file delete io.mc } 1609 | 1610 | set tmp_log ${tmp_prefix}.log 1611 | 1612 | # Some versions of APBS sometimes throw a "Vio_scanf" error as follows: 1613 | # "asc_getToken: Error occurred (bailing out). 1614 | # Vio_scanf: Format problem with input." 1615 | # The error is harmless but will stop the calculations. So it should 1616 | # be ignored. The bug is found by an anonymous reviewer. Thank you! 1617 | exec -ignorestderr $pb_exe $tmp_prm > $tmp_log 1618 | 1619 | # the unit is kcal/mol 1620 | set pb_out [parse_apbs $tmp_log -elec] 1621 | lappend pb_list $pb_out 1622 | 1623 | if { $debug < 2 } { cleanup ${prefix}_pb } 1624 | } 1625 | 1626 | $sel delete 1627 | 1628 | if { [file exists io.mc] } { file delete io.mc } 1629 | 1630 | return $pb_list 1631 | } 1632 | 1633 | proc ::cafe::mmpbsa::minmax { x r } { 1634 | set xmin 9999 1635 | set xmax -9999 1636 | 1637 | foreach n [vecsub $x $r] { 1638 | if { $n < $xmin } { set xmin $n } 1639 | } 1640 | 1641 | foreach n [vecadd $x $r] { 1642 | if { $n > $xmax } { set xmax $n } 1643 | } 1644 | 1645 | return [list $xmin $xmax] 1646 | } 1647 | 1648 | # parse an APBS output file 1649 | proc ::cafe::mmpbsa::parse_apbs { fname opt } { 1650 | if { [catch { set fp [open $fname r] } err] } { 1651 | show -err "Failed to open APBS output file: $fname" 1652 | } 1653 | 1654 | set found 0 1655 | 1656 | switch -- $opt { 1657 | -elec { 1658 | while { [gets $fp line] >= 0 } { 1659 | if { [regexp {^ Global net ELEC energy\s*=(.*)kJ/mol} $line -> s] } { 1660 | set s [string trim $s] 1661 | set found 1 1662 | break 1663 | } 1664 | } 1665 | } 1666 | -sasa { 1667 | while { [gets $fp line] >= 0 } { 1668 | if { [regexp {^Total solvent accessible surface area:(.*)A\^2} $line -> s] } { 1669 | set s [string trim $s] 1670 | set found 1 1671 | break 1672 | } 1673 | } 1674 | } 1675 | default { show -err "Typo?" } 1676 | } 1677 | 1678 | close $fp 1679 | 1680 | if { !$found } { 1681 | show -err "Unknown or broken APBS output file: $fname" 1682 | } 1683 | 1684 | return $s 1685 | } 1686 | 1687 | # ###################################################################### 1688 | # SA related 1689 | # ###################################################################### 1690 | proc ::cafe::mmpbsa::calc_sa { molid prefix selstr } { 1691 | variable first 1692 | variable stride 1693 | variable sa 1694 | variable sa_prbrad 1695 | variable sa_samples 1696 | variable sa_gamma 1697 | variable sa_beta 1698 | variable debug 1699 | 1700 | if { $sa == 1 } { 1701 | set sa_list [run_vmd $molid $prefix $selstr] 1702 | } elseif { $sa == 2 } { 1703 | set sa_list [run_apbs_apol $molid $prefix $selstr] 1704 | } else { 1705 | show -err "Unknown non-polar type" 1706 | } 1707 | 1708 | if { $debug > 0 } { 1709 | set tfmt "#%14s %15s" 1710 | set dfmt "%15d %15.4f" 1711 | set fname ${prefix}_sa.log 1712 | set title [format $tfmt Frame SASA] 1713 | set frames { } 1714 | 1715 | for { set i 0 } { $i < [llength $sa_list] } { incr i } { 1716 | lappend frames [expr $first + $i*$stride] 1717 | } 1718 | 1719 | set data { } 1720 | lappend data $frames 1721 | lappend data $sa_list 1722 | 1723 | write_log $fname $title $dfmt $data 1724 | } 1725 | 1726 | set offset [lrepeat [llength $sa_list] $sa_beta] 1727 | set sa_list [vecadd [vecscale $sa_gamma $sa_list] $offset] 1728 | 1729 | return $sa_list 1730 | } 1731 | 1732 | # calculate SASA by VMD 1733 | proc ::cafe::mmpbsa::run_vmd { molid prefix selstr } { 1734 | variable stride 1735 | variable sa_prbrad 1736 | variable sa_samples 1737 | variable sa_gamma 1738 | variable sa_beta 1739 | 1740 | set sa_list { } 1741 | set sel [atomselect $molid $selstr] 1742 | 1743 | for { set i 0 } { $i < [molinfo $molid get numframes] } { incr i } { 1744 | molinfo $molid set frame $i 1745 | 1746 | # the unit is angstrom^2 1747 | set val [measure sasa $sa_prbrad $sel -samples $sa_samples] 1748 | lappend sa_list $val 1749 | } 1750 | 1751 | $sel delete 1752 | 1753 | return $sa_list 1754 | } 1755 | 1756 | # calculate SASA/SAV/WCA by APBS 1757 | proc ::cafe::mmpbsa::run_apbs_apol { molid prefix selstr } { 1758 | variable first 1759 | variable stride 1760 | variable sa_exe 1761 | variable sa_prbrad 1762 | variable sa_samples 1763 | variable sa_gamma 1764 | variable sa_beta 1765 | variable debug 1766 | 1767 | set sa_list { } 1768 | set sel [atomselect $molid $selstr] 1769 | 1770 | for { set i 0 } { $i < [molinfo $molid get numframes] } { incr i } { 1771 | molinfo $molid set frame $i 1772 | set iframe [expr $first + $i*$stride] 1773 | 1774 | set tmp_prefix ${prefix}_sa_tmp_${iframe} 1775 | set tmp_pqr ${tmp_prefix}.pqr 1776 | write_pqr $sel $tmp_pqr 1777 | 1778 | set tmp_prm ${tmp_prefix}.apbs 1779 | set apbsin [open $tmp_prm w] 1780 | 1781 | puts $apbsin "read" 1782 | puts $apbsin " mol pqr $tmp_pqr" 1783 | puts $apbsin "end" 1784 | puts $apbsin "apolar name apol" 1785 | puts $apbsin " mol 1" 1786 | puts $apbsin " gamma 1" 1787 | puts $apbsin " press 0" 1788 | puts $apbsin " bconc 0" 1789 | puts $apbsin " dpos 0.01" 1790 | puts $apbsin " grid 0.5 0.5 0.5" 1791 | puts $apbsin " sdens $sa_samples" 1792 | puts $apbsin " srad $sa_prbrad" 1793 | puts $apbsin " srfm sacc" 1794 | puts $apbsin " swin 0.3" 1795 | puts $apbsin " temp 298.15" 1796 | puts $apbsin " calcenergy total" 1797 | puts $apbsin " calcforce no" 1798 | puts $apbsin "end" 1799 | puts $apbsin "print" 1800 | puts $apbsin " apolEnergy apol" 1801 | puts $apbsin "end" 1802 | puts $apbsin "quit" 1803 | 1804 | close $apbsin 1805 | 1806 | if { [file exists io.mc] } { file delete io.mc } 1807 | 1808 | set tmp_log ${tmp_prefix}.log 1809 | exec $sa_exe $tmp_prm > $tmp_log 1810 | 1811 | # the unit is angstrom^2 1812 | set sa_out [parse_apbs $tmp_log -sasa] 1813 | lappend sa_list $sa_out 1814 | 1815 | if { $debug < 2 } { cleanup ${prefix}_sa } 1816 | } 1817 | 1818 | $sel delete 1819 | 1820 | if { [file exists io.mc] } { file delete io.mc } 1821 | 1822 | return $sa_list 1823 | } 1824 | 1825 | -------------------------------------------------------------------------------- /src/cafe_tools.tcl: -------------------------------------------------------------------------------- 1 | package provide cafe_tools 1.0 2 | 3 | namespace eval ::cafe::tools:: { 4 | namespace export show timer check_file check_exe check_string check_bool \ 5 | check_int check_pos_int check_nneg_int check_real \ 6 | check_pos_real check_nneg_real write_item write_log \ 7 | parse_namd cleanup calc_stats 8 | } 9 | 10 | # print info/error messages 11 | proc ::cafe::tools::show { opt { msg "" } } { 12 | switch -- $opt { 13 | -info { 14 | puts "CaFE) $msg" 15 | } 16 | -err { 17 | error "CaFE) Error: $msg" 18 | } 19 | default { 20 | error "" 21 | } 22 | } 23 | } 24 | 25 | # a timer 26 | proc ::cafe::tools::timer { start } { 27 | set tmp [expr [clock seconds] - $start] 28 | set day [expr $tmp / 86400] 29 | set tmp [expr $tmp % 86400] 30 | set hrs [expr $tmp / 3600] 31 | set tmp [expr $tmp % 3600] 32 | set min [expr $tmp / 60] 33 | set sec [expr $tmp % 60] 34 | return [list $day $hrs $min $sec] 35 | } 36 | 37 | proc ::cafe::tools::check_file { s n } { 38 | if { [file exists $s] } { 39 | return $s 40 | } else { 41 | show -err "Cannot find file '$s' for '$n'" 42 | } 43 | } 44 | 45 | proc ::cafe::tools::check_exe { s n } { 46 | if { [file executable $s] } { 47 | return $s 48 | } else { 49 | # $tcl_platform(pathSeparator) is only in Tcl 8.6 and later 50 | # do nothing for macintosh and others 51 | switch -- $::tcl_platform(platform) { 52 | -unix { set sep ":" } 53 | -windows { set sep ";" } 54 | default { return $s } 55 | } 56 | 57 | foreach path [split $::env(PATH) $sep] { 58 | set exe [file join $path $s] 59 | if [file executable $exe] { return $s } 60 | } 61 | show -err "Expected an executable file for '$n' but got '$s'" 62 | } 63 | } 64 | 65 | proc ::cafe::tools::check_string { s n } { 66 | if { $s ne "" } { 67 | return [string tolower $s] 68 | } else { 69 | show -err "Expected a non-empty string for '$n'" 70 | } 71 | } 72 | 73 | proc ::cafe::tools::check_bool { s n } { 74 | if { [string is boolean $s] } { 75 | return $s 76 | } else { 77 | show -err "Expected a boolean for '$n' but got '$s'" 78 | } 79 | } 80 | 81 | proc ::cafe::tools::check_int { s n } { 82 | if { [string is integer -strict $s] } { 83 | return $s 84 | } else { 85 | show -err "Expected an integer for '$n' but got '$s'" 86 | } 87 | } 88 | 89 | proc ::cafe::tools::check_pos_int { s n } { 90 | if { [string is integer -strict $s] && $s > 0 } { 91 | return $s 92 | } else { 93 | show -err "Expected a positive integer for '$n' but got '$s'" 94 | } 95 | } 96 | 97 | proc ::cafe::tools::check_nneg_int { s n } { 98 | if { [string is integer -strict $s] && $s >= 0 } { 99 | return $s 100 | } else { 101 | show -err "Expected a non-negative integer for '$n' but got '$s'" 102 | } 103 | } 104 | 105 | proc ::cafe::tools::check_real { s n } { 106 | if { [string is double -strict $s] } { 107 | return $s 108 | } else { 109 | show -err "Expected a real for '$n' but got '$s'" 110 | } 111 | } 112 | 113 | proc ::cafe::tools::check_pos_real { s n } { 114 | if { [string is double -strict $s] && $s > 0 } { 115 | return $s 116 | } else { 117 | show -err "Expected a positive real for '$n' but got '$s'" 118 | } 119 | } 120 | 121 | proc ::cafe::tools::check_nneg_real { s n } { 122 | if { [string is double -strict $s] && $s >= 0 } { 123 | return $s 124 | } else { 125 | show -err "Expected a non-negative real for '$n' but got '$s'" 126 | } 127 | } 128 | 129 | proc ::cafe::tools::write_item { fp name data } { 130 | set fmt " %-6s %15d %15.4f %15.4f" 131 | foreach { mean sd } [calc_stats $data] { break } 132 | set n [llength $data] 133 | puts $fp [format $fmt $name $n $mean $sd] 134 | } 135 | 136 | proc ::cafe::tools::write_log { fname title fmt data } { 137 | if { [catch { set log [open $fname w] } err] } { 138 | show -err "Failed to write log file: $fname" 139 | } 140 | 141 | puts $log $title 142 | 143 | for { set i 0 } { $i < [llength [lindex $data 0]] } { incr i } { 144 | set s "\"$fmt\"" 145 | for { set j 0 } { $j < [llength $data] } { incr j } { 146 | append s " [lindex [lindex $data $j] $i]" 147 | } 148 | puts $log [eval format $s] 149 | } 150 | 151 | close $log 152 | } 153 | 154 | # parse a NAMD output file 155 | proc ::cafe::tools::parse_namd { fname } { 156 | if { [catch { set fp [open $fname r] } err] } { 157 | show -err "Failed to open NAMD log file: $fname" 158 | } 159 | 160 | set enerlists { } 161 | 162 | while { [gets $fp line] >= 0 } { 163 | if { [regexp {^ENERGY:} $line] } { 164 | set enerlist { } 165 | foreach item [split $line] { 166 | if { $item ne "" } { 167 | lappend enerlist $item 168 | } 169 | } 170 | # bond angle dihedral improper elec vdw 171 | lappend enerlists [lrange $enerlist 2 7] 172 | } 173 | } 174 | 175 | close $fp 176 | 177 | return $enerlists 178 | } 179 | 180 | # remove tmp files 181 | proc ::cafe::tools::cleanup { prefix } { 182 | foreach f [glob ${prefix}_tmp*] { 183 | file delete $f 184 | } 185 | } 186 | 187 | # statistical analysis 188 | proc ::cafe::tools::calc_stats { x } { 189 | # mean: 190 | # av = sum(x)/n 191 | # standard diviation (SD): 192 | # sd = sqrt(sum(x-av)^2/n) 193 | # standard error of the mean (SEM): 194 | # sem = sd/sqrt(n) 195 | set av [vecmean $x] 196 | set sd [vecstddev $x] 197 | 198 | return [list $av $sd] 199 | } 200 | 201 | -------------------------------------------------------------------------------- /src/pkgIndex.tcl: -------------------------------------------------------------------------------- 1 | # Tcl package index file, version 1.1 2 | # This file is generated by the "pkg_mkIndex" command 3 | # and sourced either when an application starts up or 4 | # by a "package unknown" script. It invokes the 5 | # "package ifneeded" command to set up package-related 6 | # information so that packages will be loaded automatically 7 | # in response to "package require" commands. When this 8 | # script is sourced, the variable $dir must contain the 9 | # full path name of this file's directory. 10 | 11 | package ifneeded cafe 1.0 [list source [file join $dir cafe.tcl]] 12 | package ifneeded cafe_tools 1.0 [list source [file join $dir cafe_tools.tcl]] 13 | package ifneeded cafe_mmpbsa 1.0 "set env(CAFEDIR) [list $dir] ; [list source [file join $dir cafe_mmpbsa.tcl]]" 14 | package ifneeded cafe_lie 1.0 "set env(CAFEDIR) [list $dir] ; [list source [file join $dir cafe_lie.tcl]]" 15 | 16 | --------------------------------------------------------------------------------