Select#

Selecting elements from a molecular system

Element selection is probably one of the most frequent tasks when working with molecular systems. There are many circumstances under which we need to know lists of elements meeting certain conditions. We probably need, for instance, to calculate de contact map between CA atoms from two chains, or to remove the solvent atoms, or to know how many ‘HIS’ residues there are in a protein. All these conditions can be expressed as a query sentence the elements of the system needs to match. Each library to work with molecular systems has its own syntax you have to follow to write these query sentences. See for instance different examples in the tools MDTraj, PyTraj, MDAnalysis, NGLView.

The basic module of MolSysMT includes the function molsysmt.basic.select() to perform elements selection on molecular systems with a native syntax or making use of other supported supported syntaxes.

Added in version 1.0.0.

MolSysMT selection syntax#

Although you can use the function molsysmt.basic.select() with some of your preferred syntaxes (see User guide > Introduction > Selection syntaxes), MolSysMT has its own selection syntax based on the names of the attributes of the elements as atoms, groups, molecules, etc. These are the “words” allowed for the elements attributes to be include in the query strings:


Word

Attribute

“atom_index”

atom_index

“atom_name”

atom_name

“atom_id”

atom_id

“atom_type”

atom_type

“group_index”

group_index

“group_name”

group_name

“group_id”

group_id

“group_type”

group_type

“component_index”

component_index

“component_name”

component_name

“component_id”

component_id

“component_type”

component_type

“chain_index”

chain_index

“chain_name”

chain_name

“chain_id”

chain_id

“chain_type”

chain_type

“molecule_index”

molecule_index

“molecule_name”

molecule_name

“molecule_id”

molecule_id

“molecule_type”

molecule_type

“entity_index”

entity_index

“entity_name”

entity_name

“entity_id”

entity_id

“entity_type”

entity_type

“occupancy”

occupancy

“alternate_location”

alternate_location

“b_factor”

b_factor

“formal_charge”

formal_charge

“partial_charge”

partial_charge


The plural forms of the former words are also accepted. For example:


Word

Equivalent

“atom_indices”

“atom_index”

“component_names”

“component_name”

“occupancies”

“occupancy”

“formal_charges”

“formal_charge”


The boolean syntax MolSysMT accepts includes the following words and symbols:


Word

Symbol

Meaning

“and”

&

and

“or”

|

or

“not”

~

not

“in”

in

==

equal

!=

not equal

<

less than

<=

less or equal than

>

greater than

>=

greater or equal than


MolSysMT includes in its native selection syntax some other query restrictions involving spatial coordinates and bonds:


Words

Meaning

“within … of”

Elements are selected if they are at a certain distance of other elements

“not within … of”

Elements are selected if they not are at a certain distance of other elements

“within … with pbc of”

Elements are selected if they are at a certain distance of other elements with periodic boundary conditions

“within … without pbc of”

Elements are selected if they are at a certain distance of other elements without periodic boundary conditions


Words

Meaning

“bonded to”

Elements are selected if they are bonded to other elements

“not bonded to”

Elements are selected if they are not bonded to other elements


Finally, lists of elements can be queried with the help of the following expressions:


Words

Meaning

“in groups of”

Elements are selected and returned in lists corresponding to different groups

“in components of”

Elements are selected and returned in lists corresponding to different components

“in molecules of”

Elements are selected and returned in lists corresponding to different molecules

“in chains of”

Elements are selected and returned in lists corresponding to different chains

“in entities of”

Elements are selected and returned in lists corresponding to different entities


Native selection shortcuts#

In addition to the former words and symbols, the native MolSysMT selection syntax includes some shortcuts:


Word

Equivalent

“all”

Any element in the system where element is given by the input argument element

“index” or “indices”

element_index” where element is given by the input argument element

“id” or “ids”

element_id” where element is given by the input argument element

“name” or “names”

element_name” where element is given by the input argument element

“type” or “types”

element_type” where element is given by the input argument element


Word

Equivalent

“backbone”

“atom_name in [‘CA’, ‘N’, ‘C’, ‘O’]”

“hydrogen” or “hydrogens”

“atom_type==’H’”


Your own selection shortcuts#

You can customize the selection experience with your own selection shortcuts. Have a look to the section User guide > Introduction > Configuration options

How this function works#

API documentation

Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function:molsysmt.basic.select().

Let’s explore how molsysmt.basic.select() works using its native selection syntax. The following are some examples where a list of atoms is obtained matching some selection criteria based on atoms attributes:

import molsysmt as msm
molsys = msm.convert('1TCD')
[1, 4, 10, 13, 17]

Tip

All functions defined in the molsysmt.basic module can be invoked also from the main level of the library. Hence, molsysmt.select() is the same function as molsysmt.basic.select().

# Heavy atoms
msm.select(molsys, 'not atom_type=="H"')
[0,
 1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 11,
 12,
 13,
 14,
 15,
 16,
 17,
 18,
 19,
 20,
 21,
 22,
 23,
 24,
 25,
 26,
 27,
 28,
 29,
 30,
 31,
 32,
 33,
 34,
 35,
 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,
 ...]

Tip

By default, the input argument element takes the value “atom” in molsysmt.basic.select().

The selection argument accepts also lists of indices, which are always intepreted as element indices.

msm.select(molsys, element='atom', selection=[0,1,2])
[0, 1, 2]

Some examples of atoms selections#

Let’s show here some examples of atoms selections using the MolSysMT native syntax.

