pdbread function doesn't read individual models

6 views (last 30 days)
The matlab pdbread function (and a similar function from a toolbox with the same codebase) appears to never correctly execute the 'ModelNum' name-value argument. I've tried many multi-model .pdb files from RCSB and some i've made myself, and it will always throw a warning "Warning: PDB file does not contain Model 1. Reading the entire file.". This is despite pymol, chimera, and chimerax recognizing the separate models immediately. I'm at a loss as to how a PDB could ever lack a model 1 in the first place, because the same thing happens for single-model pdbs. Most amusingly, the output struct actually has the correct number of separate model records!
Anyone ever encountered this behavior? Is pdbread old enough to be buggy with changes to the pdb format?

Accepted Answer

Carson Purnell
Carson Purnell on 17 Jun 2022
Well I ended up needed to make my own pdb reader function for my purpose (generating density maps). Here's the function if anyone else wants specifically atom coordinates or the volume(s) itself many times faster than pdbread and no other pdb record information.

More Answers (1)

dmitry luchinskii
dmitry luchinskii on 8 Jul 2022
Edited: dmitry luchinskii on 8 Jul 2022
Most likely you need to modify the following lines (108-109 in version R2022b):
% modelMatch = ['^MODEL \s*' num2str(modelNum) '\s'];
% h = find(~cellfun(@isempty,regexp(theLines(modelStarts),modelMatch,'once')));
modelMatch = ['MODEL \s* ' num2str(modelNum)];
h = find(~cellfun(@isempty,regexp(theLines(modelStarts),modelMatch)));
I had the same error because "h" was empty. In turn, it was empty because "modelMatch" expression was wrong (specifically there was no "\s" (space) in the end of the 'MODEL' lines in my PDB files.
Writing your own file is fine but it will not be general.
Also to speed up calculations one can use extractfeild, e.g.
X=extractfield(PDBStruct.Model.Atom,'X');
And the original pdbread file can be very useful this way.

Categories

Find more on Partial Differential Equation Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!