Index: src/Actions/GlobalListOfActions.hpp
===================================================================
--- src/Actions/GlobalListOfActions.hpp	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ src/Actions/GlobalListOfActions.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -93,4 +93,5 @@
 	(SelectionNotMoleculeByName) \
 	(SelectionNotAtomById) \
+	(SelectionNotAtomByOrder) \
 	(SelectionAllAtomsInsideCuboid) \
 	(SelectionAllAtoms) \
@@ -105,4 +106,5 @@
 	(SelectionNotAllAtomsInsideCuboid) \
 	(SelectionAtomById) \
+	(SelectionAtomByOrder) \
 	(FragmentationFragmentation) \
 	(FillRegularGrid)
Index: src/Actions/Makefile.am
===================================================================
--- src/Actions/Makefile.am	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ src/Actions/Makefile.am	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -290,4 +290,5 @@
   Actions/SelectionAction/Atoms/AtomByElementAction.cpp \
   Actions/SelectionAction/Atoms/AtomByIdAction.cpp \
+  Actions/SelectionAction/Atoms/AtomByOrderAction.cpp \
   Actions/SelectionAction/Atoms/ClearAllAtomsAction.cpp \
   Actions/SelectionAction/Atoms/NotAllAtomsAction.cpp \
@@ -296,5 +297,6 @@
   Actions/SelectionAction/Atoms/NotAllAtomsOfMoleculeAction.cpp \
   Actions/SelectionAction/Atoms/NotAtomByElementAction.cpp \
-  Actions/SelectionAction/Atoms/NotAtomByIdAction.cpp
+  Actions/SelectionAction/Atoms/NotAtomByIdAction.cpp \
+  Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp
 SELECTIONATOMACTIONHEADER = \
   Actions/SelectionAction/Atoms/AllAtomsAction.hpp \
@@ -304,4 +306,5 @@
   Actions/SelectionAction/Atoms/AtomByElementAction.hpp \
   Actions/SelectionAction/Atoms/AtomByIdAction.hpp \
+  Actions/SelectionAction/Atoms/AtomByOrderAction.hpp \
   Actions/SelectionAction/Atoms/ClearAllAtomsAction.hpp \
   Actions/SelectionAction/Atoms/NotAllAtomsAction.hpp \
@@ -310,5 +313,6 @@
   Actions/SelectionAction/Atoms/NotAllAtomsOfMoleculeAction.hpp \
   Actions/SelectionAction/Atoms/NotAtomByElementAction.hpp \
-  Actions/SelectionAction/Atoms/NotAtomByIdAction.hpp
+  Actions/SelectionAction/Atoms/NotAtomByIdAction.hpp \
+  Actions/SelectionAction/Atoms/NotAtomByOrderAction.hpp
 SELECTIONATOMACTIONDEFS = \
   Actions/SelectionAction/Atoms/AllAtomsAction.def \
@@ -318,4 +322,5 @@
   Actions/SelectionAction/Atoms/AtomByElementAction.def \
   Actions/SelectionAction/Atoms/AtomByIdAction.def \
+  Actions/SelectionAction/Atoms/AtomByOrderAction.def \
   Actions/SelectionAction/Atoms/ClearAllAtomsAction.def \
   Actions/SelectionAction/Atoms/NotAllAtomsAction.def \
@@ -324,5 +329,6 @@
   Actions/SelectionAction/Atoms/NotAllAtomsOfMoleculeAction.def \
   Actions/SelectionAction/Atoms/NotAtomByElementAction.def \
-  Actions/SelectionAction/Atoms/NotAtomByIdAction.def
+  Actions/SelectionAction/Atoms/NotAtomByIdAction.def \
+  Actions/SelectionAction/Atoms/NotAtomByOrderAction.def
 
 SELECTIONMOLECULEACTIONSOURCE = \
Index: src/Actions/SelectionAction/Atoms/AtomByOrderAction.cpp
===================================================================
--- src/Actions/SelectionAction/Atoms/AtomByOrderAction.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Actions/SelectionAction/Atoms/AtomByOrderAction.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,84 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * AtomByOrderAction.cpp
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Atom/atom.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "World.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/AtomOrderDescriptor.hpp"
+
+#include <iostream>
+#include <string>
+
+#include "AtomByOrderAction.hpp"
+
+using namespace MoleCuilder;
+
+// and construct the stuff
+#include "AtomByOrderAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr SelectionAtomByOrderAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+  const atom *Walker = World::getInstance().getAtom(AtomByOrder(params.order));
+  if (Walker != NULL) {
+    if (!World::getInstance().isSelected(Walker)) {
+      LOG(1, "Selecting atom " << *Walker);
+      World::getInstance().selectAtom(Walker);
+      LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected.");
+      return Action::state_ptr(new SelectionAtomByOrderState(Walker->getId(), params));
+    } else {
+      return Action::success;
+    }
+  } else {
+    return Action::failure;
+  }
+}
+
+Action::state_ptr SelectionAtomByOrderAction::performUndo(Action::state_ptr _state) {
+  SelectionAtomByOrderState *state = assert_cast<SelectionAtomByOrderState*>(_state.get());
+
+  const atom *Walker = World::getInstance().getAtom(AtomById(state->WalkerId));
+  World::getInstance().unselectAtom(Walker);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionAtomByOrderAction::performRedo(Action::state_ptr _state){
+  SelectionAtomByOrderState *state = assert_cast<SelectionAtomByOrderState*>(_state.get());
+
+  const atom *Walker = World::getInstance().getAtom(AtomById(state->WalkerId));
+  World::getInstance().selectAtom(Walker);
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionAtomByOrderAction::canUndo() {
+  return true;
+}
+
+bool SelectionAtomByOrderAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/SelectionAction/Atoms/AtomByOrderAction.def
===================================================================
--- src/Actions/SelectionAction/Atoms/AtomByOrderAction.def	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Actions/SelectionAction/Atoms/AtomByOrderAction.def	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,33 @@
+/*
+ * AtomByOrderAction.def
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+class atom;
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#define paramtypes (int)
+#define paramtokens ("select-atom-by-order")
+#define paramdescriptions ("order index")
+#undef paramdefaults
+#define paramreferences (order)
+
+#define statetypes (atomId_t)
+#define statereferences (WalkerId)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Selection
+#define MENUNAME "selection"
+#define MENUPOSITION 6
+#define ACTIONNAME AtomByOrder
+#define TOKEN "select-atom-by-order"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "select an atom by order of appearance"
+#undef SHORTFORM
Index: src/Actions/SelectionAction/Atoms/AtomByOrderAction.hpp
===================================================================
--- src/Actions/SelectionAction/Atoms/AtomByOrderAction.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Actions/SelectionAction/Atoms/AtomByOrderAction.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,22 @@
+/*
+ * AtomByOrderAction.hpp
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+#ifndef ATOMBYORDERACTION_HPP_
+#define ATOMBYORDERACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "AtomByOrderAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* ATOMBYORDERACTION_HPP_ */
Index: src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp
===================================================================
--- src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,84 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * NotAtomByOrderAction.cpp
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Atom/atom.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/AtomOrderDescriptor.hpp"
+#include "World.hpp"
+
+#include <iostream>
+#include <string>
+
+#include "NotAtomByOrderAction.hpp"
+
+using namespace MoleCuilder;
+
+// and construct the stuff
+#include "NotAtomByOrderAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr SelectionNotAtomByOrderAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+  const atom * Walker = World::getInstance().getAtom(AtomByOrder(params.order));
+  if (Walker != NULL) {
+    if (World::getInstance().isSelected(Walker)) {
+      LOG(1, "Unselecting atom " << *Walker);
+      World::getInstance().unselectAtom(Walker);
+      LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
+      return Action::state_ptr(new SelectionNotAtomByOrderState(Walker->getId(), params));
+    } else {
+      return Action::success;
+    }
+  } else {
+    return Action::failure;
+  }
+}
+
+Action::state_ptr SelectionNotAtomByOrderAction::performUndo(Action::state_ptr _state) {
+  SelectionNotAtomByOrderState *state = assert_cast<SelectionNotAtomByOrderState*>(_state.get());
+
+  const atom * Walker = World::getInstance().getAtom(AtomById(state->WalkerId));
+  World::getInstance().selectAtom(Walker);
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr SelectionNotAtomByOrderAction::performRedo(Action::state_ptr _state){
+  SelectionNotAtomByOrderState *state = assert_cast<SelectionNotAtomByOrderState*>(_state.get());
+
+  const atom * Walker = World::getInstance().getAtom(AtomById(state->WalkerId));
+  World::getInstance().unselectAtom(Walker);
+
+  return Action::state_ptr(_state);
+}
+
+bool SelectionNotAtomByOrderAction::canUndo() {
+  return true;
+}
+
+bool SelectionNotAtomByOrderAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.def
===================================================================
--- src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.def	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.def	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,33 @@
+/*
+ * NotAtomByOrderAction.def
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+class atom;
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#define paramtypes (int)
+#define paramtokens ("unselect-atom-by-order")
+#define paramdescriptions ("order index")
+#undef paramdefaults
+#define paramreferences (order)
+
+#define statetypes (atomId_t)
+#define statereferences (WalkerId)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Selection
+#define MENUNAME "selection"
+#define MENUPOSITION 16
+#define ACTIONNAME NotAtomByOrder
+#define TOKEN "unselect-atom-by-order"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "unselect an atom by order of appearance"
+#undef SHORTFORM
Index: src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.hpp
===================================================================
--- src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Actions/SelectionAction/Atoms/NotAtomByOrderAction.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,22 @@
+/*
+ * NotAtomByOrderAction.hpp
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+#ifndef NOTATOMBYORDERACTION_HPP_
+#define NOTATOMBYORDERACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "NotAtomByOrderAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* NOTATOMBYORDERACTION_HPP_ */
Index: src/Descriptors/AtomOrderDescriptor.cpp
===================================================================
--- src/Descriptors/AtomOrderDescriptor.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Descriptors/AtomOrderDescriptor.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,87 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters _atomecular systems
+ * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * AtomOrderDescriptor.cpp
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "AtomOrderDescriptor.hpp"
+#include "AtomOrderDescriptor_impl.hpp"
+
+#include "Atom/atom.hpp"
+#include "CodePatterns/Observer/ObservedContainer_impl.hpp"
+
+using namespace std;
+
+
+AtomOrderDescriptor_impl::AtomOrderDescriptor_impl(int _id) :
+  id(_id)
+{}
+
+AtomOrderDescriptor_impl::~AtomOrderDescriptor_impl()
+{}
+
+bool AtomOrderDescriptor_impl::predicate(std::pair<atomId_t,atom*> _atom)
+{
+  atom *Walker = find();
+  return (Walker == _atom.second);
+}
+
+AtomDescriptor AtomByOrder(int id){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomOrderDescriptor_impl(id)));
+}
+
+World::AtomSet& AtomOrderDescriptor_impl::getAtoms()
+{
+  return World::getInstance().atoms;
+}
+
+
+atom *AtomOrderDescriptor_impl::find(){
+  World::AtomSet &atoms = getAtoms();
+
+  int i=0;
+  atom *_atom = NULL;
+  if (id == 0) {
+    return NULL;
+  } else if (id > 0) {
+    World::AtomSet::internal_iterator res = atoms.begin_internal();
+    for (; res != atoms.end_internal(); ++res) { // when iterator is normal, ++ goes forward!
+      ++i;
+      if (id == i) {
+        _atom = res->second;
+        break;
+      }
+    }
+  } else {
+    World::AtomSet::reverse_internal_iterator res = atoms.rbegin_internal();
+    for (; res != atoms.rend_internal(); ++res) {  // when iterator is reverse, ++ goes backward!
+      --i;
+      if (id == i) {
+        _atom = res->second;
+        break;
+      }
+    }
+  }
+
+  return _atom;
+}
+
+vector<atom*> AtomOrderDescriptor_impl::findAll(){
+  atom *res = find();
+  return (res)?(vector<atom*>(1,res)):(vector<atom*>());
+}
Index: src/Descriptors/AtomOrderDescriptor.hpp
===================================================================
--- src/Descriptors/AtomOrderDescriptor.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Descriptors/AtomOrderDescriptor.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,22 @@
+/*
+ * AtomOrderDescriptor.hpp
+ *
+ *  Created on: Mar 22, 2012
+ *      Author: heber
+ */
+
+#ifndef ATOMORDERDESCRIPTOR_HPP_
+#define ATOMORDERDESCRIPTOR_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "types.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+
+AtomDescriptor AtomByOrder(int id);
+
+#endif /* ATOMORDERDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomOrderDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomOrderDescriptor_impl.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ src/Descriptors/AtomOrderDescriptor_impl.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,30 @@
+#ifndef ATOMORDERDESCRIPTOR_IMPL_HPP
+#define ATOMORDERDESCRIPTOR_IMPL_HPP
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+class AtomOrderDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomOrderDescriptor_impl(int _id);
+  virtual ~AtomOrderDescriptor_impl();
+
+  bool predicate(std::pair<atomId_t,atom*> atom);
+
+protected:
+  virtual atom *find();
+  virtual std::vector<atom*> findAll();
+
+  World::AtomSet& getAtoms();
+
+private:
+  int id;
+};
+
+#endif //ATOMORDERDESCRIPTOR_IMPL_HPP
Index: src/Descriptors/unittests/AtomDescriptorUnitTest.cpp
===================================================================
--- src/Descriptors/unittests/AtomDescriptorUnitTest.cpp	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ src/Descriptors/unittests/AtomDescriptorUnitTest.cpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -28,4 +28,5 @@
 #include <Descriptors/AtomIdDescriptor.hpp>
 #include <Descriptors/AtomOfMoleculeDescriptor.hpp>
+#include <Descriptors/AtomOrderDescriptor.hpp>
 #include <Descriptors/AtomsWithinDistanceOfDescriptor.hpp>
 
@@ -153,4 +154,28 @@
 }
 
+void AtomDescriptorTest::AtomOrderTest()
+{
+  atom* testAtom;
+
+  // test in normal order: 1, 2, ...
+  for(int i=1;i<=ATOM_COUNT;++i){
+    testAtom = World::getInstance().getAtom(AtomByOrder(i));
+    CPPUNIT_ASSERT_EQUAL( atomIds[i-1], testAtom->getId());
+  }
+
+  // test in reverse order: -1, -2, ...
+  for(int i=1; i<= ATOM_COUNT;++i){
+    testAtom = World::getInstance().getAtom(AtomByOrder(-i));
+    CPPUNIT_ASSERT_EQUAL( atomIds[(int)ATOM_COUNT-i], testAtom->getId());
+  }
+
+  // test from outside of set
+  testAtom = World::getInstance().getAtom(AtomByOrder(ATOM_COUNT+1));
+  CPPUNIT_ASSERT(!testAtom);
+  testAtom = World::getInstance().getAtom(AtomByOrder(-ATOM_COUNT-1));
+  CPPUNIT_ASSERT(!testAtom);
+}
+
+
 std::set<atomId_t> getDistanceList(const double distance, const Vector &position, atom **list)
 {
@@ -172,4 +197,49 @@
   return testlist;
 }
+
+//void AtomDescriptorTest::AtomsShapeTest()
+//{
+//  // align atoms along an axis
+//  for(int i=0;i<ATOM_COUNT;++i) {
+//    atoms[i]->setPosition(Vector((double)i, 0., 0.));
+//    //std::cout << "atoms[" << i << "]: " << atoms[i]->getId() << " at " << atoms[i]->getPosition() << std::endl;
+//  }
+//
+//  // get atom by descriptor ...
+//  // ... from origin up to 2.5
+//  {
+//    const double distance = 1.5;
+//    Vector position(0.,0.,0.);
+//    Shape s = Sphere(position, distance);
+//    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s));
+//    CPPUNIT_ASSERT_EQUAL( (size_t)2, atomlist.size() );
+//    std::set<atomId_t> reflist = getDistanceList(distance, position, atoms);
+//    std::set<atomId_t> testlist = getIdList(atomlist);
+//    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
+//  }
+//  // ... from (4,0,0) up to 2.9 (i.e. more shells or different view)
+//  {
+//    const double distance = 2.9;
+//    Vector position(4.,0.,0.);
+//    Shape s = Sphere(position, distance);
+//    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s));
+//    CPPUNIT_ASSERT_EQUAL( (size_t)5, atomlist.size() );
+//    std::set<atomId_t> reflist = getDistanceList(distance, position, atoms);
+//    std::set<atomId_t> testlist = getIdList(atomlist);
+//    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
+//  }
+//  // ... from (10,0,0) up to 1.5
+//  {
+//    const double distance = 1.5;
+//    Vector *position = new Vector(10.,0.,0.);
+//    Shape s = Sphere(position, distance);
+//    World::AtomComposite atomlist = World::getInstance().getAllAtoms(AtomsByShape(s));
+//    CPPUNIT_ASSERT_EQUAL( (size_t)1, atomlist.size() );
+//    std::set<atomId_t> reflist = getDistanceList(distance, *position, atoms);
+//    std::set<atomId_t> testlist = getIdList(atomlist);
+//    CPPUNIT_ASSERT_EQUAL( reflist, testlist );
+//    delete position;
+//  }
+//}
 
 void AtomDescriptorTest::AtomsWithinDistanceOfTest()
Index: src/Descriptors/unittests/AtomDescriptorUnitTest.hpp
===================================================================
--- src/Descriptors/unittests/AtomDescriptorUnitTest.hpp	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ src/Descriptors/unittests/AtomDescriptorUnitTest.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -30,5 +30,7 @@
   CPPUNIT_TEST ( AtomIdTest );
   CPPUNIT_TEST ( AtomOfMoleculeTest );
+  CPPUNIT_TEST ( AtomOrderTest );
   CPPUNIT_TEST ( AtomsWithinDistanceOfTest );
+//  CPPUNIT_TEST ( AtomsShapeTest );
   CPPUNIT_TEST ( AtomCalcTest );
   CPPUNIT_TEST_SUITE_END();
@@ -39,7 +41,9 @@
 
   void AtomBaseSetsTest();
+  void AtomIdTest();
   void AtomOfMoleculeTest();
-  void AtomIdTest();
+  void AtomOrderTest();
   void AtomsWithinDistanceOfTest();
+//  void AtomsShapeTest();
   void AtomCalcTest();
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ src/Makefile.am	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -41,4 +41,5 @@
   Descriptors/AtomOfMoleculeDescriptor.cpp \
   Descriptors/AtomOfMoleculeSelectionDescriptor.cpp \
+  Descriptors/AtomOrderDescriptor.cpp \
   Descriptors/AtomSelectionDescriptor.cpp \
   Descriptors/AtomShapeDescriptor.cpp \
@@ -60,4 +61,5 @@
   Descriptors/AtomOfMoleculeDescriptor.hpp \
   Descriptors/AtomOfMoleculeSelectionDescriptor.hpp \
+  Descriptors/AtomOrderDescriptor.hpp \
   Descriptors/AtomSelectionDescriptor.hpp \
   Descriptors/AtomShapeDescriptor.hpp \
@@ -80,4 +82,5 @@
   Descriptors/AtomOfMoleculeDescriptor_impl.hpp \
   Descriptors/AtomOfMoleculeSelectionDescriptor_impl.hpp \
+  Descriptors/AtomOrderDescriptor_impl.hpp \
   Descriptors/AtomSelectionDescriptor_impl.hpp \
   Descriptors/AtomShapeDescriptor_impl.hpp \
Index: src/World.hpp
===================================================================
--- src/World.hpp	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ src/World.hpp	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -88,4 +88,5 @@
 friend class AtomSelectionDescriptor_impl;
 friend class AtomOfMoleculeSelectionDescriptor_impl;
+friend class AtomOrderDescriptor_impl;
 friend class MoleculeOfAtomSelectionDescriptor_impl;
 friend class MoleculeOrderDescriptor_impl;
Index: tests/Python/AllActions/moltest.py
===================================================================
--- tests/Python/AllActions/moltest.py	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ tests/Python/AllActions/moltest.py	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -24,5 +24,9 @@
     for line in f:
         if len(line) > 0 and line[0] != '#':
-            key, value = line.split('\t', 1)
+            try:
+              key, value = line.split('\t', 1)
+            except ValueError:
+              print "line needs two values, tab-separated: "+line
+              sys.exit(1)
             value = value[1:-2] # quotes entfernen
         
Index: tests/Python/AllActions/moltest_check.py
===================================================================
--- tests/Python/AllActions/moltest_check.py	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ tests/Python/AllActions/moltest_check.py	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -11,5 +11,9 @@
     for line in f:
         if len(line) > 0 and line[0] != '#':
-            key, value = line.split('\t', 1)
+            try:
+              key, value = line.split('\t', 1)
+            except ValueError:
+              print "line needs two values, tab-separated: "+line
+              sys.exit(1)
             value = value[1:-2] # remove quotes
         
Index: tests/Python/AllActions/options.dat
===================================================================
--- tests/Python/AllActions/options.dat	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ tests/Python/AllActions/options.dat	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -138,4 +138,5 @@
 select-atom-by-element	"4"
 select-atom-by-id	"0"
+select-atom-by-order	"1"
 select-atoms-inside-cuboid	"10 10 10"
 select-atoms-inside-cuboid	"2 2 2"
@@ -176,4 +177,5 @@
 unselect-atom-by-element	"4"
 unselect-atom-by-id	"0"
+unselect-atom-by-order	"1"
 unselect-atoms-inside-cuboid	"10 10 10"
 unselect-atoms-inside-cuboid	"2 2 2"
Index: tests/regression/Makefile.am
===================================================================
--- tests/regression/Makefile.am	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ tests/regression/Makefile.am	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -151,4 +151,6 @@
 	$(srcdir)/Selection/Atoms/AtomById/testsuite-selection-select-atom-by-id.at \
 	$(srcdir)/Selection/Atoms/AtomById/testsuite-selection-unselect-atom-by-id.at \
+	$(srcdir)/Selection/Atoms/AtomByOrder/testsuite-selection-select-atom-by-order.at \
+	$(srcdir)/Selection/Atoms/AtomByOrder/testsuite-selection-unselect-atom-by-order.at \
 	$(srcdir)/Selection/Atoms/AtomsInsideCuboid/testsuite-selection-select-atoms-inside-cuboid.at \
 	$(srcdir)/Selection/Atoms/AtomsInsideCuboid/testsuite-selection-select-atoms-inside-cuboid-with-defaults.at \
Index: tests/regression/Selection/Atoms/AtomByOrder/post/empty.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/empty.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/empty.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,2 @@
+0
+	Created by molecuilder for unselect-atom-by-id test
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id0_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id0_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id0_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id0_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id0_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id0_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	0	0	0
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id1_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id1_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id1_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id1_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id1_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id1_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	0	0	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id2_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id2_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id2_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id2_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id2_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id2_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	0	1	0
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id3_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id3_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id3_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	1	0	0
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id3_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id3_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id3_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	0	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id4_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id4_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id4_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id4_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id4_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id4_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	1	0	0
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id5_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id5_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id5_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id5_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id5_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id5_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	1	0	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id6_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id6_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id6_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id6_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id6_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id6_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	1	1	0
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id7_missing.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id7_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id7_missing.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,9 @@
+7
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	0
Index: tests/regression/Selection/Atoms/AtomByOrder/post/id7_present.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/id7_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/id7_present.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,3 @@
+1
+	Created by molecuilder for unselect-atom-by-id
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/post/test-undo.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/post/test-undo.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/post/test-undo.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,10 @@
+8
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,10 @@
+8
+	Created by molecuilder for select-atom-by-id
+H	0	0	0
+H	0	0	1
+H	0	1	0
+H	0	1	1
+H	1	0	0
+H	1	0	1
+H	1	1	0
+H	1	1	1
Index: tests/regression/Selection/Atoms/AtomByOrder/testsuite-selection-select-atom-by-order.at
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/testsuite-selection-select-atom-by-order.at	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/testsuite-selection-select-atom-by-order.at	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,87 @@
+### 6. (un)select atom by order
+
+AT_SETUP([Selection - atom with specific order])
+AT_KEYWORDS([selection order atom select-atom-by-order])
+# go through all possible orders (0-7) and removed
+i=1
+while test $i -le 8; do
+  let id=$i-1
+  file=id${id}_missing.xyz
+  # normal
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-atom-by-order ${i} -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_missing.xyz])
+  ((i+=1))
+done
+# go through all possible orders (0-7) and removed
+i=1
+while test $i -le 8; do
+  let id=8-$i
+  file=id${id}_missing.xyz
+  # normal
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-atom-by-order -${i} -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_missing.xyz])
+  ((i+=1))
+done
+AT_CLEANUP
+
+
+AT_SETUP([Selection - atom with specific order with Undo])
+AT_KEYWORDS([selection order atom select-atom-by-order undo])
+# go through all possible ids (0-7) and removed
+i=1
+while test $i -le 8; do
+  let id=$i-1
+  file=id${id}_missing.xyz
+  # undo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-atom-by-order ${i} --undo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/test-undo.xyz])
+  ((i+=1))
+done
+# go reverse through all possible ids (0-7) and removed
+i=1
+while test $i -le 8; do
+  let id=8-$i
+  file=id${id}_missing.xyz
+  # undo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-atom-by-order -${i} --undo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/test-undo.xyz])
+  ((i+=1))
+done
+AT_CLEANUP
+
+
+AT_SETUP([Selection - atom with specific order with Redo])
+AT_KEYWORDS([selection order atom select-atom-by-order redo])
+# go through all possible ids (0-7) and removed
+i=1
+while test $i -le 8; do
+  let id=$i-1
+  file=id${id}_missing.xyz
+  # redo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-atom-by-order ${i} --undo --redo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_missing.xyz])
+  ((i+=1))
+done
+# go reverse through all possible ids (0-7) and removed
+i=1
+while test $i -le 8; do
+  let id=8-$i
+  file=id${id}_missing.xyz
+  # redo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-atom-by-order -${i} --undo --redo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_missing.xyz])
+  ((i+=1))
+done
+AT_CLEANUP
Index: tests/regression/Selection/Atoms/AtomByOrder/testsuite-selection-unselect-atom-by-order.at
===================================================================
--- tests/regression/Selection/Atoms/AtomByOrder/testsuite-selection-unselect-atom-by-order.at	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
+++ tests/regression/Selection/Atoms/AtomByOrder/testsuite-selection-unselect-atom-by-order.at	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -0,0 +1,88 @@
+### 6. (un)select atom by order
+
+
+AT_SETUP([Unselection - atom with specific order])
+AT_KEYWORDS([unselection order atom unselect-atom-by-order])
+# go through all possible orders (0-7) and remove others
+i=1
+while test $i -le 8; do
+  let id=$i-1
+  file=order${id}_present.xyz
+  # normal
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-all-atoms --unselect-atom-by-order ${i} -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_present.xyz])
+  ((i+=1))
+done
+# go reverse through all possible orders (0-7) and remove others
+i=1
+while test $i -le 8; do
+  let id=8-$i
+  file=order${id}_present.xyz
+  # normal
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-all-atoms --unselect-atom-by-order -${i} -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_present.xyz])
+  ((i+=1))
+done
+AT_CLEANUP
+
+
+AT_SETUP([Unselection - atom with specific order with Undo])
+AT_KEYWORDS([unselection order atom unselect-atom-by-order undo])
+# go through all possible orders (0-7) and remove others
+i=1
+while test $i -le 8; do
+  let id=$i-1
+  file=order${id}_present.xyz
+  # undo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-all-atoms --unselect-atom-by-order ${i} --undo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/empty.xyz])
+  ((i+=1))
+done
+# go reverse through all possible orders (0-7) and remove others
+i=1
+while test $i -le 8; do
+  let id=8-$i
+  file=order${id}_present.xyz
+  # undo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-all-atoms --unselect-atom-by-order -${i} --undo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/empty.xyz])
+  ((i+=1))
+done
+AT_CLEANUP
+
+
+AT_SETUP([Unselection - atom with specific order with Redo])
+AT_KEYWORDS([unselection order atom unselect-atom-by-order redo])
+# go through all possible orders (0-7) and remove others
+i=1
+while test $i -le 8; do
+  let id=$i-1
+  file=order${id}_present.xyz
+  # redo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-all-atoms --unselect-atom-by-order ${i} --undo --redo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_present.xyz])
+  ((i+=1))
+done
+# go reverse through all possible orders (0-7) and remove others
+i=1
+while test $i -le 8; do
+  let id=8-$i
+  file=order${id}_present.xyz
+  # redo
+  AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/pre/test.xyz $file])
+  AT_CHECK([chmod u+w $file], 0)
+  AT_CHECK([../../molecuilder -i $file -v 3 --select-all-atoms --unselect-atom-by-order -${i} --undo --redo -r], [], [ignore], [ignore])
+  AT_CHECK([diff -I '.*Created by molecuilder.*' $file ${abs_top_srcdir}/tests/regression/Selection/Atoms/AtomByOrder/post/id${id}_present.xyz])
+  ((i+=1))
+done
+AT_CLEANUP
Index: tests/regression/Selection/Atoms/testsuite-selection-atoms.at
===================================================================
--- tests/regression/Selection/Atoms/testsuite-selection-atoms.at	(revision 8de597c3fb205163fbb84791b76d54a43062db72)
+++ tests/regression/Selection/Atoms/testsuite-selection-atoms.at	(revision 61c364e5234bfac462d451e14f2d8a128787f6bb)
@@ -19,4 +19,8 @@
 m4_include(Selection/Atoms/AtomById/testsuite-selection-unselect-atom-by-id.at)
 
+# (un)select atom by order
+m4_include(Selection/Atoms/AtomByOrder/testsuite-selection-select-atom-by-order.at)
+m4_include(Selection/Atoms/AtomByOrder/testsuite-selection-unselect-atom-by-order.at)
+
 # (un)select atoms inside cuboid
 m4_include(Selection/Atoms/AtomsInsideCuboid/testsuite-selection-select-atoms-inside-cuboid.at)
