code: private static RgroupStructure buildMoleculefromCHEM(final String id, final List<Monomer> validMonomers) throws BuilderMoleculeException, ChemistryException {
      LOG.info("Build molecule for chemical component");
      /* a chemical molecule should only contain one monomer */
      if (validMonomers.size() == 1) {
        try {
          Monomer monomer = validMonomers.get(0);
          String input = getInput(monomer);
          if (input != null) {
            /* Build monomer + Rgroup information! */
  
            List<Attachment> listAttachments = monomer.getAttachmentList();
            AttachmentList list = new AttachmentList();
  
            for (Attachment attachment : listAttachments) {
              list.add(new org.helm.chemtoolkit.Attachment(attachment.getAlternateId(), attachment.getLabel(), attachment.getCapGroupName(), attachment.getCapGroupSMILES()));
            }
            AbstractMolecule molecule = Chemistry.getInstance().getManipulator().getMolecule(input, list);
            RgroupStructure result = new RgroupStructure();
            result.setMolecule(molecule);
            result.setRgroupMap(generateRgroupMap(id + ":" + "1", molecule));
            return result;
  
          } else {
            LOG.error("Chemical molecule should have canonical smiles");
            throw new BuilderMoleculeException("Chemical molecule should have canoncial smiles");
          }
        } catch (NullPointerException ex) {
          throw new BuilderMoleculeException("Monomer is not stored in the monomer database");
        } catch (IOException | CTKException e) {
          LOG.error("Molecule can't be built " + e.getMessage());
          throw new BuilderMoleculeException("Molecule can't be built " + e.getMessage());
        }
      } else {
        LOG.error("Chemical molecule should contain exactly one monomer");
        throw new BuilderMoleculeException("Chemical molecule should contain exactly one monomer");
      }
    }
docs: method to build a molecule from a chemical component
  
  @param validMonomers all valid monomers of the chemical component
  @return Built Molecule
  @throws BuilderMoleculeException if the polymer contains more than one
  monomer or if the molecule can't be built
  @throws ChemistryException if the Chemistry Engine can not be initialized