# Atoms of type C not named CA
msm.select(molsys, 'atom_type=="C" and not atom_name=="CA"')
[2,
 4,
 5,
 6,
 7,
 11,
 13,
 14,
 15,
 18,
 20,
 21,
 22,
 27,
 29,
 30,
 31,
 34,
 36,
 37,
 38,
 39,
 42,
 44,
 47,
 49,
 52,
 54,
 57,
 59,
 60,
 65,
 67,
 68,
 69,
 70,
 72,
 73,
 74,
 75,
 76,
 79,
 81,
 82,
 83,
 84,
 88,
 90,
 94,
 96,
 97,
 102,
 106,
 108,
 112,
 114,
 115,
 116,
 121,
 123,
 127,
 129,
 130,
 131,
 132,
 135,
 137,
 138,
 139,
 140,
 143,
 145,
 146,
 147,
 150,
 152,
 153,
 154,
 157,
 159,
 160,
 161,
 162,
 165,
 167,
 168,
 169,
 170,
 173,
 175,
 176,
 177,
 182,
 184,
 186,
 189,
 191,
 192,
 193,
 194,
 197,
 199,
 200,
 205,
 207,
 210,
 212,
 215,
 217,
 219,
 222,
 224,
 225,
 226,
 227,
 228,
 229,
 230,
 233,
 235,
 236,
 241,
 243,
 244,
 246,
 247,
 251,
 253,
 254,
 259,
 261,
 262,
 263,
 266,
 268,
 269,
 270,
 275,
 277,
 281,
 283,
 284,
 285,
 288,
 290,
 291,
 292,
 295,
 297,
 300,
 302,
 303,
 304,
 307,
 309,
 311,
 314,
 316,
 317,
 318,
 319,
 320,
 321,
 322,
 325,
 327,
 328,
 329,
 330,
 333,
 335,
 336,
 338,
 339,
 343,
 345,
 346,
 347,
 348,
 351,
 353,
 354,
 355,
 358,
 360,
 361,
 363,
 366,
 368,
 370,
 373,
 375,
 376,
 377,
 378,
 382,
 384,
 387,
 389,
 390,
 391,
 393,
 398,
 400,
 401,
 402,
 403,
 406,
 408,
 410,
 413,
 415,
 416,
 421,
 423,
 424,
 425,
 428,
 430,
 431,
 432,
 433,
 437,
 439,
 440,
 441,
 442,
 443,
 444,
 445,
 448,
 450,
 451,
 452,
 457,
 459,
 460,
 461,
 462,
 465,
 467,
 470,
 472,
 475,
 477,
 478,
 479,
 484,
 486,
 487,
 492,
 494,
 497,
 499,
 500,
 501,
 502,
 505,
 507,
 509,
 512,
 514,
 515,
 516,
 518,
 523,
 525,
 529,
 533,
 535,
 538,
 540,
 541,
 542,
 543,
 544,
 545,
 546,
 549,
 551,
 553,
 556,
 560,
 562,
 563,
 564,
 569,
 571,
 572,
 573,
 576,
 578,
 582,
 584,
 585,
 586,
 587,
 590,
 592,
 593,
 594,
 599,
 601,
 602,
 603,
 604,
 607,
 609,
 610,
 611,
 612,
 615,
 617,
 618,
 619,
 620,
 624,
 626,
 627,
 632,
 634,
 635,
 636,
 637,
 638,
 639,
 640,
 644,
 648,
 650,
 651,
 652,
 653,
 656,
 658,
 662,
 664,
 665,
 666,
 667,
 669,
 670,
 671,
 672,
 673,
 676,
 678,
 679,
 680,
 683,
 685,
 686,
 687,
 690,
 692,
 693,
 694,
 695,
 698,
 702,
 704,
 705,
 707,
 708,
 712,
 714,
 718,
 720,
 721,
 722,
 727,
 729,
 730,
 731,
 733,
 738,
 740,
 741,
 742,
 744,
 749,
 751,
 752,
 753,
 754,
 757,
 759,
 760,
 761,
 762,
 763,
 764,
 765,
 769,
 771,
 772,
 773,
 774,
 775,
 776,
 777,
 781,
 785,
 787,
 788,
 789,
 794,
 796,
 798,
 801,
 803,
 804,
 809,
 811,
 812,
 813,
 818,
 820,
 821,
 822,
 823,
 826,
 828,
 829,
 830,
 833,
 835,
 838,
 840,
 841,
 842,
 847,
 849,
 850,
 851,
 852,
 856,
 858,
 859,
 860,
 863,
 865,
 868,
 870,
 871,
 872,
 877,
 879,
 882,
 884,
 888,
 890,
 893,
 895,
 898,
 902,
 904,
 905,
 906,
 907,
 908,
 909,
 910,
 913,
 915,
 916,
 918,
 919,
 923,
 925,
 926,
 927,
 930,
 932,
 933,
 934,
 935,
 938,
 940,
 941,
 942,
 945,
 947,
 951,
 953,
 954,
 955,
 958,
 962,
 964,
 965,
 966,
 971,
 973,
 975,
 978,
 980,
 981,
 986,
 988,
 989,
 990,
 995,
 997,
 998,
 999,
 1004,
 1006,
 1007,
 1008,
 1010,
 1015,
 1017,
 1018,
 1019,
 1024,
 1026,
 1029,
 1033,
 1035,
 1036,
 1037,
 1039,
 1044,
 1046,
 1048,
 1051,
 1053,
 1056,
 1058,
 1061,
 1063,
 1064,
 1065,
 1068,
 1070,
 1071,
 1072,
 1075,
 1077,
 1078,
 1079,
 1080,
 1083,
 1085,
 1087,
 1090,
 1092,
 1093,
 1094,
 1099,
 1101,
 1102,
 1103,
 1104,
 1107,
 1109,
 1112,
 1114,
 1117,
 1119,
 1120,
 1121,
 1124,
 1126,
 1129,
 1131,
 1132,
 1133,
 1138,
 1140,
 1141,
 1142,
 1143,
 1147,
 1149,
 1150,
 1151,
 1152,
 1155,
 1157,
 1161,
 1163,
 1164,
 1165,
 1166,
 1170,
 1172,
 1173,
 1174,
 1179,
 1181,
 1184,
 1186,
 1187,
 1188,
 1189,
 1191,
 1192,
 1193,
 1194,
 1195,
 1198,
 1200,
 1204,
 1206,
 1207,
 1208,
 1210,
 1215,
 1217,
 1218,
 1219,
 1222,
 1224,
 1225,
 1226,
 1229,
 1231,
 1232,
 1233,
 1234,
 1237,
 1239,
 1242,
 1244,
 1245,
 1246,
 1247,
 1248,
 1249,
 1250,
 1254,
 1256,
 1257,
 1258,
 1263,
 1265,
 1266,
 1267,
 1270,
 1272,
 1273,
 1274,
 1277,
 1279,
 1280,
 1281,
 1282,
 1284,
 1285,
 1286,
 1287,
 1288,
 1291,
 1293,
 1296,
 1298,
 1299,
 1300,
 1301,
 1304,
 1308,
 1310,
 1312,
 1315,
 1319,
 1321,
 1322,
 1323,
 1324,
 1328,
 1330,
 1331,
 1332,
 1335,
 1337,
 1340,
 1342,
 1344,
 1347,
 1349,
 1350,
 1351,
 1354,
 1356,
 1357,
 1358,
 1363,
 1365,
 1366,
 1367,
 1372,
 1374,
 1377,
 1379,
 1380,
 1381,
 1386,
 1388,
 1389,
 1390,
 1395,
 1397,
 1398,
 1399,
 1402,
 1404,
 1405,
 1407,
 1408,
 1412,
 1414,
 1415,
 1416,
 1421,
 1423,
 1424,
 1425,
 1426,
 1429,
 1431,
 1432,
 1433,
 1434,
 1437,
 1439,
 1440,
 1441,
 1443,
 1448,
 1450,
 1451,
 1452,
 1454,
 1459,
 1461,
 1462,
 1463,
 1464,
 1466,
 1467,
 1468,
 1469,
 1470,
 1473,
 1475,
 1476,
 1477,
 1480,
 1482,
 1483,
 1484,
 1486,
 1491,
 1493,
 1497,
 1499,
 1500,
 1501,
 1502,
 1506,
 1508,
 1509,
 1510,
 1511,
 1514,
 1518,
 1520,
 1522,
 1525,
 1527,
 1528,
 1533,
 1535,
 1536,
 1537,
 1538,
 1541,
 1543,
 1546,
 1548,
 1551,
 1553,
 1554,
 1555,
 1560,
 1562,
 1563,
 1564,
 1565,
 1568,
 1570,
 1571,
 1572,
 1574,
 1579,
 1581,
 1582,
 1583,
 1584,
 1587,
 1589,
 1590,
 1591,
 1592,
 1595,
 1597,
 1598,
 1599,
 1600,
 1601,
 1602,
 1603,
 1607,
 1611,
 1615,
 1617,
 1621,
 1623,
 1624,
 1625,
 1628,
 1630,
 1632,
 1635,
 1637,
 1640,
 1642,
 1643,
 1644,
 1645,
 1649,
 1651,
 1652,
 1657,
 1659,
 1662,
 1664,
 1665,
 1666,
 1668,
 1673,
 1675,
 1677,
 1680,
 1682,
 1683,
 1684,
 1685,
 1688,
 1690,
 1691,
 1692,
 1693,
 1694,
 1695,
 1696,
 1700,
 1702,
 1703,
 1704,
 1709,
 1711,
 1712,
 1714,
 1717,
 1719,
 1720,
 1721,
 1723,
 1728,
 1730,
 1731,
 1736,
 1738,
 1739,
 1740,
 1741,
 1744,
 1746,
 1747,
 1752,
 1756,
 1758,
 1759,
 1760,
 1761,
 1762,
 1763,
 1764,
 1767,
 1769,
 1770,
 1771,
 1772,
 1775,
 1777,
 1778,
 1779,
 1782,
 1786,
 1790,
 1792,
 1795,
 1797,
 1801,
 1803,
 1804,
 1805,
 1806,
 1809,
 1811,
 1812,
 1813,
 1814,
 1818,
 1820,
 1821,
 1822,
 1825,
 1827,
 1828,
 1829,
 1834,
 1836,
 1837,
 1838,
 1839,
 1840,
 1841,
 1842,
 1845,
 1847,
 1848,
 1849,
 1852,
 1854,
 1855,
 1856,
 1861,
 1863,
 1864,
 1865,
 1866,
 1869,
 1871,
 1872,
 1873,
 1874,
 1877,
 1879,
 1880,
 1881,
 1886,
 1888,
 1891,
 1893,
 1895,
 1898,
 1900,
 1901,
 1902,
 1903,
 1908,
 1910,
 1914,
 1916,
 1917,
 1918,
 1919,
 1923,
 1925,
 1926,
 1927,
 1930,
 1932,
 1933,
 1934,
 1939,
 1941,
 1942,
 1943,
 1946,
 1948,
 1949,
 1950,
 1951,
 1954,
 1956,
 1959,
 1961,
 1964,
 1966,
 1969,
 1971,
 1972,
 1977,
 1979,
 1980,
 ...]
