Difference between revisions of "Tutorial:Selecting subsets of atoms"

From MSL-Libraries
Jump to navigationJump to search
(Program description)
(Background)
 
(3 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
    
 
    
 
 
 
 
====Selection By Name:====
+
<font color="blue">Selection By Name</font>
 +
 
 
Can select based on selection flags that are inside each Atom.  By default every atom has an "all" selection flag set.
 
Can select based on selection flags that are inside each Atom.  By default every atom has an "all" selection flag set.
 
       
 
       
Line 26: Line 27:
 
</source>
 
</source>
  
====Selection By Property====
+
<font color="blue">Selection By Property</font>
 +
 
 
Using '''[[MSL Objects:AtomSelection|AtomSelection]]''' Object, to select all atoms of chain A:
 
Using '''[[MSL Objects:AtomSelection|AtomSelection]]''' Object, to select all atoms of chain A:
 
  <source lang="cpp">
 
  <source lang="cpp">
Line 54: Line 56:
 
<source lang="cpp">
 
<source lang="cpp">
 
AtomPointerVector allAts = sel.select("all");
 
AtomPointerVector allAts = sel.select("all");
<source>
+
</source>
  
 
 
Line 65: Line 67:
  
 
 
// Expanding the selection logic
+
* Expanding the selection logic , first a long-hand selection string is used. second a short-hand version of the same selection is used.
cout << "Select backbone atoms using selection logic"<<endl;
+
<source lang="cpp">
cout << "    sel.select(\"bb, (((name CA OR name N) OR name C) OR name O)\");"<<endl;
 
cout << " Hit any character and enter to execute test"<<endl;
 
cin >> file; // dummy line to wait for input to run
 
  
 
AtomPointerVector backbone    = sel.select("bb, (((name CA OR name N) OR name C) OR name O)");
 
AtomPointerVector backbone    = sel.select("bb, (((name CA OR name N) OR name C) OR name O)");
for (uint i = 0; i < backbone.size();i++){
+
 
  cout << *backbone[i]<<endl;
 
}
 
cout << endl;
 
cout << "Select backbone atoms using short-hand selection logic"<<endl;
 
cout << "    sel.select(\"bb2, name CA+N+C+O\");"<<endl;
 
cout << " Hit any character and enter to execute test"<<endl;
 
cin >> file; // dummy line to wait for input to run
 
 
AtomPointerVector bbShortHand = sel.select("bb2, name CA+N+C+O");
 
AtomPointerVector bbShortHand = sel.select("bb2, name CA+N+C+O");
for (uint i = 0; i < bbShortHand.size();i++){
 
  cout << *bbShortHand[i]<<endl;
 
}
 
  
// Selections using names from previous selections
+
</source>
cout << "Create a selection using the name of a previous selection.."<<endl;
+
 
cout << "    AtomPointerVector test = sel.select(\"new, bb AND name O\");"<<endl;
+
 
cout << " Hit any character and enter to execute test"<<endl;
+
 
cin >> file; // dummy line to wait for input to run
+
* Selections using names from previous selections
 +
<source lang="cpp">
 
AtomPointerVector test = sel.select("new, bb AND name O");
 
AtomPointerVector test = sel.select("new, bb AND name O");
for (uint i = 0; i < test.size();i++){
+
</source>
  cout << *test[i]<<endl;
+
 
}
+
* Selections using NOT operator
 +
<source lang="cpp">
  
// Selections using NOT operator
 
cout << "Create a selection using the NOT operator.."<<endl;
 
cout <<"      AtomPointerVector notBB = sel.select(\"notBB, not name CA+C+O+N\")"<<endl;
 
cout << " Hit any character and enter to execute test"<<endl;
 
cin >> file; // dummy line to wait for input to run
 
 
AtomPointerVector notBB = sel.select("notBB, not name CA+C+O+N");
 
AtomPointerVector notBB = sel.select("notBB, not name CA+C+O+N");
for (uint i = 0; i < notBB.size();i++){
 
  cout << *notBB[i]<<endl;
 
}
 
  
// Selections using range "-" operator.
+
</source>
cout << "Create a selection using the '-' operator.."<<endl;
+
 
cout <<"      AtomPointerVector res26 = sel.select(\"res26, resi 2-6\")"<<endl;
+
* Selections using range "-" operator.
cout << " Hit any character and enter to execute test"<<endl;
+
<source lang="cpp">
cin >> file; // dummy line to wait for input to run
 
 
AtomPointerVector res26 = sel.select("res26, resi 2-6");
 
AtomPointerVector res26 = sel.select("res26, resi 2-6");
for (uint i = 0; i < res26.size();i++){
+
</source>
  cout << *res26[i]<<endl;
 
}
 
  
// Selection using distances to a sub-selection
+
* Selection using distances to a sub-selection
cout << "Create an atom selection named 'oxygensHbondSer', based on a distance from another selection 'name OG'\n";
+
<source lang="cpp">
cout << "    AtomPointerVector oxygensHbondSer = sel.select(\"oxygensHbondSer, name O WITHIN 3.5 OF name OG\");"<<endl;
 
cout << " Hit any character and enter to execute test"<<endl;
 
cin >> file; // dummy line to wait for input to run
 
 
AtomPointerVector oxygensHbondSer = sel.select("oxygensHbondSer, name O WITHIN 3.5 OF name OG");
 
AtomPointerVector oxygensHbondSer = sel.select("oxygensHbondSer, name O WITHIN 3.5 OF name OG");
for (uint i = 0; i < oxygensHbondSer.size();i++){
+
</source>
  cout << *oxygensHbondSer[i]<<endl;
 
}
 
  
  
return 0;
 
}
 
 
</source>
 
  
 
