예제 #1
0
		/**
		 * Make atom container from a given bond list. For each bond iterate over atoms and add them to the partContainer 
		 * 
		 * @param the atom
		 * @param List of parts
		 * 
		 * @return partContainer
		 */

		private IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts)
		{
			var atoms = new List<IAtom>();
			var bonds = new List<IBond>();
			var atomsDone = new Dictionary<string, bool>();

			atoms.Add(atom);
			atomsDone[atom.getID()] = true;

			foreach (var aBond in parts)
			{
				foreach (var bondedAtom in aBond.atoms().ToWindowsEnumerable<IAtom>())
				{
					var done = false;
					atomsDone.TryGetValue(bondedAtom.getID(), out done);
					//check if the atom is already contained
					if (done)
					{
						continue;
					}
					
					atoms.Add(bondedAtom);
					atomsDone[bondedAtom.getID()] = true;
				}
				bonds.Add(aBond);				
			}

			IAtomContainer partContainer = new AtomContainer();
			partContainer.setAtoms(atoms.ToArray());
			partContainer.setBonds(bonds.ToArray());
			return partContainer;
		}