@Override public void setLabel(String label) { pseudo.setLabel(label); }
@Override public void setLabel(String label) { pseudo.setLabel(label); }
@Override public void setLabel(String label) { pseudo.setLabel(label); }
@Override public void setLabel(String label) { pseudo.setLabel(label); }
public void applyChanges() { String label=labelField.getText(); if (label!=null && label.startsWith("R")&&label.length()>1 && !RGroupQuery.isValidRgroupQueryLabel(label) ) { JOptionPane.showMessageDialog(null, GT.get("This is not a valid R-group label.\nPlease label in range R1 .. R32")); } else { IPseudoAtom atom = (IPseudoAtom)source; atom.setLabel(labelField.getText()); } } }
public IPseudoAtom convertToPseudoAtom(IAtom atom, String label) { IPseudoAtom pseudo = atom.getBuilder().newInstance(IPseudoAtom.class,atom); pseudo.setLabel(label); replaceAtom(pseudo, atom); return pseudo; }
original); ((IPseudoAtom) replacement).setLabel(label); if (!replacement.equals(original)) AtomContainerManipulator.replaceAtomByAtom(readData, original, replacement);
currentAtom = builder.newInstance(IPseudoAtom.class, currentAtom); ((IPseudoAtom) currentAtom).setLabel(propertyValue);
currentAtom = builder.newInstance(IPseudoAtom.class, currentAtom); ((IPseudoAtom) currentAtom).setLabel(propertyValue);
/** * 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); }
@Test public void testGetLabel() { String label = "Arg255"; IPseudoAtom a = (IPseudoAtom) newChemObject(); a.setLabel(label); Assert.assertEquals(label, a.getLabel()); }
/** * 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); } }
/** * 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 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()); } }
/** * Checks that null atom labels are handled correctly. */ @Test public void testWritePseudoAtoms_nullLabel() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer container = builder.newInstance(IAtomContainer.class); IAtom c1 = builder.newInstance(IAtom.class, "C"); IPseudoAtom nullAtom = builder.newInstance(IPseudoAtom.class, ""); nullAtom.setLabel(null); container.addAtom(c1); container.addAtom(nullAtom); StringWriter sw = new StringWriter(); MDLV2000Writer writer = new MDLV2000Writer(sw); writer.write(container); writer.close(); String output = sw.toString(); Assert.assertTrue(output.contains("R")); }
/** * Test correct output of R-groups, using the hash (#) and a separate RGP line. */ @Test public void testRGPLine() throws Exception { StringWriter writer = new StringWriter(); IAtomContainer molecule = builder.newInstance(IAtomContainer.class); IPseudoAtom atom1 = builder.newInstance(IPseudoAtom.class); atom1.setSymbol("R"); atom1.setLabel("R12"); IAtom atom2 = builder.newInstance(IAtom.class, "C"); IBond bond = builder.newInstance(IBond.class, atom1, atom2); IPseudoAtom atom3 = builder.newInstance(IPseudoAtom.class); atom3.setSymbol("A"); atom3.setLabel("A"); IBond bond2 = builder.newInstance(IBond.class, atom3, atom2); molecule.addAtom(atom1); molecule.addAtom(atom2); molecule.addAtom(atom3); molecule.addBond(bond); molecule.addBond(bond2); MDLV2000Writer mdlWriter = new MDLV2000Writer(writer); mdlWriter.write(molecule); mdlWriter.close(); String output = writer.toString(); Assert.assertTrue("Test for R#", -1 != output.indexOf("R#")); Assert.assertTrue("Test for RGP line", -1 != output.indexOf("M RGP 1 1 12")); }
atom.setStereoParity(0); Statement label = rdfAtom.getProperty(CDK.HASLABEL); if (label != null) ((IPseudoAtom) atom).setLabel(label.getString()); } else { atom = builder.newInstance(IAtom.class);
atom.setStereoParity(0); Statement label = rdfAtom.getProperty(CDK.HASLABEL); if (label != null) ((IPseudoAtom) atom).setLabel(label.getString()); } else { atom = builder.newInstance(IAtom.class);