# Atoms not named CA, CB or C
msm.select(molsys, 'atom_name!=["CA","CB","C"]')
[0,
 3,
 5,
 6,
 7,
 8,
 9,
 12,
 14,
 15,
 16,
 19,
 21,
 22,
 23,
 24,
 25,
 28,
 30,
 31,
 32,
 35,
 37,
 38,
 39,
 40,
 43,
 45,
 48,
 50,
 53,
 55,
 58,
 60,
 61,
 62,
 63,
 66,
 68,
 69,
 70,
 71,
 72,
 73,
 74,
 75,
 76,
 77,
 80,
 82,
 83,
 84,
 85,
 86,
 89,
 91,
 92,
 95,
 97,
 98,
 99,
 100,
 103,
 104,
 107,
 109,
 110,
 113,
 115,
 116,
 117,
 118,
 119,
 122,
 124,
 125,
 128,
 130,
 131,
 132,
 133,
 136,
 138,
 139,
 140,
 141,
 144,
 146,
 147,
 148,
 151,
 153,
 154,
 155,
 158,
 160,
 161,
 162,
 163,
 166,
 168,
 169,
 170,
 171,
 174,
 176,
 177,
 178,
 179,
 180,
 183,
 185,
 186,
 187,
 190,
 192,
 193,
 194,
 195,
 198,
 200,
 201,
 202,
 203,
 206,
 208,
 211,
 213,
 216,
 218,
 219,
 220,
 223,
 225,
 226,
 227,
 228,
 229,
 230,
 231,
 234,
 236,
 237,
 238,
 239,
 242,
 244,
 245,
 246,
 247,
 248,
 249,
 252,
 254,
 255,
 256,
 257,
 260,
 262,
 263,
 264,
 267,
 269,
 270,
 271,
 272,
 273,
 276,
 278,
 279,
 282,
 284,
 285,
 286,
 289,
 291,
 292,
 293,
 296,
 298,
 301,
 303,
 304,
 305,
 308,
 310,
 311,
 312,
 315,
 317,
 318,
 319,
 320,
 321,
 322,
 323,
 326,
 328,
 329,
 330,
 331,
 334,
 336,
 337,
 338,
 339,
 340,
 341,
 344,
 346,
 347,
 348,
 349,
 352,
 354,
 355,
 356,
 359,
 361,
 362,
 363,
 364,
 367,
 369,
 370,
 371,
 374,
 376,
 377,
 378,
 379,
 380,
 383,
 385,
 388,
 390,
 391,
 392,
 393,
 394,
 395,
 396,
 399,
 401,
 402,
 403,
 404,
 407,
 409,
 410,
 411,
 414,
 416,
 417,
 418,
 419,
 422,
 424,
 425,
 426,
 429,
 431,
 432,
 433,
 434,
 435,
 438,
 440,
 441,
 442,
 443,
 444,
 445,
 446,
 449,
 451,
 452,
 453,
 454,
 455,
 458,
 460,
 461,
 462,
 463,
 466,
 468,
 471,
 473,
 476,
 478,
 479,
 480,
 481,
 482,
 485,
 487,
 488,
 489,
 490,
 493,
 495,
 498,
 500,
 501,
 502,
 503,
 506,
 508,
 509,
 510,
 513,
 515,
 516,
 517,
 518,
 519,
 520,
 521,
 524,
 526,
 527,
 530,
 531,
 534,
 536,
 539,
 541,
 542,
 543,
 544,
 545,
 546,
 547,
 550,
 552,
 553,
 554,
 557,
 558,
 561,
 563,
 564,
 565,
 566,
 567,
 570,
 572,
 573,
 574,
 577,
 579,
 580,
 583,
 585,
 586,
 587,
 588,
 591,
 593,
 594,
 595,
 596,
 597,
 600,
 602,
 603,
 604,
 605,
 608,
 610,
 611,
 612,
 613,
 616,
 618,
 619,
 620,
 621,
 622,
 625,
 627,
 628,
 629,
 630,
 633,
 635,
 636,
 637,
 638,
 639,
 640,
 641,
 642,
 645,
 646,
 649,
 651,
 652,
 653,
 654,
 657,
 659,
 660,
 663,
 665,
 666,
 667,
 668,
 669,
 670,
 671,
 672,
 673,
 674,
 677,
 679,
 680,
 681,
 684,
 686,
 687,
 688,
 691,
 693,
 694,
 695,
 696,
 699,
 700,
 703,
 705,
 706,
 707,
 708,
 709,
 710,
 713,
 715,
 716,
 719,
 721,
 722,
 723,
 724,
 725,
 728,
 730,
 731,
 732,
 733,
 734,
 735,
 736,
 739,
 741,
 742,
 743,
 744,
 745,
 746,
 747,
 750,
 752,
 753,
 754,
 755,
 758,
 760,
 761,
 762,
 763,
 764,
 765,
 766,
 767,
 770,
 772,
 773,
 774,
 775,
 776,
 777,
 778,
 779,
 782,
 783,
 786,
 788,
 789,
 790,
 791,
 792,
 795,
 797,
 798,
 799,
 802,
 804,
 805,
 806,
 807,
 810,
 812,
 813,
 814,
 815,
 816,
 819,
 821,
 822,
 823,
 824,
 827,
 829,
 830,
 831,
 834,
 836,
 839,
 841,
 842,
 843,
 844,
 845,
 848,
 850,
 851,
 852,
 853,
 854,
 857,
 859,
 860,
 861,
 864,
 866,
 869,
 871,
 872,
 873,
 874,
 875,
 878,
 880,
 883,
 885,
 886,
 889,
 891,
 894,
 896,
 899,
 900,
 903,
 905,
 906,
 907,
 908,
 909,
 910,
 911,
 914,
 916,
 917,
 918,
 919,
 920,
 921,
 924,
 926,
 927,
 928,
 931,
 933,
 934,
 935,
 936,
 939,
 941,
 942,
 943,
 946,
 948,
 949,
 952,
 954,
 955,
 956,
 959,
 960,
 963,
 965,
 966,
 967,
 968,
 969,
 972,
 974,
 975,
 976,
 979,
 981,
 982,
 983,
 984,
 987,
 989,
 990,
 991,
 992,
 993,
 996,
 998,
 999,
 1000,
 1001,
 1002,
 1005,
 1007,
 1008,
 1009,
 1010,
 1011,
 1012,
 1013,
 1016,
 1018,
 1019,
 1020,
 1021,
 1022,
 1025,
 1027,
 1030,
 1031,
 1034,
 1036,
 1037,
 1038,
 1039,
 1040,
 1041,
 1042,
 1045,
 1047,
 1048,
 1049,
 1052,
 1054,
 1057,
 1059,
 1062,
 1064,
 1065,
 1066,
 1069,
 1071,
 1072,
 1073,
 1076,
 1078,
 1079,
 1080,
 1081,
 1084,
 1086,
 1087,
 1088,
 1091,
 1093,
 1094,
 1095,
 1096,
 1097,
 1100,
 1102,
 1103,
 1104,
 1105,
 1108,
 1110,
 1113,
 1115,
 1118,
 1120,
 1121,
 1122,
 1125,
 1127,
 1130,
 1132,
 1133,
 1134,
 1135,
 1136,
 1139,
 1141,
 1142,
 1143,
 1144,
 1145,
 1148,
 1150,
 1151,
 1152,
 1153,
 1156,
 1158,
 1159,
 1162,
 1164,
 1165,
 1166,
 1167,
 1168,
 1171,
 1173,
 1174,
 1175,
 1176,
 1177,
 1180,
 1182,
 1185,
 1187,
 1188,
 1189,
 1190,
 1191,
 1192,
 1193,
 1194,
 1195,
 1196,
 1199,
 1201,
 1202,
 1205,
 1207,
 1208,
 1209,
 1210,
 1211,
 1212,
 1213,
 1216,
 1218,
 1219,
 1220,
 1223,
 1225,
 1226,
 1227,
 1230,
 1232,
 1233,
 1234,
 1235,
 1238,
 1240,
 1243,
 1245,
 1246,
 1247,
 1248,
 1249,
 1250,
 1251,
 1252,
 1255,
 1257,
 1258,
 1259,
 1260,
 1261,
 1264,
 1266,
 1267,
 1268,
 1271,
 1273,
 1274,
 1275,
 1278,
 1280,
 1281,
 1282,
 1283,
 1284,
 1285,
 1286,
 1287,
 1288,
 1289,
 1292,
 1294,
 1297,
 1299,
 1300,
 1301,
 1302,
 1305,
 1306,
 1309,
 1311,
 1312,
 1313,
 1316,
 1317,
 1320,
 1322,
 1323,
 1324,
 1325,
 1326,
 1329,
 1331,
 1332,
 1333,
 1336,
 1338,
 1341,
 1343,
 1344,
 1345,
 1348,
 1350,
 1351,
 1352,
 1355,
 1357,
 1358,
 1359,
 1360,
 1361,
 1364,
 1366,
 1367,
 1368,
 1369,
 1370,
 1373,
 1375,
 1378,
 1380,
 1381,
 1382,
 1383,
 1384,
 1387,
 1389,
 1390,
 1391,
 1392,
 1393,
 1396,
 1398,
 1399,
 1400,
 1403,
 1405,
 1406,
 1407,
 1408,
 1409,
 1410,
 1413,
 1415,
 1416,
 1417,
 1418,
 1419,
 1422,
 1424,
 1425,
 1426,
 1427,
 1430,
 1432,
 1433,
 1434,
 1435,
 1438,
 1440,
 1441,
 1442,
 1443,
 1444,
 1445,
 1446,
 1449,
 1451,
 1452,
 1453,
 1454,
 1455,
 1456,
 1457,
 1460,
 1462,
 1463,
 1464,
 1465,
 1466,
 1467,
 1468,
 1469,
 1470,
 1471,
 1474,
 1476,
 1477,
 1478,
 1481,
 1483,
 1484,
 1485,
 1486,
 1487,
 1488,
 1489,
 1492,
 1494,
 1495,
 1498,
 1500,
 1501,
 1502,
 1503,
 1504,
 1507,
 1509,
 1510,
 1511,
 1512,
 1515,
 1516,
 1519,
 1521,
 1522,
 1523,
 1526,
 1528,
 1529,
 1530,
 1531,
 1534,
 1536,
 1537,
 1538,
 1539,
 1542,
 1544,
 1547,
 1549,
 1552,
 1554,
 1555,
 1556,
 1557,
 1558,
 1561,
 1563,
 1564,
 1565,
 1566,
 1569,
 1571,
 1572,
 1573,
 1574,
 1575,
 1576,
 1577,
 1580,
 1582,
 1583,
 1584,
 1585,
 1588,
 1590,
 1591,
 1592,
 1593,
 1596,
 1598,
 1599,
 1600,
 1601,
 1602,
 1603,
 1604,
 1605,
 1608,
 1609,
 1612,
 1613,
 1616,
 1618,
 ...]

