NeighborPairs
lahuta.NeighborPairs ¶
A class that manages pairs of atoms that are considered "neighbors" within a defined distance threshold.
The NeighborPairs
class stores atom pairs (identified by their indices) and the corresponding distances
between them, which represent the concept of "neighbors" in the context of molecular simulations or structural
biology. The class provides various functionalities to manipulate and interrogate these pairs, including
methods to retrieve specific pairs, add or modify pairs, convert the data to different formats (e.g., pandas
DataFrame or dictionary), and compute derived properties such as distances and indices.
The class also implements several magic methods to support common operations like indexing, testing for membership, set-like operations (e.g., union, intersection), and equality testing. Furthermore, the class is designed to be extensible and supports the addition of custom annotations to the pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mda |
AtomGroupType
|
The group of atoms under consideration. |
required |
mol |
MolType
|
The molecule under consideration. |
required |
atom_types |
csc_array
|
A sparse matrix containing the atom types. |
required |
pairs |
NDArray[int32]
|
A 2D numpy array of pairs of atom indices that are neighbors. |
required |
distances |
NDArray[float32]
|
A 1D numpy array of distances between the pairs of atoms. |
required |
Attributes:
Name | Type | Description |
---|---|---|
pairs |
NDArray[int32]
|
A 2D numpy array of pairs of atom indices that are neighbors. |
distances |
NDArray[float32]
|
A 1D numpy array of distances between the pairs of atoms. |
annotations |
dict[str, NDArray[Any]]
|
A dictionary containing the annotations of the NeighborPairs object. |
partner1 |
AtomGroupType
|
The first column of the pairs of atoms. |
partner2 |
AtomGroupType
|
The second column of the pairs of atoms. |
indices |
NDArray[int32]
|
A 2D numpy array of the indices of the pairs of atoms. |
Source code in lahuta/core/neighbors.py
36 37 38 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 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 797 798 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 902 903 904 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 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 |
|
annotations
property
writable
¶
annotations
Get the annotations of the NeighborPairs object.
Returns:
Type | Description |
---|---|
dict[str, NDArray[Any]]
|
A dictionary containing the annotations of the NeighborPairs object. |
partner1
property
¶
partner1
Get the first partner of the pairs of indices of atoms that are neighbors.
Returns:
Type | Description |
---|---|
AtomGroupType
|
The first partner of the atom pairs. |
partner2
property
¶
partner2
Get the second partner of the pairs of indices of atoms that are neighbors.
Returns:
Type | Description |
---|---|
AtomGroupType
|
The second partner of the atom pairs. |
pairs
property
¶
pairs
Get the pairs of atoms that are neighbors.
Returns:
Type | Description |
---|---|
NDArray[int32]
|
An array containing the pairs of indices of neighboring atoms. |
distances
property
¶
distances
Get the distances between the pairs of indices of atoms that are neighbors.
Returns An array containing the distances between the pairs of indices of neighboring atoms.
names
property
¶
names
Get the names of the atoms that are neighbors.
Returns An array containing the atom names of the neighboring atoms.
resnames
property
¶
resnames
Get the residue names of the atoms that are neighbors.
Returns An array containing the residue names of the neighboring atoms.
resids
property
¶
resids
Get the residue IDs of the atoms that are neighbors.
Returns An array containing the residue IDs of the neighboring atoms.
indices
property
¶
indices
Get the indices of the atoms that are neighbors.
Returns An array containing the indices of the neighboring atoms.
labels
property
¶
labels
Get the pairs of atoms that are neighbors.
Returns:
Type | Description |
---|---|
NDArray[void]
|
An array containing the pairs of indices of neighboring atoms. |
sort_inputs
staticmethod
¶
sort_inputs(pairs, distances)
Sorts the provided pairs and distances arrays based on the first column of the sorted pairs array.
This method first sorts the pairs
array along axis 1 and then sorts the pairs
and distances
arrays based on the first column of the sorted pairs array. This is done to ensure that the pairs and
distances arrays are always in the same order, which is necessary for correctly associating
each pair of atoms with its corresponding distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pairs |
NDArray[int32]
|
An array containing the pairs of atoms. |
required |
distances |
NDArray[float32]
|
An array containing the distances between each pair of atoms. |
required |
Returns:
Type | Description |
---|---|
tuple[NDArray[int32], NDArray[float32]]
|
tuple[NDArray[np.int32], NDArray[np.float32]]: A tuple containing the sorted pairs and distances arrays. |
Example
pairs = np.array([[2, 1], [4, 3]])
distances = np.array([1.0, 2.0])
sorted_pairs, sorted_distances = NeighborPairs.sort_inputs(pairs, distances)
print(sorted_pairs)
print(sorted_distances)
[[1, 2], [3, 4]]
[2.0, 1.0]
Source code in lahuta/core/neighbors.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
type_filter ¶
type_filter(atom_type, partner)
Filter pairs based on atom types.
The method selects pairs from the NeighborPairs object where the atoms have the specified type.
The partner
parameter specifies the column (1 or 2) from which the atom types are selected.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atom_type |
str
|
Specifies the atom type. Must be one of:
|
required |
partner |
int
|
The column for atom type selection. Can be either 1 or 2. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the atom type filter. |
Source code in lahuta/core/neighbors.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
index_filter ¶
index_filter(indices, partner)
Select pairs based on the atom indices.
The method selects pairs from the NeighborPairs object where the atoms have the specified indices.
The partner
parameter specifies the column (1 or 2) from which the atom indices are selected.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indices |
NDArray[int32]
|
The atom indices to select. |
required |
partner |
int
|
The column to select the atom indices from. It can be either 1 or 2. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the index filter. |
Source code in lahuta/core/neighbors.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
distance_filter ¶
distance_filter(distance)
Select pairs based on the distance.
The method selects pairs from the NeighborPairs object where the distances between the atoms are less than or equal to the specified distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
distance |
float
|
The distance to select. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the distance filter. |
Source code in lahuta/core/neighbors.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
numeric_filter ¶
numeric_filter(array, cutoff)
Select pairs based on a numeric cutoff.
The method selects pairs from the NeighborPairs object where the values in the specified array are less than or
equal to the cutoff (if lte
is True) or greater than the cutoff (if lte
is False).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array |
NDArray[float32]
|
The array containing the values to compare with the cutoff. |
required |
cutoff |
float
|
The cutoff value for the filter. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the numeric filter. |
Source code in lahuta/core/neighbors.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
radius_filter ¶
radius_filter(radius, partner)
Select pairs based on the radius.
The method selects pairs from the NeighborPairs object where the van der Waals radii of the atoms
are less than or equal to the specified radius. The partner
parameter specifies the column (1 or 2)
from which the radii are selected.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float
|
The radius to select. |
required |
partner |
int
|
The column to select the radii from. It can be either 1 or 2. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the radius filter. |
Source code in lahuta/core/neighbors.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
hbond_distance_filter ¶
hbond_distance_filter(partner, vdw_comp_factor=0.1)
Filter the pairs based on the distance between the hydrogen bonded atoms.
The method filters pairs from the NeighborPairs object where the hydrogen bond distances
are less than or equal to the specified van der Waals distances. The partner
parameter specifies
the column of hydrogen bonded atom indices in the hbond_array
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
partner |
int
|
The column of the hydrogen bonded atom indices in the |
required |
vdw_comp_factor |
float
|
The van der Waals complementarity factor. Defaults to 0.1. |
0.1
|
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the hydrogen bond distance filter. |
Source code in lahuta/core/neighbors.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
hbond_angle_filter ¶
hbond_angle_filter(partner, weak=False)
Filter the pairs based on the angle between the hydrogen bonded atoms.
The method filters pairs from the NeighborPairs object where the hydrogen bond angles are greater
than or equal to the specified contact angle. The partner
parameter specifies the column of hydrogen
bonded atom indices in the hbond_array
. If weak
is True, the function will accept weaker hydrogen bonds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
partner |
int
|
The column of the hydrogen bonded atom indices in the |
required |
weak |
bool
|
If True, accept weaker hydrogen bonds. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the pairs that meet the hydrogen bond angle filter. |
Source code in lahuta/core/neighbors.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
map ¶
map(seq)
Map the pairs
indices to indices in the multiple sequence alignment.
The method maps the indices in the pairs
array to indices in the multiple sequence alignment
using the specified sequence ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seq |
Seq
|
The sequence to map the indices to. |
required |
Returns:
Type | Description |
---|---|
LabeledNeighborPairs
|
A NeighborPairs object containing the mapped pairs. |
Source code in lahuta/core/neighbors.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
backmap ¶
backmap(seq, pairs)
Map the pairs
indices to indices in the structure.
The method maps the indices in the pairs
array to indices in the structure
using the specified sequence ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seq |
Seq
|
The sequence to map the indices to. |
required |
pairs |
NDArray[void]
|
The mapped pairs to backmap. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the backmapped pairs. |
Source code in lahuta/core/neighbors.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
intersection ¶
intersection(other)
Return the intersection of two NeighborPairs objects.
The method calculates the intersection of the pairs from self
and other
, and then returns a new
NeighborPairs object that contains the intersecting pairs along with their corresponding distances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
intersected_pairs |
NeighborPairs
|
A NeighborPairs object containing the pairs and their corresponding distances
that are common between |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
# 2 ways to get the intersection
>>> np_intersected = np1 & np2
>>> np_intersected = np1.intersection(np2)
Source code in lahuta/core/neighbors.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
union ¶
union(other)
Return the union of two NeighborPairs objects.
The method finds the union of the pairs from self
and other
. It also ensures that the distances
in the resulting object correspond to the union pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object to be unified with. |
required |
Returns:
Name | Type | Description |
---|---|---|
pairs |
NeighborPairs
|
A NeighborPairs object containing the union of the pairs from |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
# 2 ways to get the union
>>> np_union = np1 + np2
>>> np_union = np1.union(np2)
Source code in lahuta/core/neighbors.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
|
difference ¶
difference(other)
Return the difference between two NeighborPairs objects.
The method calculates the difference between the pairs from self
and other
, then returns a new
NeighborPairs object that contains the pairs from self
that are not in other
, along with their
corresponding distances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
difference_pairs |
NeighborPairs
|
A NeighborPairs object containing the pairs and their corresponding distances
from |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
# 2 ways to get the difference
>>> np_diff = np1 - np2
>>> np_diff = np1.difference(np2)
Source code in lahuta/core/neighbors.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
symmetric_difference ¶
symmetric_difference(other)
Return the symmetric difference of two NeighborPairs objects.
This method creates a new NeighborPairs
object that contains pairs and distances
that are unique to self
or other
, but not both.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A NeighborPairs object containing the symmetric difference of the two NeighborPairs objects. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
# 2 ways to get the symmetric difference
>>> np_sym_diff = np1 | np2
>>> np_sym_diff = np1.symmetric_difference(np2)
Source code in lahuta/core/neighbors.py
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 |
|
isdisjoint ¶
isdisjoint(other)
Check if the intersection of two NeighborPairs objects is null.
This method checks whether the intersection of the two NeighborPairs objects is null, thus determining if the two objects are disjoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the two NeighborPairs objects are disjoint (i.e., have no common pairs), and False otherwise. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
>>> np1.isdisjoint(np2)
True
Source code in lahuta/core/neighbors.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
issubset ¶
issubset(other)
Check if all elements (pairs) of a NeighborPairs object are found in another NeighborPairs object.
This method checks whether every pair of atoms from the current NeighborPairs object is also present in the other NeighborPairs object, thus determining if this object is a subset of the 'other'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if every pair in the current NeighborPairs object is found in the other NeighborPairs object, and False otherwise. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
>>> np1.issubset(np2)
Source code in lahuta/core/neighbors.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
|
issuperset ¶
issuperset(other)
Determine if all pairs from another NeighborPairs object are found in this object.
This method checks whether every pair of atoms from the 'other' NeighborPairs object is also present in this object, thus determining if this object is a superset of the 'other'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if all pairs from 'other' are found in this object, False otherwise. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
>>> np1.issuperset(np2)
True
Source code in lahuta/core/neighbors.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
|
isequal ¶
isequal(other)
Check if this NeighborPairs object is equal to another.
Two NeighborPairs objects are considered equal if they contain exactly the same pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the two NeighborPairs objects contain the same pairs, False otherwise. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
>>> np1.isequal(np2)
True
Source code in lahuta/core/neighbors.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
isunique ¶
isunique()
Check if all pairs in this NeighborPairs object are unique.
This method checks if all pairs in this NeighborPairs object are unique, i.e., there are no duplicate pairs.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if all pairs in this object are unique, False otherwise. |
Example
>>> np = NeighborPairs(...)
>>> np.isunique()
False
Source code in lahuta/core/neighbors.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
|
is_strict_subset ¶
is_strict_subset(other)
Check if all pairs of this NeighborPairs object are in another, and the two sets are not equal.
A strict subset has all pairs in the 'other' object but the two sets are not identical.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this object is a strict subset of 'other', False otherwise. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
>>> np1.is_strict_subset(np2)
True
Source code in lahuta/core/neighbors.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
|
is_strict_superset ¶
is_strict_superset(other)
Check if all pairs of another NeighborPairs object are in this one, and the two sets are not equal.
A strict superset has all pairs from the 'other' object but the two sets are not identical.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
NeighborPairs
|
The other NeighborPairs object. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this object is a strict superset of 'other', False otherwise. |
Example
>>> np1 = NeighborPairs(...)
>>> np2 = NeighborPairs(...)
>>> np1.is_strict_superset(np2)
True
Source code in lahuta/core/neighbors.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
|
clone ¶
clone(pairs, distances)
Return a new NeighborPairs object that is a copy of the current object, but with specified pairs and distances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pairs |
NDArray[int32]
|
The atom pairs for the new object. |
required |
distances |
NDArray[float32]
|
The corresponding distances for the new object. |
required |
Returns:
Type | Description |
---|---|
NeighborPairs
|
A new NeighborPairs object with the provided pairs and distances. |
Source code in lahuta/core/neighbors.py
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 |
|
plot ¶
plot(which='matching', half_only=False)
Plot the contact map of the NeighborPairs object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
which |
str
|
Which contact map to plot ('matching' or 'full'). Defaults to 'matching'. |
'matching'
|
half_only |
bool
|
Whether to plot only the upper half of the contact map. Defaults to False. |
False
|
Source code in lahuta/core/neighbors.py
623 624 625 626 627 628 629 630 |
|
add_annotations ¶
add_annotations(annotations)
Add annotations to the existing NeighborPairs object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
annotations |
dict[str, NDArray[Any]]
|
A dictionary containing the annotations to be added. |
required |
Source code in lahuta/core/neighbors.py
650 651 652 653 654 655 656 657 658 659 |
|
to_frame ¶
to_frame(df_format='expanded', annotations=False)
Convert the NeighborPairs object to a pandas DataFrame.
The method provides two formatting options. The 'compact' format contains two columns
for atom indices and one column for distances. The 'expanded' format contains four columns
for atom indices (two columns for each atom pair) and one column for distances.
If annotations
is True, the resulting DataFrame will also include annotation columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_format |
str
|
The format of the DataFrame. It can be either "compact" or "expanded". Defaults to "expanded". |
'expanded'
|
annotations |
bool
|
Whether to include annotations in the DataFrame. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
A pandas DataFrame containing the atom pairs and their distances. |
Source code in lahuta/core/neighbors.py
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
|
to_dict ¶
to_dict(df_format='expanded')
Convert the NeighborPairs object to a dictionary.
The method converts the NeighborPairs object to a pandas DataFrame (using the specified format), and then converts that DataFrame to a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_format |
str
|
The format of the DataFrame. It can be either "compact" or "expanded". Defaults to "expanded". |
'expanded'
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A dictionary representation of the NeighborPairs object. |
Source code in lahuta/core/neighbors.py
686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
|
vmd_exporter ¶
vmd_exporter(sphere_resolution=20, save_to_file=False)
Export a TCL script to visualize the neighbor pairs in VMD.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sphere_resolution |
int
|
The resolution of the spheres. Defaults to 20. |
20
|
save_to_file |
bool
|
Flag to save the script to a file. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Optional[str]
|
str | None: The TCL script to visualize the neighbor pairs in VMD. |
Source code in lahuta/core/neighbors.py
719 720 721 722 723 724 725 726 727 728 729 730 |
|