Borrar filtros
Borrar filtros

Index in position 2 exceeds array bounds

1 visualización (últimos 30 días)
Masha
Masha el 16 de Mzo. de 2023
Comentada: Masha el 16 de Mzo. de 2023
I am trying to find the centre of mass of (sidechain of) tyrosine residues in a protein. I extracted the coordinates and then found the mass of the atoms in the following code. But while trying to find the X coordinate of centre of mass, I had this error show up
% Starting from pdb file
uxc = getpdb('1UXC');
No_of_residues = uxc.Sequence.NumOfResidues
No_of_residues = 65
isTYR = ({uxc.Model.Atom.resName} == "TYR");
uxcTYR = uxc.Model.Atom(isTYR) % Extracts particulars of only TYR
uxcTYR = 1×63 struct array with fields:
AtomSerNo AtomName altLoc resName chainID resSeq iCode X Y Z occupancy tempFactor segID element charge AtomNameStruct
%Extracting sidechain coordinates:
uxcTYRt = struct2table(uxcTYR)
uxcTYRt = 63×16 table
AtomSerNo AtomName altLoc resName chainID resSeq iCode X Y Z occupancy tempFactor segID element charge AtomNameStruct _________ ________ __________ _______ _______ ______ __________ ______ ______ ______ _________ __________ ________ _______ ______ ______________ 277 {'N' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 0.363 -2.991 -2.5 1 4.78 {' '} {'N'} {' '} 1×1 struct 278 {'CA' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 0.582 -4.369 -1.965 1 4.8 {' '} {'C'} {' '} 1×1 struct 279 {'C' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} -0.04 -4.407 -0.575 1 2.45 {' '} {'C'} {' '} 1×1 struct 280 {'O' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} -0.797 -5.299 -0.238 1 2.8 {' '} {'O'} {' '} 1×1 struct 281 {'CB' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 2.085 -4.607 -1.81 1 5.31 {' '} {'C'} {' '} 1×1 struct 282 {'CG' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 2.817 -4.625 -3.14 1 4.9 {' '} {'C'} {' '} 1×1 struct 283 {'CD1'} {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 2.135 -4.505 -4.363 1 4.99 {' '} {'C'} {' '} 1×1 struct 284 {'CD2'} {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 4.208 -4.767 -3.146 1 5.42 {' '} {'C'} {' '} 1×1 struct 285 {'CE1'} {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 2.83 -4.527 -5.574 1 2.66 {' '} {'C'} {' '} 1×1 struct 286 {'CE2'} {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 4.906 -4.789 -4.358 1 2.93 {' '} {'C'} {' '} 1×1 struct 287 {'CZ' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 4.22 -4.669 -5.574 1 2.4 {' '} {'C'} {' '} 1×1 struct 288 {'OH' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 4.906 -4.693 -6.77 1 2.22 {' '} {'O'} {' '} 1×1 struct 289 {'H' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 1.161 -2.485 -2.762 1 0 {' '} {'H'} {' '} 1×1 struct 290 {'HA' } {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 0.151 -5.119 -2.608 1 0 {' '} {'H'} {' '} 1×1 struct 291 {'HB2'} {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 2.49 -3.839 -1.168 1 0 {' '} {'H'} {' '} 1×1 struct 292 {'HB3'} {0×0 char} {'TYR'} {'A'} 19 {0×0 char} 2.211 -5.547 -1.313 1 0 {' '} {'H'} {' '} 1×1 struct
atomName=string(uxcTYRt.AtomName); %converting the column AtomName to string array;
REQtyr=uxcTYRt(ismember(atomName,[ "CB","CG","CD1","CD2","CE1","CE2","CZ","OH","HB2","HB3","HD1","HD2","HE1","HE2"]),["AtomName" "resSeq" "X" "Y" "Z"])
REQtyr = 42×5 table
AtomName resSeq X Y Z ________ ______ _____ ______ ______ {'CB' } 19 2.085 -4.607 -1.81 {'CG' } 19 2.817 -4.625 -3.14 {'CD1'} 19 2.135 -4.505 -4.363 {'CD2'} 19 4.208 -4.767 -3.146 {'CE1'} 19 2.83 -4.527 -5.574 {'CE2'} 19 4.906 -4.789 -4.358 {'CZ' } 19 4.22 -4.669 -5.574 {'OH' } 19 4.906 -4.693 -6.77 {'HB2'} 19 2.49 -3.839 -1.168 {'HB3'} 19 2.211 -5.547 -1.313 {'HD1'} 19 1.061 -4.394 -4.371 {'HD2'} 19 4.743 -4.861 -2.212 {'HE1'} 19 2.29 -4.432 -6.505 {'HE2'} 19 5.979 -4.898 -4.354 {'CB' } 28 4.35 -8.133 -3.978 {'CG' } 28 2.99 -8.068 -4.646
Atom_mass = ["CB", 12.01;"CG", 12.01; "CD1",12.01; "CD2",12.01;"CE1", 12.01;"CE2", 12.01; "CZ", 12.01; "OH", 17.006; "HB2", 1.007; "HB3", 1.007; "HD1", 1.007;"HD2", 1.007; "HE1", 1.007; "HE2", 1.007];
DICTAtom_mass = dictionary(Atom_mass(:,1), Atom_mass(:,2));
sizeTyr = size(REQtyr);
numTyr = sizeTyr(1)/14; %number of tyrosine residues
resSeq = REQtyr.resSeq;
sizeresSeq = size(resSeq);
eresSeq = sizeresSeq(1);
% To extract XYZ coordinates of only the tyrosine residues.
uniq = unique(resSeq)
uniq = 3×1
19 28 47
for i = uniq(1,1):uniq(end,end)
Tyro1{i} = table2cell(REQtyr(ismember(resSeq,i),["AtomName","X","Y","Z"]));
Tyro{i} = table2struct(REQtyr(ismember(resSeq,i),["AtomName","X","Y","Z"]));
Tyroc{i} = [Tyro{i}.X;Tyro{i}.Y;Tyro{i}.Z];
Tyrocd{i} = Tyroc{i}';
end
% Finding out the mass of each and every atom in the sidechain of the
% tyrosine residue
for i = uniq(1,1):uniq(end,end)
Tyromas{i} = str2double(DICTAtom_mass(Tyro1{i}(:,1)));
Tyromass{i} = [Tyromas{i}];
end
%X coordinate:
for i= uniq(1,1):uniq(end,end)
TyrocdX{i} = (Tyromass{i}'*Tyrocd{i}(:,1))/sum(Tyromass{i})
end
TyrocdX = 1×19 cell array
{0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {[3.5566]}
Index in position 2 exceeds array bounds.

Respuesta aceptada

David Hill
David Hill el 16 de Mzo. de 2023
for i = 1:numel(uniq)
Tyro1{i} = table2cell(REQtyr(ismember(resSeq,uniq(i)),["AtomName","X","Y","Z"]));
Tyro{i} = table2struct(REQtyr(ismember(resSeq,uniq(i)),["AtomName","X","Y","Z"]));
Tyroc{i} = [Tyro{i}.X;Tyro{i}.Y;Tyro{i}.Z];
Tyrocd{i} = Tyroc{i}';
end
% Finding out the mass of each and every atom in the sidechain of the
% tyrosine residue
for i = 1:numel(uniq)
Tyromas{i} = str2double(DICTAtom_mass(Tyro1{i}(:,1)));
Tyromass{i} = [Tyromas{i}];
end
%X coordinate:
for i= 1:numel(uniq)
TyrocdX{i} = (Tyromass{i}'*Tyrocd{i}(:,1))/sum(Tyromass{i})
end
  4 comentarios
David Hill
David Hill el 16 de Mzo. de 2023
ismember(resSeq,uniq(i))
Masha
Masha el 16 de Mzo. de 2023
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by