@Override public String getLabel() { return pseudo.getLabel(); }
@Override public void setLabel(String label) { pseudo.setLabel(label); }
/** * Determine if an atom is an attach point. * * @param atom potential attach point atom * @return the atom is an attachment point */ private boolean isAttachPoint(IAtom atom) { return atom instanceof IPseudoAtom && ((IPseudoAtom) atom).getAttachPointNum() > 0; }
/** * Labels the atom at the specified index with the provide label. If the * atom was not already a pseudo atom then the original atom is replaced. * * @param container structure * @param index atom index to replace * @param label the label for the atom * @see IPseudoAtom#setLabel(String) */ static void label(final IAtomContainer container, final int index, final String label) { final IAtom atom = container.getAtom(index); final IPseudoAtom pseudoAtom = atom instanceof IPseudoAtom ? (IPseudoAtom) atom : container.getBuilder() .newInstance(IPseudoAtom.class); if (atom.equals(pseudoAtom)) { pseudoAtom.setLabel(label); } else { pseudoAtom.setSymbol(label); pseudoAtom.setAtomicNumber(0); pseudoAtom.setPoint2d(atom.getPoint2d()); pseudoAtom.setPoint3d(atom.getPoint3d()); pseudoAtom.setMassNumber(atom.getMassNumber()); pseudoAtom.setFormalCharge(atom.getFormalCharge()); pseudoAtom.setValency(atom.getValency()); pseudoAtom.setLabel(label); // XXX: would be faster to track all replacements and do it all in one AtomContainerManipulator.replaceAtomByAtom(container, atom, pseudoAtom); } }
@Test public void testPseudoAtom_String() { String label = "Arg255"; IPseudoAtom a = new PseudoAtom(label); Assert.assertEquals("R", a.getSymbol()); Assert.assertEquals(label, a.getLabel()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getFractionalPoint3d()); }
if (atom instanceof IPseudoAtom) { IPseudoAtom pAtom = (IPseudoAtom) atom; if (pAtom.getAttachPointNum() <= 0) { if (pAtom.getLabel().equals("*")) { int mass = unboxSafely(pAtom.getMassNumber(), 0); int charge = unboxSafely(pAtom.getFormalCharge(), 0); int hcnt = unboxSafely(pAtom.getImplicitHydrogenCount(), 0); int nrad = container.getConnectedSingleElectronsCount(atom); if (mass != 0 || charge != 0 || hcnt != 0) {
if (pseudo.getAttachPointNum() > 0) { state.atomLabels.put(idx, "_AP" + pseudo.getAttachPointNum()); } else { if (!"*".equals(pseudo.getLabel())) state.atomLabels.put(idx, pseudo.getLabel());
val = val.substring(0, val.length() - 2); else if (val.startsWith("_AP")) // attachment point pseudo.setAttachPointNum(parseIntSafe(val.substring(3))); pseudo.setLabel(val); pseudo.setAtomicNumber(0); pseudo.setImplicitHydrogenCount(0); IAtomContainer mol = atomToMol.get(old); AtomContainerManipulator.replaceAtomByAtom(mol, old, pseudo);
@Test public void testPseudoAtomCharges() { String label = "charged patom"; IPseudoAtom a = (IPseudoAtom) newChemObject(); a.setLabel(label); a.setFormalCharge(-1); Assert.assertNotNull(a); Assert.assertNotNull(a.getFormalCharge()); Assert.assertEquals(-1, a.getFormalCharge().intValue()); } }
/** * Create a new CDK {@link IAtom} from the Beam Atom. If the element is * unknown (i.e. '*') then an pseudo atom is created. * * @param atom an Atom from the Beam Graph * @return the CDK atom to have it's properties set */ IAtom newCDKAtom(Atom atom) { Element element = atom.element(); boolean unknown = element == Element.Unknown; if (unknown) { IPseudoAtom pseudoAtom = builder.newInstance(IPseudoAtom.class, element.symbol()); pseudoAtom.setSymbol(element.symbol()); pseudoAtom.setLabel(atom.label()); return pseudoAtom; } return createAtom(element); }
((IPseudoAtom) aliasAtom).setLabel(alias); continue; IPseudoAtom pseudoAtom = container.getBuilder().newInstance(IPseudoAtom.class, atomName); if (prevAtom.getPoint2d() != null) { pseudoAtom.setPoint2d(prevAtom.getPoint2d()); pseudoAtom.setPoint3d(prevAtom.getPoint3d()); IPseudoAtom pseudoAtom = (IPseudoAtom) container.getAtom(index); if (pseudoAtom != null) { pseudoAtom.setLabel("R" + rNumber);
@Test public void testPseudoAtom_IAtom() { IChemObject object = newChemObject(); IAtom atom = object.getBuilder().newInstance(IAtom.class, "C"); Point3d fract = new Point3d(0.5, 0.5, 0.5); Point3d threeD = new Point3d(0.5, 0.5, 0.5); Point2d twoD = new Point2d(0.5, 0.5); atom.setFractionalPoint3d(fract); atom.setPoint3d(threeD); atom.setPoint2d(twoD); IPseudoAtom a = object.getBuilder().newInstance(IPseudoAtom.class, atom); assertEquals(fract, a.getFractionalPoint3d(), 0.0001); assertEquals(threeD, a.getPoint3d(), 0.0001); assertEquals(twoD, a.getPoint2d(), 0.0001); }
int attachNum = ((IPseudoAtom) atom).getAttachPointNum(); if (attachNum > 0) attachPoints.add((IPseudoAtom) atom); int attachNum = atom.getAttachPointNum(); new ArrayList<Vector2d>()); final TextOutline outline = generateAnnotation(atom.getPoint2d(), Integer.toString(attachNum), vector,
@Test public void testDebugPseudoAtom_String() { String label = "Arg255"; IPseudoAtom a = new DebugPseudoAtom(label); Assert.assertEquals("R", a.getSymbol()); Assert.assertEquals(label, a.getLabel()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void markushFragment() throws InvalidSmilesException { IAtomContainer mol = smipar.parseSmiles("**.c1ccccc1CC |m:1:2.3.4.5.6.7,Sg:n:8:m:ht,$R';;;;;;;;;_AP1$|"); List<Sgroup> sgroups = mol.getProperty(CDKConstants.CTAB_SGROUPS); // P-var and F-var assertThat(sgroups.size(), is(2)); // atom-labels assertThat(mol.getAtom(0), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) mol.getAtom(0)).getLabel(), is("R'")); // attach-points assertThat(mol.getAtom(9), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) mol.getAtom(9)).getAttachPointNum(), is(1)); assertThat(mol.getTitle(), is("")); }
/** * Labels the atom at the specified index with the provide label. If the * atom was not already a pseudo atom then the original atom is replaced. * * @param container structure * @param index atom index to replace * @param label the label for the atom * @see IPseudoAtom#setLabel(String) */ static void label(final IAtomContainer container, final int index, final String label) { final IAtom atom = container.getAtom(index); final IPseudoAtom pseudoAtom = atom instanceof IPseudoAtom ? (IPseudoAtom) atom : container.getBuilder() .newInstance(IPseudoAtom.class); if (atom.equals(pseudoAtom)) { pseudoAtom.setLabel(label); } else { pseudoAtom.setSymbol(label); pseudoAtom.setAtomicNumber(0); pseudoAtom.setPoint2d(atom.getPoint2d()); pseudoAtom.setPoint3d(atom.getPoint3d()); pseudoAtom.setMassNumber(atom.getMassNumber()); pseudoAtom.setFormalCharge(atom.getFormalCharge()); pseudoAtom.setValency(atom.getValency()); pseudoAtom.setLabel(label); // XXX: would be faster to track all replacements and do it all in one AtomContainerManipulator.replaceAtomByAtom(container, atom, pseudoAtom); } }