I am trying to assign a pattern of alphabets to a sequence of alphabets that I have.
1 次查看(过去 30 天)
显示 更早的评论
seq_file = fopen('insulinDNAseq.txt');
template5_3 = fscanf(seq_file,'%s');
seq_len = length(template5_3);
template3_5 = [flip(template5_3)];
A = {'a' 't'
'c' 'g'
'g' 'c'
't' 'a'};
I am supposed to modify the code below in order to get a stand of alphabets of a,c,g,t. On the process above, I import a document of a sequence of alphabets and flip it front a back. I need to modify the code below in order to assign a new alphabet and come up with a new strand according to the pattern A shown above. I am attaching the text file with the question.
for i = 1:seq_len
template_base = template3_5(i); % pull the ith base of the template strand
row_A = strcmp(template_base,A(:,1)); % identify the row in matrix A corresponding to templateBase; note that the variable row_A is a boolean vector
% Define the base added to the synthesized strand using matrix 'A' and
% vector 'row_A'
synth_base = [row_A];
% Store synth_base in the ith element of your storage vector. You'll
% need to use the command 'char' to store the character properly.
[];
end
0 个评论
回答(2 个)
VBBV
2024-2-19
编辑:VBBV
2024-2-19
seq_file = fopen('insulinDNAseq.txt');
template5_3 = fscanf(seq_file,'%s');
seq_len = length(template5_3);
template3_5 = [flip(template5_3)];
A = {'a' 't'
'c' 'g'
'g' 'c'
't' 'a'};
for i = 1:seq_len
for k = 1:size(A,2)
template_base = template3_5(i); % pull the ith base of the template strand
row_A = strcmp(template_base,A(:,k)); % identify the row in matrix A corresponding to templateBase; note that the variable row_A is a boolean vector
% Define the base added to the synthesized strand using matrix 'A' and
% vector 'row_A'
synth_base{i} = A{[row_A]};
% Store synth_base in the ith element of your storage vector. You'll
% need to use the command 'char' to store the character properly.
[];
end
end
synth_base{:}
2 个评论
VBBV
2024-2-19
seq_file = fopen('insulinDNAseq.txt');
template5_3 = fscanf(seq_file,'%s');
seq_len = length(template5_3);
template3_5 = [flip(template5_3)];
A = {'a' 't'
'c' 'g'
'g' 'c'
't' 'a'};
for i = 1:seq_len
for k = 1:size(A,2)
template_base = template3_5(i); % pull the ith base of the template strand
row_A = strcmp(template_base,A(:,k)); % identify the row in matrix A corresponding to templateBase; note that the variable row_A is a boolean vector
% Define the base added to the synthesized strand using matrix 'A' and
% vector 'row_A'
synth_base(i) = A{[row_A]};
% Store synth_base in the ith element of your storage vector. You'll
% need to use the command 'char' to store the character properly.
[];
end
end
disp(synth_base) %
Voss
2024-2-19
seq_file = fopen('insulinDNAseq.txt');
template5_3 = fscanf(seq_file,'%s');
fclose(seq_file); % close the file when you're done reading it!!!
template3_5 = flip(template5_3);
A = {'a' 't'
'c' 'g'
'g' 'c'
't' 'a'};
[ism,idx] = ismember(template3_5,[A{:,1}]);
assert(all(ism),'Not all characters are a, c, g, or t')
synth_base = [A{idx,2}];
disp(synth_base)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!