Atoms can be selected using attributes of other elements within the molecular system’s hierarchical structure: ‘group’, ‘component’, ‘molecule’, ‘chain’, ‘entity’. You can find further information of these elements in User guide > Introduction > Molecular system > Elements. These are some examples of selection sentences including other criteria than atoms attributes:

# Atoms belonging to molecules of type water.
msm.select(molsys, 'molecule_type=="water"')
[3818,
 3819,
 3820,
 3821,
 3822,
 3823,
 3824,
 3825,
 3826,
 3827,
 3828,
 3829,
 3830,
 3831,
 3832,
 3833,
 3834,
 3835,
 3836,
 3837,
 3838,
 3839,
 3840,
 3841,
 3842,
 3843,
 3844,
 3845,
 3846,
 3847,
 3848,
 3849,
 3850,
 3851,
 3852,
 3853,
 3854,
 3855,
 3856,
 3857,
 3858,
 3859,
 3860,
 3861,
 3862,
 3863,
 3864,
 3865,
 3866,
 3867,
 3868,
 3869,
 3870,
 3871,
 3872,
 3873,
 3874,
 3875,
 3876,
 3877,
 3878,
 3879,
 3880,
 3881,
 3882,
 3883,
 3884,
 3885,
 3886,
 3887,
 3888,
 3889,
 3890,
 3891,
 3892,
 3893,
 3894,
 3895,
 3896,
 3897,
 3898,
 3899,
 3900,
 3901,
 3902,
 3903,
 3904,
 3905,
 3906,
 3907,
 3908,
 3909,
 3910,
 3911,
 3912,
 3913,
 3914,
 3915,
 3916,
 3917,
 3918,
 3919,
 3920,
 3921,
 3922,
 3923,
 3924,
 3925,
 3926,
 3927,
 3928,
 3929,
 3930,
 3931,
 3932,
 3933,
 3934,
 3935,
 3936,
 3937,
 3938,
 3939,
 3940,
 3941,
 3942,
 3943,
 3944,
 3945,
 3946,
 3947,
 3948,
 3949,
 3950,
 3951,
 3952,
 3953,
 3954,
 3955,
 3956,
 3957,
 3958,
 3959,
 3960,
 3961,
 3962,
 3963,
 3964,
 3965,
 3966,
 3967,
 3968,
 3969,
 3970,
 3971,
 3972,
 3973,
 3974,
 3975,
 3976,
 3977,
 3978,
 3979,
 3980,
 3981,
 3982]
