Пример #1
0
 public static void main(String[] args) {
   Example4 ef = new Example4();
   try {
     final String molS = "C1C2=CC=CC=C2C3=C4CC5=CC=CC=C5C4=C6CC7=CC=CC=C7C6=C13";
     Molecule mol = MolImporter.importMol(molS);
     PolarizabilityPlugin plugin = new PolarizabilityPlugin();
     plugin.setMolecule(mol);
     plugin.run();
     ArrayList values = new ArrayList();
     java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
     nf.setMaximumFractionDigits(3);
     for (int i = 0; i < mol.getAtomCount(); i++) {
       values.add(Float.valueOf(nf.format(((Double) plugin.getResult(i)).floatValue())));
     }
     mol.hydrogenize(true);
     for (int i = 0; i < mol.getExplicitHcount(); i++) {
       values.add(new Double(0));
     }
     ef.setPlugin(plugin);
     JFrame frame = ef.createSpaceFrame(mol, values);
     frame.setTitle("Polarizability");
     java.net.URL u = ef.getClass().getResource("/chemaxon/marvin/space/gui/mspace16.gif");
     frame.setIconImage(
         Toolkit.getDefaultToolkit().createImage((java.awt.image.ImageProducer) u.getContent()));
     frame.setVisible(true);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #2
0
 private static void saveImage(String notation, String imageFilePath)
     throws NotationException, MonomerException, StructureException, JDOMException, IOException {
   String complexNotation = SimpleNotationParser.getComplextNotationForRNA(notation);
   String smiles = ComplexNotationParser.getComplexPolymerSMILES(complexNotation);
   Molecule mol = MolImporter.importMol(smiles);
   Image image = (Image) mol.toObject("image");
   new SaveAsPNG(image, imageFilePath);
 }
  public static void main(String[] args) throws IOException {

    // Import a molecule from smiles
    Molecule mol = MolImporter.importMol("O=C1NC=CC=C1");
    mol.setDim(0);

    // Call basic aromatization method
    mol.aromatize(MoleculeGraph.AROM_BASIC);
    System.out.println("Aromatic: " + isAromatic(mol));

    // Call general aromatization method
    mol.aromatize(MoleculeGraph.AROM_GENERAL);
    System.out.println("Aromatic: " + isAromatic(mol));
  }
Пример #4
0
  public static void main(String[] args) {
    try {
      // instantiate the plugin object
      ElementalAnalyserPlugin plugin = new ElementalAnalyserPlugin();

      // set the parameters for the calculation (plugin specific))
      plugin.setDoublePrecision(2);

      // read the input molecules and perform the calculations
      MolImporter importer = new MolImporter(args[0]);
      Molecule mol;
      while ((mol = importer.read()) != null) {

        // set the input molecule
        plugin.setMolecule(mol);

        // run the calculation
        plugin.run();

        // get the results (plugin specific)
        // mass and exact mass
        double mass = plugin.getMass();
        double exactMass = plugin.getExactMass();
        // the number of all atoms in the molecule
        int atomCount = plugin.getAllAtomCount();
        // carbon atom count
        int countOfC = plugin.getAtomCount(6);
        // carbon-14 isotope count
        int countOfC14 = plugin.getAtomCount(6, 14);
        // formula
        String formula = plugin.getFormula();
        // composition
        String composition = plugin.getComposition();

        // display the results
        System.out.println(
            mol.toFormat("smiles")
                + "\n  formula: "
                + formula
                + ", mass: "
                + mass
                + ", exact mass: "
                + exactMass
                + "\n  number of atoms ("
                + atomCount
                + "): C ("
                + countOfC
                + "), C-14 ("
                + countOfC14
                + ")"
                + "\n  composition: "
                + composition
                + "\n");
      }
      importer.close();
    } catch (IOException e) {
      System.err.println("I/O error has occurred.");
      e.printStackTrace();
    } catch (PluginException e) {
      System.err.println("Plugin processing or calculation error.");
      e.printStackTrace();
    }
  }