mismatchstringkernel.m
来自「Proteins _ String Kernel」· M 代码 · 共 41 行
M
41 行
%Computes the string kernel for contiguous strings of length seqLength%between the strings in proteinStrings.%Arthur Grettonfunction [K_mismatch]=mismatchStringKernel(seqLength,proteinStrings);disp('Computing mismatch kernel...')totalStringNum =length(proteinStrings);sequenceFeatures = zeros(totalStringNum,26^seqLength); %rows are data pointsfor l=1:totalStringNum singleString = char(proteinStrings(l)); for m=1:length(singleString)-seqLength+1 %loop through substrings substring=singleString(m:m+seqLength-1); featureIndices = zeros(1,seqLength); %terms that sum to the feature index %of string "substring". for n=1:seqLength featureIndices(n) = featureIndices(n)+(substring(n)-'a')*26^(n-1); end %Generate all possible feature indices which result from the %perturbation of ONE entry in the starting string for n=1:seqLength featureIndexBase = 1+ sum(featureIndices([1:n-1 n+1:seqLength])); for p=0:25 featureIndex=featureIndexBase+p*26^(n-1); sequenceFeatures(l,featureIndex)=sequenceFeatures(l,featureIndex)+1; end end endl;endK_mismatch=sequenceFeatures*sequenceFeatures';
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?