Find a specific characters in a string
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Miriam Contreras Castillo
el 25 de Nov. de 2022
Hello, I am trying to I get certain amino acids from my sequence, however, my output only gives that there are 3 of the amino acids I am looking for but I want it to tell me the amino acid name and create a new string.
I would also want my code to run other larger sequences if need be.
I am not sure if a swich case was the best approach to do this task. Can someone please help me, thank you!
aminoacids = 'MetArgGlyLeuAspTrpAspGlyAsn'
for d = 1:3:(length(aminoacids)-2)
rgroup = aminoacids(d:(d+2));
switch (rgroup)
case {'Arg', 'Asp', 'Cys', 'Glu','Lys','Tyr'}
disp(aminoacids)
end
end
0 comentarios
Respuesta aceptada
Stephen23
el 25 de Nov. de 2022
C = {'Arg', 'Asp', 'Cys', 'Glu','Lys','Tyr'};
T = 'MetArgGlyLeuAspTrpAspGlyAsn';
R = join(string(C),'|');
A = regexp(T,R,'match')
4 comentarios
Miriam Contreras Castillo
el 26 de Nov. de 2022
Editada: Miriam Contreras Castillo
el 26 de Nov. de 2022
Más respuestas (1)
Paul
el 26 de Nov. de 2022
Editada: Paul
el 26 de Nov. de 2022
Hi Miriam
I'm not quite sure what you're looking for. However, transforming everything to strings might offer a path forward via standard Matlab functions and indexing. For example
aminoacids = 'MetArgGlyLeuAspTrpAspGlyAsn';
C = string({'Arg', 'Asp', 'Cys', 'Glu','Lys','Tyr'})
S = string(reshape(aminoacids,3,[]).')
Find all the acids in S that are present in C
S(ismember(S,C))
0 comentarios
Ver también
Categorías
Más información sobre Protein and Amino Acid Sequence Analysis en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!