/** * Post process a fragment. --> find neutral possible neutral losses read in * from the file * * @param original * the original * * @return the i atom container set * * @throws CDKException * the CDK exception * @throws CloneNotSupportedException * the clone not supported exception */ public List<IAtomContainer> PostProcess(IAtomContainer original, double neutralLossMass) { // Render.Draw(original, "Original Main"); var ret = new List<IAtomContainer>(); allRings = new RingSet(); if (allRingsOrig.getAtomContainerCount() > 0) { // get the rings which are not broken up yet var bondMap = new Dictionary<IBond, int>(); var count = 0; foreach (var bondOrig in original.bonds().ToWindowsEnumerable<IBond>()) { bondMap[bondOrig] = count; count++; } // check for rings which are not broken up! IRingSet validRings = new RingSet(); for (var i = 0; i < allRingsOrig.getAtomContainerCount(); i++) { var bondcount = 0; foreach (var bondRing in allRingsOrig.getAtomContainer(i).bonds().ToWindowsEnumerable<IBond>()) { if (bondMap.ContainsKey(bondRing)) { bondcount++; } } if (bondcount == allRingsOrig.getAtomContainer(i).getBondCount()) { validRings.addAtomContainer(allRingsOrig.getAtomContainer(i)); } } // rings which are not split up allRings = validRings; } IAtomContainer temp = new AtomContainer(); var doneAtoms = new List<IAtom>(); var doneBonds = new List<IBond>(); // now find out the important atoms of the neutral loss var atomToStart = neutralLoss[neutralLossMass].AtomToStart; foreach (var bond in original.bonds().ToWindowsEnumerable<IBond>()) { if (doneBonds.Contains(bond)) { continue; } else { doneBonds.Add(bond); } // check if this was checked b4 foreach (var atom in bond.atoms().ToWindowsEnumerable<IAtom>()) { if (doneAtoms.Contains(atom)) { continue; } else { doneAtoms.Add(atom); } // a possible hit if (atom.getSymbol().Equals(atomToStart) && !allRings.contains(atom)) { // Render.Draw(original, "BEFORE"); // check if it is a terminal bond...and not in between! var atomList = original.getConnectedAtomsList(atom); var atomCount = 0; foreach (var iAtom in atomList.ToWindowsEnumerable<IAtom>()) { // dont check if (iAtom.getSymbol().Equals("H")) { continue; } else { atomCount++; } } // not a terminal atom...so skip it! if (atomCount > 1) { continue; } temp = checkForCompleteNeutralLoss(original, atom, neutralLossMass); if (temp.getAtomCount() > 0) { if (ConnectivityChecker.isConnected(temp)) { ret.Add(temp); } else { var set = ConnectivityChecker .partitionIntoMolecules(temp); foreach (var molecule in set.molecules().ToWindowsEnumerable<IMolecule>()) { ret.Add(molecule); } } // create a atom container temp = new AtomContainer(); } } } } return ret; }