Esempio n. 1
0
  @Override
  public IAtomContainer getStructure(ChemSpiderIdentifier identifier) {

    try {

      StringPreference key = ServicePreferences.getInstance().getPreference("CHEM_SPIDER_KEY");

      if (key.get().isEmpty()) {
        System.err.println("No ChemSpider key available: please input the key via preferences!");
        return BUILDER.newInstance(IAtomContainer.class);
      }

      CompoundInfo info =
          service.getCompoundInfo(Integer.parseInt(identifier.getAccession()), key.get());

      InChIGeneratorFactory inchiFactory = InChIGeneratorFactory.getInstance();
      InChIToStructure inchi2structure = inchiFactory.getInChIToStructure(info.getInChI(), BUILDER);

      return inchi2structure.getAtomContainer();

    } catch (CDKException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    } catch (RemoteException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }

    return BUILDER.newInstance(IAtomContainer.class);
  }
Esempio n. 2
0
 private static String nextAccession() {
   StringPreference format =
       ResourcePreferences.getInstance().getPreference("BASIC_PROT_ID_FORMAT");
   IncrementalPreference ticker =
       ResourcePreferences.getInstance().getPreference("BASIC_GENE_ID_TICK");
   return String.format(format.get(), ticker.get());
 }