Ejemplo n.º 1
0
 std::string MolFragmentToSmilesHelper(const ROMol &mol,
                                       python::object atomsToUse,
                                       python::object bondsToUse,
                                       python::object atomSymbols,
                                       python::object bondSymbols,
                                       bool doIsomericSmiles,
                                       bool doKekule,
                                       int rootedAtAtom,
                                       bool canonical,
                                       bool allBondsExplicit
                                       ){
   std::vector<int> *avect=pythonObjectToVect(atomsToUse,static_cast<int>(mol.getNumAtoms()));
   if(!avect || !(avect->size())){
     throw_value_error("atomsToUse must not be empty");
   }
   std::vector<int> *bvect=pythonObjectToVect(bondsToUse,static_cast<int>(mol.getNumBonds()));
   std::vector<std::string> *asymbols=pythonObjectToVect<std::string>(atomSymbols);
   std::vector<std::string> *bsymbols=pythonObjectToVect<std::string>(bondSymbols);
   if(asymbols && asymbols->size()!=mol.getNumAtoms()){
     throw_value_error("length of atom symbol list != number of atoms");
   }
   if(bsymbols && bsymbols->size()!=mol.getNumBonds()){
     throw_value_error("length of bond symbol list != number of bonds");
   }
   
   std::string res=MolFragmentToSmiles(mol,*avect,bvect,asymbols,bsymbols,
                                       doIsomericSmiles,doKekule,rootedAtAtom,
                                       canonical,allBondsExplicit);
   if(avect) delete avect;
   if(bvect) delete bvect;
   if(asymbols) delete asymbols;
   if(bsymbols) delete bsymbols;
   return res;
 }
Ejemplo n.º 2
0
void drawMoleculeHelper2(MolDraw2D &self, const ROMol &mol,
                         python::object highlight_atoms,
                         python::object highlight_bonds,
                         python::object highlight_atom_map,
                         python::object highlight_bond_map,
                         python::object highlight_atom_radii, int confId = -1) {
  rdk_auto_ptr<std::vector<int> > highlightAtoms =
      pythonObjectToVect(highlight_atoms, static_cast<int>(mol.getNumAtoms()));
  rdk_auto_ptr<std::vector<int> > highlightBonds =
      pythonObjectToVect(highlight_bonds, static_cast<int>(mol.getNumBonds()));
  // FIX: support these
  std::map<int, DrawColour> *ham = pyDictToColourMap(highlight_atom_map);
  std::map<int, DrawColour> *hbm = pyDictToColourMap(highlight_bond_map);
  std::map<int, double> *har = pyDictToDoubleMap(highlight_atom_radii);

  self.drawMolecule(mol, highlightAtoms.get(), highlightBonds.get(), ham, hbm,
                    har, confId);

  delete ham;
  delete hbm;
  delete har;
}
Ejemplo n.º 3
0
void drawMoleculeHelper1(MolDraw2D &self, const ROMol &mol,
                         python::object highlight_atoms,
                         python::object highlight_atom_map,
                         python::object highlight_atom_radii, int confId = -1) {
    std::vector<int> *highlightAtoms =
        pythonObjectToVect(highlight_atoms, static_cast<int>(mol.getNumAtoms()));
    std::map<int, DrawColour> *ham = pyDictToColourMap(highlight_atom_map);
    std::map<int, double> *har = pyDictToDoubleMap(highlight_atom_radii);

    self.drawMolecule(mol, highlightAtoms, ham, har, confId);

    delete highlightAtoms;
    delete ham;
    delete har;
}