test_class.file: descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/AutocorrelationDescriptorChargeTest.java
test_class.identifier: AutocorrelationDescriptorChargeTest
test_class.superclass: extends MolecularDescriptorTest
test_case.body: @Test
      public void test1() throws Exception {
          String filename = "data/mdl/clorobenzene.mol";
          InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
          MDLV2000Reader reader = new MDLV2000Reader(ins);
          IAtomContainer container = reader.read(new AtomContainer());
          DescriptorValue count = descriptor.calculate(container);
          Assert.assertEquals(5, count.getValue().length());
          Assert.assertTrue(count.getValue() instanceof DoubleArrayResult);
          DoubleArrayResult result = (DoubleArrayResult) count.getValue();
          for (int i = 0; i < 5; i++) {
              Assert.assertFalse(Double.isNaN(result.get(i)));
              Assert.assertTrue(0.0 != result.get(i));
          }
      }
test_case.class_method_signature: AutocorrelationDescriptorChargeTest.test1()
test_case.full_signature: @Test public void test1()
test_case.identifier: test1
test_case.invocations: getResourceAsStream getClassLoader getClass read calculate assertEquals length getValue assertTrue getValue getValue assertFalse isNaN get assertTrue get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test1()
focal_class.declarator: NAMES = {"ATSc1", "ATSc2", "ATSc3", "ATSc4", "ATSc5"}
focal_class.modifier: private static final
focal_class.original_string: private static final String[] NAMES = {"ATSc1", "ATSc2", "ATSc3", "ATSc4", "ATSc5"};
focal_class.type: String[]
focal_class.var_name: NAMES
focal_class.file: descriptor/qsarmolecular/src/main/java/org/openscience/cdk/qsar/descriptors/molecular/AutocorrelationDescriptorCharge.java
focal_class.identifier: AutocorrelationDescriptorCharge
focal_class.interfaces: implements IMolecularDescriptor
focal_class.class_method_signature: AutocorrelationDescriptorCharge.listcharges(IAtomContainer container)
focal_class.full_signature: private static double[] listcharges(IAtomContainer container)
focal_class.identifier: listcharges
focal_class.modifiers: private static
focal_class.parameters: (IAtomContainer container)
focal_class.return: double[]
focal_class.signature: double[] listcharges(IAtomContainer container)
focal_class.class_method_signature: AutocorrelationDescriptorCharge.calculate(IAtomContainer atomContainer)
focal_class.full_signature: @Override public DescriptorValue calculate(IAtomContainer atomContainer)
focal_class.identifier: calculate
focal_class.modifiers: @Override public
focal_class.parameters: (IAtomContainer atomContainer)
focal_class.return: DescriptorValue
focal_class.signature: DescriptorValue calculate(IAtomContainer atomContainer)
focal_class.class_method_signature: AutocorrelationDescriptorCharge.getParameterNames()
focal_class.full_signature: @Override public String[] getParameterNames()
focal_class.identifier: getParameterNames
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String[]
focal_class.signature: String[] getParameterNames()
focal_class.class_method_signature: AutocorrelationDescriptorCharge.getParameterType(String name)
focal_class.full_signature: @Override public Object getParameterType(String name)
focal_class.identifier: getParameterType
focal_class.modifiers: @Override public
focal_class.parameters: (String name)
focal_class.return: Object
focal_class.signature: Object getParameterType(String name)
focal_class.class_method_signature: AutocorrelationDescriptorCharge.getParameters()
focal_class.full_signature: @Override public Object[] getParameters()
focal_class.identifier: getParameters
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Object[]
focal_class.signature: Object[] getParameters()
focal_class.class_method_signature: AutocorrelationDescriptorCharge.getDescriptorNames()
focal_class.full_signature: @Override public String[] getDescriptorNames()
focal_class.identifier: getDescriptorNames
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String[]
focal_class.signature: String[] getDescriptorNames()
focal_class.class_method_signature: AutocorrelationDescriptorCharge.getSpecification()
focal_class.full_signature: @Override public DescriptorSpecification getSpecification()
focal_class.identifier: getSpecification
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: DescriptorSpecification
focal_class.signature: DescriptorSpecification getSpecification()
focal_class.class_method_signature: AutocorrelationDescriptorCharge.getDescriptorResultType()
focal_class.full_signature: @Override public IDescriptorResult getDescriptorResultType()
focal_class.identifier: getDescriptorResultType
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: IDescriptorResult
focal_class.signature: IDescriptorResult getDescriptorResultType()
focal_class.class_method_signature: AutocorrelationDescriptorCharge.setParameters(Object[] params)
focal_class.full_signature: @Override public void setParameters(Object[] params)
focal_class.identifier: setParameters
focal_class.modifiers: @Override public
focal_class.parameters: (Object[] params)
focal_class.return: void
focal_class.signature: void setParameters(Object[] params)
focal_class.superclass: extends AbstractMolecularDescriptor
focal_method.body: @Override
      public DescriptorValue calculate(IAtomContainer atomContainer) {
          IAtomContainer container;
          try {
              container = (IAtomContainer) atomContainer.clone();
              container = AtomContainerManipulator.removeHydrogens(container);
          } catch (CloneNotSupportedException e) {
              DoubleArrayResult result = new DoubleArrayResult(5);
              for (int i = 0; i < 5; i++)
                  result.add(Double.NaN);
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result,
                      getDescriptorNames(), new CDKException("Error during cloner: " + e.getMessage(), e));
          }
  
          try {
              double[] w = listcharges(container);
              int natom = container.getAtomCount();
              int[][] distancematrix = TopologicalMatrix.getMatrix(container);
  
              double[] chargeSum = new double[5];
  
              for (int k = 0; k < 5; k++) {
                  for (int i = 0; i < natom; i++) {
                      for (int j = 0; j < natom; j++) {
                          if (distancematrix[i][j] == k) {
                              chargeSum[k] += w[i] * w[j];
                          } else
                              chargeSum[k] += 0.0;
                      }
                  }
                  if (k > 0) chargeSum[k] = chargeSum[k] / 2;
  
              }
              DoubleArrayResult result = new DoubleArrayResult(5);
              for (double aChargeSum : chargeSum) {
                  result.add(aChargeSum);
              }
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result, NAMES);
  
          } catch (Exception ex) {
              DoubleArrayResult result = new DoubleArrayResult(5);
              for (int i = 0; i < 5; i++)
                  result.add(Double.NaN);
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), result, NAMES,
                      new CDKException("Error while calculating the ATS_charge descriptor: " + ex.getMessage(), ex));
          }
      }
focal_method.class_method_signature: AutocorrelationDescriptorCharge.calculate(IAtomContainer atomContainer)
focal_method.full_signature: @Override public DescriptorValue calculate(IAtomContainer atomContainer)
focal_method.identifier: calculate
focal_method.invocations: clone removeHydrogens add getSpecification getParameterNames getParameters getDescriptorNames getMessage listcharges getAtomCount getMatrix add getSpecification getParameterNames getParameters add getSpecification getParameterNames getParameters getMessage
focal_method.modifiers: @Override public
focal_method.parameters: (IAtomContainer atomContainer)
focal_method.return: DescriptorValue
focal_method.signature: DescriptorValue calculate(IAtomContainer atomContainer)