test_class.file: descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/MomentOfInertiaDescriptorTest.java
test_class.identifier: MomentOfInertiaDescriptorTest
test_class.superclass: extends MolecularDescriptorTest
test_case.body: @Test
      public void testMomentOfInertia1() throws ClassNotFoundException, CDKException, java.lang.Exception {
          String filename = "data/hin/gravindex.hin";
          InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
          ISimpleChemObjectReader reader = new HINReader(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();
  
          Assert.assertEquals(1820.692519, retval.get(0), 0.00001);
          Assert.assertEquals(1274.532522, retval.get(1), 0.00001);
          Assert.assertEquals(979.210423, retval.get(2), 0.00001);
          Assert.assertEquals(1.428517, retval.get(3), 0.00001);
          Assert.assertEquals(1.859347, retval.get(4), 0.00001);
          Assert.assertEquals(1.301592, retval.get(5), 0.00001);
          Assert.assertEquals(5.411195, retval.get(6), 0.00001);
      }
test_case.class_method_signature: MomentOfInertiaDescriptorTest.testMomentOfInertia1()
test_case.full_signature: @Test public void testMomentOfInertia1()
test_case.identifier: testMomentOfInertia1
test_case.invocations: getResourceAsStream getClassLoader getClass read getAllAtomContainers get getValue calculate assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMomentOfInertia1()
focal_class.declarator: logger = LoggingToolFactory.createLoggingTool(MomentOfInertiaDescriptor.class)
focal_class.modifier: private static
focal_class.original_string: private static ILoggingTool   logger = LoggingToolFactory.createLoggingTool(MomentOfInertiaDescriptor.class);
focal_class.type: ILoggingTool
focal_class.var_name: logger
focal_class.declarator: NAMES  = {"MOMI-X", "MOMI-Y", "MOMI-Z", "MOMI-XY", "MOMI-XZ", "MOMI-YZ", "MOMI-R"}
focal_class.modifier: private static final
focal_class.original_string: private static final String[] NAMES  = {"MOMI-X", "MOMI-Y", "MOMI-Z", "MOMI-XY", "MOMI-XZ", "MOMI-YZ", "MOMI-R"};
focal_class.type: String[]
focal_class.var_name: NAMES
focal_class.file: descriptor/qsarmolecular/src/main/java/org/openscience/cdk/qsar/descriptors/molecular/MomentOfInertiaDescriptor.java
focal_class.identifier: MomentOfInertiaDescriptor
focal_class.interfaces: implements IMolecularDescriptor
focal_class.class_method_signature: MomentOfInertiaDescriptor.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: MomentOfInertiaDescriptor.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: MomentOfInertiaDescriptor.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: MomentOfInertiaDescriptor.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: MomentOfInertiaDescriptor.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: MomentOfInertiaDescriptor.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: MomentOfInertiaDescriptor.getDummyDescriptorValue(Exception e)
focal_class.full_signature: private DescriptorValue getDummyDescriptorValue(Exception e)
focal_class.identifier: getDummyDescriptorValue
focal_class.modifiers: private
focal_class.parameters: (Exception e)
focal_class.return: DescriptorValue
focal_class.signature: DescriptorValue getDummyDescriptorValue(Exception e)
focal_class.class_method_signature: MomentOfInertiaDescriptor.calculate(IAtomContainer container)
focal_class.full_signature: @Override public DescriptorValue calculate(IAtomContainer container)
focal_class.identifier: calculate
focal_class.modifiers: @Override public
focal_class.parameters: (IAtomContainer container)
focal_class.return: DescriptorValue
focal_class.signature: DescriptorValue calculate(IAtomContainer container)
focal_class.class_method_signature: MomentOfInertiaDescriptor.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 container) {
          if (!GeometryUtil.has3DCoordinates(container))
              return getDummyDescriptorValue(new CDKException("Molecule must have 3D coordinates"));
  
          IAtomContainer clone;
          IsotopeFactory factory;
          try {
              clone = (IAtomContainer) container.clone();
              factory = Isotopes.getInstance();
              factory.configureAtoms(clone);
          } catch (CloneNotSupportedException | IOException e) {
              logger.debug(e);
              return getDummyDescriptorValue(e);
          }
  
          DoubleArrayResult retval = new DoubleArrayResult(7);
  
          double ccf = 1.000138;
          double eps = 1e-5;
  
          double[][] imat = new double[3][3];
          Point3d centerOfMass = GeometryUtil.get3DCentreOfMass(clone);
  
          double xdif;
          double ydif;
          double zdif;
          double xsq;
          double ysq;
          double zsq;
          for (int i = 0; i < clone.getAtomCount(); i++) {
              IAtom currentAtom = clone.getAtom(i);
  
              Double mass = factory.getMajorIsotope(currentAtom.getSymbol()).getExactMass();
              if (mass == null)
                  mass = factory.getNaturalMass(currentAtom);
  
              xdif = currentAtom.getPoint3d().x - centerOfMass.x;
              ydif = currentAtom.getPoint3d().y - centerOfMass.y;
              zdif = currentAtom.getPoint3d().z - centerOfMass.z;
              xsq = xdif * xdif;
              ysq = ydif * ydif;
              zsq = zdif * zdif;
  
              imat[0][0] += mass * (ysq + zsq);
              imat[1][1] += mass * (xsq + zsq);
              imat[2][2] += mass * (xsq + ysq);
  
              imat[1][0] += -1 * mass * ydif * xdif;
              imat[0][1] = imat[1][0];
  
              imat[2][0] += -1 * mass * xdif * zdif;
              imat[0][2] = imat[2][0];
  
              imat[2][1] += -1 * mass * ydif * zdif;
              imat[1][2] = imat[2][1];
          }
  
          // diagonalize the MI tensor
          Matrix tmp = new Matrix(imat);
          EigenvalueDecomposition eigenDecomp = tmp.eig();
          double[] eval = eigenDecomp.getRealEigenvalues();
  
          retval.add(eval[2]);
          retval.add(eval[1]);
          retval.add(eval[0]);
  
          double etmp = eval[0];
          eval[0] = eval[2];
          eval[2] = etmp;
  
          if (Math.abs(eval[1]) > 1e-3)
              retval.add(eval[0] / eval[1]);
          else
              retval.add(1000);
  
          if (Math.abs(eval[2]) > 1e-3) {
              retval.add(eval[0] / eval[2]);
              retval.add(eval[1] / eval[2]);
          } else {
              retval.add(1000);
              retval.add(1000);
          }
  
          // finally get the radius of gyration
          double pri;
          IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula(clone);
          if (Math.abs(eval[2]) > eps)
              pri = Math.pow(eval[0] * eval[1] * eval[2], 1.0 / 3.0);
          else
              pri = Math.sqrt(eval[0] * ccf / MolecularFormulaManipulator.getTotalExactMass(formula));
          retval.add(Math.sqrt(Math.PI * 2 * pri * ccf / MolecularFormulaManipulator.getTotalExactMass(formula)));
  
          return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                  getDescriptorNames());
      }
focal_method.class_method_signature: MomentOfInertiaDescriptor.calculate(IAtomContainer container)
focal_method.full_signature: @Override public DescriptorValue calculate(IAtomContainer container)
focal_method.identifier: calculate
focal_method.invocations: has3DCoordinates getDummyDescriptorValue clone getInstance configureAtoms debug getDummyDescriptorValue get3DCentreOfMass getAtomCount getAtom getExactMass getMajorIsotope getSymbol getNaturalMass getPoint3d getPoint3d getPoint3d eig getRealEigenvalues add add add abs add add abs add add add add getMolecularFormula abs pow sqrt getTotalExactMass add sqrt getTotalExactMass getSpecification getParameterNames getParameters getDescriptorNames
focal_method.modifiers: @Override public
focal_method.parameters: (IAtomContainer container)
focal_method.return: DescriptorValue
focal_method.signature: DescriptorValue calculate(IAtomContainer container)