class_docstr: Wandb class for 3D Molecular data.
  
  Arguments:
      data_or_path: (string, io)
          Molecule can be initialized from a file name or an io object.
      caption: (string)
          Caption associated with the molecule for display.
class_docstr_tok: ["Wandb","class","for","3D","Molecular","data",".","Arguments",":","data_or_path",":","(","string",",","io",")","Molecule","can","be","initialized","from","a","file","name","or","an","io","object",".","caption",":","(","string",")","Caption","associated","with","the","molecule","for","display","."]
docstr: Convert RDKit-supported file/object types to wandb.Molecule.
  
  Arguments:
      data_or_path: (string, rdkit.Chem.rdchem.Mol)
          Molecule can be initialized from a file name or an rdkit.Chem.rdchem.Mol object.
      caption: (string)
          Caption associated with the molecule for display.
      convert_to_3d_and_optimize: (bool)
          Convert to rdkit.Chem.rdchem.Mol with 3D coordinates.
          This is an expensive operation that may take a long time for complicated molecules.
      mmff_optimize_molecule_max_iterations: (int)
          Number of iterations to use in rdkit.Chem.AllChem.MMFFOptimizeMolecule
docstr_tok: ["Convert","RDKit-supported","file\/object","types","to","wandb.Molecule",".","Arguments",":","data_or_path",":","(","string",",","rdkit.Chem.rdchem.Mol",")","Molecule","can","be","initialized","from","a","file","name","or","an","rdkit.Chem.rdchem.Mol","object",".","caption",":","(","string",")","Caption","associated","with","the","molecule","for","display",".","convert_to_3d_and_optimize",":","(","bool",")","Convert","to","rdkit.Chem.rdchem.Mol","with","3D","coordinates",".","This","is","an","expensive","operation","that","may","take","a","long","time","for","complicated","molecules",".","mmff_optimize_molecule_max_iterations",":","(","int",")","Number","of","iterations","to","use","in","rdkit.Chem.AllChem.MMFFOptimizeMolecule"]
code: def from_rdkit(
      cls,
      data_or_path: "RDKitDataType",
      caption: Optional[str] = None,
      convert_to_3d_and_optimize: bool = True,
      mmff_optimize_molecule_max_iterations: int = 200,
  ) -> "Molecule":
      """Convert RDKit-supported file/object types to wandb.Molecule.
  
      Arguments:
          data_or_path: (string, rdkit.Chem.rdchem.Mol)
              Molecule can be initialized from a file name or an rdkit.Chem.rdchem.Mol object.
          caption: (string)
              Caption associated with the molecule for display.
          convert_to_3d_and_optimize: (bool)
              Convert to rdkit.Chem.rdchem.Mol with 3D coordinates.
              This is an expensive operation that may take a long time for complicated molecules.
          mmff_optimize_molecule_max_iterations: (int)
              Number of iterations to use in rdkit.Chem.AllChem.MMFFOptimizeMolecule
      """
      rdkit_chem = util.get_module(
          "rdkit.Chem",
          required='wandb.Molecule needs the rdkit-pypi package. To get it, run "pip install rdkit-pypi".',
      )
      rdkit_chem_all_chem = util.get_module(
          "rdkit.Chem.AllChem",
          required='wandb.Molecule needs the rdkit-pypi package. To get it, run "pip install rdkit-pypi".',
      )
  
      if isinstance(data_or_path, str):
          # path to a file?
          path = pathlib.Path(data_or_path)
          extension = path.suffix.split(".")[-1]
          if extension not in Molecule.SUPPORTED_RDKIT_TYPES:
              raise ValueError(
                  "Molecule.from_rdkit only supports files of the type: "
                  + ", ".join(Molecule.SUPPORTED_RDKIT_TYPES)
              )
          # use the appropriate method
          if extension == "sdf":
              with rdkit_chem.SDMolSupplier(data_or_path) as supplier:
                  molecule = next(
                      supplier
                  )  # get only the first molecule
          else:
              molecule = getattr(
                  rdkit_chem, f"MolFrom{extension.capitalize()}File"
              )(data_or_path)
      elif isinstance(data_or_path, rdkit_chem.rdchem.Mol):
          molecule = data_or_path
      else:
          raise ValueError(
              "Data must be file name or an rdkit.Chem.rdchem.Mol object"
          )
  
      if convert_to_3d_and_optimize:
          molecule = rdkit_chem.AddHs(molecule)
          rdkit_chem_all_chem.EmbedMolecule(molecule)
          rdkit_chem_all_chem.MMFFOptimizeMolecule(
              molecule,
              maxIters=mmff_optimize_molecule_max_iterations,
          )
      # convert to the pdb format supported by Molecule
      pdb_block = rdkit_chem.rdmolfiles.MolToPDBBlock(molecule)
  
      return cls(
          io.StringIO(pdb_block), caption=caption, file_type="pdb"
      )
  
file_path: wandb/wandb/sdk/data_types/molecule.py
imports: import io
  import os
  import pathlib
  from typing import TYPE_CHECKING, Optional, Sequence, Type, Union
  from wandb import util
  from wandb.sdk.lib import runid
  from wandb.sdk.lib.paths import LogicalPath
  from ._private import MEDIA_TMP
  from .base_types.media import BatchableMedia, Media
label_desc: Use image node_id 2 for calling the Molecule obj's underlying member method code with example usage: obj.from_rdkit(cls, data_or_path, caption, convert_to_3d_and_optimize, mmff_optimize_molecule_max_iterations) and returns: cls