Index: src/Fragmentation/Summation/IndexSetContainer.cpp
===================================================================
--- src/Fragmentation/Summation/IndexSetContainer.cpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
+++ src/Fragmentation/Summation/IndexSetContainer.cpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
@@ -0,0 +1,78 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * IndexSetContainer.cpp
+ *
+ *  Created on: Aug 2, 2012
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "IndexSetContainer.hpp"
+
+#include "CodePatterns/Log.hpp"
+
+#include "Fragmentation/Summation/IndexSet.hpp"
+#include "Fragmentation/KeySetsContainer.hpp"
+
+IndexSet::ptr IndexSetContainer::AllIndices(new IndexSet);
+
+IndexSet::ptr& IndexSetContainer::createSuperSet(const KeySetsContainer &_keysets) const
+{
+  // create superset
+  //IndexSet::ptr AllIndices(new IndexSet);
+  for (KeySetsContainer::ArrayOfIntVectors::const_iterator iter = _keysets.KeySets.begin();
+      iter != _keysets.KeySets.end(); ++iter)
+    for(KeySetsContainer::IntVector::const_iterator keyiter = (*iter).begin();
+        keyiter != (*iter).end(); ++keyiter) {
+      if (*keyiter != -1)
+        AllIndices->insert((Index_t)*keyiter);
+    }
+  LOG(1, "INFO: AllIndices is " << *AllIndices << ".");
+
+  return AllIndices;
+}
+
+IndexSetContainer::IndexSetContainer(const KeySetsContainer &_keysets) :
+  SortedVector<IndexSet>(createSuperSet(_keysets))
+{
+  const size_t SupersetSize = getContainer()[0]->size();
+  // create container with all keysets
+  for (KeySetsContainer::ArrayOfIntVectors::const_iterator iter = _keysets.KeySets.begin();
+      iter != _keysets.KeySets.end(); ++iter) {
+    IndexSet tempset;
+    for(KeySetsContainer::IntVector::const_iterator keyiter = (*iter).begin();
+        keyiter != (*iter).end(); ++keyiter)
+      if (*keyiter != -1)
+        tempset.insert((Index_t)*keyiter);
+    if (tempset.size() < SupersetSize)  // only insert if not super set
+      insert(tempset);
+  }
+}
Index: src/Fragmentation/Summation/IndexSetContainer.hpp
===================================================================
--- src/Fragmentation/Summation/IndexSetContainer.hpp	(revision c40e15d6697957957c2cc47a2cd1f72c7a539eae)
+++ src/Fragmentation/Summation/IndexSetContainer.hpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
@@ -22,4 +22,5 @@
 
 class IndexSetContainerTest;
+class KeySetsContainer;
 
 /**
@@ -63,5 +64,26 @@
     SortedVector<IndexSet>(_instance)
   {}
+
+  /** Conversion constructor from a KeySetConntainer.
+   *
+   * We create the super set of all found key sets and then each single set,
+   * while always dropping indices equal to -1.
+   *
+   * @param _keysets keysets to turn into IndexSets
+   */
+  explicit IndexSetContainer(const KeySetsContainer &_keysets);
+
+private:
+  /** Helper function to get the super set out of a KeySetsContainer.
+   *
+   * @param _keysets keysets to construct super set for
+   * @return IndexSet that contains each index once that appears in the sets of \a _keysets
+   */
+  IndexSet::ptr& createSuperSet(const KeySetsContainer &_keysets) const;
+
+  //!> static instance for AllIndices such that createSuperSet may return a reference.
+  static IndexSet::ptr AllIndices;
 };
+
 //!> typedef for IndexSet instance stored as shared_ptr in SortedVector
 typedef IndexSetContainer::T_ptr IndexSet_ptr;
Index: src/Fragmentation/Summation/Makefile.am
===================================================================
--- src/Fragmentation/Summation/Makefile.am	(revision c40e15d6697957957c2cc47a2cd1f72c7a539eae)
+++ src/Fragmentation/Summation/Makefile.am	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
@@ -4,4 +4,5 @@
 FRAGMENTATIONSUMMATIONSOURCE = \
 	Fragmentation/Summation/IndexSet.cpp \
+	Fragmentation/Summation/IndexSetContainer.cpp \
 	Fragmentation/Summation/SubsetMap.cpp
 
Index: src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp
===================================================================
--- src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp	(revision c40e15d6697957957c2cc47a2cd1f72c7a539eae)
+++ src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
@@ -45,4 +45,6 @@
 #include <boost/assign.hpp>
 #include <boost/foreach.hpp>
+
+#include "Fragmentation/KeySetsContainer.hpp"
 
 #ifdef HAVE_TESTRUNNER
@@ -138,2 +140,23 @@
   CPPUNIT_ASSERT( !SV->ContainerSorted );
 }
+
+/** Unit tests for cstr(KeySetsContainer)
+ *
+ */
+void IndexSetContainerTest::KeySetContainerTest()
+{
+  KeySetsContainer keysets;
+  KeySetsContainer::IntVector vector1;
+  vector1 += 1,-1;
+  KeySetsContainer::IntVector vector2;
+  vector2 += -1,1,2,-1;
+  keysets.KeySets.push_back(vector1);
+  keysets.KeySets.push_back(vector2);
+  SV = new IndexSetContainer(keysets);
+
+  // check sets
+  CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->getContainer().size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)1, SV->getContainer()[0]->size() );
+  CPPUNIT_ASSERT_EQUAL( (size_t)2, SV->getContainer()[1]->size() );
+
+}
Index: src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp
===================================================================
--- src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp	(revision c40e15d6697957957c2cc47a2cd1f72c7a539eae)
+++ src/Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
@@ -30,4 +30,5 @@
     CPPUNIT_TEST ( comparatorTest );
     CPPUNIT_TEST ( insertTest );
+    CPPUNIT_TEST ( KeySetContainerTest );
     CPPUNIT_TEST_SUITE_END();
 
@@ -38,4 +39,5 @@
       void comparatorTest();
       void insertTest();
+      void KeySetContainerTest();
 
 private:
Index: src/Fragmentation/Summation/unittests/Makefile.am
===================================================================
--- src/Fragmentation/Summation/unittests/Makefile.am	(revision c40e15d6697957957c2cc47a2cd1f72c7a539eae)
+++ src/Fragmentation/Summation/unittests/Makefile.am	(revision fb69e991ceb98f78bdb604d5dd15bfe1438c640e)
@@ -47,5 +47,8 @@
 	../Fragmentation/Summation/unittests/IndexSetContainerUnitTest.cpp \
 	../Fragmentation/Summation/unittests/IndexSetContainerUnitTest.hpp
-IndexSetContainerUnitTest_LDADD = ${FRAGMENTATIONSUMMATIONLIBS}
+IndexSetContainerUnitTest_LDADD = \
+	../libMolecuilderFragmentation.la \
+	../libMolecuilderHelpers.la \
+	${FRAGMENTATIONSUMMATIONLIBS}
 
 OrthogonalSummationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