# Heavy atoms belonging to molecules of type protein.
msm.select(molsys, 'molecule_type=="protein" and atom_type!="H" and group_index==3')
[25, 26, 27, 28, 29, 30, 31]
# Atoms belonging to residues named GLY, ALA or VAL in chain id A.
msm.select(molsys, 'group_name==["GLY","ALA","VAL"] and chain_name=="A"')
[40,
 41,
 42,
 43,
 44,
 45,
 46,
 47,
 48,
 49,
 50,
 51,
 52,
 53,
 54,
 100,
 101,
 102,
 103,
 141,
 142,
 143,
 144,
 145,
 146,
 147,
 203,
 204,
 205,
 206,
 207,
 208,
 209,
 210,
 211,
 212,
 257,
 258,
 259,
 260,
 261,
 262,
 263,
 279,
 280,
 281,
 282,
 283,
 284,
 285,
 286,
 287,
 288,
 289,
 290,
 291,
 292,
 293,
 294,
 295,
 296,
 297,
 380,
 381,
 382,
 383,
 384,
 463,
 464,
 465,
 466,
 467,
 468,
 469,
 470,
 471,
 472,
 490,
 491,
 492,
 493,
 494,
 527,
 528,
 529,
 530,
 531,
 532,
 533,
 534,
 535,
 554,
 555,
 556,
 557,
 567,
 568,
 569,
 570,
 571,
 572,
 573,
 642,
 643,
 644,
 645,
 674,
 675,
 676,
 677,
 678,
 679,
 680,
 681,
 682,
 683,
 684,
 685,
 686,
 687,
 696,
 697,
 698,
 699,
 779,
 780,
 781,
 782,
 824,
 825,
 826,
 827,
 828,
 829,
 830,
 831,
 832,
 833,
 834,
 835,
 854,
 855,
 856,
 857,
 858,
 859,
 860,
 861,
 862,
 863,
 864,
 865,
 875,
 876,
 877,
 878,
 879,
 886,
 887,
 888,
 889,
 890,
 891,
 892,
 893,
 894,
 895,
 896,
 897,
 898,
 899,
 921,
 922,
 923,
 924,
 925,
 926,
 927,
 936,
 937,
 938,
 939,
 940,
 941,
 942,
 949,
 950,
 951,
 952,
 953,
 954,
 955,
 956,
 957,
 958,
 959,
 1022,
 1023,
 1024,
 1025,
 1026,
 1027,
 1028,
 1029,
 1030,
 1049,
 1050,
 1051,
 1052,
 1053,
 1054,
 1055,
 1056,
 1057,
 1058,
 1059,
 1060,
 1061,
 1062,
 1063,
 1064,
 1065,
 1066,
 1067,
 1068,
 1069,
 1070,
 1071,
 1072,
 1105,
 1106,
 1107,
 1108,
 1109,
 1110,
 1111,
 1112,
 1113,
 1114,
 1115,
 1116,
 1117,
 1118,
 1119,
 1120,
 1121,
 1122,
 1123,
 1124,
 1125,
 1126,
 1177,
 1178,
 1179,
 1180,
 1181,
 1213,
 1214,
 1215,
 1216,
 1217,
 1218,
 1219,
 1220,
 1221,
 1222,
 1223,
 1224,
 1225,
 1226,
 1235,
 1236,
 1237,
 1238,
 1239,
 1268,
 1269,
 1270,
 1271,
 1272,
 1273,
 1274,
 1289,
 1290,
 1291,
 1292,
 1293,
 1302,
 1303,
 1304,
 1305,
 1313,
 1314,
 1315,
 1316,
 1326,
 1327,
 1328,
 1329,
 1330,
 1331,
 1332,
 1333,
 1334,
 1335,
 1336,
 1337,
 1370,
 1371,
 1372,
 1373,
 1374,
 1393,
 1394,
 1395,
 1396,
 1397,
 1398,
 1399,
 1471,
 1472,
 1473,
 1474,
 1475,
 1476,
 1477,
 1512,
 1513,
 1514,
 1515,
 1539,
 1540,
 1541,
 1542,
 1543,
 1544,
 1545,
 1546,
 1547,
 1548,
 1605,
 1606,
 1607,
 1608,
 1609,
 1610,
 1611,
 1612,
 1619,
 1620,
 1621,
 1622,
 1623,
 1624,
 1625,
 1633,
 1634,
 1635,
 1636,
 1637,
 1655,
 1656,
 1657,
 1658,
 1659,
 1750,
 1751,
 1752,
 1753,
 1773,
 1774,
 1775,
 1776,
 1777,
 1778,
 1779,
 1780,
 1781,
 1782,
 1783,
 1784,
 1785,
 1786,
 1787,
 1788,
 1789,
 1790,
 1791,
 1792,
 1843,
 1844,
 1845,
 1846,
 1847,
 1848,
 1849,
 1884,
 1885,
 1886,
 1887,
 1888]

Remember that when selection takes a list of integers as value, this is always intepreted as a list of element indices -atoms in this case-:

msm.select(molsys, selection=[10,11,12,13])
[10, 11, 12, 13]

Some examples of other elements selections#

The selection method of MolSysMT can also return other elements indices than atoms. As many functions in MolSysMT, molsysmt.basic.select() has an input argument named element to select the elements to which the function operates. Let’s see some examples:

# Groups with name "ALA"
msm.select(molsys,  element='group', selection='group_name=="ALA"')
[5,
 6,
 7,
 27,
 28,
 39,
 50,
 60,
 61,
 64,
 70,
 107,
 111,
 113,
 115,
 116,
 133,
 137,
 138,
 145,
 146,
 148,
 155,
 162,
 168,
 175,
 180,
 200,
 201,
 213,
 216,
 233,
 245,
 254,
 255,
 256,
 276,
 277,
 288,
 299,
 309,
 310,
 313,
 319,
 356,
 360,
 362,
 364,
 365,
 382,
 386,
 387,
 394,
 395,
 397,
 404,
 411,
 417,
 424,
 429,
 449,
 450,
 462,
 465,
 482,
 494]
