Repository navigation
Pdb residue string - #3676
Pdb residue string#3676rob-miller wants to merge 5 commits into
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3676 +/- ##
==============================
==============================
☔ View full report in Codecov by Sentry. |
|
This makes the code in FWIW, I just created #3679 and was toying with the idea of breaking down the code in more functions, for easier test coverage, so this would play along those lines. |
|
I ran into issues trying to output and color (in a PDB viewer) arbitrary
sets of residues from multiple PDB files, preferably in a simple way to put
in a tutorial. It seems like the existing selector method requires a bunch
of code to do this and processes the chain for every residue, when what I
really want is to re-use the lines already inside PDBIO.
With the current system to write a single residue I think I need two lines,
one to change the chain ID followed by a PDBIO.save() with a trivial
selector to catch the target residue. Inside PDBIO.save() every time
though we open/close a file and spin through the chain just to find the
one/few target residues. For flexibility on the user side I use
io.StringIO to collect the file writes back into strings because as I'm
processing the chain I've not decided that I want to write out this
residue, or maybe I want it after another residue later in the file, or
really I just want to send the data to stdout so I can pipe it into
something else. Doing things correctly I probably want to save/restore the
chain ID back to original state so I can re-use this code later. After all
this PDB viewer Chimera complains that all my atom serial numbers are
messed up (always start with 1 for every save(), or use
preserve_atom_numbering and that will mess up across structures collected
in same file), and my TER lines don't have any data fields (not that I care
too much).
So the idea was just to pull out the PDBIO residue lines to an accessible
subroutine, but that insidious TER line complicates things because you
can't know when it will be needed. I tried just storing the data for the
TER string in self, but this was slower in my tests.
I do agree it makes PDBIO more convoluted, but on the user side this way I
Initialize PDBIO's self.atom_number once and then freely mix/match
set_structure()s and residue and/or TER strings as desired - and the serial
numbers are all correct at the end too.
[Just to reiterate from the sample file above, all of this is only useful
for working with structurally aligned pieces so we're not just spitting out
residues randomly all over 3D space.]
Happy to merge in with your error message improvements if you like, and
happy to see it got you apparently catching up on some PDBIO work :-).
…On Sun, Aug 1, 2021 at 1:28 AM João Rodrigues ***@***.***> wrote:
This makes the code in PDBIO a little more convoluted than it needs to
be, in my opinion. Could you change the chains of the residues themselves
instead before writing? What exactly would be the use case here? Trying to
see if the change is worth it.
FWIW, I just created #3679
<#3679> and was toying with
the idea of breaking down the code in more functions, for easier test
coverage, so this would play along those lines.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3676 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZW3QCUKZ76A7VCA5CYPJ3T2TLORANCNFSM5BJAJBCQ>
.
|
|
Catching up indeed :) The TER statement is something we can try to improve. Some tools write "naked" TER statements (simply TER), while others output a little more info. Most tools I know of don't actually read the info on the TER statement. I like the idea of refactoring PDBIO to make it a little more modular. That's what I had in mind too when I looked at it yesterday. Would make it much simpler to unit test as well, as opposed to the current style of more like "integration" tests. Having said that, the records are pretty much written atom by atom (line by line), so bundling them would be annoying. We'd have to reverse the parser process in order to be robust, when writing is a much simpler aspect. Can you post a sample of what you are trying to do? I have the feeling there's a simpler solution here. |
|
On Sun, 1 Aug 2021 at 19:57, João Rodrigues ***@***.***> wrote:
Can you post a sample of what you are trying to do? I have the feeling
there's a simpler solution here.
Just quickly on this part, have you looked at the pdb file attached to the
first post on this PR? You might have to go on GitHub, don't think it came
with the emails.
—
… You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3676 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZW3QF6T4WFKCFJXT2SI2DT2XNOVANCNFSM5BJAJBCQ>
.
|
lennax fixed Biopython's TER records in 7e185d8, but as you say I'd never noticed the other fields. Nonetheless it does seem like we should do the right thing, and I can't seem to load the redmine.open-bio.org link from that previous commit to see if that explains why it was an issue.
I do think it is useful to bundle the atoms together as residues, and initially just had this as a convenience function inside my current internal_coords.py -- but assumed this would be criticized for code duplication. I would like to replace the similar _pdb_atom_string in the Biopython internal_coords.py if we changed PDBIO's version to be public.
Sorry, just noticed I had re-sequenced parts of my code before generating the previous sample and broke the serial numbers again. Here's three more views on the same data since I'm playing with them: phe-pair-groups.pdb.gz Again, they are all intended to be color-by-chain in your structure viewer of choice, and this time have the serial numbers correct throughout. I don't think you can actually generate these with the current PDBIO short of creating a new (SM)CRA object, and with that you would lose the ability to annotate different residues in the file as these examples do (another advantage of exposing this part of PDBIO as a subroutine). |
|
Cross reference PR #989, to fix redmine 2292 https://redmine.open-bio.org/issues/2292 - from my emails:
(with a patch which I think is what Lenna committed) |
f148ac5 to
f9fb2ca
Compare
|
updated to incorporate #3679 |
f9fb2ca to
222fedd
Compare
e23033c to
4baba03
Compare
|
updated to incorporate #3882 @JoaoRodrigues I am still keen to get this in :-) I want/need the ability to write arbitrary PDB residues with control over chain ID and atom numbering in order to study pairwise residue interactions like: I support doing this in #3774 and describe it in #3898. I've implemented this functionality ( The implementation suggested here for PDBIO is much better than what I've done in internal_coords, and I would very much like to remove this code from internal_coords in time for a 1.80 release. Abusing PDB files is an old and venerable technique, and the kind of thing I feel Biopython really should support! |
4baba03 to
1955998
Compare
|
Some explanation on the image above and why it needs this PR: The image shows 3 pairs of PHE residues from PDB structure 3PBL (Human dopamine D3 receptor), selected as putatively interacting on the basis that their C-alphas are within 6 angstroms of each other (there are much better and more stringent tests in the literature). The N-Ca-C atoms (hedra) of the first residue in each pair (197-201, 345-346, and 390-394) are aligned using Chi1 transformation matrices exposed by the internal_coords module. The attached PDB format file presents these pairs for analysis in PDB viewer software, as used to make the screenshot shown. The key characteristics that I don't think are possible (at least without a lot more work) without this PR are:
Clearly the generated PDB file is not a 'structure', and various viewers will handle the issues this addresses differently. The goal is to generate data that can be interactively selected, inspected and analysed with the minimum of noise - whether that's warnings and complaints or extraneous bonds. |
1955998 to
6ff1cf0
Compare
6ff1cf0 to
2a4250e
Compare
|
My reasons for wanting this merged:
|
2a4250e to
05a1fce
Compare
|
Could you take a fresh look at this @JoaoRodrigues? Or maybe @etal or @lennax? |
|
Will do today.
… Message ID: ***@***.***>
|
05a1fce to
aac0e31
Compare
|
Update for 1.84 |

I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile, have runpre-commitlocally,and understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
tests and style checks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)
This patch exposes functionality in PDBIO to generate a string for a single residue in PDB or PQR format. The primary new functionality over the 'selector' mechanism is that residues can be generated with arbitrary chain IDs. Relevant test code is added.
Less significant features are accessing as a string instead of e.g. using io.StringIO, documenting the preserve_atom_numbering parameter, addressing #1383, and minor cleanup of the PDBIO tests.
This functionality enables generating non-standard 'PDB' files like the attached for investigating residue sidechain interactions. (suggest 'color by chain' if you load this into a viewer; each 'chain' is a group of potentially interacting PHE residues, with one member of each group superimposed on the N-CA-CB plane.)
phe-pair.pdb.gz
With respect to #1383, the discussion appears to have stopped with the question of 'what to do if preserve_atom_numbering=True'. I submit that this is not the default case, so (1) we should do the correct TER numbering in the default case, (2) for the non-default user this solution is correct for exporting correctly numbered (accounting for TER) input data, and (3) I think this exposes enough functionality for the non-default user to generate their desired output in the remaining cases.
With respect to the PDBIO tests, I believe that the
write_auto_numberingandwrite_preserve_numberingtest labels are currently swapped, and this fixes that as well.