I need to read a sequence and convert it t0 numerical text
조회 수: 1 (최근 30일)
이전 댓글 표시
Can any body help me to find a solution.My objective is to convert a dna sequence into numerical form ie A with 1, C with 2, T with 3 and G with 4.hcv is a structure having two fields header and sequence. when i tried to display it is not showing any ouput, no errors.the code is given below.Eg of sequence ACTTTGGCTT.........
s1='A';s2='C';s3='T';s4='G';
n=10;%%%%%%%%number of sequences%%%%%%
hcv = fastaread('hcv1.fas','IgnoreGaps',true);
hcvnum=hcv;
for i=1:n
len(i) = cellfun(@length, {hcv(i).Sequence});
for j=1:len(i)
if strcmp(hcv(i).Sequence(j),s1)
hcvnum(i).Sequence(j)=1;
elseif strcmp(hcv(i).Sequence(j),s2)
hcvnum(i).Sequence(j)=2;
elseif strcmp(hcv(i).Sequence(j),s3)
hcvnum(i).Sequence(j)=3;
else
strcmp(hcv(i).Sequence(j),s4)
hcvnum(i).Sequence(j)=4;
end
end
end
댓글 수: 0
채택된 답변
Walter Roberson
2011년 11월 18일
for j=1:len(i)
[tf, idx] = ismember(hcv(i).Sequence(j), {s1,s2,s3,s4});
if tf; hcvnum(i).Sequence(j) = idx; end
%if tf is false then it was some other character
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!