text: user9344: The residue numbering in PDB (in my understanding) coincides with UniProtKB align. However, this might not be consistent with that in PDB fasta file. To complicate it further, UniProtKB align can be a few mutations away from the PDB sequence. Disordered/unidentified residues in structures also create gaps in numbering.
  Is there a way/suggestion to create a matched residue numbering between sequence and structure? For example
  12345678 (residue numbering)
  ATPWQMSQ (sequence)
  ---W-MSQ (PDB residues) "-" for missing residue in structure
  
  
  user6322: Unfortunately, PDB numbering can be one of different schemes. The main three:
  
  Uniprot numbering (canonical isoform)
  Construct numbering with or without tag removal
  Start from 1 for what has density
  
  However, the are many many corner cases. In Proteopedia there is a lovely article about weird PDB numbering.
  The best way to find the details about what part of the sequence is covered is to use the Swissmodel API. It's actually better than either the PDBe and RCSB PDB APIs. Swissmodel is a homology modelling service that maintains close threaded models (>30% ID), but also has PDB data. Here is a Python3 method I use, (provider='pdb') is what is required here).
  def get_data(uniprot: str, provider='swissmodel') -> List[dict]:
          """
          Gets data from Swissmodel. Convert each entry with convert_SM_entry
          """
      assert provider in ('swissmodel', 'pdb'), 'Provider has to be swissmodel or pdb'
          url = f'https://swissmodel.expasy.org/repository/uniprot/{uniprot.strip()}.json?provider={provider.strip()}'
          data = requests.get(url).json()
          return data['result']['structures']  # [0] # from to coordinates description
  
  The returned dictionary contains a start and end of the uniprot <--> PDB. It does not however, say where the missing density residues are. But in deposited structures the PDB numbering skips where these residues ought to be... So might not be an important problem.
  Another database of interest is SIFTS.
  To make a multiple sequence alignment of a non-deposited PDB, you need to extract the sequence and do the alignment here is a snippet using pymol module (from conda):
  import pymol2
  
  pdbfile = '' #your pdb file name..
  selector = 'chain A' # or whatever chain you want
  with pymol2.PyMOL() as pymol:
      pymol.cmd.load(pdbfile)
      fasta = pymol.cmd.get_fastastr(selector)
  
  seq = ''.join(fasta.replace('?','').split('\n')[1:]) # remove header and non AA residues
  
  Biopython has a dozen sequence alignment tools. But the original one still works fine
  from Bio import pairwise2
  from Bio.Seq import Seq
  
  alignment = pairwise2.align.globalxx(''.join(seq).replace('?',''), "ACQQG")[0]
  
  alignments is a tuple of the MSA sequences.
  If you want to do the latter without coding. Extract the sequence from the PDB using PyMOL the normal application and load the pdb and then print cmd.get_fastastr('chain A') in the command line part of the GUI. Copy this. Go to Muscle or other onliner aligner and align!
  
original_text: 9344: <p>The residue numbering in PDB (in my understanding) coincides with UniProtKB align. However, this might not be consistent with that in PDB fasta file. To complicate it further, UniProtKB align can be a few mutations away from the PDB sequence. Disordered/unidentified residues in structures also create gaps in numbering.</p>
  <p>Is there a way/suggestion to create a matched residue numbering between sequence and structure? For example</p>
  <pre><code>12345678 (residue numbering)
  ATPWQMSQ (sequence)
  ---W-MSQ (PDB residues) &quot;-&quot; for missing residue in structure
  </code></pre>
   6322: <p>Unfortunately, PDB numbering can be one of different schemes. The main three:</p>
  <ul>
  <li>Uniprot numbering (canonical isoform)</li>
  <li>Construct numbering with or without tag removal</li>
  <li>Start from 1 for what has density</li>
  </ul>
  <p>However, the are many many corner cases. In Proteopedia there is <a href="https://proteopedia.org/wiki/index.php/Unusual_sequence_numbering" rel="nofollow noreferrer">a lovely article about weird PDB numbering</a>.</p>
  <p>The best way to find the details about what part of the sequence is covered is to use the <a href="https://swissmodel.expasy.org/docs/smr_openapi" rel="nofollow noreferrer">Swissmodel API</a>. It's actually better than either the PDBe and RCSB PDB APIs. Swissmodel is a homology modelling service that maintains close threaded models (&gt;30% ID), but also has PDB data. Here is a Python3 method I use, (<code>provider='pdb'</code>) is what is required here).</p>
  <pre><code>def get_data(uniprot: str, provider='swissmodel') -&gt; List[dict]:
          &quot;&quot;&quot;
          Gets data from Swissmodel. Convert each entry with convert_SM_entry
          &quot;&quot;&quot;
      assert provider in ('swissmodel', 'pdb'), 'Provider has to be swissmodel or pdb'
          url = f'https://swissmodel.expasy.org/repository/uniprot/{uniprot.strip()}.json?provider={provider.strip()}'
          data = requests.get(url).json()
          return data['result']['structures']  # [0] # from to coordinates description
  </code></pre>
  <p>The returned dictionary contains a start and end of the uniprot &lt;--&gt; PDB. It does not however, say where the missing density residues are. But in <em>deposited</em> structures the PDB numbering skips where these residues ought to be... So might not be an important problem.</p>
  <p>Another database of interest is <a href="https://www.ebi.ac.uk/pdbe/docs/sifts/" rel="nofollow noreferrer">SIFTS</a>.</p>
  <p>To make a multiple sequence alignment of a non-deposited PDB, you need to extract the sequence and do the alignment here is a snippet using <a href="https://anaconda.org/schrodinger/pymol" rel="nofollow noreferrer">pymol module (from conda)</a>:</p>
  <pre><code>import pymol2
  
  pdbfile = '' #your pdb file name..
  selector = 'chain A' # or whatever chain you want
  with pymol2.PyMOL() as pymol:
      pymol.cmd.load(pdbfile)
      fasta = pymol.cmd.get_fastastr(selector)
  
  seq = ''.join(fasta.replace('?','').split('\n')[1:]) # remove header and non AA residues
  </code></pre>
  <p>Biopython has a dozen sequence alignment tools. But the original one still works fine</p>
  <pre><code>from Bio import pairwise2
  from Bio.Seq import Seq
  
  alignment = pairwise2.align.globalxx(''.join(seq).replace('?',''), &quot;ACQQG&quot;)[0]
  </code></pre>
  <p><code>alignments</code> is a tuple of the MSA sequences.</p>
  <p>If you want to do the latter without coding. Extract the sequence from the PDB using PyMOL the normal application and load the pdb and then <code>print cmd.get_fastastr('chain A')</code> in the command line part of the GUI. Copy this. Go to <a href="https://www.ebi.ac.uk/Tools/msa/muscle/" rel="nofollow noreferrer">Muscle</a> or other onliner aligner and align!</p>
  