docstr: Fetches mmCIF file contents from the Protein Databank at rcsb.org or AlphaFold database at https://alphafold.ebi.ac.uk/.
  .
  
          Parameters
          ----------
          pdb_code : str, optional
              A 4-letter PDB code, e.g., `"3eiy"` to retrieve structures from the PDB. Defaults to `None`.
  
          uniprot_id : str, optional
              A UniProt Identifier, e.g., `"Q5VSL9"` to retrieve structures from the AF2 database. Defaults to `None`.
  
          source : str
              The source to retrieve the structure from 
              (`"pdb"`, `"alphafold2-v3"` or `"alphafold2-v4"`). Defaults to `"pdb"`.
  
          Returns
          ---------
          self
  
          
docstr_tok: ["Fetches","mmCIF","file","contents","from","the","Protein","Databank","at","rcsb.org","or","AlphaFold","database","at","https",":","\/\/alphafold.ebi.ac.uk\/",".",".","Parameters","--","--","--","--","--","pdb_code",":","str",",","optional","A","4-letter","PDB","code",",","e.g.",",","`","``","3eiy","''","`","to","retrieve","structures","from","the","PDB",".","Defaults","to","`","None","`",".","uniprot_id",":","str",",","optional","A","UniProt","Identifier",",","e.g.",",","`","``","Q5VSL9","''","`","to","retrieve","structures","from","the","AF2","database",".","Defaults","to","`","None","`",".","source",":","str","The","source","to","retrieve","the","structure","from","(","`","``","pdb","''","`",",","`","``","alphafold2-v3","''","`","or","`","``","alphafold2-v4","''","`",")",".","Defaults","to","`","``","pdb","''","`",".","Returns","--","--","--","--","-","self"]
code: def fetch_mmcif(
      self,
      pdb_code: Optional[str] = None,
      uniprot_id: Optional[str] = None,
      source: str = "pdb",
  ):
      """Fetches mmCIF file contents from the Protein Databank at rcsb.org or AlphaFold database at https://alphafold.ebi.ac.uk/.
      .
  
              Parameters
              ----------
              pdb_code : str, optional
                  A 4-letter PDB code, e.g., `"3eiy"` to retrieve structures from the PDB. Defaults to `None`.
  
              uniprot_id : str, optional
                  A UniProt Identifier, e.g., `"Q5VSL9"` to retrieve structures from the AF2 database. Defaults to `None`.
  
              source : str
                  The source to retrieve the structure from
                  (`"pdb"`, `"alphafold2-v3"` or `"alphafold2-v4"`). Defaults to `"pdb"`.
  
              Returns
              ---------
              self
  
      """
      # Sanitize input
      invalid_input_identifier_1 = (
          pdb_code is None and uniprot_id is None
      )
      invalid_input_identifier_2 = (
          pdb_code is not None and uniprot_id is not None
      )
      invalid_input_combination_1 = (
          uniprot_id is not None and source == "pdb"
      )
      invalid_input_combination_2 = pdb_code is not None and source in {
          "alphafold2-v3",
          "alphafold2-v4",
      }
  
      if invalid_input_identifier_1 or invalid_input_identifier_2:
          raise ValueError(
              "Please provide either a PDB code or a UniProt ID."
          )
  
      if invalid_input_combination_1:
          raise ValueError(
              "Please use a 'pdb_code' instead of 'uniprot_id' for source='pdb'."
          )
      elif invalid_input_combination_2:
          raise ValueError(
              f"Please use a 'uniprot_id' instead of 'pdb_code' for source={source}."
          )
  
      if source == "pdb":
          self.mmcif_path, self.mmcif_text = self._fetch_mmcif(pdb_code)
      elif source == "alphafold2-v3":
          af2_version = 3
          self.mmcif_path, self.mmcif_text = self._fetch_af2(
              uniprot_id, af2_version
          )
      elif source == "alphafold2-v4":
          af2_version = 4
          self.mmcif_path, self.mmcif_text = self._fetch_af2(
              uniprot_id, af2_version
          )
      else:
          raise ValueError(
              f"Invalid source: {source}."
              " Please use one of 'pdb', 'alphafold2-v3' or 'alphafold2-v4'."
          )
  
      self._df = self._construct_df(text=self.mmcif_text)
      return self
  
imports: import gzip
  import sys
  import warnings
  from typing import Dict, List, Optional
  from urllib.error import HTTPError, URLError
  from urllib.request import urlopen
  import numpy
  import pandas
  from looseversion import LooseVersion
  from ..pdb.engines import amino3to1dict
  from ..pdb.pandas_pdb import PandasPdb
  from .engines import ANISOU_DF_COLUMNS, MMCIF_PDB_COLUMN_MAP, MMCIF_PDB_NONEFIELDS, PDB_COLUMN_ORDER, mmcif_col_types
  from .mmcif_parser import load_cif_data
label_desc: Use image node_id 5 for calling the PandasMmcif obj's underlying member method code with example usage: obj.fetch_mmcif(pdb_code, uniprot_id, source) and returns: self