# Groups of atoms index 34, 44 or 64
msm.select(molsys, element='group', selection='atom_index==[34,44,64]')
[4, 5, 9]
# Groups belonging to chain id A or C and molecule of type anything but water
msm.select(molsys, element='group', selection='chain_name in ["A", "C"] and molecule_type!="water"')
[0,
 1,
 2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 11,
 12,
 13,
 14,
 15,
 16,
 17,
 18,
 19,
 20,
 21,
 22,
 23,
 24,
 25,
 26,
 27,
 28,
 29,
 30,
 31,
 32,
 33,
 34,
 35,
 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]
# Molecules of type water
msm.select(molsys, 'molecule_type=="water"', element='molecule')
[2,
 3,
 4,
 5,
 6,
 7,
 8,
 9,
 10,
 11,
 12,
 13,
 14,
 15,
 16,
 17,
 18,
 19,
 20,
 21,
 22,
 23,
 24,
 25,
 26,
 27,
 28,
 29,
 30,
 31,
 32,
 33,
 34,
 35,
 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]
# Chains with molecules of type water
msm.select(molsys, 'molecule_type=="water"', element='chain')
[2, 3]
# Bonds in group index 5
msm.select(molsys, 'group_index==5', element='bond')
[42, 43, 44, 45]

When selection takes a list of integers as value, this is always intepreted as a list of elements indices:

msm.select(molsys, element='group', selection=[0,1,2,3,4,5,6,7,8,9,10,11])
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
msm.select(molsys, element='molecule', selection=[3900, 3910, 3920])
[3900, 3910, 3920]

Including external variables in the selection sentence#

Pandas query method allows the use of external variables in the logical sentence. To include them, variables names have to be preceded by the character ‘@’. Let’s illustrate its use with some examples:

# Atoms in groups with indices 10, 11 or 12.
indices = [10,11,12]
msm.select(molsys, 'group_index==@indices')
[77,
 78,
 79,
 80,
 81,
 82,
 83,
 84,
 85,
 86,
 87,
 88,
 89,
 90,
 91,
 92,
 93,
 94,
 95,
 96,
 97,
 98,
 99]
# Atoms named CA, C, O or N in groups with indices 10 to 29.
indices = list(range(10,30))
atoms = ["CA", "C", "O", "N"]
msm.select(molsys, 'atom_name==@atoms & atom_index==@indices')
[10, 11, 12, 16, 17, 18, 19, 25, 26, 27, 28]
# Groups with indices equal to 0, 100 or 200
indices = [0,100,200]
msm.select(molsys, element='group', selection='group_index==@indices')
[0, 100, 200]

Selecting elements “within a distance of”#

A selection of elements within a certain distance of a set of elements can be obtained using the string within ... of. Here you can find some examples:

msm.select(molsys, 'chain_name=="A" within 0.3 nm of chain_name=="B"')
[89,
 480,
 489,
 527,
 547,
 550,
 552,
 554,
 557,
 566,
 600,
 723,
 734,
 3818,
 3819,
 3820,
 3833,
 3836,
 3854,
 3866,
 3870,
 3872]
msm.select(molsys, '(atom_name=="N" and chain_name=="A") within 3 angstroms of (atom_type=="O" and molecule_type=="water")')
[119, 213, 473, 531, 654, 696, 799, 1049]
msm.select(molsys, '(atom_name=="CA" and chain_name=="A") within 0.5 nm of (atom_name=="CA" and chain_name=="B")',
          element='group')
[10, 42, 62, 72, 73]

The string “not within … of …” can also be used:

msm.select(molsys, 'chain_name=="A" not within 7.8 nanometers of chain_name=="B"')
[1521, 1522, 1723, 1724, 3882]

And distances can be interpreted with or without periodic boundary conditions:

msm.select(molsys, 'chain_name=="A" within 0.3 nm without pbc of chain_name=="B"')
[89,
 480,
 489,
 527,
 547,
 550,
 552,
 554,
 557,
 566,
 600,
 723,
 734,
 3818,
 3819,
 3820,
 3833,
 3836,
 3854,
 3866,
 3870,
 3872]
msm.select(molsys, 'chain_name=="A" within 0.3 nm with pbc of chain_name=="B"')
[89,
 480,
 489,
 527,
 547,
 550,
 552,
 554,
 557,
 566,
 600,
 723,
 734,
 3818,
 3819,
 3820,
 3833,
 3836,
 3854,
 3866,
 3870,
 3872]

Selecting atoms “bonded to …”#

Atoms bonded to specific atoms can also be selected with bonded to:

