Counting the number of occurrence of a particolar letter in a string iteratively with a moving window like process
조회 수: 1 (최근 30일)
이전 댓글 표시
HI! I have this kind of problem:
STR='AAAQQQPPPTTTCCCPPAAANNNDDDAAATTPPPPNNNAAA'
%Random Amino acidic sequence
Having this kind of sequence I want to count the number of occurrences that I would find using a sliding window process.
Like I give you my window's length and slinding this i get for each iteration a new pattern of aa where i count a new number of a particular residue. In my particular problem I have a cellarray containing 5000 and more sequences so I would prefer to avoid a double for loop. Anyone knows some kind of function or itaration that can be usefull?
Thanks very much!
댓글 수: 2
Image Analyst
2018년 12월 4일
Don't worry about a few thousand iterations - it will be very very fast.
So you want some kind of histogram (count) of the letters at each window location as the window slides along? So you'd have thousands of histograms?
Have you tried reshape() to shape it into a 2-D matrix and then sum across the matrix?
답변 (2개)
Bio_Ing_Sapienza
2018년 12월 4일
댓글 수: 1
Image Analyst
2018년 12월 4일
movmean() slides over by one element. reshape() will let you, in effect, move in "jumps" of the window size. How much do you want the window to slide over each time?
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!