text: user180: I have a pdb file of a protein structure, and I would like to programmatically select certain peptides and label them in an annotated pdb file output, so that when the output pdb file is opened again by one of the 3D viewers, one can highlight the annotated peptides.
  I can do this interactively using UCSF Chimera or https://www.rcsb.org/3d-view,
  and with Chimera, I can even save a session which is a python file that contains the lines of my manual annotations as lists of coordinates.
  whereas in RCSB, saving a session produces a molx compressed file that includes hashes such as this one, where myseq is defined by a range within the file:
                {
                  "parent": "yNaD8QxiUNHaHCvxrC5rew",
                  "transformer": "ms-plugin.structure-component",
                  "params": {
                    "type": {
                      "name": "bundle",
                      "params": {
                        "hash": 1673297064,
                        "elements": [
                          {
                            "groupedUnits": [
                              [
                                0
                              ]
                            ],
                            "set": [],
                            "ranges": [
                              1669,
                              1777
                            ]
                          }
                        ]
                      }
                    },
                    "nullIfEmpty": true,
                    "label": "myseq2"
                  },
  
  So I want to do the same programmatically, e.g.:
  annotate_sequences --input file.pdb --sequences 1:ARNDC,2:CDNRA,foo:VYWTSP 
  
  I expect an output file where these three peptides are annotated with the labels 1, 2, and foo, so when someone opens the file in a 3D structure viewer, then can select/deselect the annotations.
  Any ideas on how to do this?
  
  user6322: There is no consensus on how different programs do representations (example of NGL vs. PyMOL) or what they are called so there is not official way to store selections.
  Annotations can be REMARK lines, which have a specific format or simply lines after a hash at the bottom of the file get ignored by most viewers but that specific program may read. Here is a scored Rosetta PDB file for example:
  HEADER                                            14-JUN-21   XXXX              
  EXPDTA    THEORETICAL MODEL                                                     
  REMARK 220                                                                      
  REMARK 220 EXPERIMENTAL DETAILS                                                 
  REMARK 220  EXPERIMENT TYPE                : THEORETICAL MODELLING              
  REMARK 220  DATE OF DATA COLLECTION        : 14-JUN-21                          
  REMARK 220                                                                      
  REMARK 220 REMARK: MODEL GENERATED BY ROSETTA                                   
  REMARK 220  VERSION 2020.49+release.fac69dd    
  ATOM      1  N   MET A   1     107.793 134.398   6.022  1.00  0.00           N  
  ATOM      2  CA  MET A   1     108.468 134.162   7.299  1.00  0.00           C  
  ATOM      3  C   MET A   1     108.644 135.405   8.219  1.00  0.00           C  
  ATOM      4  O   MET A   1     108.050 135.416   9.303  1.00  0.00           O  
  ATOM      5  CB  MET A   1     109.782 133.398   7.080  1.00  0.00           C  
  ATOM      6  CG  MET A   1     110.650 133.262   8.335  1.00  0.00           C  
  ATOM      7  SD  MET A   1     112.224 132.454   8.016  1.00  0.00           S  
  ...
  # All scores below are weighted scores, not raw scores.
  #BEGIN_POSE_ENERGIES_TABLE 
  label fa_atr fa_rep fa_sol fa_intra_rep fa_intra_sol_xover4 lk_ball_wtd fa_elec pro_close hbond_sr_bb hbond_lr_bb hbond_bb_sc hbond_sc dslf_fa13 omega fa_dun p_aa_pp yhh_planarity ref rama_prepro total
  weights 1 0.55 1 0.005 1 1 1 1.25 1 1 1 1 1.25 0.4 0.7 0.6 0.625 1 0.45 NA
  pose -17624.7 2135.24 10828.2 38.8161 591.762 -521.596 -5634.4 9.63107 -1337.76 -585.258 -616.219 -453.443 0 197.59 3291.97 -602.3 2.74143 1088.19 99.1601 -9092.4
  MET:NtermProteinFull_1 -2.63316 0.99093 2.70981 0.01206 0.04738 -0.17936 0.08728 0.00151 0 0 0 0 0 0.35192 1.9909 0 0 1.65735 0 5.0366
                   
  
  Hacked b-factors
  Another way is to store numerical data as b-factors. The AlphaFold2 data for example stores pLDDT in the b-factor column, while consurf stores conservation score there. So a boolean 1=show, 0=hide could be done for example, which would allow one to select these, e.g. in PyMOL:
  # store chosen selection...
  alter chosen, "b=1"
  sort
  save foo.pdb
  
  # load it back...
  select chosen, b<0
  
  Although this makes no sense as one can save a session file...
  Also note, that for multiple selections, you'd need create different models, but whatever happens the other non-coordinate column, occupancy, should not be touched.
  Sharing
  If the problem is that you want to share a protein with someone and want to let the recipient know about features of interest but are using different software than you, you may want to consider Michelanglo, a website I wrote that allows one to share a webpage with an interactive protein viewer (using NGL.js, hence the name) and a side description with custom annotations that control the protein representation (example).
  
original_text: 180: <p>I have a pdb file of a protein structure, and I would like to programmatically select certain peptides and label them in an annotated pdb file output, so that when the output pdb file is opened again by one of the 3D viewers, one can highlight the annotated peptides.</p>
  <p>I can do this interactively using UCSF Chimera or <a href="https://www.rcsb.org/3d-view" rel="nofollow noreferrer">https://www.rcsb.org/3d-view</a>,</p>
  <p>and with Chimera, I can even save a session which is a python file that contains the lines of my manual annotations as lists of coordinates.</p>
  <p>whereas in RCSB, saving a session produces a molx compressed file that includes hashes such as this one, where <code>myseq</code> is defined by a range within the file:</p>
  <pre><code>              {
                  &quot;parent&quot;: &quot;yNaD8QxiUNHaHCvxrC5rew&quot;,
                  &quot;transformer&quot;: &quot;ms-plugin.structure-component&quot;,
                  &quot;params&quot;: {
                    &quot;type&quot;: {
                      &quot;name&quot;: &quot;bundle&quot;,
                      &quot;params&quot;: {
                        &quot;hash&quot;: 1673297064,
                        &quot;elements&quot;: [
                          {
                            &quot;groupedUnits&quot;: [
                              [
                                0
                              ]
                            ],
                            &quot;set&quot;: [],
                            &quot;ranges&quot;: [
                              1669,
                              1777
                            ]
                          }
                        ]
                      }
                    },
                    &quot;nullIfEmpty&quot;: true,
                    &quot;label&quot;: &quot;myseq2&quot;
                  },
  </code></pre>
  <p>So I want to do the same programmatically, e.g.:</p>
  <pre><code>annotate_sequences --input file.pdb --sequences 1:ARNDC,2:CDNRA,foo:VYWTSP 
  </code></pre>
  <p>I expect an output file where these three peptides are annotated with the labels <code>1</code>, <code>2</code>, and <code>foo</code>, so when someone opens the file in a 3D structure viewer, then can select/deselect the annotations.</p>
  <p>Any ideas on how to do this?</p>
   6322: <p>There is no consensus on how different programs do representations (<a href="https://github.com/matteoferla/MichelaNGLo-transpiler/blob/master/docs/conversion.md" rel="nofollow noreferrer">example of NGL vs. PyMOL</a>) or what they are called so there is not official way to store selections.</p>
  <p>Annotations can be <code>REMARK</code> lines, which have a <a href="https://www.wwpdb.org/documentation/file-format-content/format33/remarks1.html" rel="nofollow noreferrer">specific format</a> or simply lines after a hash at the bottom of the file get ignored by most viewers but that specific program may read. Here is a scored Rosetta PDB file for example:</p>
  <pre><code>HEADER                                            14-JUN-21   XXXX              
  EXPDTA    THEORETICAL MODEL                                                     
  REMARK 220                                                                      
  REMARK 220 EXPERIMENTAL DETAILS                                                 
  REMARK 220  EXPERIMENT TYPE                : THEORETICAL MODELLING              
  REMARK 220  DATE OF DATA COLLECTION        : 14-JUN-21                          
  REMARK 220                                                                      
  REMARK 220 REMARK: MODEL GENERATED BY ROSETTA                                   
  REMARK 220  VERSION 2020.49+release.fac69dd    
  ATOM      1  N   MET A   1     107.793 134.398   6.022  1.00  0.00           N  
  ATOM      2  CA  MET A   1     108.468 134.162   7.299  1.00  0.00           C  
  ATOM      3  C   MET A   1     108.644 135.405   8.219  1.00  0.00           C  
  ATOM      4  O   MET A   1     108.050 135.416   9.303  1.00  0.00           O  
  ATOM      5  CB  MET A   1     109.782 133.398   7.080  1.00  0.00           C  
  ATOM      6  CG  MET A   1     110.650 133.262   8.335  1.00  0.00           C  
  ATOM      7  SD  MET A   1     112.224 132.454   8.016  1.00  0.00           S  
  ...
  # All scores below are weighted scores, not raw scores.
  #BEGIN_POSE_ENERGIES_TABLE 
  label fa_atr fa_rep fa_sol fa_intra_rep fa_intra_sol_xover4 lk_ball_wtd fa_elec pro_close hbond_sr_bb hbond_lr_bb hbond_bb_sc hbond_sc dslf_fa13 omega fa_dun p_aa_pp yhh_planarity ref rama_prepro total
  weights 1 0.55 1 0.005 1 1 1 1.25 1 1 1 1 1.25 0.4 0.7 0.6 0.625 1 0.45 NA
  pose -17624.7 2135.24 10828.2 38.8161 591.762 -521.596 -5634.4 9.63107 -1337.76 -585.258 -616.219 -453.443 0 197.59 3291.97 -602.3 2.74143 1088.19 99.1601 -9092.4
  MET:NtermProteinFull_1 -2.63316 0.99093 2.70981 0.01206 0.04738 -0.17936 0.08728 0.00151 0 0 0 0 0 0.35192 1.9909 0 0 1.65735 0 5.0366
                   
  </code></pre>
  <h3 id="hacked-b-factors-2yn8">Hacked b-factors</h3>
  <p>Another way is to store numerical data as b-factors. The AlphaFold2 data for example stores pLDDT in the b-factor column, while consurf stores conservation score there. So a boolean 1=show, 0=hide could be done for example, which would allow one to select these, e.g. in PyMOL:</p>
  <pre><code># store chosen selection...
  alter chosen, &quot;b=1&quot;
  sort
  save foo.pdb
  
  # load it back...
  select chosen, b&lt;0
  </code></pre>
  <p>Although this makes no sense as one can save a session file...
  Also note, that for multiple selections, you'd need create different models, but whatever happens the other non-coordinate column, occupancy, should not be touched.</p>
  <h3 id="sharing-buuz">Sharing</h3>
  <p>If the problem is that you want to share a protein with someone and want to let the recipient know about features of interest but are using different software than you, you may want to consider <a href="https://michelanglo.sgc.ox.ac.uk" rel="nofollow noreferrer">Michelanglo</a>, a website I wrote that allows one to share a webpage with an interactive protein viewer (using NGL.js, hence the name) and a side description with custom annotations that control the protein representation (<a href="https://michelanglo.sgc.ox.ac.uk/r/basics" rel="nofollow noreferrer">example</a>).</p>
  