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)
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];

Answers (5)

priyanka ilango
priyanka ilango on 1 May 2019
I am doing internship.My professor asked me to use file handling commands.After reading a file I have to extract coordinate and calculate angle between successive calpha atom.

Walter Roberson
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
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.

Sign in to comment.


priyanka ilango
priyanka ilango on 1 May 2019
Thank you so much.I got the coordinate values.How to calculate angle between successive calpha atoms from these values?
  1 Comment
Walter Roberson
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.

Sign in to comment.


priyanka ilango
priyanka ilango on 1 May 2019
CA is calpha atom of a protein.Here I extract coordinates values for all atoms.But I need to calculate angle for all calpha atom using these coordinate values.I am using 1UBQ protein.
  1 Comment
Walter Roberson
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.

Sign in to comment.


priyanka ilango
priyanka ilango on 3 May 2019
If there is a values in linear line like X= 27.567 24.789 45.879 27.568 26.897... upto 100 values How to extract or take particular values from this?

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!