class_docstr: Object for working with Protein Databank structure files.
  
  Attributes
  ----------
  df : dict
      Dictionary storing pandas DataFrames for PDB record sections.
      The dictionary keys are {'ATOM', 'HETATM', 'ANISOU', 'OTHERS'}
      where 'OTHERS' contains all entries that are not parsed as
      'ATOM', 'HETATM', or 'ANISOU'.
  
  pdb_text : str
      PDB file contents in raw text format.
  
  pdb_path : Union[str, os.PathLike]
      Location of the PDB file that was read in via `read_pdb`
      or URL of the page where the PDB content was fetched from
      if `fetch_pdb` was called.
  
  header : str
      PDB file description.
  
  code : str
      PDB code
class_docstr_tok: ["Object","for","working","with","Protein","Databank","structure","files",".","Attributes","--","--","--","--","--","df",":","dict","Dictionary","storing","pandas","DataFrames","for","PDB","record","sections",".","The","dictionary","keys","are","{","'ATOM","'",",","'HETATM","'",",","'ANISOU","'",",","'OTHERS","'","}","where","'OTHERS","'","contains","all","entries","that","are","not","parsed","as","'ATOM","'",",","'HETATM","'",",","or","'ANISOU","'",".","pdb_text",":","str","PDB","file","contents","in","raw","text","format",".","pdb_path",":","Union","[","str",",","os.PathLike","]","Location","of","the","PDB","file","that","was","read","in","via","`","read_pdb","`","or","URL","of","the","page","where","the","PDB","content","was","fetched","from","if","`","fetch_pdb","`","was","called",".","header",":","str","PDB","file","description",".","code",":","str","PDB","code"]
docstr: Fetches PDB 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"`, `"alphafold2-v4"`(latest)).
              Defaults to `"pdb"`.
  
          Returns
          ---------
          self
  
          
docstr_tok: ["Fetches","PDB","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","''","`",",","`","``","alphafold2-v4","''","`","(","latest",")",")",".","Defaults","to","`","``","pdb","''","`",".","Returns","--","--","--","--","-","self"]
code: def fetch_pdb(
      self,
      pdb_code: Optional[str] = None,
      uniprot_id: Optional[str] = None,
      source: str = "pdb",
  ):
      """Fetches PDB 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"`, `"alphafold2-v4"`(latest)).
                  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 == "alphafold2-v3":
          af2_version = 3
          self.pdb_path, self.pdb_text = self._fetch_af2(
              uniprot_id, af2_version
          )
      elif source == "alphafold2-v4":
          af2_version = 4
          self.pdb_path, self.pdb_text = self._fetch_af2(
              uniprot_id, af2_version
          )
      elif source == "pdb":
          self.pdb_path, self.pdb_text = self._fetch_pdb(pdb_code)
      else:
          raise ValueError(
              f"Invalid source: {source}."
              " Please use one of 'pdb' or 'alphafold2-v3' or 'alphafold2-v4'."
          )
  
      self._df = self._construct_df(
          pdb_lines=self.pdb_text.splitlines(True)
      )
      return self
  
imports: from __future__ import annotations
  import gzip
  import sys
  import warnings
  import textwrap
  from copy import deepcopy
  from io import StringIO
  from typing import List, Optional
  from urllib.error import HTTPError, URLError
  from urllib.request import urlopen
  from warnings import warn
  import numpy
  import pandas
  from looseversion import LooseVersion
  from .engines import amino3to1dict, pdb_df_columns, pdb_records
  from biopandas.constants import ATOMIC_MASSES
label_desc: Use image node_id 6 for calling the PandasPdb obj's underlying member method code with example usage: obj.fetch_pdb(pdb_code, uniprot_id, source) and returns: self