/** * Constructs an query bond from an expression type. * * <pre>{@code * new QueryBond(beg, end, IS_IN_RING); * }</pre> * * @param type the expression type */ public QueryBond(IAtom beg, IAtom end, Expr.Type type) { this(beg, end, null, IQueryBond.Stereo.NONE, beg.getBuilder()); this.expr.setPrimitive(type); atomCount = 2; }
public SymbolQueryAtom(IAtom atom) { super(atom.getSymbol(), atom.getBuilder()); }
/** * Constructs an query bond from an expression type and value. * * <pre>{@code * new QueryBond(beg, end, ALIPHATIC_ORDER, 8); * }</pre> * * @param type the expression type * @param val the expression value */ public QueryBond(IAtom beg, IAtom end, Expr.Type type, int val) { this(beg, end, null, IQueryBond.Stereo.NONE, beg.getBuilder()); this.expr.setPrimitive(type, val); atomCount = 2; }
/** * Constructs an query bond from an expression. * * <pre>{@code * // pi-bond in a ring * Expr e = new Expr(IS_IN_RING); * e.and(new Expr(ALIPHATIC_ORDER, 2)); * new QueryBond(beg, end, e); * }</pre> * * @param expr the expression */ public QueryBond(IAtom beg, IAtom end, Expr expr) { this(beg, end, null, IQueryBond.Stereo.NONE, beg.getBuilder()); this.expr.set(expr); atomCount = 2; }
public IAtomContainer getConnectedAtomContainer() { IAtomContainer ac = new AtomContainer(); if (atoms.size() != 0) { ac = atoms.get(0).getBuilder().newInstance(IAtomContainer.class); for (IAtom atom : atoms) { ac.addAtom(atom); } } for (IBond bond : bonds) { ac.addBond(bond); } return ac; }
public IPseudoAtom convertToPseudoAtom(IAtom atom, String label) { IPseudoAtom pseudo = atom.getBuilder().newInstance(IPseudoAtom.class,atom); pseudo.setLabel(label); replaceAtom(pseudo, atom); return pseudo; }
/** * TODO * @param at * @param hub * @return */ public boolean checkRGroupOkayForDelete(IAtom at,IChemModelRelay hub ) { IAtomContainer tmp = at.getBuilder().newInstance(IAtomContainer.class); tmp.addAtom(at); return (checkRGroupOkayForDelete(tmp,hub)); }
public SymbolAndChargeQueryAtom(IAtom atom) { super(atom.getSymbol(), atom.getBuilder()); setFormalCharge(atom.getFormalCharge()); }
private void addHydrogens(IAtomContainer container, IAtom atom, int numberOfHydrogens) { for (int i = 0; i < numberOfHydrogens; i++) container.addBond(atom.getBuilder().newInstance(IBond.class, atom, atom.getBuilder().newInstance(IAtom.class, "H"))); }
/** * Gets all placed neighbouring atoms of a atom. * *@param atom central atom (Atom) *@param ac the molecule *@return all connected and placed atoms to the central atom * ((AtomContainer) */ public IAtomContainer getPlacedAtomsInAtomContainer(IAtom atom, IAtomContainer ac) { List bonds = ac.getConnectedBondsList(atom); IAtomContainer connectedAtoms = atom.getBuilder().newInstance(IAtomContainer.class); IAtom connectedAtom = null; for (int i = 0; i < bonds.size(); i++) { connectedAtom = ((IBond) bonds.get(i)).getOther(atom); if (connectedAtom.getFlag(CDKConstants.ISPLACED)) { connectedAtoms.addAtom(connectedAtom); } } return connectedAtoms; }
protected static IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom) { IAtomContainer partContainer = atom.getBuilder().newInstance(IAtomContainer.class); partContainer.addAtom(atom); for (IBond aBond : parts) { for (IAtom bondedAtom : aBond.atoms()) { if (!bondedAtom.equals(excludedAtom) && !partContainer.contains(bondedAtom)) partContainer.addAtom(bondedAtom); } if (!aBond.contains(excludedAtom)) partContainer.addBond(aBond); } return partContainer; }
protected static IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom) { IAtomContainer partContainer = atom.getBuilder().newInstance(IAtomContainer.class); partContainer.addAtom(atom); for (IBond aBond : parts) { for (IAtom bondedAtom : aBond.atoms()) { if (!bondedAtom.equals(excludedAtom) && !partContainer.contains(bondedAtom)) partContainer.addAtom(bondedAtom); } if (!aBond.contains(excludedAtom)) partContainer.addBond(aBond); } return partContainer; }
public SymbolChargeIDQueryAtom(IAtom atom) { super(atom.getSymbol(), atom.getBuilder()); setFormalCharge(atom.getFormalCharge()); setID(atom.getID()); }
public void undo() throws CannotUndoException { this.atom.setSymbol(formerSymbol); try { IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder()); this.atom.setMassNumber(ifac.getMajorIsotope(formerSymbol).getMassNumber()); chemModelRelay.updateAtom(atom); ifac.configure(atom); } catch (OptionalDataException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void addSingleElectron(IAtom atom) { IAtomContainer relevantContainer = ChemModelManipulator .getRelevantAtomContainer(chemModel, atom); ISingleElectron singleElectron = atom.getBuilder().newInstance(ISingleElectron.class,atom); relevantContainer.addSingleElectron(singleElectron); updateAtom(atom); if (undoredofactory != null && undoredohandler != null) { IUndoRedoable undoredo = undoredofactory.getSingleElectronEdit( relevantContainer, singleElectron, true, this, atom, "Add Single Electron"); undoredohandler.postEdit(undoredo); } }
public void redo() throws CannotRedoException { this.atom.setSymbol(symbol); try { IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder()); this.atom.setMassNumber(ifac.getMajorIsotope(symbol).getMassNumber()); chemModelRelay.updateAtom(atom); ifac.configure(atom); } catch (OptionalDataException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * Saturates an IAtom by adding the appropriate number lone pairs. */ public void saturate(IAtom atom, IAtomContainer ac) throws CDKException { logger.info("Saturating atom by adjusting lone pair electrons..."); IAtomType atomType = factory.getAtomType(atom.getAtomTypeName()); int lpCount = (Integer) atomType.getProperty(CDKConstants.LONE_PAIR_COUNT); int missingLPs = lpCount - ac.getConnectedLonePairsCount(atom); for (int j = 0; j < missingLPs; j++) { ILonePair lp = atom.getBuilder().newInstance(ILonePair.class, atom); ac.addLonePair(lp); } }
public IAtom addAtom(String atomType, IAtom atom, boolean makePseudoAtom) { IAtomContainer undoRedoContainer = atom.getBuilder().newInstance(IAtomContainer.class); undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, atom, makePseudoAtom)); IAtomContainer atomContainer = ChemModelManipulator .getRelevantAtomContainer(getIChemModel(), undoRedoContainer .getAtom(0)); IBond newBond = atomContainer.getBond(atom, undoRedoContainer .getAtom(0)); undoRedoContainer.addBond(newBond); if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) { IUndoRedoable undoredo = getUndoRedoFactory() .getAddAtomsAndBondsEdit(chemModel, undoRedoContainer, null, "Add Atom", this); getUndoRedoHandler().postEdit(undoredo); } return undoRedoContainer.getAtom(0); }
/** * Method to test the compare() method. */ @Test @Override public void testCompare_Object() { IAtom someAtom = new Atom("C"); if (someAtom instanceof org.openscience.cdk.Atom) { org.openscience.cdk.Atom atom = (org.openscience.cdk.Atom) someAtom; Assert.assertTrue(atom.compare(atom)); IAtom hydrogen = someAtom.getBuilder().newInstance(IAtom.class, "H"); Assert.assertFalse(atom.compare(hydrogen)); Assert.assertFalse(atom.compare("C")); } }
/** * @cdk.bug 3190151 */ @Test public void testPine() throws Exception { IAtom atomP = new Atom(Elements.PHOSPHORUS); IAtomType atomTypeP = new AtomType(Elements.PHOSPHORUS); AtomTypeManipulator.configure(atomP, atomTypeP); IAtomContainer ac = atomP.getBuilder().newInstance(IAtomContainer.class); ac.addAtom(atomP); IAtomType type = null; for (IAtom atom : ac.atoms()) { type = CDKAtomTypeMatcher.getInstance(ac.getBuilder()).findMatchingAtomType(ac, atom); Assert.assertNotNull(type); } }