Index: src/Descriptors/AtomOfMoleculeSelectionDescriptor.cpp
===================================================================
--- src/Descriptors/AtomOfMoleculeSelectionDescriptor.cpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
+++ src/Descriptors/AtomOfMoleculeSelectionDescriptor.cpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
@@ -0,0 +1,64 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * AtomOfMoleculeSelectionDescriptor.cpp
+ *
+ *  Created on: Dec 11, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp"
+#include "Descriptors/AtomOfMoleculeSelectionDescriptor_impl.hpp"
+
+#include "molecule.hpp"
+
+#include "Helpers/helpers.hpp"
+
+AtomOfMoleculeSelectionDescriptor_impl::AtomOfMoleculeSelectionDescriptor_impl(){}
+
+AtomOfMoleculeSelectionDescriptor_impl::~AtomOfMoleculeSelectionDescriptor_impl(){}
+
+bool AtomOfMoleculeSelectionDescriptor_impl::predicate(std::pair<atomId_t,atom*> atom){
+  return World::getInstance().isSelected(atom.second->getMolecule());
+}
+
+atom* AtomOfMoleculeSelectionDescriptor_impl::find(){
+  World &instance = World::getInstance();
+  for (World::MoleculeSelectionIterator iter = instance.beginMoleculeSelection();
+      iter != instance.endMoleculeSelection();
+      ++iter) {
+    if (iter->second->begin() != iter->second->end())
+      return *(iter->second->begin());
+  }
+  return 0;
+}
+
+std::vector<atom*> AtomOfMoleculeSelectionDescriptor_impl::findAll(){
+  std::vector<atom*> res;
+  World &instance = World::getInstance();
+  for (World::MoleculeSelectionIterator iter = instance.beginMoleculeSelection();
+      iter != instance.endMoleculeSelection();
+      ++iter) {
+    transform(iter->second->begin(),
+              iter->second->end(),
+              back_inserter(res),
+              _take<atom*,molecule::atomSet::value_type>::get);
+  }
+  return res;
+}
+
+AtomDescriptor AtomsByMoleculeSelection(){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomOfMoleculeSelectionDescriptor_impl()));
+}
Index: src/Descriptors/AtomOfMoleculeSelectionDescriptor.hpp
===================================================================
--- src/Descriptors/AtomOfMoleculeSelectionDescriptor.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
+++ src/Descriptors/AtomOfMoleculeSelectionDescriptor.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
@@ -0,0 +1,15 @@
+/*
+ * AtomOfMoleculeSelectionDescriptor.hpp
+ *
+ *  Created on: Dec 11, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMOFMOLECULESELECTIONDESCRIPTOR_HPP_
+#define ATOMOFMOLECULESELECTIONDESCRIPTOR_HPP_
+
+#include "Descriptors/AtomDescriptor.hpp"
+
+AtomDescriptor AtomsByMoleculeSelection();
+
+#endif /* ATOMOFMOLECULESELECTIONDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomOfMoleculeSelectionDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomOfMoleculeSelectionDescriptor_impl.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
+++ src/Descriptors/AtomOfMoleculeSelectionDescriptor_impl.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
@@ -0,0 +1,24 @@
+/*
+ * AtomOfMoleculeSelectionDescriptor_impl.hpp
+ *
+ *  Created on: Dec 11, 2010
+ *      Author: heber
+ */
+
+#ifndef ATOMOFMOLECULESELECTIONDESCRIPTOR_IMPL_HPP_
+#define ATOMOFMOLECULESELECTIONDESCRIPTOR_IMPL_HPP_
+
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+class AtomOfMoleculeSelectionDescriptor_impl : public AtomDescriptor_impl{
+public:
+  AtomOfMoleculeSelectionDescriptor_impl();
+  virtual ~AtomOfMoleculeSelectionDescriptor_impl();
+  bool predicate(std::pair<atomId_t,atom*> atom);
+protected:
+  // need to overide more than the standard methods to make this fast
+  virtual atom* find();
+  virtual std::vector<atom*> findAll();
+};
+
+#endif /* ATOMOFMOLECULESELECTIONDESCRIPTOR_IMPL_HPP_ */
Index: src/Descriptors/MoleculeOfAtomSelectionDescriptor.cpp
===================================================================
--- src/Descriptors/MoleculeOfAtomSelectionDescriptor.cpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
+++ src/Descriptors/MoleculeOfAtomSelectionDescriptor.cpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
@@ -0,0 +1,74 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * MoleculeOfAtomSelectionDescriptor.cpp
+ *
+ *  Created on: Dec 11, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Helpers/MemDebug.hpp"
+
+#include "Descriptors/MoleculeOfAtomSelectionDescriptor.hpp"
+#include "Descriptors/MoleculeOfAtomSelectionDescriptor_impl.hpp"
+
+#include "Helpers/helpers.hpp"
+
+#include "molecule.hpp"
+#include "World.hpp"
+
+MoleculeOfAtomSelectionDescriptor_impl::MoleculeOfAtomSelectionDescriptor_impl(){}
+
+MoleculeOfAtomSelectionDescriptor_impl::~MoleculeOfAtomSelectionDescriptor_impl(){}
+
+bool MoleculeOfAtomSelectionDescriptor_impl::predicate(std::pair<moleculeId_t,molecule*> molecule){
+  for (molecule::const_iterator iter = molecule.second->begin();
+      iter != molecule.second->end();
+      ++iter) {
+    if (World::getInstance().isSelected(*iter))
+      return true;
+  }
+  return false;
+}
+
+molecule* MoleculeOfAtomSelectionDescriptor_impl::find(){
+  World &instance = World::getInstance();
+  for (World::AtomSelectionIterator iter = instance.beginAtomSelection();
+      iter != instance.endAtomSelection();
+      ++iter) {
+    if (iter->second->getMolecule() != NULL)
+      return iter->second->getMolecule();
+  }
+  return 0;
+}
+
+std::vector<molecule*> MoleculeOfAtomSelectionDescriptor_impl::findAll(){
+  std::vector<molecule*> res;
+  std::set<molecule*> temp;
+  std::pair< std::set<molecule*>::iterator, bool> inserter;
+  World &instance = World::getInstance();
+  for (World::AtomSelectionIterator iter = instance.beginAtomSelection();
+      iter != instance.endAtomSelection();
+      ++iter) {
+    if (iter->second->getMolecule() != NULL) {
+      inserter = temp.insert( iter->second->getMolecule() );
+      if (inserter.second)
+        res.push_back(iter->second->getMolecule());
+    }
+  }
+  return res;
+}
+
+MoleculeDescriptor MoleculesByAtomSelection(){
+  return MoleculeDescriptor(MoleculeDescriptor::impl_ptr(new MoleculeOfAtomSelectionDescriptor_impl()));
+}
Index: src/Descriptors/MoleculeOfAtomSelectionDescriptor.hpp
===================================================================
--- src/Descriptors/MoleculeOfAtomSelectionDescriptor.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
+++ src/Descriptors/MoleculeOfAtomSelectionDescriptor.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
@@ -0,0 +1,15 @@
+/*
+ * MoleculeOfAtomSelectionDescriptor.hpp
+ *
+ *  Created on: Dec 11, 2010
+ *      Author: heber
+ */
+
+#ifndef MOLECULEOFATOMSELECTIONDESCRIPTOR_HPP_
+#define MOLECULEOFATOMSELECTIONDESCRIPTOR_HPP_
+
+#include "Descriptors/MoleculeDescriptor.hpp"
+
+MoleculeDescriptor MoleculesByAtomSelection();
+
+#endif /* MOLECULEOFATOMSELECTIONDESCRIPTOR_HPP_ */
Index: src/Descriptors/MoleculeOfAtomSelectionDescriptor_impl.hpp
===================================================================
--- src/Descriptors/MoleculeOfAtomSelectionDescriptor_impl.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
+++ src/Descriptors/MoleculeOfAtomSelectionDescriptor_impl.hpp	(revision ff237cac90abf3bb5724922b22e18dfefccb8028)
@@ -0,0 +1,24 @@
+/*
+ * MoleculeOfAtomSelectionDescriptor_impl.hpp
+ *
+ *  Created on: Jul 16, 2010
+ *      Author: crueger
+ */
+
+#ifndef MOLECULEOFATOMSELECTIONDESCRIPTOR_IMPL_HPP_
+#define MOLECULEOFATOMSELECTIONDESCRIPTOR_IMPL_HPP_
+
+#include "Descriptors/MoleculeDescriptor_impl.hpp"
+
+class MoleculeOfAtomSelectionDescriptor_impl : public MoleculeDescriptor_impl{
+public:
+  MoleculeOfAtomSelectionDescriptor_impl();
+  virtual ~MoleculeOfAtomSelectionDescriptor_impl();
+  bool predicate(std::pair<moleculeId_t,molecule*> molecule);
+protected:
+  // need to overide more than the standard methods to make this fast
+  virtual molecule* find();
+  virtual std::vector<molecule*> findAll();
+};
+
+#endif /* MOLECULEOFATOMSELECTIONDESCRIPTOR_IMPL_HPP_ */
