Clear Filters
Clear Filters

Find isn't getting the right index it says: "Error using > Matrix dimensions must agree."

1 view (last 30 days)
How do I change the find to get the right index in the program that finds stop and start codons to get the longest reading frame?
function [ptn]=seq_transcribe2(x)
y=seq_transcribe1(x);
frames={};
frames={x(1:end) x(2:end) x(3:end) y(1:end) y(2:end) y(3:end)};
starts=[];
stops=[];
allorfs={};
for i=1:3:numel(frames)-2
for j=1:numel(frames)
codon= frames{j}([i i+1 i+2])
if strcmp(codon,'ATG')
starts= [starts codon];
end
if strcmp(codon,'TAA') | strcmp(codon,'TAG') | strcmp(codon,'TGA')
stops = [stops codon];
end
end
end
stops= find(stops>starts,1)
lengthofthisstart=stops-starts
allorfs{end+1}=frames(starts:stops-1)
map=geneticcode;
names=fieldnames(map);
ptn={};
% for i=1:numel(codon)
% ptn{end+1}=map.(codon{i})
% end
% ptn=char(ptn)';

Accepted Answer

Walter Roberson
Walter Roberson on 16 Jan 2017
It is not self-obvious from the code that the number of starts and the number of stops must be equal. Also, your starts and stops contain the condon characters themselves, not the positions, and all of your stop codons are alphabetically after your start codon so provided that stops and starts are non-empty, the find is going to return position 1.
By the way, you can write
if strcmp(codon,'TAA') | strcmp(codon,'TAG') | strcmp(codon,'TGA')
as
if ismember(codon, {'TAA', 'TAG', 'TGA'})
I wonder whether you could replace the loops entirely with some strfind() such as
strfind(frames{j}, 'ATG')
and
sort( [strfind(frames{j}, 'TAA'), strfind(frames{j}, 'TAG'), stfind(frames{j}, 'TGA')] )

More Answers (0)

Categories

Find more on Genomics and Next Generation Sequencing 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!