PeriodicTablePositionDescriptor extends AbstractAtomicDescriptor implements IAtomicDescriptor { public PeriodicTablePositionDescriptor() { if (periodicTable == null) { periodicTable = new Hashtable<String, Integer>(); periodicTable.put("H", 1); periodicTable.put("Li", 2); periodicTable.put("Be", 2); periodicTable.put("B", 2); periodicTable.put("C", 2); periodicTable.put("N", 2); periodicTable.put("O", 2); periodicTable.put("F", 2); periodicTable.put("Na", 3); periodicTable.put("Mg", 3); periodicTable.put("Al", 3); periodicTable.put("Si", 3); periodicTable.put("P", 3); periodicTable.put("S", 3); periodicTable.put("Cl", 3); periodicTable.put("K", 4); periodicTable.put("Ca", 4); periodicTable.put("Ga", 4); periodicTable.put("Ge", 4); periodicTable.put("As", 4); periodicTable.put("Se", 4); periodicTable.put("Br", 4); periodicTable.put("Rb", 5); periodicTable.put("Sr", 5); periodicTable.put("In", 5); periodicTable.put("Sn", 5); periodicTable.put("Sb", 5); periodicTable.put("Te", 5); periodicTable.put("I", 5); periodicTable.put("Cs", 6); periodicTable.put("Ba", 6); periodicTable.put("Tl", 6); periodicTable.put("Pb", 6); periodicTable.put("Bi", 6); periodicTable.put("Po", 6); periodicTable.put("At", 6); periodicTable.put("Fr", 7); periodicTable.put("Ra", 7); } } PeriodicTablePositionDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtom atom, IAtomContainer container); @Override String[] getParameterNames(); @Override Object getParameterType(String name); public Map<String, Integer> periodicTable; }
@Test public void testPeriodicTablePositionDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception { IAtomicDescriptor descriptor = new PeriodicTablePositionDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CCCl"); Assert.assertEquals(3, ((IntegerResult) descriptor.calculate(mol.getAtom(2), mol).getValue()).intValue()); }