public void setChemObject(IChemObject object) { if (object instanceof IPseudoAtom) { source = object; // update table contents labelField.setText(((IPseudoAtom)object).getLabel()); } else { throw new IllegalArgumentException("Argument must be an PseudoAtom"); } }
/** * Constructs an EnzymeResidueLocator from an existing Atom. * * @param atom Atom that should be converted into a EnzymeResidueLocator. */ public EnzymeResidueLocator(IAtom atom) { super(atom); if (atom instanceof IPseudoAtom) { this.setLabel(((IPseudoAtom) atom).getLabel()); } } }
/** * Constructs an EnzymeResidueLocator from an existing Atom. * * @param atom Atom that should be converted into a EnzymeResidueLocator. */ public EnzymeResidueLocator(IAtom atom) { super(atom); if (atom instanceof IPseudoAtom) { this.setLabel(((IPseudoAtom) atom).getLabel()); } } }
@Test public void accessNullPseudoLabel() throws Exception { IPseudoAtom atom = mock(IPseudoAtom.class); when(atom.getLabel()).thenReturn(null); assertThat(StandardAtomGenerator.accessPseudoLabel(atom, "*"), is("*")); }
@Test public void generatesRgroupPseudoAtom() { IAtomContainer container = mock(IAtomContainer.class); IPseudoAtom atom = mock(IPseudoAtom.class); when(atom.getLabel()).thenReturn("R1"); AtomSymbol atomSymbol = atomGenerator.generateSymbol(container, atom, HydrogenPosition.Left, new RendererModel()); List<Shape> shapes = atomSymbol.getOutlines(); assertThat(shapes.size(), is(2)); }
@Test public void atomAlias() throws Exception { IAtomContainer mock = mock(4); read("A 4\n" + "Gly", mock); assertThat(mock.getAtom(3), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) mock.getAtom(3)).getLabel(), is("Gly")); }
@Test public void testAliasAfterRgroup() throws Exception { InputStream in = getClass().getResourceAsStream("/data/mdl/r-group-with-alias.mol"); MDLV2000Reader reader = new MDLV2000Reader(in); IAtomContainer container = reader.read(new AtomContainer()); reader.close(); assertThat(container.getAtom(6), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) container.getAtom(6)).getLabel(), is("R6")); assertThat(container.getAtom(7), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) container.getAtom(7)).getLabel(), is("Protein")); }
@Test public void atomLabels() throws InvalidSmilesException { IAtomContainer mol = smipar.parseSmiles("**.c1ccccc1CC |$R'$|"); assertThat(mol.getAtom(0), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) mol.getAtom(0)).getLabel(), is("R'")); }
@Test public void erroneousLabels_tRNA() throws Exception { IAtomContainer ac = convert("[tRNA]CC"); assertThat(ac.getAtom(0).getSymbol(), is("R")); assertThat(ac.getAtom(0), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) ac.getAtom(0)).getLabel(), is("tRNA")); }
@Test public void erroneousLabels_nested() throws Exception { IAtomContainer ac = convert("[now-[this]-is-mean]CC"); assertThat(ac.getAtom(0).getSymbol(), is("R")); assertThat(ac.getAtom(0), is(instanceOf(IPseudoAtom.class))); assertThat(((IPseudoAtom) ac.getAtom(0)).getLabel(), is("now-[this]-is-mean")); }
@Test public void testRGroup() throws Exception { String filename = "data/mdl/SARGROUPTEST.sdf"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IAtomContainer mol = reader.read(new AtomContainer()); reader.close(); Assert.assertEquals("R2", ((IPseudoAtom) mol.getAtom(19)).getLabel()); }
@Test public void testGetLabel() { String label = "Arg255"; IPseudoAtom a = (IPseudoAtom) newChemObject(); a.setLabel(label); Assert.assertEquals(label, a.getLabel()); }
@Test public void testAliasPropertyGroup() throws Exception { String filename = "data/mdl/AliasPropertyRGroup.sdf"; logger.info("Testing: " + filename); InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IAtomContainer mol = reader.read(new AtomContainer()); reader.close(); IAtom atom = mol.getAtom(0); assertTrue(atom instanceof IPseudoAtom); Assert.assertEquals("R\\1", ((IPseudoAtom) atom).getLabel()); }
@Test public void testSetLabel_String() { String label = "Arg255"; IPseudoAtom atom = (IPseudoAtom) newChemObject(); atom.setLabel(label); String label2 = "His66"; atom.setLabel(label2); Assert.assertEquals(label2, atom.getLabel()); }
@Test public void testPseudoAtomLabels() throws Exception { InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/pseudoatoms.sdf"); MDLV2000Reader reader = new MDLV2000Reader(in); IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class); molecule = reader.read(molecule); reader.close(); assertTrue(molecule.getAtom(4) instanceof IPseudoAtom); Assert.assertEquals("R", molecule.getAtom(4).getSymbol()); IPseudoAtom pa = (IPseudoAtom) molecule.getAtom(4); Assert.assertEquals("Gln", pa.getLabel()); }
@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()); }
@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 testDebugPseudoAtom_String_Point2d() { Point2d point = new Point2d(1.0, 2.0); String label = "Arg255"; IPseudoAtom a = new DebugPseudoAtom(label, point); Assert.assertEquals("R", a.getSymbol()); Assert.assertEquals(label, a.getLabel()); Assert.assertEquals(point, a.getPoint2d()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void testPseudoAtom_String_Point2d() { Point2d point = new Point2d(1.0, 2.0); String label = "Arg255"; IPseudoAtom a = new PseudoAtom(label, point); Assert.assertEquals("R", a.getSymbol()); Assert.assertEquals(label, a.getLabel()); Assert.assertEquals(point, a.getPoint2d()); Assert.assertNull(a.getPoint3d()); Assert.assertNull(a.getFractionalPoint3d()); }
@Test public void testPseudoAtom_String_Point3d() { Point3d point = new Point3d(1.0, 2.0, 3.0); String label = "Arg255"; IPseudoAtom a = new PseudoAtom(label, point); Assert.assertEquals("R", a.getSymbol()); Assert.assertEquals(label, a.getLabel()); Assert.assertEquals(point, a.getPoint3d()); Assert.assertNull(a.getPoint2d()); Assert.assertNull(a.getFractionalPoint3d()); } }