void XMLArchive::WriteBond(Bond &hbond) { /* write an hbond */ calc_indent(); f = format("%s<Bond atom1=\"%d\" atom2=\"%d\" type=\"%d\" />\n", indent, (int)hbond.getAtom1()->atomnumber(), (int)hbond.getAtom2()->atomnumber(), (int)hbond.type); Write(f); }
///////////////////////////////////////////////////////////////////////////// // Function: Constructor // Purpose: Creates a bond object from an existing Bond struct // Input: A Bond object (passed by ref) // A vector of MIAtom structs containing the atoms in the bond // A vector of corresponding MIAtom objects to use for the new ptrs // Output: None // Note: Correspondence between MIAtom is inferred from their bondOrder // in the vector containers ///////////////////////////////////////////////////////////////////////////// Bond::Bond(const Bond &bond, const MIAtomList &old_atoms, const MIAtomList &new_atoms) { std::string error_message; int i1 = GetIndex(static_cast<MIAtom*> (bond.getAtom1()), old_atoms); int i2 = GetIndex(static_cast<MIAtom*> (bond.getAtom2()), old_atoms); if (i1 < 0 || i2 < 0) { error_message = "Corrupted bond."; throw error_message; } bondOrder = bond.bondOrder; atom1 = new_atoms[i1]; atom2 = new_atoms[i2]; type = bond.type; stereo = bond.stereo; ideal_length = bond.ideal_length; tolerance = bond.tolerance; dict_include = bond.dict_include; isaromatic = bond.isaromatic; iscyclic = bond.iscyclic; ring_system = bond.ring_system; smallest_ring_size = bond.smallest_ring_size; smallest_aromatic_ring = bond.smallest_aromatic_ring; }
void XMLArchive::WriteConnect(Bond &bond) { /* write a connect */ calc_indent(); f = format("%s<Connect atom1=\"%d\" atom2=\"%d\" />\n", indent, (int)bond.getAtom1()->atomnumber(), (int)bond.getAtom2()->atomnumber()); Write(f); }
void Bond::copyBondOrders(const std::vector<Bond> &fromBonds, std::vector<Bond> &toBonds) { std::map<std::pair<MIAtom*, MIAtom*>, unsigned char> bondOrders; std::vector<Bond>::const_iterator constBondIter; for (constBondIter = fromBonds.begin(); constBondIter != fromBonds.end(); ++constBondIter) { Bond b = *constBondIter; if (b.getAtom1() < b.getAtom2()) { bondOrders[std::make_pair(b.getAtom1(), b.getAtom2())] = b.getOrder(); } else { bondOrders[std::make_pair(b.getAtom2(), b.getAtom1())] = b.getOrder(); } } std::vector<Bond>::iterator bondIter; for (bondIter = toBonds.begin(); bondIter != toBonds.end(); ++bondIter) { Bond b = *bondIter; if (b.getAtom1() < b.getAtom2()) { bondIter->setOrder(bondOrders[std::make_pair(b.getAtom1(), b.getAtom2())]); } else { bondIter->setOrder(bondOrders[std::make_pair(b.getAtom2(), b.getAtom1())]); } } }