Code covered by the BSD License  

Highlights from
MetaboNetworks

image thumbnail

MetaboNetworks

by

 

18 Jul 2013 (Updated )

A toolbox to interactively create, customize and explore multi-systemic metabolic reaction networks

E=GetENZYMEData(E,PID)
function E=GetENZYMEData(E,PID)
%% Getting enzymes for organisms from KEGG
% Used by MetaboGetworks
% E: enzyme list
% PID: KEGG pathway ID

    [keggtext,status]=urlread(['http://rest.kegg.jp/get/',PID]);
    
    if status==0
        return
    end
    
    if isempty(strfind(keggtext,'COMPOUND'))
        cmpfind=strfind(keggtext,'REFERENCE');
        if isempty(cmpfind)
            cmpfind=strfind(keggtext,'REL_PATHWAY');
            if isempty(cmpfind)
                cmpfind=strfind(keggtext,'KO_PATHWAY');
                if isempty(cmpfind)
                    cmpfind=strfind(keggtext,'///');
                end
            end
        end
    else
        cmpfind=strfind(keggtext,'COMPOUND');
    end
    genefind=strfind(keggtext,'GENE');
    if isempty(genefind)
        genefind=strfind(keggtext,'ENTRY');
    end
    
    keggtext3=keggtext(genefind:(cmpfind-1));
    % catch needed for the last one
    keggtext3=[keggtext3,'EC:'];
    f=strfind(keggtext3,'EC:');
    a3={};
    j=1;
    for k=1:(length(f)-1)
        g=strfind(keggtext3(f(k):f(k+1)),']');
        if ~isempty(g)
            h=strfind(keggtext3(f(k):(f(k)+g(1)-1)),' ');
            h=[h g(1)];
            a3{j,1}=keggtext3((f(k)+3):(f(k)+h(1)-2));
            j=j+1;
            for d=2:length(h)
                a3{j,1}=keggtext3((f(k)+h(d-1)):(f(k)+h(d)-2));
                j=j+1;
            end
        end
    end
    % add entries to kegg list
    a3=unique(a3);
    if isempty(E) || isempty(a3)
        if ~isempty(a3)
            cm=zeros(size(a3));
        else
            cm=[];
        end
    else
        cm=sum(strcmp(repmat(a3,1,length(E)),repmat(E',length(a3),1)),2);
    end
    a3(cm==1)=[];
    E=[E;a3];
    
end

Contact us