openmm
deepdrivewe.simulation.openmm ¶
OpenMM simulation module.
OpenMMReporter ¶
Bases: ABC
Reporter interface for OpenMM simulations.
Source code in deepdrivewe/simulation/openmm.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
__init__ ¶
Initialize the reporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_interval
|
int
|
The interval at which to write frames. |
required |
openmm_selection
|
Sequence[str]
|
The OpenMM selection strings for the atoms to use when reporting positions (default is ('CA',)). |
('CA',)
|
Source code in deepdrivewe/simulation/openmm.py
describeNextReport ¶
Get information about the next report this object will generate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
Simulation
|
The Simulation to generate a report for |
required |
Returns:
| Type | Description |
|---|---|
tuple
|
A six element tuple. The first element is the number of steps until the next report. The next four elements specify whether that report will require positions, velocities, forces, and energies respectively. The final element specifies whether positions should be wrapped to lie in a single periodic box. |
Source code in deepdrivewe/simulation/openmm.py
get_positions ¶
Get the atomic positions from the simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
Simulation
|
The Simulation to generate a report for. |
required |
state
|
State
|
The current state of the simulation. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The atomic positions from the simulation. |
Source code in deepdrivewe/simulation/openmm.py
report
abstractmethod
¶
Generate a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
Simulation
|
The Simulation to generate a report for |
required |
state
|
State
|
The current state of the simulation |
required |
Source code in deepdrivewe/simulation/openmm.py
Collector ¶
Bases: ABC
Collector interface for OpenMM simulations.
Source code in deepdrivewe/simulation/openmm.py
__init__ ¶
get
abstractmethod
¶
Get the collected data from the simulation.
Returns:
| Type | Description |
|---|---|
ndarray
|
The collected data from the simulation. |
collect
abstractmethod
¶
Collect data from the simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
The atomic positions from the simulation. |
required |
CoordinatesCollector ¶
Bases: Collector
Coordinates collector for OpenMM simulations.
Source code in deepdrivewe/simulation/openmm.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
__init__ ¶
__init__(
reference_file: Path | None = None,
mda_selection: str = "protein and name CA",
topic: str = "coordinates",
) -> None
Initialize the coordinates collector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_file
|
Path | None
|
The reference PDB file for the analysis (if provided, the coordinates will be aligned to the reference). Default is None. |
None
|
mda_selection
|
str
|
The MDAnalysis selection string for the atoms to use for alignment (default is 'protein and name CA'). |
'protein and name CA'
|
topic
|
str
|
The topic of the collector, default is 'coordinates'. |
'coordinates'
|
Source code in deepdrivewe/simulation/openmm.py
get ¶
Get the coordinates from the simulation.
Returns:
| Type | Description |
|---|---|
ndarray
|
The atomic positions from each frame of the simulation (n_frames, n_atoms, 3). Where n_atoms is the number of atoms in the openmm_selection of the corresponding OpenMMReporter. |
Source code in deepdrivewe/simulation/openmm.py
collect ¶
Generate a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
The atomic positions from the simulation. |
required |
Source code in deepdrivewe/simulation/openmm.py
RMSDCollector ¶
Bases: Collector
RMSD collector for OpenMM simulations.
Source code in deepdrivewe/simulation/openmm.py
__init__ ¶
__init__(
reference_file: Path,
mda_selection: str = "protein and name CA",
topic: str = "rmsds",
) -> None
Initialize the RMSD collector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference_file
|
Path
|
The reference PDB file for the analysis. |
required |
mda_selection
|
str
|
The MDAnalysis selection string for the atoms to use (default is 'protein and name CA'). |
'protein and name CA'
|
topic
|
str
|
The topic of the collector, default is 'rmsd'. |
'rmsds'
|
Source code in deepdrivewe/simulation/openmm.py
get ¶
Get the RMSDs from the simulation.
Returns:
| Type | Description |
|---|---|
ndarray
|
The RMSDs from the simulation shaped as (n_frames, 1). |
collect ¶
Generate a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
The atomic positions from the simulation. |
required |
Source code in deepdrivewe/simulation/openmm.py
ContactMapCollector ¶
Bases: Collector
Contact map collector for OpenMM simulations.
Source code in deepdrivewe/simulation/openmm.py
__init__ ¶
Initialize the contact map collector.
Source code in deepdrivewe/simulation/openmm.py
get ¶
Get the contact maps from the simulation.
Returns:
| Type | Description |
|---|---|
ndarray
|
The contact maps from the simulation as a ragged array shaped as (n_frames, *). |
Source code in deepdrivewe/simulation/openmm.py
collect ¶
Generate a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
The atomic positions from the simulation. |
required |
Source code in deepdrivewe/simulation/openmm.py
CollectionReporter ¶
Bases: OpenMMReporter
Reporter to collect multiple data products from an OpenMM simulation.
Source code in deepdrivewe/simulation/openmm.py
__init__ ¶
__init__(
report_interval: int,
collectors: list[Collector],
openmm_selection: Sequence[str] = ("CA",),
) -> None
Initialize the reporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_interval
|
int
|
The interval at which to write frames. |
required |
collectors
|
list[Collector]
|
The collectors to inject into the simulation. |
required |
openmm_selection
|
Sequence[str]
|
The OpenMM selection strings for the atoms to use when reporting positions (default is ('CA',)). |
('CA',)
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the collectors have duplicate topics. |
Source code in deepdrivewe/simulation/openmm.py
get_collected_data ¶
Get the collected data from the simulation.
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
The collected data from the simulation. |
Source code in deepdrivewe/simulation/openmm.py
report ¶
Generate a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
Simulation
|
The Simulation to generate a report for. |
required |
state
|
State
|
The current state of the simulation. |
required |
Source code in deepdrivewe/simulation/openmm.py
OpenMMConfig ¶
Bases: BaseModel
Configuration for an OpenMM simulation.
Source code in deepdrivewe/simulation/openmm.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
validate_explicit_barostat ¶
Check for valid explicit_barostat options.
Source code in deepdrivewe/simulation/openmm.py
validate_hardware_platform ¶
Check for valid hardware_platform options.
Source code in deepdrivewe/simulation/openmm.py
load_explicit_system_from_top ¶
load_explicit_system_from_top(
top_file: str | Path, pdb_file: str | Path
) -> tuple[openmm.System, app.Topology]
Load an explicit solvent system from a topology file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_file
|
str | Path
|
The topology file to load the system from. |
required |
pdb_file
|
str | Path
|
The PDB file to load the system topology. |
required |
Returns:
| Type | Description |
|---|---|
tuple[System, Topology]
|
The OpenMM system and topology. |
Source code in deepdrivewe/simulation/openmm.py
load_implicit_system_from_pdb ¶
Load an implicit solvent system from a PDB file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pdb_file
|
str | Path
|
The PDB file to load the system from. |
required |
Returns:
| Type | Description |
|---|---|
tuple[System, Topology]
|
The OpenMM system and topology. |
Source code in deepdrivewe/simulation/openmm.py
load_implicit_system_from_top ¶
Load an implicit solvent system from a topology file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top_file
|
str | Path
|
The topology file to load the system from. |
required |
Returns:
| Type | Description |
|---|---|
tuple[System, Topology]
|
The OpenMM system and topology. |
Source code in deepdrivewe/simulation/openmm.py
configure_hardware ¶
Configure the hardware for the simulation.
Returns:
| Type | Description |
|---|---|
tuple[Platform, dict[str, str]]
|
The OpenMM platform and the platform properties. |
Source code in deepdrivewe/simulation/openmm.py
configure_integrator ¶
Configure the integrator for the simulation.
Returns:
| Type | Description |
|---|---|
LangevinIntegrator
|
The configured integrator. |
Source code in deepdrivewe/simulation/openmm.py
configure_barostat ¶
Configure the barostat for the simulation.
Returns:
| Type | Description |
|---|---|
MonteCarloBarostat | MonteCarloAnisotropicBarostat | None
|
The configured barostat or None if no barostat is used. |
Source code in deepdrivewe/simulation/openmm.py
configure_simulation ¶
configure_simulation(
pdb_file: str | Path,
top_file: str | Path | None,
checkpoint_file: str | Path | None = None,
) -> app.Simulation
Configure an OpenMM simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pdb_file
|
str | Path
|
The PDB file to initialize the positions (used to load the system topology for implicit solvent). |
required |
top_file
|
str | Path | None
|
The optional topology file to initialize the systems topology (required for explicit solvent). |
required |
checkpoint_file
|
str | Path | None
|
The checkpoint file to initialize the simulation. |
None
|
Returns:
| Type | Description |
|---|---|
Simulation
|
Configured OpenMM Simulation object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If explicit solvent is selected and no topology file is provided. |
Source code in deepdrivewe/simulation/openmm.py
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
OpenMMSimulation ¶
Bases: BaseModel
OpenMM simulation.
Source code in deepdrivewe/simulation/openmm.py
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | |
restart_file
property
¶
The restart file for the simulation.
NOTE: In the case of OpenMM, this PDB file is used to initialize the simulation, and used as a proxy for the restart file (which is a checkpoint file). The actual checkpoint file is seg.chk (found in the same directory as the checkpoint file) which is used to save the simulation state and is automatically loaded if it exists.
run ¶
Run the simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reporters
|
list[OpenMMReporter]
|
Custom reporters to inject into the simulation, by default None. |
None
|
Source code in deepdrivewe/simulation/openmm.py
ContactMapRMSDReporter ¶
Bases: OpenMMReporter
Reporter to compute contact maps and RMSD from an OpenMM simulation.
Source code in deepdrivewe/simulation/openmm.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 | |
__init__ ¶
__init__(
report_interval: int,
reference_file: Path,
cutoff_angstrom: float = 8.0,
mda_selection: str = "protein and name CA",
openmm_selection: Sequence[str] = ("CA",),
) -> None
Initialize the reporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report_interval
|
int
|
The interval at which to write frames. |
required |
reference_file
|
Path
|
The reference PDB file for the analysis. |
required |
cutoff_angstrom
|
float
|
The angstrom cutoff distance for defining contacts (default is 8.0). |
8.0
|
mda_selection
|
str
|
The MDAnalysis selection string for the atoms to use (default is 'protein and name CA'). |
'protein and name CA'
|
openmm_selection
|
Sequence[str]
|
The OpenMM selection strings for the atoms to use (default is ('CA',)). |
('CA',)
|
Source code in deepdrivewe/simulation/openmm.py
get_contact_maps ¶
Get the contact maps from the simulation.
Returns:
| Type | Description |
|---|---|
ndarray
|
The contact maps from the simulation as a ragged array shaped as (n_frames, *). |
Source code in deepdrivewe/simulation/openmm.py
get_rmsds ¶
Get the RMSDs from the simulation.
Returns:
| Type | Description |
|---|---|
ndarray
|
The RMSDs from the simulation shaped as (n_frames, 1). |
report ¶
Generate a report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
simulation
|
Simulation
|
The Simulation to generate a report for |
required |
state
|
State
|
The current state of the simulation |
required |