⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 creongramconalfa.m

📁 base implementaion of the protein (starting from the amino acid sequence) feature extractor used in
💻 M
字号:
function Feat=CreoNgramConAlfa(Training,N,alfabeto)
%to implement a N-gram based feature extractor considering the
%alphabet "alfabeto"

if N==1
    tmp=1;
    for i=1:length(alfabeto)
        Tabella(tmp,1)=(i) ;
        tmp=tmp+1;
    end
    Tabella=single(Tabella);
    Feat=single(zeros(size(Training,2),length(alfabeto)^N));
    for i=1:size(Training,2)
        Tr=single(ConvertiAlfabeto(Training{i},alfabeto));
        for j=1:size(Tr,2)
            indice=find(Tabella(:,1)==Tr(j));
            Feat(i,indice)=Feat(i,indice)+1;
        end
        Feat(i,:)=Feat(i,:)./j;
    end

elseif N==2
    tmp=1;
    for i=1:length(alfabeto)
        for j=1:length(alfabeto)
            Tabella(tmp,1)=(i) ;
            Tabella(tmp,2)=(j) ;
            tmp=tmp+1;
        end
    end
    Tabella=single(Tabella);
    Feat=single(zeros(size(Training,2),length(alfabeto)^N));
    for i=1:size(Training,2)
        Tr=single(ConvertiAlfabeto(Training{i},alfabeto));
        Feat(i,:)=cicloVeloce2(Tr,Tabella,Feat(i,:));
        Feat(i,:)=Feat(i,:)./(size(Tr,2)-1);
    end
    
elseif N==3
    
    tmp=1;
    for i=1:length(alfabeto)
        for j=1:length(alfabeto)
            for ij=1:length(alfabeto)
                Tabella(tmp,1)=(i) ;
                Tabella(tmp,2)=(j) ;
                Tabella(tmp,3)=(ij) ;
                tmp=tmp+1;
            end
        end
    end
    Tabella=single(Tabella);
    Feat=single(zeros(size(Training,2),length(alfabeto)^N));
    for i=1:size(Training,2)
        Tr=single(ConvertiAlfabeto(Training{i},alfabeto));
        Feat(i,:)=cicloVeloce3(Tr,Tabella,Feat(i,:));
        Feat(i,:)=Feat(i,:)./(size(Tr,2)-2);
    end
    
elseif N==4
    
    tmp=1;
    for i=1:length(alfabeto)
        for j=1:length(alfabeto)
            for ij=1:length(alfabeto)
                for ii=1:length(alfabeto)
                    Tabella(tmp,1)=(i) ;
                    Tabella(tmp,2)=(j) ;
                    Tabella(tmp,3)=(ij) ;
                    Tabella(tmp,4)=(ii) ;
                    tmp=tmp+1;
                end
            end
        end
    end
    Tabella=single(Tabella);
    Feat=single(zeros(size(Training,2),length(alfabeto)^N));
    for i=1:size(Training,2)
        Tr=single(ConvertiAlfabeto(Training{i},alfabeto));
        Feat(i,:)=cicloVeloce4(Tr,Tabella,Feat(i,:));
        Feat(i,:)=Feat(i,:)./(size(Tr,2)-3);
    end
    
elseif N==5
    
    tmp=1;
    for i=1:length(alfabeto)
        for j=1:length(alfabeto)
            for ij=1:length(alfabeto)
                for ii=1:length(alfabeto)
                    for ji=1:length(alfabeto)
                        Tabella(tmp,1)=(i) ;
                        Tabella(tmp,2)=(j) ;
                        Tabella(tmp,3)=(ij) ;
                        Tabella(tmp,4)=(ii) ;
                        Tabella(tmp,5)=(ji) ;
                        tmp=tmp+1;
                    end
                end
            end
        end
    end
    Tabella=single(Tabella);
    Feat=single(zeros(size(Training,2),length(alfabeto)^N));
    for i=1:size(Training,2)
        Tr=single(ConvertiAlfabeto(Training{i},alfabeto));
        Feat(i,:)=cicloVeloce5(Tr,Tabella,Feat(i,:));
        Feat(i,:)=Feat(i,:)./(size(Tr,2)-4);
    end
    
    
elseif N==6
    
    tmp=1;
    for i=1:length(alfabeto)
        for j=1:length(alfabeto)
            for ij=1:length(alfabeto)
                for ii=1:length(alfabeto)
                    for ji=1:length(alfabeto)
                        for jii=1:length(alfabeto)
                            Tabella(tmp,1)=(i) ;
                            Tabella(tmp,2)=(j) ;
                            Tabella(tmp,3)=(ij) ;
                            Tabella(tmp,4)=(ii) ;
                            Tabella(tmp,5)=(ji) ;
                            Tabella(tmp,6)=(jii) ;
                            tmp=tmp+1;
                        end
                    end
                end
            end
        end
    end
    Tabella=single(Tabella);
    Feat=single(zeros(size(Training,2),length(alfabeto)^N));
    for i=1:size(Training,2)
        Tr=single(ConvertiAlfabeto(Training{i},alfabeto));
        Feat(i,:)=cicloVeloce6(Tr,Tabella,Feat(i,:));
        Feat(i,:)=Feat(i,:)./(size(Tr,2)-5);
    end
    
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -