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 d927abb3d77a2859e44f0802e7b32cf4c5385ec6)
+++ 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 d927abb3d77a2859e44f0802e7b32cf4c5385ec6)
+++ 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();
 
