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

📄 take_res.m

📁 greedy em 混和模型训练算法
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Store motifs explanation and statistics in res.txt   %%%%%
%%%%%%                                                      %%%%%
%%%%%% Kostas Blekas, 19 Dec. 2001                          %%%%%
%%%%%% please contact at kblekas@cc.uoi.gr in case of problems %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function [f1] = take_res(N,g,motif_res,seq,seqname)

W = size(motif_res(1).pwm,1);
m = g-1;

fid = fopen('res.txt','w');

for i=1:m
    
    fprintf(fid,' Motif %d results\n\n', i);
    
    fprintf(fid,'[*] Motif occurrences \n');
    fprintf(fid,'----------------------\n');
    fprintf(fid,'Seq   Start  substring \n');
    
    for j=1:motif_res(i).noc
        s=motif_res(i).seqs(j);
        p=motif_res(i).pos(j);
        fprintf(fid,' %d    %d    %s\n',s,p,seq(s,p:p+W-1));
    end
    fprintf(fid,'\nConsensus:   %s \n',motif_res(i).consensus);
    fprintf(fid,'\n');
    fprintf(fid,'[*] Position Weight Matrix\n');
    fprintf(fid,'--------------------------\n');
    for l=1:W
        fprintf(fid,'%.4f ',motif_res(i).pwm(l,:));
        fprintf(fid,'\n');
    end
    fprintf(fid,'\n');
    fprintf(fid,'[*] Position Specific Scoring Matrix\n');
    fprintf(fid,'------------------------------------\n');
    for l=1:W
        fprintf(fid,'%+4.3d ',motif_res(i).pssm(l,:));
        fprintf(fid,'\n');
    end

    fprintf(fid,'\n');
    
end

fprintf(fid,'[*] Allocation of Motifs in the set of sequences\n');
fprintf(fid,'------------------------------------------------\n');

x=zeros(1,N);
for i = 1:N
    seq_mots{i} = [];
    distr_mot{i} = [];
    for j = 1:m
        seqm = length(find(motif_res(j).seqs == i));
        if seqm > 0
            x(i) = 1;
            seq_mots{i} = [seq_mots{i} motif_res(j).pos(find(motif_res(j).seqs == i))];
            distr_mot{i} = [distr_mot{i} j*ones(1,seqm)];
        end
    end
end

for i =1:N
    [m1,m2] = sort(seq_mots{i});
    
    fprintf(fid,'%s \n',char(seqname(i)));
    
    k1 = 1;
    for j = 1:length(m1)
        moc = seq_mots{i}(m2(j));
        fprintf(fid,'%s [ %s ] ',seq(i,k1:moc-1),seq(i,moc:moc+W-1));
        k1 = moc+W;
    end
    fprintf(fid,'%s\n',seq(i,k1:length(find(seq(i,:)~=' '))) );
    fprintf(fid,'\n');
    
    k1 = 1;
    for j = 1:length(m1)
        moc = seq_mots{i}(m2(j));
        fprintf(fid,'%s   %d     Motif %d     %d  ',repmat('-',1,moc-k1),moc,distr_mot{i}(m2(j)),moc+W-1);
        k1 = moc + W;
    end
    fprintf(fid,'%s\n',repmat('-',1,length(find(seq(i,:)~=' '))-k1+1));
    fprintf(fid,'\n');
end

f1 =1;
    
fclose(fid);

⌨️ 快捷键说明

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