├── LICENSE ├── README.md ├── environment_gpu.yml ├── model ├── modelc.pth └── modelp.pth ├── result └── predict_test2016.csv ├── src ├── dataset.py ├── metrics.py ├── model.py ├── predict.py └── train.py └── test_set ├── Vina_terms13851.pkl ├── Vina_terms2013.pkl ├── Vina_terms2016.pkl ├── labels_test2013.csv ├── labels_test2016.csv ├── labels_train13851.csv ├── train_valte_comp.pkl └── train_valte_prot.pkl /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 | 635 | Copyright (C) 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 | Copyright (C) 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## About GraphscoreDTA 2 | 3 | GraphscoreDTA is an optimized graph neural network for protein-ligand binding affinity prediction. 4 | 5 | The benchmark dataset can be found in `./test_set/`. The GraphscoreDTA model is available in `./src/`. And the result will be generated in `./result/`. See our paper for more details. 6 | 7 | **[IMPORTANT] We provide the input file in the [release page](https://github.com/CSUBioGroup/GraphscoreDTA/releases/tag/Data).** Please download it to `./test_set/`. 8 | 9 | ### Requirements: 10 | - python 3.7.11 11 | - pytorch 1.9.0 12 | - scikit-learn 0.24.2 13 | - dgl 0.9.1.post1 14 | - tqdm 4.62.2 15 | - ipython 7.27.0 16 | - numpy 1.20.3 17 | - pandas 1.3.2 18 | - numba 0.53.1 19 | - scipy 1.7.1 20 | 21 | ### Installation 22 | 23 | In order to get GraphscoreDTA, you need to clone this repo: 24 | 25 | ```bash 26 | git clone https://github.com/CSUBioGroup/GraphscoreDTA 27 | cd GraphscoreDTA 28 | ``` 29 | The easiest way to install the required packages is to create environment with GPU-enabled version: 30 | ```bash 31 | conda env create -f environment_gpu.yml 32 | conda activate GraphscoreDTA 33 | ``` 34 | ### Predict 35 | 36 | to use our model 37 | ```bash 38 | cd ./src/ 39 | python predict.py 40 | ``` 41 | 42 | ### Training 43 | 44 | to train your own model 45 | ```bash 46 | cd ./src/ 47 | python train.py 48 | ``` 49 | 50 | ## Citation 51 | Wang K, Zhou R, Tang J, et al. GraphscoreDTA: optimized graph neural network for protein–ligand binding affinity prediction[J]. Bioinformatics, 2023, 39(6): btad340. 52 | 53 | ## Contact 54 | Kaili Wang: [kailiwang@dhu.edu.cn](mailto:kailiwang@dhu.edu.cn) 55 | 56 | You can also download the codes from https://github.com/KailiWang1/GraphscoreDTA 57 | -------------------------------------------------------------------------------- /environment_gpu.yml: -------------------------------------------------------------------------------- 1 | name: GraphscoreDTA 2 | channels: 3 | - pytorch 4 | - pypi 5 | - dglteam 6 | - defaults 7 | dependencies: 8 | - python=3.7.11 9 | - pytorch=1.9.0 10 | - scikit-learn=0.24.2 11 | - dgl-cuda10.2 12 | - tqdm=4.62.2 13 | - ipython=7.27.0 14 | - numpy=1.20.3 15 | - pandas=1.3.2 16 | - numba=0.53.1 17 | - scipy=1.7.1 -------------------------------------------------------------------------------- /model/modelc.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/model/modelc.pth -------------------------------------------------------------------------------- /model/modelp.pth: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/model/modelp.pth -------------------------------------------------------------------------------- /result/predict_test2016.csv: -------------------------------------------------------------------------------- 1 | ,pdbid,predicted,real,set 2 | 0,2v7a,7.6303573,8.3,test2016 3 | 1,4dld,7.873048,5.82,test2016 4 | 2,3l7b,4.6245966,2.4,test2016 5 | 3,3zdg,5.9849367,7.1,test2016 6 | 4,2xys,7.237025,7.42,test2016 7 | 5,3b65,9.411119,9.27,test2016 8 | 6,3dd0,7.4992,9.0,test2016 9 | 7,3d4z,5.805631,4.89,test2016 10 | 8,1owh,6.4837055,7.4,test2016 11 | 9,2x00,8.75426,11.33,test2016 12 | 10,4tmn,7.755299,10.17,test2016 13 | 11,3b5r,9.680069,8.77,test2016 14 | 12,1z6e,10.391121,9.72,test2016 15 | 13,3acw,6.3909254,4.76,test2016 16 | 14,3rsx,4.7372603,4.41,test2016 17 | 15,1uto,3.4435027,2.27,test2016 18 | 16,3fur,8.225012,8.0,test2016 19 | 17,4u4s,4.699029,2.92,test2016 20 | 18,2wbg,6.9708347,4.45,test2016 21 | 19,3n86,6.4653425,5.64,test2016 22 | 20,1bcu,4.1381946,3.28,test2016 23 | 21,1w4o,5.5914364,5.22,test2016 24 | 22,4ciw,5.7581167,4.82,test2016 25 | 23,4wiv,6.5986557,6.26,test2016 26 | 24,3coz,6.456817,5.57,test2016 27 | 25,3ueu,5.6081324,5.24,test2016 28 | 26,3n7a,4.8354597,3.7,test2016 29 | 27,3ryj,7.7368197,7.8,test2016 30 | 28,2xb8,6.5363717,7.59,test2016 31 | 29,3dxg,4.619605,2.4,test2016 32 | 30,2wvt,6.4094086,6.12,test2016 33 | 31,3gr2,3.7336683,2.52,test2016 34 | 32,2c3i,6.9618106,7.6,test2016 35 | 33,4ih5,5.5253396,4.11,test2016 36 | 34,3fcq,5.039253,2.77,test2016 37 | 35,4j28,6.296357,5.7,test2016 38 | 36,2wca,6.2217593,5.6,test2016 39 | 37,1o3f,6.7167664,7.96,test2016 40 | 38,3ao4,4.8489695,2.07,test2016 41 | 39,3kgp,3.362556,2.57,test2016 42 | 40,3gv9,4.176258,2.12,test2016 43 | 41,4ddk,3.3901515,2.29,test2016 44 | 42,2xii,8.096202,7.2,test2016 45 | 43,4f09,7.366829,6.7,test2016 46 | 44,1nc3,9.765774,5.0,test2016 47 | 45,2xj7,6.307228,6.66,test2016 48 | 46,1s38,6.0069504,5.15,test2016 49 | 47,3u9q,5.5265017,4.38,test2016 50 | 48,4m0z,8.85213,5.19,test2016 51 | 49,3aru,4.5950613,3.22,test2016 52 | 50,3u8n,7.6959057,10.17,test2016 53 | 51,1syi,6.4097133,5.44,test2016 54 | 52,5tmn,7.192945,8.04,test2016 55 | 53,4bkt,4.6998386,3.62,test2016 56 | 54,3arv,6.0708714,5.64,test2016 57 | 55,4f9w,7.132108,6.94,test2016 58 | 56,1k1i,7.182219,6.58,test2016 59 | 57,1g2k,9.27205,7.96,test2016 60 | 58,3mss,4.501284,4.66,test2016 61 | 59,1q8t,6.1461234,4.76,test2016 62 | 60,2qbq,7.175554,7.44,test2016 63 | 61,3coy,6.6698203,6.02,test2016 64 | 62,4mgd,6.4333825,4.69,test2016 65 | 63,3gy4,4.2233167,5.1,test2016 66 | 64,3up2,7.7981477,7.4,test2016 67 | 65,1z95,8.948653,7.12,test2016 68 | 66,2brb,5.7621856,4.86,test2016 69 | 67,4jxs,5.6384096,4.74,test2016 70 | 68,3pxf,4.798699,4.43,test2016 71 | 69,2wn9,6.8261495,8.52,test2016 72 | 70,4k18,8.28023,8.96,test2016 73 | 71,3tsk,9.032233,7.17,test2016 74 | 72,3u8k,7.1196527,8.66,test2016 75 | 73,3u5j,6.9128447,5.61,test2016 76 | 74,4rfm,8.480545,10.05,test2016 77 | 75,4eky,6.1730213,3.52,test2016 78 | 76,4f2w,9.776813,11.3,test2016 79 | 77,1gpk,7.3712363,5.37,test2016 80 | 78,4w9c,5.6894813,4.65,test2016 81 | 79,4w9l,7.177781,5.02,test2016 82 | 80,1ydt,7.020065,7.32,test2016 83 | 81,3twp,4.454733,3.92,test2016 84 | 82,1o5b,4.92477,5.77,test2016 85 | 83,1h22,7.9882755,9.1,test2016 86 | 84,3g31,2.312668,2.89,test2016 87 | 85,2wtv,8.124891,8.74,test2016 88 | 86,2j7h,6.470794,7.19,test2016 89 | 87,3utu,8.682378,10.92,test2016 90 | 88,4cig,7.141781,3.67,test2016 91 | 89,3bgz,6.8940854,6.26,test2016 92 | 90,3e5a,7.71851,8.23,test2016 93 | 91,3uex,6.518548,6.92,test2016 94 | 92,1z9g,5.8198056,5.64,test2016 95 | 93,3n76,6.6049366,6.85,test2016 96 | 94,4gr0,9.633907,9.55,test2016 97 | 95,4m0y,7.048541,6.46,test2016 98 | 96,4ea2,7.2346992,6.44,test2016 99 | 97,4gfm,7.30906,7.22,test2016 100 | 98,2xnb,7.5775256,6.83,test2016 101 | 99,3g0w,9.283262,9.52,test2016 102 | 100,2vw5,7.2913218,8.52,test2016 103 | 101,3g2n,4.996393,4.09,test2016 104 | 102,2j78,6.934214,6.42,test2016 105 | 103,2xbv,8.477117,8.43,test2016 106 | 104,4kzq,6.213276,6.1,test2016 107 | 105,3dx1,5.579704,3.58,test2016 108 | 106,2wnc,7.027504,6.32,test2016 109 | 107,3d6q,4.7493453,3.76,test2016 110 | 108,1qf1,7.661256,7.32,test2016 111 | 109,2yki,8.259633,9.46,test2016 112 | 110,3f3d,6.2350883,7.16,test2016 113 | 111,2p4y,8.427146,9.0,test2016 114 | 112,5c28,5.683432,5.66,test2016 115 | 113,3wtj,6.637191,6.53,test2016 116 | 114,4de1,6.072432,5.96,test2016 117 | 115,2wer,6.0601726,7.05,test2016 118 | 116,3lka,5.263263,2.82,test2016 119 | 117,4cr9,5.4938035,4.1,test2016 120 | 118,4e6q,7.8986945,8.36,test2016 121 | 119,3pww,8.596116,7.32,test2016 122 | 120,4mme,6.78308,6.5,test2016 123 | 121,2xdl,4.844299,3.1,test2016 124 | 122,4agq,5.264821,5.01,test2016 125 | 123,2hb1,4.5040526,3.8,test2016 126 | 124,4k77,7.6139092,6.63,test2016 127 | 125,2br1,7.7452245,5.14,test2016 128 | 126,4dli,6.560338,5.62,test2016 129 | 127,3ge7,7.858788,8.7,test2016 130 | 128,3ehy,6.5198665,5.85,test2016 131 | 129,3uew,5.8085804,6.31,test2016 132 | 130,2zda,6.406876,8.4,test2016 133 | 131,1yc1,6.6333866,6.17,test2016 134 | 132,3pyy,5.896455,6.86,test2016 135 | 133,2weg,6.5540404,6.5,test2016 136 | 134,3jvs,7.265838,6.54,test2016 137 | 135,3fv1,8.233913,9.3,test2016 138 | 136,4ogj,7.4885216,6.79,test2016 139 | 137,3ary,4.879796,6.0,test2016 140 | 138,3ozt,7.145324,4.13,test2016 141 | 139,4w9i,5.7115684,5.96,test2016 142 | 140,2cet,7.9025836,8.02,test2016 143 | 141,3p5o,7.3898797,7.26,test2016 144 | 142,1q8u,6.262714,5.96,test2016 145 | 143,3jvr,7.170198,5.72,test2016 146 | 144,1qkt,7.958788,9.04,test2016 147 | 145,3ivg,6.654808,4.3,test2016 148 | 146,1p1q,6.3220615,4.89,test2016 149 | 147,4kzu,6.912194,6.5,test2016 150 | 148,3b27,5.2588444,5.16,test2016 151 | 149,4ivb,9.33064,8.72,test2016 152 | 150,1h23,8.293453,8.35,test2016 153 | 151,2zcq,6.760478,8.82,test2016 154 | 152,2yfe,5.9513025,6.63,test2016 155 | 153,4ddh,4.250196,3.3,test2016 156 | 154,4abg,4.592633,3.57,test2016 157 | 155,1ydr,6.185873,5.52,test2016 158 | 156,3qgy,7.992554,7.8,test2016 159 | 157,3dx2,5.370128,6.82,test2016 160 | 158,3cj4,6.7300024,6.51,test2016 161 | 159,3nq9,4.7073946,4.03,test2016 162 | 160,1gpn,7.7713556,6.48,test2016 163 | 161,1pxn,7.0876474,7.15,test2016 164 | 162,4f3c,10.561628,11.82,test2016 165 | 163,4cra,8.143695,7.22,test2016 166 | 164,3e93,8.854314,8.85,test2016 167 | 165,3myg,8.250257,10.7,test2016 168 | 166,3f3c,6.573939,6.02,test2016 169 | 167,4ih7,5.7807884,5.24,test2016 170 | 168,1c5z,3.8498063,4.01,test2016 171 | 169,4kz6,4.5549107,3.1,test2016 172 | 170,3ozs,6.554404,5.33,test2016 173 | 171,3oe4,6.664712,7.47,test2016 174 | 172,4qd6,6.9185853,8.64,test2016 175 | 173,3e92,8.488787,8.0,test2016 176 | 174,3f3e,6.146279,7.7,test2016 177 | 175,2yge,6.075923,5.06,test2016 178 | 176,1sqa,7.7434435,9.21,test2016 179 | 177,3syr,5.2938275,5.1,test2016 180 | 178,3ui7,8.097094,9.0,test2016 181 | 179,4jia,7.329177,9.22,test2016 182 | 180,4eor,7.7379026,6.3,test2016 183 | 181,2qbr,6.196664,6.33,test2016 184 | 182,4j3l,7.894313,7.8,test2016 185 | 183,1mq6,9.910781,11.15,test2016 186 | 184,5dwr,8.714201,11.22,test2016 187 | 185,3qqs,5.9713583,5.82,test2016 188 | 186,4crc,9.008612,8.72,test2016 189 | 187,3kwa,7.462444,4.08,test2016 190 | 188,1e66,7.8522396,9.89,test2016 191 | 189,3f3a,5.9470005,4.19,test2016 192 | 190,5c2h,9.839066,11.09,test2016 193 | 191,3uuo,7.794179,7.96,test2016 194 | 192,3gc5,7.0315323,7.26,test2016 195 | 193,1p1n,6.674413,6.8,test2016 196 | 194,2ymd,6.142821,3.16,test2016 197 | 195,2cbv,6.6532726,5.48,test2016 198 | 196,3b1m,7.7574472,8.48,test2016 199 | 197,4jfs,6.3394613,5.27,test2016 200 | 198,3jya,6.7049465,6.89,test2016 201 | 199,3rlr,7.006081,7.52,test2016 202 | 200,1u1b,7.2163095,7.8,test2016 203 | 201,3prs,7.3524,7.82,test2016 204 | 202,2p15,9.311235,10.3,test2016 205 | 203,3uo4,7.592238,6.52,test2016 206 | 204,5aba,4.378899,2.98,test2016 207 | 205,4lzs,6.072438,4.8,test2016 208 | 206,2qbp,7.14246,8.4,test2016 209 | 207,3oe5,7.1906104,6.88,test2016 210 | 208,1o0h,6.256222,5.92,test2016 211 | 209,2y5h,8.694404,5.79,test2016 212 | 210,2r9w,6.022336,5.1,test2016 213 | 211,2pog,7.712463,9.54,test2016 214 | 212,2vvn,6.8440804,7.3,test2016 215 | 213,4e5w,9.195507,7.66,test2016 216 | 214,3arp,7.4546103,7.15,test2016 217 | 215,4ivc,9.843692,10.0,test2016 218 | 216,1ps3,4.6830053,2.28,test2016 219 | 217,5a7b,5.4405527,3.57,test2016 220 | 218,2iwx,5.934406,6.68,test2016 221 | 219,1r5y,6.0517054,6.46,test2016 222 | 220,3udh,4.056195,2.85,test2016 223 | 221,1nc1,8.033656,6.12,test2016 224 | 222,4de3,5.825116,5.52,test2016 225 | 223,3zso,7.8449097,5.12,test2016 226 | 224,4ivd,9.524307,9.52,test2016 227 | 225,4djv,6.4546037,6.72,test2016 228 | 226,3ejr,7.1626663,8.57,test2016 229 | 227,4agp,5.131384,4.69,test2016 230 | 228,4w9h,6.6891475,6.73,test2016 231 | 229,3o9i,8.965921,11.82,test2016 232 | 230,1eby,9.356077,9.7,test2016 233 | 231,2qnq,8.740219,6.11,test2016 234 | 232,1oyt,6.8518834,7.24,test2016 235 | 233,3gnw,8.350996,9.1,test2016 236 | 234,4j21,7.786333,7.41,test2016 237 | 235,1vso,6.949091,4.72,test2016 238 | 236,4pcs,6.3378606,7.85,test2016 239 | 237,3zsx,7.0306234,3.28,test2016 240 | 238,4jsz,5.929236,2.3,test2016 241 | 239,1nvq,9.328385,8.25,test2016 242 | 240,1bzc,6.64793,4.92,test2016 243 | 241,4de2,6.1416984,4.12,test2016 244 | 242,4gid,9.347021,10.77,test2016 245 | 243,3uev,5.951255,5.89,test2016 246 | 244,2fvd,7.935787,8.52,test2016 247 | 245,4gkm,6.0913544,5.17,test2016 248 | 246,3k5v,6.081811,6.3,test2016 249 | 247,3ebp,5.6452465,5.91,test2016 250 | 248,3gbb,7.261223,6.9,test2016 251 | 249,2w66,6.439715,4.05,test2016 252 | 250,2fxs,6.385102,6.06,test2016 253 | 251,3r88,4.8311443,4.82,test2016 254 | 252,3rr4,6.5643177,4.55,test2016 255 | 253,2vkm,9.193043,8.74,test2016 256 | 254,4agn,5.050665,3.97,test2016 257 | 255,3kr8,7.4719357,8.1,test2016 258 | 256,4qac,9.012026,9.4,test2016 259 | 257,4owm,4.0151052,2.96,test2016 260 | 258,3arq,6.394947,6.4,test2016 261 | 259,2zb1,7.891885,6.32,test2016 262 | 260,3g2z,3.2193325,2.36,test2016 263 | 261,4hge,8.539055,7.92,test2016 264 | 262,4twp,7.186953,10.0,test2016 265 | 263,2w4x,5.172502,4.85,test2016 266 | 264,3wz8,6.919074,5.82,test2016 267 | 265,3fv2,7.5154085,8.11,test2016 268 | 266,1lpg,8.856076,7.09,test2016 269 | 267,3nw9,8.7463875,9.0,test2016 270 | 268,4llx,4.46778,2.89,test2016 271 | 269,4eo8,7.170371,8.15,test2016 272 | 270,3nx7,7.09548,8.1,test2016 273 | 271,1y6r,9.657782,10.11,test2016 274 | 272,4ty7,8.774184,9.52,test2016 275 | 273,3b68,9.309081,8.4,test2016 276 | 274,2al5,6.62235,8.4,test2016 277 | 275,2qe4,8.151821,7.96,test2016 278 | 276,4x6p,10.029287,8.3,test2016 279 | 277,2v00,3.4644861,3.66,test2016 280 | 278,3zt2,6.388214,2.84,test2016 281 | -------------------------------------------------------------------------------- /src/dataset.py: -------------------------------------------------------------------------------- 1 | from torch.utils.data import Dataset 2 | import numpy as np 3 | import dgl 4 | import torch 5 | 6 | class WholeDataset(Dataset): 7 | def __init__(self, graphs, vina, labels, affinities): 8 | self.graphs = graphs 9 | self.vina = vina 10 | self.labels = labels 11 | self.affinities = affinities 12 | self.length = len(labels) 13 | 14 | def __getitem__(self, index: int): 15 | return (self.graphs[index], self.vina[index], self.affinities[index]) 16 | 17 | def get_name(self, index): 18 | return self.labels[index] 19 | 20 | def __len__(self) -> int: 21 | return self.length 22 | 23 | class SepDataset(WholeDataset): 24 | def __init__(self, graphs, vina, labels, affinities, edge_types): 25 | super().__init__(graphs, vina, labels, affinities) 26 | self.edge_types = edge_types 27 | def __getitem__(self, index: int): 28 | g = self.graphs[index] 29 | sub_gs = [g.edge_type_subgraph((i,)) for i in self.edge_types] 30 | return (*sub_gs, self.vina[index], self.affinities[index], self.labels[index]) 31 | 32 | def collate_fn(data): 33 | *gs, vina, labels, idlist = zip(*data) 34 | vina_list = [] 35 | for vina_i in vina: 36 | vina_list.append(list(vina_i)) 37 | vina = np.array(vina_list) 38 | labels = torch.tensor(labels) 39 | vina = torch.tensor(vina) 40 | gs = [dgl.batch(i) for i in gs] 41 | 42 | return gs+ [labels.float()], vina, idlist 43 | -------------------------------------------------------------------------------- /src/metrics.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import sklearn.metrics as m 3 | from scipy.stats import pearsonr 4 | from numba import njit 5 | 6 | @njit 7 | def c_index(y_true, y_pred): 8 | summ = 0 9 | pair = 0 10 | 11 | for i in range(1, len(y_true)): 12 | for j in range(0, i): 13 | pair += 1 14 | if y_true[i] > y_true[j]: 15 | summ += 1 * (y_pred[i] > y_pred[j]) + 0.5 * (y_pred[i] == y_pred[j]) 16 | elif y_true[i] < y_true[j]: 17 | summ += 1 * (y_pred[i] < y_pred[j]) + 0.5 * (y_pred[i] == y_pred[j]) 18 | else: 19 | pair -= 1 20 | if pair != 0: 21 | return summ / pair 22 | else: 23 | return 0 24 | 25 | def RMSE(y_true, y_pred): 26 | return np.sqrt(m.mean_squared_error(y_true, y_pred)) 27 | 28 | def MAE(y_true, y_pred): 29 | return m.mean_absolute_error(y_true, y_pred) 30 | 31 | def CORR(y_true, y_pred): 32 | return pearsonr(y_true, y_pred)[0] 33 | 34 | def SD(y_true, y_pred): 35 | from sklearn.linear_model import LinearRegression 36 | y_pred = y_pred.reshape((-1,1)) 37 | lr = LinearRegression().fit(y_pred,y_true) 38 | y_ = lr.predict(y_pred) 39 | return np.sqrt(np.square(y_true - y_).sum() / (len(y_pred) - 1)) 40 | -------------------------------------------------------------------------------- /src/model.py: -------------------------------------------------------------------------------- 1 | import dgl 2 | import dgl.function as dglfn 3 | import dgl.nn.pytorch as dglnn 4 | import numpy as np 5 | import torch 6 | import torch.nn as nn 7 | import torch.nn.functional as F 8 | 9 | 10 | class ModelNew(nn.Module): 11 | 12 | def __init__(self): 13 | super().__init__() 14 | self.a_init = nn.Linear(82, 120) 15 | self.b_init = nn.Linear(12, 8) 16 | self.r_init_1 = nn.Linear(20, 9) 17 | self.r_init_2 = nn.Linear(9 + 21, 120) 18 | # message transport 19 | self.r_mt = MT(120) 20 | self.a_mt = MT(120) 21 | # ligand 22 | self.A = nn.Linear(120, 120) 23 | self.B = nn.Linear(120*2,120) 24 | self.a_conv1 = SConv1(120, 8, 120, 4) 25 | self.a_conv2 = SConv1(120, 8, 120, 4) 26 | # protein 27 | self.C = nn.Linear(120, 120) 28 | self.D = nn.Linear(120*2,120) 29 | self.r_conv1 = SConvr1(120, 0, 120, 4) 30 | self.r_conv2 = SConvr1(120, 0, 120, 4) 31 | # interaction 32 | self.i_conf = DistanceConv(120, 8, 3) 33 | # predict 34 | self.classifier = nn.Sequential( 35 | nn.Linear(120 + 120 + 120 + 6, 298), 36 | nn.PReLU(), 37 | nn.Linear(298, 160), 38 | nn.PReLU(), 39 | nn.Linear(160, 1) 40 | ) 41 | 42 | self.sum_pool = dglnn.SumPooling() 43 | self.mean_pool = dglnn.AvgPooling() 44 | 45 | def forward(self, ga, gr, gi, vina): 46 | device = torch.device("cuda:0") 47 | ga = ga.to('cuda:0') 48 | gr = gr.to('cuda:0') 49 | gi = gi.to('cuda:0') 50 | vina = vina.to('cuda:0') 51 | 52 | va_init = self.a_init(ga.ndata['feat']) 53 | ea = self.b_init(ga.edata['feat']) 54 | vr = self.r_init_1(gr.ndata['feat'][:, :20]) 55 | vr = torch.cat((vr, gr.ndata['feat'][:, 20:]), -1) 56 | vr_init = self.r_init_2(vr) 57 | 58 | vi_a = self.a_init(gi.ndata['feat']['atom']) 59 | vi_r = self.r_init_1(gi.ndata['feat']['residue'][:, :20]) 60 | vi_r = torch.cat((vi_r, gi.ndata['feat']['residue'][:, 20:]), -1) 61 | vi_r = self.r_init_2(vi_r) 62 | vi_init = torch.cat((vi_a, vi_r), dim=0) 63 | ei = gi.edata['weight'].reshape(-1) 64 | ei = torch.cat((ei, ei)).unsqueeze(1) 65 | 66 | gii = dgl.add_reverse_edges(dgl.to_homogeneous(gi)) 67 | gii.set_batch_num_nodes(gi.batch_num_nodes('atom') + gi.batch_num_nodes('residue')) 68 | gii.set_batch_num_edges(gi.batch_num_edges() * 2) 69 | va = self.a_mt(gr, vr_init, ga, va_init) 70 | vr = self.r_mt(ga, va_init, gr, vr_init) 71 | # ligand 72 | va = F.leaky_relu(self.A(va), 0.1) 73 | sa = self.sum_pool(ga, va) 74 | va, sa = self.a_conv1(ga, va, ea, sa) 75 | va, sa = self.a_conv2(ga, va+va_init, ea, sa) 76 | fa = torch.cat((self.mean_pool(ga, va), sa), dim=-1) 77 | fa = self.B(fa) 78 | fa = fa + self.mean_pool(ga,va_init) 79 | vr = F.leaky_relu(self.C(vr), 0.1) 80 | sr = self.sum_pool(gr, vr) 81 | vr, sr = self.r_conv1(gr, vr, torch.Tensor().reshape(gr.num_edges(),-1).to(device), sr) 82 | vr, sr = self.r_conv2(gr, vr+vr_init, torch.Tensor().reshape(gr.num_edges(),-1).to(device), sr) 83 | fr = torch.cat((self.mean_pool(gr, vr), sr), dim=-1) 84 | fr = self.D(fr) 85 | fr = fr + self.mean_pool(gr,vr_init) 86 | # interaction 87 | vi = self.i_conf(gii, vi_init, ei) 88 | vi = vi + vi_init 89 | 90 | fi = self.mean_pool(gii, vi) 91 | f = torch.cat((fa, fr, fi, vina), dim=-1) 92 | y = self.classifier(f) 93 | 94 | return y 95 | 96 | class MT(nn.Module): 97 | 98 | def __init__(self, in_dim): 99 | super().__init__() 100 | 101 | self.A = nn.Linear(in_dim, 64) 102 | self.B = nn.Linear(in_dim, 8) 103 | self.C = nn.Linear(64, in_dim) 104 | self.sum_pool = dglnn.SumPooling() 105 | self.D = nn.Linear(in_dim, 120) 106 | self.E = nn.Linear(in_dim, 120) 107 | 108 | def forward(self, ga, va, gb, vb): 109 | s = self.A(va) 110 | h = self.B(va) 111 | with ga.local_scope(): 112 | ga.ndata['h'] = h 113 | h = dgl.softmax_nodes(ga, 'h') 114 | ga.ndata['h'] = h 115 | ga.ndata['s'] = s 116 | gga = dgl.unbatch(ga) 117 | gp_ = torch.stack([torch.mm(g.ndata['s'].T, g.ndata['h']) for g in gga]) 118 | gp_ = self.C(gp_.mean(dim=-1)) 119 | 120 | gp2_ = self.D(gp_) 121 | gp3_ = dgl.broadcast_nodes(gb, gp2_) 122 | gp3_ = gp3_.permute(1,0) 123 | r_ = torch.sum(torch.mm(self.E(vb),gp3_),dim=-1) 124 | pad_ = torch.sigmoid(r_) 125 | vbb = vb + vb * pad_.unsqueeze(1) 126 | 127 | return vbb 128 | 129 | class SConv1(nn.Module): 130 | def __init__(self, v_dim, e_dim, h_dim, k_head): 131 | super().__init__() 132 | 133 | self.A = nn.Linear(v_dim, h_dim) 134 | self.m2s = nn.ModuleList([SConv1.Helper(v_dim, h_dim) for _ in range(k_head)]) 135 | self.B = nn.Linear(h_dim * k_head, h_dim) 136 | self.C = nn.Linear(v_dim, h_dim) 137 | self.D = nn.Linear(e_dim + v_dim, h_dim) 138 | self.E = nn.Linear(h_dim + v_dim, h_dim) 139 | self.K = nn.Linear(e_dim, h_dim) 140 | self.gate_update_m = SConv1.GateUpdate(h_dim) 141 | self.gate_update_s = SConv1.GateUpdate(h_dim) 142 | 143 | def __msg_func(self, edges): 144 | v = edges.src['v'] 145 | e = edges.data['e'] 146 | 147 | return {'ve': F.leaky_relu(self.K(e) * v,0.1)} 148 | 149 | def forward(self, g, v, e, s): 150 | s2s = torch.tanh(self.A(s)) 151 | m2s = torch.cat([layer(g, v, s) for layer in self.m2s],dim=1) 152 | m2s = torch.tanh(self.B(m2s)) 153 | s2m = torch.tanh(self.C(s)) 154 | s2m = dgl.broadcast_nodes(g, s2m) 155 | 156 | with g.local_scope(): 157 | g.ndata['v'] = v 158 | g.edata['e'] = e 159 | g.update_all(self.__msg_func, dglfn.sum('ve', 'sve')) 160 | svev = torch.cat((g.ndata['sve'], v),dim=1) 161 | m2m = F.leaky_relu(self.E(svev), 0.1 ) 162 | vv = self.gate_update_m(m2m, s2m, v) 163 | ss = self.gate_update_s(s2s, m2s, s) 164 | 165 | return vv, ss 166 | 167 | class Helper(nn.Module): 168 | def __init__(self, v_dim, h_dim): 169 | super().__init__() 170 | 171 | self.A = nn.Linear(v_dim, h_dim) 172 | self.B = nn.Linear(v_dim, h_dim) 173 | self.C = nn.Linear(h_dim, 1) 174 | self.D = nn.Linear(v_dim, h_dim) 175 | 176 | def forward(self, g, v, s): 177 | d_node = torch.tanh(self.A(v)) 178 | d_super = torch.tanh(self.B(s)) 179 | d_super = dgl.broadcast_nodes(g, d_super) 180 | 181 | a = self.C(d_node * d_super).reshape(-1) 182 | 183 | with g.local_scope(): 184 | g.ndata['a'] = a 185 | a = dgl.softmax_nodes(g, 'a') 186 | 187 | g.ndata['h'] = self.D(v) * a.unsqueeze(1) 188 | main2super_i = dgl.sum_nodes(g, 'h') 189 | 190 | return main2super_i 191 | 192 | class GateUpdate(nn.Module): 193 | 194 | def __init__(self, h_dim): 195 | super().__init__() 196 | 197 | self.A = nn.Linear(h_dim, h_dim) 198 | self.B = nn.Linear(h_dim, h_dim) 199 | self.gru = nn.GRUCell(h_dim, h_dim) 200 | 201 | def forward(self, a, b, c): 202 | z = torch.sigmoid(self.A(a) + self.B(b)) 203 | h = z * b + (1 - z) * a 204 | cc = self.gru(c, h) 205 | return cc 206 | 207 | class SConvr1(nn.Module): 208 | def __init__(self, v_dim, e_dim, h_dim, k_head): 209 | super().__init__() 210 | 211 | self.A = nn.Linear(v_dim, h_dim) 212 | self.m2s = nn.ModuleList([SConvr1.Helper(v_dim, h_dim) for _ in range(k_head)]) 213 | self.B = nn.Linear(h_dim * k_head, h_dim) 214 | self.C = nn.Linear(v_dim, h_dim) 215 | self.D = nn.Linear(e_dim + v_dim, h_dim) 216 | self.E = nn.Linear(h_dim + v_dim, h_dim) 217 | self.gate_update_m = SConvr1.GateUpdate(h_dim) 218 | self.gate_update_s = SConvr1.GateUpdate(h_dim) 219 | 220 | def __msg_func(self, edges): 221 | v = edges.src['v'] 222 | e = edges.data['e'] 223 | return {'ve': F.leaky_relu(v,0.1)} 224 | 225 | def forward(self, g, v, e, s): 226 | s2s = torch.tanh(self.A(s)) 227 | m2s = torch.cat([layer(g, v, s) for layer in self.m2s],dim=1) 228 | m2s = torch.tanh(self.B(m2s)) 229 | s2m = torch.tanh(self.C(s)) 230 | s2m = dgl.broadcast_nodes(g, s2m) 231 | 232 | with g.local_scope(): 233 | g.ndata['v'] = v 234 | g.edata['e'] = e 235 | g.update_all(self.__msg_func, dglfn.sum('ve', 'sve')) 236 | svev = torch.cat((g.ndata['sve'], v),dim=1) 237 | m2m = F.leaky_relu(self.E(svev), 0.1 ) 238 | vv = self.gate_update_m(m2m, s2m, v) 239 | ss = self.gate_update_s(s2s, m2s, s) 240 | 241 | return vv, ss 242 | 243 | class Helper(nn.Module): 244 | def __init__(self, v_dim, h_dim): 245 | super().__init__() 246 | self.A = nn.Linear(v_dim, h_dim) 247 | self.B = nn.Linear(v_dim, h_dim) 248 | self.C = nn.Linear(h_dim, 1) 249 | self.D = nn.Linear(v_dim, h_dim) 250 | 251 | def forward(self, g, v, s): 252 | d_node = torch.tanh(self.A(v)) 253 | d_super = torch.tanh(self.B(s)) 254 | d_super = dgl.broadcast_nodes(g, d_super) 255 | a = self.C(d_node * d_super).reshape(-1) 256 | 257 | with g.local_scope(): 258 | g.ndata['a'] = a 259 | a = dgl.softmax_nodes(g, 'a') 260 | g.ndata['h'] = self.D(v) * a.unsqueeze(1) 261 | main2super_i = dgl.sum_nodes(g, 'h') 262 | 263 | return main2super_i 264 | 265 | class GateUpdate(nn.Module): 266 | def __init__(self, h_dim): 267 | super().__init__() 268 | self.A = nn.Linear(h_dim, h_dim) 269 | self.B = nn.Linear(h_dim, h_dim) 270 | self.gru = nn.GRUCell(h_dim, h_dim) 271 | 272 | def forward(self, a, b, c): 273 | z = torch.sigmoid(self.A(a) + self.B(b)) 274 | h = z * b + (1 - z) * a 275 | cc = self.gru(c, h) 276 | return cc 277 | 278 | class DistanceConv(nn.Module): 279 | 280 | def __init__(self, dim, rc, depth): 281 | super().__init__() 282 | self.rs = nn.Parameter(torch.rand(1)) 283 | self.sigma = nn.Parameter(torch.rand(1)) 284 | self.A = nn.Linear(dim, dim) 285 | self.rc = rc 286 | self.depth = depth 287 | 288 | def f(self, r): 289 | return torch.exp((-torch.square(r - self.rs) / torch.square(self.sigma))) * \ 290 | 0.5 * torch.cos(np.pi * r / self.rc) * (r < self.rc) 291 | 292 | def __msg_func(self, edges): 293 | v = edges.src['v'] 294 | f = edges.data['f'] 295 | return {'vf': f * v} 296 | 297 | def forward(self, g, v, e): 298 | with g.local_scope(): 299 | g.ndata['v'] = v 300 | g.edata['f'] = self.f(e) 301 | for _ in range(self.depth): 302 | g.update_all(self.__msg_func, dglfn.sum('vf', 'svf')) 303 | g.ndata['v'] = torch.relu(self.A(g.ndata['svf']+v)) 304 | v = g.ndata['v'] 305 | 306 | return v 307 | -------------------------------------------------------------------------------- /src/predict.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | from datetime import datetime 4 | import numpy as np 5 | import pandas as pd 6 | import torch 7 | import torch.nn as nn 8 | import torch.nn.functional as F 9 | from torch.utils.data import DataLoader 10 | # from tqdm import tqdm_notebook as tqdm 11 | import pickle 12 | import random 13 | from sklearn.model_selection import KFold, train_test_split 14 | import dgl 15 | import dgl.nn.pytorch as dglnn 16 | import dgl.function as dglfn 17 | from collections import deque 18 | from tqdm.auto import tqdm 19 | from IPython.display import clear_output 20 | 21 | from dataset import SepDataset, collate_fn 22 | from model import ModelNew 23 | import metrics 24 | 25 | def test(model, valid_loader_compound, criterion,device): 26 | model.eval() 27 | losses = [] 28 | outputs = [] 29 | targets = [] 30 | name_list =[] 31 | tbar = tqdm(valid_loader_compound, total=len(valid_loader_compound)) 32 | for i, data in enumerate(tbar): 33 | data0 = [i.to(device) for i in data[0]] 34 | ga, gr, gi, aff = data0 35 | vina = data[1] 36 | idnames = data[2] 37 | name_l = [] 38 | for name in idnames: 39 | name_l.append(name) 40 | name_list.append(name_l) 41 | with torch.no_grad(): 42 | y_pred = model(ga,gr,gi,vina).squeeze() 43 | y_true = aff.float().squeeze() 44 | assert y_pred.shape == y_true.shape 45 | loss = criterion(y_pred,y_true).cuda() 46 | losses.append(loss.item()) 47 | outputs.append(y_pred.cpu().detach().numpy().reshape(-1)) 48 | targets.append(y_true.cpu().detach().numpy().reshape(-1)) 49 | targets = np.concatenate(targets).reshape(-1) 50 | outputs = np.concatenate(outputs).reshape(-1) 51 | name_list = np.concatenate(name_list).reshape(-1) 52 | evaluation = { 53 | 'c_index': metrics.c_index(targets, outputs), 54 | 'RMSE': metrics.RMSE(targets, outputs), 55 | 'MAE': metrics.MAE(targets, outputs), 56 | 'SD': metrics.SD(targets, outputs), 57 | 'CORR': metrics.CORR(targets, outputs),} 58 | 59 | return evaluation,targets, outputs, name_list 60 | 61 | def main(): 62 | flag = 'predict' 63 | model_path = '../model/modelp.pth' 64 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu") 65 | SHOW_PROCESS_BAR = False 66 | 67 | vina_list16 = [] 68 | graphs16 = dgl.load_graphs('../test_set/all_in_one_graph_test2016.bin')[0] 69 | labels16 = pd.read_csv('../test_set/labels_test2016.csv') 70 | vina_terms16 =open(r'../test_set/Vina_terms2016.pkl','rb') 71 | vina16 = pickle.load(vina_terms16) 72 | for i in range(279):# number 73 | if labels16.id[i] in vina16.keys(): 74 | vina_list16.append(vina16[labels16.id[i]]) 75 | 76 | test16_dataset = SepDataset([graphs16[i] for i in range(len(graphs16))], [vina_list16[i] for i in range(len(vina_list16))], [labels16.id[i] for i in range(len(labels16))], [labels16.affinity[i] for i in range(len(labels16))], ['a_conn','r_conn', 'int_l']) 77 | test2016_loader = DataLoader(test16_dataset, batch_size=32, shuffle=False, num_workers=0, collate_fn=collate_fn) 78 | 79 | model = ModelNew() 80 | checkpoint = torch.load(model_path,map_location=device) 81 | model.load_state_dict(checkpoint['model']) 82 | model.to(device) 83 | criterion = torch.nn.MSELoss() 84 | p = test2016_loader 85 | p_f = 'test2016' 86 | print(f'{flag}_{p_f}.csv') 87 | evoluation,targets,outputs,names = test(model, p, criterion,device) 88 | a = pd.DataFrame() 89 | a=a.assign(pdbid=names,predicted=outputs,real=targets,set=p_f) 90 | a.to_csv(f'../result/{flag}_{p_f}.csv') 91 | print(evoluation) 92 | if __name__ == "__main__": 93 | main() -------------------------------------------------------------------------------- /src/train.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | import random 3 | import pandas as pd 4 | import numpy as np 5 | from sklearn.model_selection import KFold, train_test_split 6 | import torch 7 | import torch.nn as nn 8 | import torch.nn.functional as F 9 | from torch.utils.data import DataLoader 10 | import dgl 11 | import dgl.nn.pytorch as dglnn 12 | import dgl.function as dglfn 13 | from collections import deque 14 | from tqdm.auto import tqdm 15 | from IPython.display import clear_output 16 | import time 17 | 18 | from dataset import SepDataset, collate_fn 19 | from model import ModelNew 20 | import metrics 21 | 22 | seed = np.random.randint(2021, 2022) ##random 23 | 24 | torch.backends.cudnn.deterministic = True 25 | torch.backends.cudnn.benchmark = False 26 | 27 | torch.manual_seed(seed) 28 | np.random.seed(seed) 29 | 30 | 31 | def timeSince(since): 32 | now = time.time() 33 | s = now - since 34 | return now, s 35 | 36 | def train(model, train_loader_compound, criterion, optimizer,epoch,device): 37 | model.train() 38 | tbar = tqdm(train_loader_compound, total=len(train_loader_compound)) 39 | losses = [] 40 | t = time.time() 41 | for i, data in enumerate(tbar): 42 | data0 = [i.to(device) for i in data[0]] 43 | ga, gr, gi, aff = data0 44 | vina = data[1] 45 | y_pred = model(ga,gr,gi,vina).squeeze() 46 | y_true = aff.float().squeeze() 47 | 48 | assert y_pred.shape == y_true.shape 49 | loss = criterion(y_pred,y_true).cuda() 50 | loss.backward() 51 | grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), 5) 52 | optimizer.step() 53 | optimizer.zero_grad() 54 | losses.append(loss.item()) 55 | # tbar.set_description(f'epoch {epoch+1} loss {np.mean(losses[-10:]):.4f} grad {grad_norm:.4f}') 56 | 57 | m_losses=np.mean(losses) 58 | 59 | return m_losses 60 | 61 | def valid(model, valid_loader_compound, criterion,device): 62 | model.eval() 63 | losses = [] 64 | outputs = [] 65 | targets = [] 66 | tbar = tqdm(valid_loader_compound, total=len(valid_loader_compound)) 67 | for i, data in enumerate(tbar): 68 | data0 = [i.to(device) for i in data[0]] 69 | ga, gr, gi, aff = data0 70 | vina = data[1] 71 | with torch.no_grad(): 72 | y_pred = model(ga,gr,gi,vina).squeeze() 73 | y_true = aff.float().squeeze() 74 | assert y_pred.shape == y_true.shape 75 | loss = criterion(y_pred,y_true).cuda() 76 | losses.append(loss.item()) 77 | outputs.append(y_pred.cpu().detach().numpy().reshape(-1)) 78 | targets.append(y_true.cpu().detach().numpy().reshape(-1)) 79 | targets = np.concatenate(targets).reshape(-1) 80 | outputs = np.concatenate(outputs).reshape(-1) 81 | 82 | evaluation = { 83 | 'c_index': metrics.c_index(targets, outputs), 84 | 'RMSE': metrics.RMSE(targets, outputs), 85 | 'MAE': metrics.MAE(targets, outputs), 86 | 'SD': metrics.SD(targets, outputs), 87 | 'CORR': metrics.CORR(targets, outputs),} 88 | ml=np.mean(losses) 89 | 90 | return ml, evaluation 91 | 92 | def main(): 93 | F=open(r'../test_set/train_valte_comp.pkl','rb') 94 | content=pickle.load(F) 95 | vina_list= [] 96 | graphs = dgl.load_graphs('../test_set/all_in_one_graph_train13851.bin')[0] 97 | labels = pd.read_csv('../test_set/labels_train13851.csv') 98 | vina_terms=open(r'../test_set/Vina_terms13851.pkl','rb') 99 | vina=pickle.load(vina_terms) 100 | for i in range(13851): 101 | if labels.id[i] in vina.keys(): 102 | vina_list.append(vina[labels.id[i]]) 103 | 104 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu") 105 | compound_train = content[0] 106 | compound_valid = content[1] 107 | compound_test = content[2] 108 | 109 | train_dataset_compound = SepDataset([graphs[i] for i in compound_train], [vina_list[i] for i in compound_train], [labels.id[i] for i in compound_train], [labels.affinity[i] for i in compound_train], ['a_conn','r_conn', 'int_l']) 110 | valid_dataset_compound = SepDataset([graphs[i] for i in compound_valid], [vina_list[i] for i in compound_valid], [labels.id[i] for i in compound_valid], [labels.affinity[i] for i in compound_valid], ['a_conn','r_conn', 'int_l']) 111 | test_dataset_compound = SepDataset([graphs[i] for i in compound_test], [vina_list[i] for i in compound_test], [labels.id[i] for i in compound_test], [labels.affinity[i] for i in compound_test], ['a_conn','r_conn', 'int_l']) 112 | 113 | train_loader_compound = DataLoader(train_dataset_compound, batch_size=8, shuffle=True, num_workers=0, collate_fn=collate_fn,pin_memory=False,drop_last=False,) 114 | valid_loader_compound = DataLoader(valid_dataset_compound, batch_size=8, shuffle=False, num_workers=0, collate_fn=collate_fn) 115 | test_loader_compound = DataLoader(test_dataset_compound, batch_size=8, shuffle=False, num_workers=0, collate_fn=collate_fn) 116 | 117 | model = ModelNew() 118 | model = model.to(device) 119 | optimizer = torch.optim.AdamW(model.parameters(), 1.2e-4, weight_decay=1e-6) ### (model.parameters(), 1e-3, weight_decay=1e-5) 120 | scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer,T_max=40, eta_min=1e-6) 121 | criterion = torch.nn.MSELoss() 122 | 123 | n_epoch = 80 124 | best_R = 0.0 125 | for epoch in range(n_epoch): 126 | ll = train(model, train_loader_compound, criterion, optimizer,epoch,device) 127 | if epoch%1==0: 128 | l,evaluation = valid(model, valid_loader_compound, criterion,device) 129 | l_, evaluation_ = valid(model, test_loader_compound, criterion,device) 130 | print(f'epoch {epoch+1} train_loss {ll:.5f} valid_loss {l:.5f}') 131 | clear_output() 132 | if evaluation_['CORR']>best_R: 133 | best_R= evaluation_['CORR'] 134 | torch.save({'model': model.state_dict()}, '../model/model.pth') 135 | scheduler.step() 136 | 137 | if __name__ == "__main__": 138 | main() -------------------------------------------------------------------------------- /test_set/Vina_terms13851.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/test_set/Vina_terms13851.pkl -------------------------------------------------------------------------------- /test_set/Vina_terms2013.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/test_set/Vina_terms2013.pkl -------------------------------------------------------------------------------- /test_set/Vina_terms2016.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/test_set/Vina_terms2016.pkl -------------------------------------------------------------------------------- /test_set/labels_test2013.csv: -------------------------------------------------------------------------------- 1 | id,affinity 2 | 2v7a,8.30 3 | 1kel,7.28 4 | 3l7b,2.40 5 | 1lol,6.39 6 | 2xys,7.42 7 | 3dd0,9.00 8 | 3d4z,4.89 9 | 1n2v,4.08 10 | 3b3w,4.19 11 | 2x00,11.33 12 | 1u33,4.60 13 | 4tmn,10.17 14 | 1xd0,7.12 15 | 3acw,4.76 16 | 1uto,2.27 17 | 3vh9,6.24 18 | 2wbg,4.45 19 | 3n86,5.64 20 | 3f17,8.63 21 | 1bcu,3.28 22 | 2qft,5.26 23 | 1w4o,5.22 24 | 2zx6,10.60 25 | 3cft,4.19 26 | 3ueu,5.24 27 | 1f8b,5.40 28 | 3n7a,3.70 29 | 2xb8,7.59 30 | 3dxg,2.40 31 | 2x97,5.66 32 | 1qi0,2.35 33 | 2obf,8.85 34 | 3fcq,2.77 35 | 2wca,5.60 36 | 1o3f,7.96 37 | 10gs,6.40 38 | 3ao4,2.07 39 | 2ole,7.25 40 | 3kgp,2.57 41 | 3cj2,4.85 42 | 2zxd,5.22 43 | 3u9q,4.38 44 | 2g70,7.77 45 | 1os0,6.03 46 | 3mss,4.66 47 | 1q8t,4.76 48 | 3coy,6.02 49 | 3gy4,5.10 50 | 2pq9,8.11 51 | 1z95,7.12 52 | 2brb,4.86 53 | 3pxf,4.43 54 | 2vl4,6.01 55 | 1sln,6.64 56 | 1f8d,3.40 57 | 2vot,7.14 58 | 1gpk,5.37 59 | 1o5b,5.77 60 | 4djr,11.52 61 | 2wtv,8.74 62 | 3utu,10.92 63 | 3muz,3.46 64 | 3uex,6.92 65 | 2d3u,6.92 66 | 2xnb,6.83 67 | 3g0w,9.52 68 | 3su5,5.58 69 | 2vw5,8.52 70 | 3g2n,4.09 71 | 3b3s,2.55 72 | 3su2,7.35 73 | 2j78,6.42 74 | 2xbv,8.43 75 | 3imc,2.96 76 | 2yki,9.46 77 | 2p4y,9.00 78 | 2xy9,9.19 79 | 4de1,5.96 80 | 3lka,2.82 81 | 4dew,7.00 82 | 3pww,7.32 83 | 2xdl,3.10 84 | 2hb1,3.80 85 | 3ge7,8.70 86 | 2vo5,4.89 87 | 3ehy,5.85 88 | 3kv2,7.32 89 | 1yc1,6.17 90 | 2weg,6.50 91 | 3jvs,6.54 92 | 3fv1,9.30 93 | 3ozt,4.13 94 | 2cet,8.02 95 | 1q8u,5.96 96 | 3ivg,4.30 97 | 1p1q,4.89 98 | 3l3n,8.18 99 | 1h23,8.35 100 | 2zcq,8.82 101 | 2yfe,6.63 102 | 2d1o,7.70 103 | 2qmj,4.21 104 | 3l4u,7.52 105 | 1lor,11.06 106 | 1hfs,8.70 107 | 2jdu,6.72 108 | 3vd4,4.82 109 | 3nox,8.66 110 | 3e93,8.85 111 | 3myg,10.70 112 | 4des,5.85 113 | 3f3c,6.02 114 | 1hnn,6.24 115 | 1n1m,5.70 116 | 2jdy,4.37 117 | 3mfv,2.52 118 | 4g8m,7.89 119 | 3f3e,7.70 120 | 2yge,5.06 121 | 1sqa,9.21 122 | 3su3,9.13 123 | 2j62,11.34 124 | 3pe2,9.76 125 | 2jdm,5.40 126 | 2qbr,6.33 127 | 2cbj,8.27 128 | 1mq6,11.15 129 | 1f8c,7.40 130 | 3kwa,4.08 131 | 1e66,9.89 132 | 3f3a,4.19 133 | 3nq3,3.78 134 | 2pcp,8.70 135 | 2ymd,3.16 136 | 2zwz,7.79 137 | 1u1b,7.80 138 | 2zjw,7.70 139 | 3uo4,6.52 140 | 2qbp,8.40 141 | 3oe5,6.88 142 | 2x0y,4.60 143 | 2y5h,5.79 144 | 3gcs,7.25 145 | 2vvn,7.30 146 | 1ps3,2.28 147 | 2iwx,6.68 148 | 2gss,4.94 149 | 1r5y,6.46 150 | 3udh,2.85 151 | 3zso,5.12 152 | 3cyx,8.00 153 | 4djv,6.72 154 | 3ejr,8.57 155 | 3i3b,2.23 156 | 1oyt,7.24 157 | 3gnw,9.10 158 | 3bkk,6.08 159 | 2xhm,6.80 160 | 1vso,4.72 161 | 1lbk,3.18 162 | 3zsx,3.28 163 | 1nvq,8.25 164 | 3l4w,6.00 165 | 4de2,4.12 166 | 4gid,10.77 167 | 2fvd,8.52 168 | 3k5v,6.30 169 | 3ebp,5.91 170 | 3gbb,6.90 171 | 3fk1,2.62 172 | 3ag9,8.05 173 | 2w66,4.05 174 | 3f80,4.22 175 | 4gqq,2.89 176 | 2x8z,7.96 177 | 3huc,5.99 178 | 3g2z,2.36 179 | 3bfu,6.27 180 | 3owj,6.07 181 | 3nw9,9.00 182 | 3b68,8.40 183 | 2v00,3.66 184 | -------------------------------------------------------------------------------- /test_set/labels_test2016.csv: -------------------------------------------------------------------------------- 1 | id,affinity 2 | 2v7a,8.30 3 | 4dld,5.82 4 | 3l7b,2.40 5 | 3zdg,7.10 6 | 2xys,7.42 7 | 3b65,9.27 8 | 3dd0,9.00 9 | 3d4z,4.89 10 | 1owh,7.40 11 | 2x00,11.33 12 | 4tmn,10.17 13 | 3b5r,8.77 14 | 1z6e,9.72 15 | 3acw,4.76 16 | 3rsx,4.41 17 | 1uto,2.27 18 | 3fur,8.00 19 | 4u4s,2.92 20 | 2wbg,4.45 21 | 3n86,5.64 22 | 1bcu,3.28 23 | 1w4o,5.22 24 | 4ciw,4.82 25 | 4wiv,6.26 26 | 3coz,5.57 27 | 3ueu,5.24 28 | 3n7a,3.70 29 | 3ryj,7.80 30 | 2xb8,7.59 31 | 3dxg,2.40 32 | 2wvt,6.12 33 | 3gr2,2.52 34 | 2c3i,7.60 35 | 4ih5,4.11 36 | 3fcq,2.77 37 | 4j28,5.70 38 | 2wca,5.60 39 | 1o3f,7.96 40 | 3ao4,2.07 41 | 3kgp,2.57 42 | 3gv9,2.12 43 | 4ddk,2.29 44 | 2xii,7.20 45 | 4f09,6.70 46 | 1nc3,5.00 47 | 2xj7,6.66 48 | 1s38,5.15 49 | 3u9q,4.38 50 | 4m0z,5.19 51 | 3aru,3.22 52 | 3u8n,10.17 53 | 1syi,5.44 54 | 5tmn,8.04 55 | 4bkt,3.62 56 | 3arv,5.64 57 | 4f9w,6.94 58 | 1k1i,6.58 59 | 1g2k,7.96 60 | 3mss,4.66 61 | 1q8t,4.76 62 | 2qbq,7.44 63 | 3coy,6.02 64 | 4mgd,4.69 65 | 3gy4,5.10 66 | 3up2,7.40 67 | 1z95,7.12 68 | 2brb,4.86 69 | 4jxs,4.74 70 | 3pxf,4.43 71 | 2wn9,8.52 72 | 4k18,8.96 73 | 3tsk,7.17 74 | 3u8k,8.66 75 | 3u5j,5.61 76 | 4rfm,10.05 77 | 4eky,3.52 78 | 4f2w,11.30 79 | 1gpk,5.37 80 | 4w9c,4.65 81 | 4w9l,5.02 82 | 1ydt,7.32 83 | 3twp,3.92 84 | 1o5b,5.77 85 | 1h22,9.10 86 | 3g31,2.89 87 | 2wtv,8.74 88 | 2j7h,7.19 89 | 3utu,10.92 90 | 4cig,3.67 91 | 3bgz,6.26 92 | 3e5a,8.23 93 | 3uex,6.92 94 | 1z9g,5.64 95 | 3n76,6.85 96 | 4gr0,9.55 97 | 4m0y,6.46 98 | 4ea2,6.44 99 | 4gfm,7.22 100 | 2xnb,6.83 101 | 3g0w,9.52 102 | 2vw5,8.52 103 | 3g2n,4.09 104 | 2j78,6.42 105 | 2xbv,8.43 106 | 4kzq,6.10 107 | 3dx1,3.58 108 | 2wnc,6.32 109 | 3d6q,3.76 110 | 1qf1,7.32 111 | 2yki,9.46 112 | 3f3d,7.16 113 | 2p4y,9.00 114 | 5c28,5.66 115 | 3wtj,6.53 116 | 4de1,5.96 117 | 2wer,7.05 118 | 3lka,2.82 119 | 4cr9,4.10 120 | 4e6q,8.36 121 | 3pww,7.32 122 | 4mme,6.50 123 | 2xdl,3.10 124 | 4agq,5.01 125 | 2hb1,3.80 126 | 4k77,6.63 127 | 2br1,5.14 128 | 4dli,5.62 129 | 3ge7,8.70 130 | 3ehy,5.85 131 | 3uew,6.31 132 | 2zda,8.40 133 | 1yc1,6.17 134 | 3pyy,6.86 135 | 2weg,6.50 136 | 3jvs,6.54 137 | 3fv1,9.30 138 | 4ogj,6.79 139 | 3ary,6.00 140 | 3ozt,4.13 141 | 4w9i,5.96 142 | 2cet,8.02 143 | 3p5o,7.26 144 | 1q8u,5.96 145 | 3jvr,5.72 146 | 1qkt,9.04 147 | 3ivg,4.30 148 | 1p1q,4.89 149 | 4kzu,6.50 150 | 3b27,5.16 151 | 4ivb,8.72 152 | 1h23,8.35 153 | 2zcq,8.82 154 | 2yfe,6.63 155 | 4ddh,3.30 156 | 4abg,3.57 157 | 1ydr,5.52 158 | 3qgy,7.80 159 | 3dx2,6.82 160 | 3cj4,6.51 161 | 3nq9,4.03 162 | 1gpn,6.48 163 | 1pxn,7.15 164 | 4f3c,11.82 165 | 4cra,7.22 166 | 3e93,8.85 167 | 3myg,10.70 168 | 3f3c,6.02 169 | 4ih7,5.24 170 | 1c5z,4.01 171 | 4kz6,3.10 172 | 3ozs,5.33 173 | 3oe4,7.47 174 | 4qd6,8.64 175 | 3e92,8.00 176 | 3f3e,7.70 177 | 2yge,5.06 178 | 1sqa,9.21 179 | 3syr,5.10 180 | 3ui7,9.00 181 | 4jia,9.22 182 | 4eor,6.30 183 | 2qbr,6.33 184 | 4j3l,7.80 185 | 1mq6,11.15 186 | 5dwr,11.22 187 | 3qqs,5.82 188 | 4crc,8.72 189 | 3kwa,4.08 190 | 1e66,9.89 191 | 3f3a,4.19 192 | 5c2h,11.09 193 | 3uuo,7.96 194 | 3gc5,7.26 195 | 1p1n,6.80 196 | 2ymd,3.16 197 | 2cbv,5.48 198 | 3b1m,8.48 199 | 4jfs,5.27 200 | 3jya,6.89 201 | 3rlr,7.52 202 | 1u1b,7.80 203 | 3prs,7.82 204 | 2p15,10.30 205 | 3uo4,6.52 206 | 5aba,2.98 207 | 4lzs,4.80 208 | 2qbp,8.40 209 | 3oe5,6.88 210 | 1o0h,5.92 211 | 2y5h,5.79 212 | 2r9w,5.10 213 | 2pog,9.54 214 | 2vvn,7.30 215 | 4e5w,7.66 216 | 3arp,7.15 217 | 4ivc,10.00 218 | 1ps3,2.28 219 | 5a7b,3.57 220 | 2iwx,6.68 221 | 1r5y,6.46 222 | 3udh,2.85 223 | 1nc1,6.12 224 | 4de3,5.52 225 | 3zso,5.12 226 | 4ivd,9.52 227 | 4djv,6.72 228 | 3ejr,8.57 229 | 4agp,4.69 230 | 4w9h,6.73 231 | 3o9i,11.82 232 | 1eby,9.70 233 | 2qnq,6.11 234 | 1oyt,7.24 235 | 3gnw,9.10 236 | 4j21,7.41 237 | 1vso,4.72 238 | 4pcs,7.85 239 | 3zsx,3.28 240 | 4jsz,2.30 241 | 1nvq,8.25 242 | 1bzc,4.92 243 | 4de2,4.12 244 | 4gid,10.77 245 | 3uev,5.89 246 | 2fvd,8.52 247 | 4gkm,5.17 248 | 3k5v,6.30 249 | 3ebp,5.91 250 | 3gbb,6.90 251 | 2w66,4.05 252 | 2fxs,6.06 253 | 3r88,4.82 254 | 3rr4,4.55 255 | 2vkm,8.74 256 | 4agn,3.97 257 | 3kr8,8.10 258 | 4qac,9.40 259 | 4owm,2.96 260 | 3arq,6.40 261 | 2zb1,6.32 262 | 3g2z,2.36 263 | 4hge,7.92 264 | 4twp,10.00 265 | 2w4x,4.85 266 | 3wz8,5.82 267 | 3fv2,8.11 268 | 1lpg,7.09 269 | 3nw9,9.00 270 | 4llx,2.89 271 | 4eo8,8.15 272 | 3nx7,8.10 273 | 1y6r,10.11 274 | 4ty7,9.52 275 | 3b68,8.40 276 | 2al5,8.40 277 | 2qe4,7.96 278 | 4x6p,8.30 279 | 2v00,3.66 280 | 3zt2,2.84 281 | -------------------------------------------------------------------------------- /test_set/train_valte_comp.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/test_set/train_valte_comp.pkl -------------------------------------------------------------------------------- /test_set/train_valte_prot.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CSUBioGroup/GraphscoreDTA/d7d1230fb33d803f5c8f86e66c1598ab4d7ea68d/test_set/train_valte_prot.pkl --------------------------------------------------------------------------------