How to read and extract X Y Z coordinates of pdb file without using pdbstruct and pdbread but using file handling commands?
5 views (last 30 days)
Show older comments
pdb='C:\Users\Priya\Documents\MATLAB\1ubq.pdb'
fileID=fopen(pdb)
x = fileread('C:\Users\Priya\Documents\MATLAB\1ubq.pdb');
x.Model.Atom(:).AtomName;
x.Model.Atom(:).X
x.Model.Atom(:).Y
x.Model.Atom(:).Z
pos = find(strcmp({x.Model.Atom(:).AtomName},'CA'));
X=[x.Model.Atom(pos).X];
Y=[x.Model.Atom(pos).Y];
Z=[x.Model.Atom(pos).Z];
2 Comments
Walter Roberson
on 1 May 2019
Why? What is the restriction against using pdbstruct() or pdbread() ? The reason why you have been forbidden to use those will inform the answers we give. For example is the reason just that you do not have the Biosystems Toolbox ?
Walter Roberson
on 1 May 2019
describes the PDB file format.
Answers (5)
Walter Roberson
on 1 May 2019
S = fileread(pdb);
info = regexp(S, '(?<=^ATOM.{27})(?<X>.{8})(?<Y>.{8})(?<Z>.{8})', 'names', 'lineanchors');
If all went well, then info is now a struct array with fields X, Y, and Z, giving the coordinates of each atom as character vectors. struct2cell() and str2double() should then produce numeric arrays.
8 Comments
Walter Roberson
on 2 May 2019
Two-coordinate form:
acos(dot([x2-x1, y2-y2, z2-z1]) ./ sqrt(sum([x2-x1, y2-y1, z2-z1].^2)))
However when you do this, you are implicitly creating a vector between the coordinates and the origin (0,0,0) . The angle you would get out would change if you were to rotate the structure in 3-space.
Unless you choose a coordinate such as (0,0,0) as your implicit starting point, two points in 3-space form a line, not an angle.
priyanka ilango
on 1 May 2019
1 Comment
Walter Roberson
on 1 May 2019
Are the calpha atoms the ones with atom name 'C' and "alternate location" 'A", and which therefore appear to have atom name 'CA' ?
You need at least three points to create an angle, and I do know that what you would be taking the angle relative to.
priyanka ilango
on 1 May 2019
1 Comment
Walter Roberson
on 1 May 2019
Please click on "Comment on this Answer" to respond to things, instead of creating new Answer each time. Answer are intended for substantial steps towards solutions to the original question, not for back and forth dialog.
See Also
Categories
Find more on Data Type Conversion 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!