test_class.file: descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/CPSADescriptorTest.java
test_class.identifier: CPSADescriptorTest
test_class.superclass: extends MolecularDescriptorTest
test_case.body: @Test
      public void testChargedMolecule() throws Exception {
          String filename = "data/mdl/cpsa-charged.sdf";
          InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
          ISimpleChemObjectReader reader = new MDLV2000Reader(ins);
          ChemFile content = (ChemFile) reader.read((ChemObject) new ChemFile());
          List cList = ChemFileManipulator.getAllAtomContainers(content);
          IAtomContainer ac = (IAtomContainer) cList.get(0);
  
          DoubleArrayResult retval = (DoubleArrayResult) descriptor.calculate(ac).getValue();
          int ndesc = retval.length();
          for (int i = 0; i < ndesc; i++)
              Assert.assertTrue(retval.get(i) != Double.NaN);
      }
test_case.class_method_signature: CPSADescriptorTest.testChargedMolecule()
test_case.full_signature: @Test public void testChargedMolecule()
test_case.identifier: testChargedMolecule
test_case.invocations: getResourceAsStream getClassLoader getClass read getAllAtomContainers get getValue calculate length assertTrue get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testChargedMolecule()
focal_class.declarator: NAMES  = {"PPSA-1", "PPSA-2", "PPSA-3", "PNSA-1", "PNSA-2", "PNSA-3", "DPSA-1",
              "DPSA-2", "DPSA-3", "FPSA-1", "FPSA-2", "FPSA-3", "FNSA-1", "FNSA-2", "FNSA-3", "WPSA-1", "WPSA-2",
              "WPSA-3", "WNSA-1", "WNSA-2", "WNSA-3", "RPCG", "RNCG", "RPCS", "RNCS", "THSA", "TPSA", "RHSA", "RPSA"}
focal_class.modifier: private static final
focal_class.original_string: private static final String[] NAMES  = {"PPSA-1", "PPSA-2", "PPSA-3", "PNSA-1", "PNSA-2", "PNSA-3", "DPSA-1",
              "DPSA-2", "DPSA-3", "FPSA-1", "FPSA-2", "FPSA-3", "FNSA-1", "FNSA-2", "FNSA-3", "WPSA-1", "WPSA-2",
              "WPSA-3", "WNSA-1", "WNSA-2", "WNSA-3", "RPCG", "RNCG", "RPCS", "RNCS", "THSA", "TPSA", "RHSA", "RPSA"};
