Example #1
0
  @Test
  public void testDragonShell() throws Exception {
    DragonShell shell = new DragonShell();
    shell.setDescriptors(new String[] {"MW", "MLOGP", "Constitutional indices"});
    IIteratingChemObjectReader reader =
        FileInputState.getReader(
            getClass().getClassLoader().getResourceAsStream("ambit2/dragon/test/structure.sdf"),
            "structure.sdf");

    Assert.assertTrue(reader != null);
    while (reader.hasNext()) {
      Object o = reader.next();
      IAtomContainer mol = (IAtomContainer) o;
      mol = shell.process(mol);
      Assert.assertTrue(mol.getProperties().size() > 0);
    }
    reader.close();
  }
Example #2
0
  /** @param args the command line arguments */
  public static void main(String[] args) throws IOException, CDKException {
    BufferedOutputStream writer = new BufferedOutputStream(new FileOutputStream(output));
    int j = 0;

    File f;

    SmilesGenerator sg;
    f = new File(input);

    System.out.println(input);
    IteratingSDFReader reader =
        new IteratingSDFReader(new FileInputStream(f), DefaultChemObjectBuilder.getInstance());

    sg = SmilesGenerator.generic().aromatic();
    sg.setUseAromaticityFlag(true);

    // List<IAtomContainer> mols = new ArrayList<IAtomContainer>();

    IAtomContainer mol;

    long totalMemory = 0;

    while (reader.hasNext()) {
      mol = (IAtomContainer) reader.next();
      // mols.add(mol);
      j++;
      String smiles = sg.create(mol);
      if (!smiles.equals("")) {
        writer.write(sg.create(mol).getBytes());
        writer.write(";".getBytes());
        writer.write("https://www.ebi.ac.uk/chembl/compound/inspect/".getBytes());
        writer.write(((String) mol.getProperties().get("chembl_id")).getBytes());
        writer.write("\n".getBytes());
      } else {
        System.out.println("HUUUUGE");
      }
      System.out.println("done" + j);
    }

    // totalMemory = MemoryUtil.deepMemoryUsageOfAll(mols, MemoryUtil.VisibilityFilter.ALL);

    // System.out.println("Average memory: " + (totalMemory/j));

    /*a a = new a();
    a aa = new a();
    a.c = new c();
    aa.c = a.c;

    System.out.println("a " + MemoryUtil.deepMemoryUsageOf(a, MemoryUtil.VisibilityFilter.ALL));
    System.out.println("aa " + MemoryUtil.deepMemoryUsageOf(aa, MemoryUtil.VisibilityFilter.ALL));
    System.out.println("a.c " + MemoryUtil.deepMemoryUsageOf(a.c, MemoryUtil.VisibilityFilter.ALL));

    List<a> ll = new ArrayList<a>();

    ll.add(a);
    ll.add(aa);

    System.out.println(MemoryUtil.deepMemoryUsageOfAll(ll, MemoryUtil.VisibilityFilter.ALL));*/

    System.out.println("done" + j);
    writer.close();
  }