AminoAcidCountDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor { @Override public DescriptorValue calculate(IAtomContainer ac) { ac = clone(ac); int resultLength = substructureSet.getAtomContainerCount(); IntegerArrayResult results = new IntegerArrayResult(resultLength); UniversalIsomorphismTester universalIsomorphismTester = new UniversalIsomorphismTester(); IAtomContainer substructure; for (int i = 0; i < resultLength; i++) { substructure = substructureSet.getAtomContainer(i); List<List<RMap>> maps; try { maps = universalIsomorphismTester.getSubgraphMaps(ac, substructure); } catch (CDKException e) { for (int j = 0; j < resultLength; j++) results.add((int) Double.NaN); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), results, getDescriptorNames(), new CDKException("Error in substructure search: " + e.getMessage())); } if (maps != null) { results.add(maps.size()); } } return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), results, getDescriptorNames()); } AminoAcidCountDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtomContainer ac); @Override IDescriptorResult getDescriptorResultType(); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testAACount() throws Exception { IBioPolymer protein = ProteinBuilderTool.createProtein("ARNDCFQEGHIPLKMSTYVW", SilentChemObjectBuilder.getInstance()); IDescriptorResult result = descriptor.calculate(protein).getValue(); Assert.assertTrue(result instanceof IntegerArrayResult); IntegerArrayResult iaResult = (IntegerArrayResult) result; for (int i = 0; i < iaResult.length(); i++) { Assert.assertTrue(iaResult.get(i) >= 1); } Assert.assertEquals(20, iaResult.get(8)); }
@Test public void testFCount() throws Exception { IBioPolymer protein = ProteinBuilderTool.createProtein("FF", SilentChemObjectBuilder.getInstance()); IDescriptorResult result = descriptor.calculate(protein).getValue(); Assert.assertTrue(result instanceof IntegerArrayResult); IntegerArrayResult iaResult = (IntegerArrayResult) result; Assert.assertEquals(2, iaResult.get(8)); Assert.assertEquals(4, iaResult.get(5)); }
@Test public void testTCount() throws Exception { IBioPolymer protein = ProteinBuilderTool.createProtein("TT", SilentChemObjectBuilder.getInstance()); IDescriptorResult result = descriptor.calculate(protein).getValue(); Assert.assertTrue(result instanceof IntegerArrayResult); IntegerArrayResult iaResult = (IntegerArrayResult) result; Assert.assertEquals(2, iaResult.get(8)); Assert.assertEquals(2, iaResult.get(16)); }