msm.select(molsys, 'atom_name=="N" bonded to atom_type=="C"')
[0,
 9,
 16,
 25,
 32,
 40,
 45,
 50,
 55,
 63,
 77,
 86,
 92,
 100,
 104,
 110,
 119,
 125,
 133,
 141,
 148,
 155,
 163,
 171,
 180,
 187,
 195,
 203,
 208,
 213,
 220,
 231,
 239,
 249,
 257,
 264,
 273,
 279,
 286,
 293,
 298,
 305,
 312,
 323,
 331,
 341,
 349,
 356,
 364,
 371,
 380,
 385,
 396,
 404,
 411,
 419,
 426,
 435,
 446,
 455,
 463,
 468,
 473,
 482,
 490,
 495,
 503,
 510,
 521,
 527,
 531,
 536,
 547,
 554,
 558,
 567,
 574,
 580,
 588,
 597,
 605,
 613,
 622,
 630,
 642,
 646,
 654,
 660,
 674,
 681,
 688,
 696,
 700,
 710,
 716,
 725,
 736,
 747,
 755,
 767,
 779,
 783,
 792,
 799,
 807,
 816,
 824,
 831,
 836,
 845,
 854,
 861,
 866,
 875,
 880,
 886,
 891,
 896,
 900,
 911,
 921,
 928,
 936,
 943,
 949,
 956,
 960,
 969,
 976,
 984,
 993,
 1002,
 1013,
 1022,
 1027,
 1031,
 1042,
 1049,
 1054,
 1059,
 1066,
 1073,
 1081,
 1088,
 1097,
 1105,
 1110,
 1115,
 1122,
 1127,
 1136,
 1145,
 1153,
 1159,
 1168,
 1177,
 1182,
 1196,
 1202,
 1213,
 1220,
 1227,
 1235,
 1240,
 1252,
 1261,
 1268,
 1275,
 1289,
 1294,
 1302,
 1306,
 1313,
 1317,
 1326,
 1333,
 1338,
 1345,
 1352,
 1361,
 1370,
 1375,
 1384,
 1393,
 1400,
 1410,
 1419,
 1427,
 1435,
 1446,
 1457,
 1471,
 1478,
 1489,
 1495,
 1504,
 1512,
 1516,
 1523,
 1531,
 1539,
 1544,
 1549,
 1558,
 1566,
 1577,
 1585,
 1593,
 1605,
 1609,
 1613,
 1619,
 1626,
 1633,
 1638,
 1647,
 1655,
 1660,
 1671,
 1678,
 1686,
 1698,
 1707,
 1715,
 1726,
 1734,
 1742,
 1750,
 1754,
 1765,
 1773,
 1780,
 1784,
 1788,
 1793,
 1799,
 1807,
 1816,
 1823,
 1832,
 1843,
 1850,
 1859,
 1867,
 1875,
 1884,
 1889,
 1896,
 1906,
 1912,
 1921,
 1928,
 1937,
 1944,
 1952,
 1957,
 1962,
 1967,
 1975,
 1989,
 1998,
 2004,
 2012,
 2016,
 2022,
 2031,
 2037,
 2045,
 2053,
 2060,
 2067,
 2075,
 2083,
 2092,
 2099,
 2107,
 2115,
 2120,
 2125,
 2132,
 2143,
 2151,
 2161,
 2169,
 2176,
 2185,
 2191,
 2198,
 2205,
 2210,
 2217,
 2224,
 2235,
 2243,
 2253,
 2261,
 2268,
 2276,
 2283,
 2292,
 2297,
 2308,
 2316,
 2323,
 2331,
 2338,
 2347,
 2358,
 2367,
 2375,
 2380,
 2385,
 2394,
 2402,
 2407,
 2415,
 2422,
 2433,
 2439,
 2443,
 2448,
 2459,
 2466,
 2470,
 2479,
 2486,
 2492,
 2500,
 2509,
 2517,
 2525,
 2534,
 2542,
 2554,
 2558,
 2566,
 2572,
 2586,
 2593,
 2600,
 2608,
 2612,
 2622,
 2628,
 2637,
 2648,
 2659,
 2667,
 2679,
 2691,
 2695,
 2704,
 2711,
 2719,
 2728,
 2736,
 2743,
 2748,
 2757,
 2766,
 2773,
 2778,
 2787,
 2792,
 2798,
 2803,
 2808,
 2812,
 2823,
 2833,
 2840,
 2848,
 2855,
 2861,
 2868,
 2872,
 2881,
 2888,
 2896,
 2905,
 2914,
 2925,
 2934,
 2939,
 2943,
 2954,
 2961,
 2966,
 2971,
 2978,
 2985,
 2993,
 3000,
 3009,
 3017,
 3022,
 3027,
 3034,
 3039,
 3048,
 3057,
 3065,
 3071,
 3080,
 3089,
 3094,
 3108,
 3114,
 3125,
 3132,
 3139,
 3147,
 3152,
 3164,
 3173,
 3180,
 3187,
 3201,
 3206,
 3214,
 3218,
 3225,
 3229,
 3238,
 3245,
 3250,
 3257,
 3264,
 3273,
 3282,
 3287,
 3296,
 3305,
 3312,
 3322,
 3331,
 3339,
 3347,
 3358,
 3369,
 3383,
 3390,
 3401,
 3407,
 3416,
 3424,
 3428,
 3435,
 3443,
 3451,
 3456,
 3461,
 3470,
 3478,
 3489,
 3497,
 3505,
 3517,
 3521,
 3525,
 3531,
 3538,
 3545,
 3550,
 3559,
 3567,
 3572,
 3583,
 3590,
 3598,
 3610,
 3619,
 3627,
 3638,
 3646,
 3654,
 3662,
 3666,
 3677,
 3685,
 3692,
 3696,
 3700,
 3705,
 3711,
 3719,
 3728,
 3735,
 3744,
 3755,
 3762,
 3771,
 3779,
 3787,
 3796,
 3801,
 3808]
msm.select(molsys, '(atom_type=="O" and chain_name=="A") bonded to (atom_type=="C" and chain_name=="A")')
[3,
 12,
 19,
 23,
 28,
 35,
 43,
 48,
 53,
 58,
 61,
 66,
 80,
 89,
 95,
 98,
 103,
 107,
 109,
 113,
 117,
 118,
 122,
 124,
 128,
 136,
 144,
 151,
 158,
 166,
 174,
 178,
 179,
 183,
 185,
 190,
 198,
 201,
 206,
 211,
 216,
 218,
 223,
 234,
 237,
 238,
 242,
 252,
 255,
 256,
 260,
 267,
 271,
 276,
 282,
 289,
 296,
 301,
 308,
 310,
 315,
 326,
 334,
 344,
 352,
 359,
 367,
 369,
 374,
 383,
 388,
 399,
 407,
 409,
 414,
 417,
 422,
 429,
 438,
 449,
 453,
 458,
 466,
 471,
 476,
 480,
 485,
 488,
 493,
 498,
 506,
 508,
 513,
 524,
 526,
 530,
 534,
 539,
 550,
 552,
 557,
 561,
 565,
 566,
 570,
 577,
 579,
 583,
 591,
 595,
 600,
 608,
 616,
 625,
 628,
 629,
 633,
 641,
 645,
 649,
 657,
 659,
 663,
 677,
 684,
 691,
 699,
 703,
 713,
 715,
 719,
 723,
 724,
 728,
 739,
 750,
 758,
 766,
 770,
 778,
 782,
 786,
 790,
 791,
 795,
 797,
 802,
 805,
 810,
 814,
 815,
 819,
 827,
 834,
 839,
 843,
 844,
 848,
 857,
 864,
 869,
 873,
 878,
 883,
 889,
 894,
 899,
 903,
 914,
 924,
 931,
 939,
 946,
 952,
 959,
 963,
 967,
 968,
 972,
 974,
 979,
 982,
 987,
 991,
 992,
 996,
 1000,
 1001,
 1005,
 1016,
 1020,
 1021,
 1025,
 1030,
 1034,
 1045,
 1047,
 1052,
 1057,
 1062,
 1069,
 1076,
 1084,
 1086,
 1091,
 1095,
 1100,
 1108,
 1113,
 1118,
 1125,
 1130,
 1134,
 1139,
 1148,
 1156,
 1158,
 1162,
 1171,
 1175,
 1176,
 1180,
 1185,
 1199,
 1201,
 1205,
 1216,
 1223,
 1230,
 1238,
 1243,
 1251,
 1255,
 1259,
 1260,
 1264,
 1271,
 1278,
 1292,
 1297,
 1305,
 1309,
 1311,
 1316,
 1320,
 1329,
 1336,
 1341,
 1343,
 1348,
 1355,
 1359,
 1364,
 1368,
 1373,
 1378,
 1382,
 1387,
 1391,
 1392,
 1396,
 1403,
 1413,
 1417,
 1418,
 1422,
 1430,
 1438,
 1449,
 1460,
 1474,
 1481,
 1492,
 1494,
 1498,
 1507,
 1515,
 1519,
 1521,
 1526,
 1529,
 1530,
 1534,
 1542,
 1547,
 1552,
 1556,
 1561,
 1569,
 1580,
 1588,
 1596,
 1604,
 1608,
 1612,
 1616,
 1618,
 1622,
 1629,
 1631,
 1636,
 1641,
 1650,
 1653,
 1658,
 1663,
 1674,
 1676,
 1681,
 1689,
 1697,
 1701,
 1705,
 1710,
 1718,
 1729,
 1732,
 1733,
 1737,
 1745,
 1748,
 1753,
 1757,
 1768,
 1776,
 1783,
 1787,
 1791,
 1796,
 1798,
 1802,
 1810,
 1819,
 1826,
 1830,
 1831,
 1835,
 1846,
 1853,
 1857,
 1858,
 1862,
 1870,
 1878,
 1882,
 1883,
 1887,
 1892,
 1894,
 1899,
 1905]

The string “not bonded to” can also be used:

msm.select(molsys, '(all not bonded to atom_type==["H","N","C","O"]) and molecule_type=="protein"')
[363, 1714, 2275, 3626]

