/** * Constructor to initialize the surface calculation with default values. * * This constructor use the Van der Waals radii as defined in <i>org/openscience/cdk/config/data/jmol_atomtypes.txt</i> * of the source distribution. Also uses a tesselation level of 4 and solvent radius of 1.4A. * * @param atomContainer The {@link IAtomContainer} for which the surface is to be calculated */ public NumericalSurface(IAtomContainer atomContainer) { this.atoms = AtomContainerManipulator.getAtomArray(atomContainer); }
/** * Constructor to initialize the surface calculation with user specified values. * * This constructor use the Van der Waals radii as defined in <i>org/openscience/cdk/config/data/jmol_atomtypes.txt</i> * of the source distribution * * @param atomContainer The {@link IAtomContainer} for which the surface is to be calculated * @param solventRadius The radius of a solvent molecule that is used to extend * the radius of each atom. Setting to 0 gives the Van der Waals surface * @param tesslevel The number of levels that the subdivision algorithm for tessellation * should use */ public NumericalSurface(IAtomContainer atomContainer, double solventRadius, int tesslevel) { this.solventRadius = solventRadius; this.atoms = AtomContainerManipulator.getAtomArray(atomContainer); this.tesslevel = tesslevel; }
/** * Constructor to initialize the surface calculation with default values. * * This constructor use the Van der Waals radii as defined in <i>org/openscience/cdk/config/data/jmol_atomtypes.txt</i> * of the source distribution. Also uses a tesselation level of 4 and solvent radius of 1.4A. * * @param atomContainer The {@link IAtomContainer} for which the surface is to be calculated */ public NumericalSurface(IAtomContainer atomContainer) { this.atoms = AtomContainerManipulator.getAtomArray(atomContainer); init(); }
/** * Constructor to initialize the surface calculation with user specified values. * * This constructor use the Van der Waals radii as defined in <i>org/openscience/cdk/config/data/jmol_atomtypes.txt</i> * of the source distribution * * @param atomContainer The {@link IAtomContainer} for which the surface is to be calculated * @param solventRadius The radius of a solvent molecule that is used to extend * the radius of each atom. Setting to 0 gives the Van der Waals surface * @param tesslevel The number of levels that the subdivision algorithm for tessellation * should use */ public NumericalSurface(IAtomContainer atomContainer, double solventRadius, int tesslevel) { this.solventRadius = solventRadius; this.atoms = AtomContainerManipulator.getAtomArray(atomContainer); this.tesslevel = tesslevel; init(); }
Congestion(IAtomContainer mol, int[][] adjList) { final int numAtoms = mol.getAtomCount(); this.contribution = new double[numAtoms][numAtoms]; this.atoms = AtomContainerManipulator.getAtomArray(mol); for (int v = 0; v < numAtoms; v++) for (int w : adjList[v]) contribution[v][v] = contribution[v][w] = -1; this.score = initScore(); }
Congestion(IAtomContainer mol, int[][] adjList) { final int numAtoms = mol.getAtomCount(); this.contribution = new double[numAtoms][numAtoms]; this.atoms = AtomContainerManipulator.getAtomArray(mol); for (int v = 0; v < numAtoms; v++) for (int w : adjList[v]) contribution[v][v] = contribution[v][w] = -1; this.score = initScore(); }
private static IBioPolymer addAminoAcid(IBioPolymer protein, IAminoAcid aaToAdd, IStrand strand) { for (IAtom atom : AtomContainerManipulator.getAtomArray(aaToAdd)) protein.addAtom(atom, aaToAdd, strand); for (IBond bond : AtomContainerManipulator.getBondArray(aaToAdd)) protein.addBond(bond); return protein; } }
private static IBioPolymer addAminoAcid(IBioPolymer protein, IAminoAcid aaToAdd, IStrand strand) { for (IAtom atom : AtomContainerManipulator.getAtomArray(aaToAdd)) protein.addAtom(atom, aaToAdd, strand); for (IBond bond : AtomContainerManipulator.getBondArray(aaToAdd)) protein.addBond(bond); return protein; } }
private int getNonHydrogenMappingAtomCount(IAtomContainerSet mol) { int count = MIN_VALUE; List<IAtomContainer> allAtomContainers = getAllAtomContainers(mol); for (IAtomContainer ac : allAtomContainers) { IAtom[] atomArray = getAtomArray(ac); for (IAtom atom : atomArray) { if (atom.getSymbol().equalsIgnoreCase("H")) { continue; } if (atom.getID() != null && parseInt(atom.getID()) > count) { count = parseInt(atom.getID()); } } } return count; } }
public String generate() { IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol); sortAtoms(atoms); // mark ring closures for (IAtom atom : atoms) if (!avisit.contains(atom)) markRings(atom, null); avisit.clear(); setBondDirs(mol); boolean isRxn = role(atoms[atoms.length - 1]) != ReactionRole.None; StringBuilder sb = new StringBuilder(); if (isRxn) { writeParts(atoms, sb, ReactionRole.Reactant); sb.append('>'); writeParts(atoms, sb, ReactionRole.Agent); sb.append('>'); writeParts(atoms, sb, ReactionRole.Product); } else { writeParts(atoms, sb, null); } return sb.toString(); }
@Test public void atomStereoReordered3() { QueryAtomContainer mol = new QueryAtomContainer(null); assertTrue(Smarts.parse(mol, "[C@H](C)(O)CC")); IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol); swap(atoms, 0, 1); mol.setAtoms(atoms); assertThat(Smarts.generate(mol), is("C[C@@H1](O)CC")); }
@Test public void atomStereoReordered2() { QueryAtomContainer mol = new QueryAtomContainer(null); assertTrue(Smarts.parse(mol, "C[C@H](O)CC")); IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol); swap(atoms, 0, 1); mol.setAtoms(atoms); assertThat(Smarts.generate(mol), is("[C@@H1](C)(O)CC")); }
@Test public void bondStereoCisThenTransUnspecWithNbr() { QueryAtomContainer mol = new QueryAtomContainer(null); assertTrue(Smarts.parse(mol, "C/C=C(C)\\C=C\\?O")); assertThat(Smarts.generate(mol), is("C/C=C(C)\\C=C\\?O")); IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol); swap(atoms, 0, atoms.length-1); mol.setAtoms(atoms); assertThat(Smarts.generate(mol), is("O/?C=C/C(=C\\C)C")); }
@Test public void bondStereoTrans() { QueryAtomContainer mol = new QueryAtomContainer(null); assertTrue(Smarts.parse(mol, "C/C=C/C")); assertThat(Smarts.generate(mol), is("C/C=C/C")); IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol); swap(atoms, 0, 1); mol.setAtoms(atoms); assertThat(Smarts.generate(mol), is("C(\\C)=C/C")); }
private void fixHydrogenIsotopes(IAtomContainer molecule, IsotopeFactory isotopeFactory) { for (IAtom atom : AtomContainerManipulator.getAtomArray(molecule)) { if (atom instanceof IPseudoAtom) { IPseudoAtom pseudo = (IPseudoAtom) atom; if ("D".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 2)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } else if ("T".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 3)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } } } }
private void fixHydrogenIsotopes(IAtomContainer molecule, IsotopeFactory isotopeFactory) { for (IAtom atom : AtomContainerManipulator.getAtomArray(molecule)) { if (atom instanceof IPseudoAtom) { IPseudoAtom pseudo = (IPseudoAtom) atom; if ("D".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 2)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } else if ("T".equals(pseudo.getLabel())) { IAtom newAtom = molecule.getBuilder().newInstance(IAtom.class, atom); newAtom.setSymbol("H"); newAtom.setAtomicNumber(1); isotopeFactory.configure(newAtom, isotopeFactory.getIsotope("H", 3)); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } } } }
@Test public void testAliasAtomNaming() throws Exception { InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/mol_testAliasAtomNaming.mol"); MDLV2000Reader reader = new MDLV2000Reader(in); IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class); reader.read(molecule); reader.close(); IAtom[] atoms = AtomContainerManipulator.getAtomArray(molecule); int r1Count = 0; for (IAtom atom : atoms) { if (atom instanceof IPseudoAtom) { Assert.assertEquals("R1", ((IPseudoAtom) atom).getLabel()); r1Count++; } } Assert.assertEquals(2, r1Count); }
@Test public void testAtomParity() throws CDKException, IOException { InputStream in = ClassLoader.getSystemResourceAsStream("data/mdl/mol_testAtomParity.mol"); MDLV2000Reader reader = new MDLV2000Reader(in); IAtomContainer molecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class); molecule = reader.read(molecule); reader.close(); Assert.assertEquals(6, molecule.getAtomCount()); boolean chiralCentre = false; IAtom[] atoms = AtomContainerManipulator.getAtomArray(molecule); for (IAtom atom : atoms) { Integer parity = atom.getStereoParity(); if (parity == 1) { chiralCentre = true; } } assertTrue(chiralCentre); }
@Test public void testGetAtomArray_IAtomContainer() { IAtomContainer mol = new AtomContainer(); // ethene mol.addAtom(new Atom("C")); mol.addAtom(new Atom("C")); mol.addAtom(new Atom("H")); mol.addAtom(new Atom("H")); mol.addAtom(new Atom("H")); mol.addAtom(new Atom("H")); IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol); Assert.assertEquals(6, atoms.length); Assert.assertEquals(mol.getAtom(0), atoms[0]); Assert.assertEquals(mol.getAtom(1), atoms[1]); Assert.assertEquals(mol.getAtom(2), atoms[2]); Assert.assertEquals(mol.getAtom(3), atoms[3]); Assert.assertEquals(mol.getAtom(4), atoms[4]); Assert.assertEquals(mol.getAtom(5), atoms[5]); }
@Test public void testGetAtomArray_List() { IAtomContainer mol = new AtomContainer(); // ethene mol.addAtom(new Atom("C")); mol.addAtom(new Atom("C")); mol.addAtom(new Atom("H")); mol.addAtom(new Atom("H")); mol.addAtom(new Atom("H")); mol.addAtom(new Atom("H")); mol.addBond(0, 1, IBond.Order.DOUBLE); mol.addBond(0, 2, IBond.Order.SINGLE); mol.addBond(0, 3, IBond.Order.SINGLE); mol.addBond(1, 4, IBond.Order.DOUBLE); mol.addBond(1, 5, IBond.Order.DOUBLE); mol.setFlag(CDKConstants.ISAROMATIC, true); IAtom[] atoms = AtomContainerManipulator.getAtomArray(mol.getConnectedAtomsList(mol.getAtom(0))); Assert.assertEquals(3, atoms.length); Assert.assertEquals(mol.getAtom(1), atoms[0]); Assert.assertEquals(mol.getAtom(2), atoms[1]); Assert.assertEquals(mol.getAtom(3), atoms[2]); }