----
 
----

Latest revision as of 22:02, 23 March 2010

NOTE: TUTORIAL WRITING IN PROGRESS DO NOT FOLLOW THIS


This is an example on how to select atoms and residues with MSL, following the example program example_selecting_atoms_and_residues.cpp in the examples/ subdirectory.

Complete source of example_selecting_atoms_and_residues


Background

MSL objects can be selected if they inherit the Selectable object. So far, Atoms and Residues are Selectable. The requirement for being selectable is to implement the virtual "addSelectableFunctions", which define what properties of the object can be selected upon.


Selection By Name

Can select based on selection flags that are inside each Atom. By default every atom has an "all" selection flag set.

You can create selection flags for atoms by:

    
    a.setSelectionFlag("foobar")
    as.select("foobar, chain A")

Selection By Property

Using AtomSelection Object, to select all atoms of chain A:

    as.select("chain A")

To compile

% make bin/example_selecting_atoms_and_residues

To run the program

Go to the main directory and run the command (note, the location of the exampleFiles subdirectory needs to be provided as an argument)

% bin/example_selecting_atoms_and_residues exampleFiles

Program description

  • Creating an AtomSelection object
	
	AtomSelection sel(sys.getAtomPointers());
  • Basic selection 'all'
	AtomPointerVector allAts = sel.select("all");


  • Select chain A atoms and store as "chA" for easy retrieval
	AtomPointerVector chainAAts = sel.select("chA, chain A");


  • Expanding the selection logic , first a long-hand selection string is used. second a short-hand version of the same selection is used.
	AtomPointerVector backbone    = sel.select("bb, (((name CA OR name N) OR name C) OR name O)");

	AtomPointerVector bbShortHand = sel.select("bb2, name CA+N+C+O");


  • Selections using names from previous selections
	AtomPointerVector test = sel.select("new, bb AND name O");
  • Selections using NOT operator
	AtomPointerVector notBB = sel.select("notBB, not name CA+C+O+N");
  • Selections using range "-" operator.
	AtomPointerVector res26 = sel.select("res26, resi 2-6");
  • Selection using distances to a sub-selection
	AtomPointerVector oxygensHbondSer = sel.select("oxygensHbondSer, name O WITHIN 3.5 OF name OG");



Back to the tutorial page