And both, within .. of and bonded to, can be mixed in the same selection sentence:

msm.select(molsys, '((atom_name=="N" and chain_name=="A") bonded to atom_type=="C") within 3 angstroms of (atom_type=="O" and molecule_type=="water")')
[119, 213, 473, 531, 654, 696, 799, 1049]

Selecting elements “in elements of …”#

The function molsysmt.basic.select() does not only return single lists of elements. This tool can also be used to find a list of elements lists fulfilling a query condition with the assistance of the strings: groups of, components of, molecules of, chains of or entities of. Let’s see a couple of examples to understand how this option works.

Let’s first of all get the lists of atoms belonging to the groups of molecule index 0 named ‘CYS’:

msm.select(molsys, 'all in groups of molecule_index==0 and group_name=="CYS"')
[[86, 87, 88, 89, 90, 91],
 [273, 274, 275, 276, 277, 278],
 [880, 881, 882, 883, 884, 885],
 [943, 944, 945, 946, 947, 948]]

We can now narrow the search to only carbon atoms:

msm.select(molsys, 'atom_type=="C" in groups of molecule_index==0 and group_name=="CYS"')
[[87, 88, 90], [274, 275, 277], [881, 882, 884], [944, 945, 947]]

Let’s show how other elements lists can be queried like groups for instance:

msm.select(molsys, element='group',
           selection='group_name=="ALA" in components of molecule_name=="TRIOSEPHOSPHATE ISOMERASE"')
[[5,
  6,
  7,
  27,
  28,
  39,
  50,
  60,
  61,
  64,
  70,
  107,
  111,
  113,
  115,
  116,
  133,
  137,
  138,
  145,
  146,
  148,
  155,
  162,
  168,
  175,
  180,
  200,
  201,
  213,
  216,
  233,
  245],
 [254,
  255,
  256,
  276,
  277,
  288,
  299,
  309,
  310,
  313,
  319,
  356,
  360,
  362,
  364,
  365,
  382,
  386,
  387,
  394,
  395,
  397,
  404,
  411,
  417,
  424,
  429,
  449,
  450,
  462,
  465,
  482,
  494]]
msm.select(molsys, element='molecule',
           selection='entity_name=="water" in chains of chain_name==["A","B"]')
[[2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  10,
  11,
  12,
  13,
  14,
  15,
  16,
  17,
  18,
  19,
  20,
  21,
  22,
  23,
  24,
  25,
  26,
  27,
  28,
  29,
  30,
  31,
  32,
  33,
  34,
  35,
  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]]

The logic behind “… in elements of …” can be used redundantly. Check the following example:

msm.select(molsys, 'all in groups of group_name=="CYS" in components of component_index==[0,1]')
[[[86, 87, 88, 89, 90, 91],
  [273, 274, 275, 276, 277, 278],
  [880, 881, 882, 883, 884, 885],
  [943, 944, 945, 946, 947, 948]],
 [[1998, 1999, 2000, 2001, 2002, 2003],
  [2185, 2186, 2187, 2188, 2189, 2190],
  [2792, 2793, 2794, 2795, 2796, 2797],
  [2855, 2856, 2857, 2858, 2859, 2860]]]

The output in this last case is a list of lists of lists of atoms. More precisely, in the former example, the output corresponds to the list of atom indices of the list of CYS groups reported in two lists, those belonging to the component with index 0 and those to the component 1.

Finally, the lack of all or of all is allowed. It can be checked that the following four selections are equivalent:

sel1 = msm.select(molsys, 'all in groups of all in components of all')
sel2 = msm.select(molsys, 'all in groups of all in components')
sel3 = msm.select(molsys, 'all in groups in components of all')
sel4 = msm.select(molsys, 'all in groups in components')
sel5 = msm.select(molsys, 'in groups in components')
equal = True
for component1, component3 in zip(sel1, sel3):
    for group1, group3 in zip(component1, component3):
        for atom1, atom3 in zip(group1, group3):
            if atom1!=atom3:
                equal = False
                break

print(f'Are "sel1" and "sel3" equivalent selections?: {equal}')

equal = True
for component3, component5 in zip(sel3, sel5):
    for group3, group5 in zip(component3, component5):
        for atom3, atom5 in zip(group3, group5):
            if atom3!=atom5:
                equal = False
                break

print(f'Are "sel3" and "sel5" equivalent selections?: {equal}')
Are "sel1" and "sel3" equivalent selections?: True
Are "sel3" and "sel5" equivalent selections?: True

Multiple selections#

With molsysmt.basic.select() multiple selections can be done at once. The input argument selection admits lists of selections:

msm.select(molsys, ['group_name=="HIS" and atom_name=="CA"',
                    'group_name=="THR" and atom_name=="CA"',
                    'group_name=="TRP" and atom_name=="CA"'])
[[240, 332, 701, 912, 1401, 2152, 2244, 2613, 2824, 3313],
 [181,
  214,
  306,
  365,
  405,
  504,
  548,
  793,
  970,
  1043,
  1082,
  1307,
  1339,
  1517,
  1627,
  1672,
  1890,
  2093,
  2126,
  2218,
  2277,
  2317,
  2416,
  2460,
  2705,
  2882,
  2955,
  2994,
  3219,
  3251,
  3429,
  3539,
  3584,
  3802],
 [64, 661, 1183, 1276, 1458, 1976, 2573, 3095, 3188, 3370]]

Every selection included in the input list of selections works as described in these sections:

group_indices=[10,11,12]
msm.select(molsys, ['group_name=="HIS" and atom_name=="CA"',
                    'atom_type=="C" and group_index==@group_indices',
                     3,
                    [4,5,6]])
[[240, 332, 701, 912, 1401, 2152, 2244, 2613, 2824, 3313],
 [78, 79, 81, 82, 83, 84, 87, 88, 90, 93, 94, 96, 97],
 [3],
 [4, 5, 6]]

Other syntaxes supported#

There is no need for the user to learn the native syntax. Other syntaxes such as the used by MDTraj is also supported by MolSysMT:

msm.select(molsys, selection='(name =~ "C[A-B]") and (resid 1 to 3)', syntax='MDTraj')
array([10, 13, 17, 20, 26, 29])

Translation between different syntaxes#

MolSysMT aims to simplify interoperability with other libraries. Since each one uses a different selection syntax, MolSysMT allows converting queries to other syntaxes using the to_syntax argument. Lets illustrate some examples:

msm.select(molsys, selection='group_index==[3,4,5]', to_syntax='NGLView')
'@25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44'
msm.select(molsys, selection='group_index==[3,4,5]', to_syntax='MDTraj')
'index 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44'

The output string can be obtained, if the selection is done over other elementted elements, as a sequence of groups or chains:

msm.select(molsys, element='group', selection='group_index==[3,4,5]', to_syntax='NGLView')
'7:A 8:A 9:A'
msm.select(molsys, element='group', selection='group_index==[3,4,5]', to_syntax='MDTraj')
'resid 3 4 5'

See also

User guide > Introduction > Molecular System > Attributes:
List of attributes available in molecular systems.

User guide > Introduction > Selection syntaxes:
Overview of supported syntaxes for element selection.

User guide > Tools > Basic > Convert:
Convert molecular systems between formats.

User guide > Tools > Basic > Info:
Display summary information about molecular systems.