focal_class.type: String[]
focal_class.var_name: NAMES
focal_class.declarator: logger = LoggingToolFactory.createLoggingTool(CPSADescriptor.class)
focal_class.modifier: private static
focal_class.original_string: private static ILoggingTool   logger = LoggingToolFactory.createLoggingTool(CPSADescriptor.class);
focal_class.type: ILoggingTool
focal_class.var_name: logger
focal_class.file: descriptor/qsarmolecular/src/main/java/org/openscience/cdk/qsar/descriptors/molecular/CPSADescriptor.java
focal_class.identifier: CPSADescriptor
focal_class.interfaces: implements IMolecularDescriptor
focal_class.class_method_signature: CPSADescriptor.CPSADescriptor()
focal_class.full_signature: public  CPSADescriptor()
focal_class.identifier: CPSADescriptor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  CPSADescriptor()
focal_class.class_method_signature: CPSADescriptor.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: CPSADescriptor.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.class_method_signature: CPSADescriptor.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: CPSADescriptor.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: CPSADescriptor.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: CPSADescriptor.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: CPSADescriptor.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: CPSADescriptor.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.superclass: extends AbstractMolecularDescriptor
focal_method.body: @Override
      public DescriptorValue calculate(IAtomContainer atomContainer) {
          DoubleArrayResult retval = new DoubleArrayResult();
  
          if (!GeometryUtil.has3DCoordinates(atomContainer)) {
              for (int i = 0; i < 29; i++)
                  retval.add(Double.NaN);
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                      getDescriptorNames(), new CDKException("Molecule must have 3D coordinates"));
          }
  
          IAtomContainer container;
          try {
              container = (IAtomContainer) atomContainer.clone();
          } catch (CloneNotSupportedException e) {
              logger.debug("Error during clone");
              for (int i = 0; i < 29; i++)
                  retval.add(Double.NaN);
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                      getDescriptorNames(), new CDKException("Error during clone" + e.getMessage()));
          }
  
          //        IsotopeFactory factory = null;
          //        try {
          //            factory = IsotopeFactory.getInstance(container.getNewBuilder());
          //        } catch (Exception e) {
          //            logger.debug(e);
          //        }
  
          GasteigerMarsiliPartialCharges peoe;
          try {
              peoe = new GasteigerMarsiliPartialCharges();
              peoe.assignGasteigerMarsiliSigmaPartialCharges(container, true);
          } catch (Exception e) {
              logger.debug("Error in assigning Gasteiger-Marsilli charges");
              for (int i = 0; i < 29; i++)
                  retval.add(Double.NaN);
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                      getDescriptorNames(), new CDKException("Error in getting G-M charges"));
          }
  
          NumericalSurface surface;
          try {
              surface = new NumericalSurface(container);
              surface.calculateSurface();
          } catch (NullPointerException npe) {
              logger.debug("Error in surface area calculation");
              for (int i = 0; i < 29; i++)
                  retval.add(Double.NaN);
              return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                      getDescriptorNames(), new CDKException("Error in surface area calculation"));
          }
  
          //double molecularWeight = mfa.getMass();
          double[] atomSurfaces = surface.getAllSurfaceAreas();
          double totalSA = surface.getTotalSurfaceArea();
  
          double ppsa1 = 0.0;
          double ppsa3 = 0.0;
          double pnsa1 = 0.0;
          double pnsa3 = 0.0;
          double totpcharge = 0.0;
          double totncharge = 0.0;
          for (int i = 0; i < container.getAtomCount(); i++) {
              if (container.getAtom(i).getCharge() > 0) {
                  ppsa1 += atomSurfaces[i];
                  ppsa3 += container.getAtom(i).getCharge() * atomSurfaces[i];
                  totpcharge += container.getAtom(i).getCharge();
              } else {
                  pnsa1 += atomSurfaces[i];
                  pnsa3 += container.getAtom(i).getCharge() * atomSurfaces[i];
                  totncharge += container.getAtom(i).getCharge();
              }
          }
  
          double ppsa2 = ppsa1 * totpcharge;
          double pnsa2 = pnsa1 * totncharge;
  
          // fractional +ve & -ve SA
          double fpsa1 = ppsa1 / totalSA;
          double fpsa2 = ppsa2 / totalSA;
          double fpsa3 = ppsa3 / totalSA;
          double fnsa1 = pnsa1 / totalSA;
          double fnsa2 = pnsa2 / totalSA;
          double fnsa3 = pnsa3 / totalSA;
  
          // surface wtd +ve & -ve SA
          double wpsa1 = ppsa1 * totalSA / 1000;
          double wpsa2 = ppsa2 * totalSA / 1000;
          double wpsa3 = ppsa3 * totalSA / 1000;
          double wnsa1 = pnsa1 * totalSA / 1000;
          double wnsa2 = pnsa2 * totalSA / 1000;
          double wnsa3 = pnsa3 * totalSA / 1000;
  
          // hydrophobic and poalr surface area
          double phobic = 0.0;
          double polar = 0.0;
          for (int i = 0; i < container.getAtomCount(); i++) {
              if (Math.abs(container.getAtom(i).getCharge()) < 0.2) {
                  phobic += atomSurfaces[i];
              } else {
                  polar += atomSurfaces[i];
              }
          }
          double thsa = phobic;
          double tpsa = polar;
          double rhsa = phobic / totalSA;
          double rpsa = polar / totalSA;
  
          // differential +ve & -ve SA
          double dpsa1 = ppsa1 - pnsa1;
          double dpsa2 = ppsa2 - pnsa2;
          double dpsa3 = ppsa3 - pnsa3;
  
          double maxpcharge = 0.0;
          double maxncharge = 0.0;
          int pidx = 0;
          int nidx = 0;
          for (int i = 0; i < container.getAtomCount(); i++) {
              double charge = container.getAtom(i).getCharge();
              if (charge > maxpcharge) {
                  maxpcharge = charge;
                  pidx = i;
              }
              if (charge < maxncharge) {
                  maxncharge = charge;
                  nidx = i;
              }
          }
  
          // relative descriptors
          double rpcg = maxpcharge / totpcharge;
          double rncg = maxncharge / totncharge;
          double rpcs = atomSurfaces[pidx] * rpcg;
          double rncs = atomSurfaces[nidx] * rncg;
  
          // fill in the values
          retval.add(ppsa1);
          retval.add(ppsa2);
          retval.add(ppsa3);
          retval.add(pnsa1);
          retval.add(pnsa2);
          retval.add(pnsa3);
  
          retval.add(dpsa1);
          retval.add(dpsa2);
          retval.add(dpsa3);
  
          retval.add(fpsa1);
          retval.add(fpsa2);
          retval.add(fpsa3);
          retval.add(fnsa1);
          retval.add(fnsa2);
          retval.add(fnsa3);
  
          retval.add(wpsa1);
          retval.add(wpsa2);
          retval.add(wpsa3);
          retval.add(wnsa1);
          retval.add(wnsa2);
          retval.add(wnsa3);
  
          retval.add(rpcg);
          retval.add(rncg);
          retval.add(rpcs);
          retval.add(rncs);
  
          retval.add(thsa);
          retval.add(tpsa);
          retval.add(rhsa);
          retval.add(rpsa);
  
          return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                  getDescriptorNames());
      }
focal_method.class_method_signature: CPSADescriptor.calculate(IAtomContainer atomContainer)
focal_method.full_signature: @Override public DescriptorValue calculate(IAtomContainer atomContainer)
focal_method.identifier: calculate
focal_method.invocations: has3DCoordinates add getSpecification getParameterNames getParameters getDescriptorNames clone debug add getSpecification getParameterNames getParameters getDescriptorNames getMessage assignGasteigerMarsiliSigmaPartialCharges debug add getSpecification getParameterNames getParameters getDescriptorNames calculateSurface debug add getSpecification getParameterNames getParameters getDescriptorNames getAllSurfaceAreas getTotalSurfaceArea getAtomCount getCharge getAtom getCharge getAtom getCharge getAtom getCharge getAtom getCharge getAtom getAtomCount abs getCharge getAtom getAtomCount getCharge getAtom add add add add add add add add add add add add add add add add add add add add add add add add add add add add add getSpecification getParameterNames getParameters getDescriptorNames
focal_method.modifiers: @Override public
focal_method.parameters: (IAtomContainer atomContainer)
focal_method.return: DescriptorValue
focal_method.signature: DescriptorValue calculate(IAtomContainer atomContainer)