findRxnsFromGenes

PURPOSE ^

findRxnsFromGenes print every reaction associated with a gene of interest

SYNOPSIS ^

function [results ListResults] = findRxnsFromGenes(model, genes, humanFlag,ListResultsFlag)

DESCRIPTION ^

findRxnsFromGenes print every reaction associated with a gene of interest

 [results ListResults] = findRxnsFromGenes(model, genes, humanFlag,ListResultsFlag)

INPUTS
 model                 COBRA model structure
 genes                 string of single gene or cell array of multiple
                       genes for which rxns are desired.

OPTIONAL INPUTS
 humanFlag             1 if using Human Recon  (Default = 0)
 ListResultsFlag       1 if you want to output ListResults (Default = 0)

OPUTPUTS
 results               structure containing cell arrays for each gene.
                       Each cell array has one column of rxn abbreviations
                       and one column containing the reaction formulae
 ListResults           same as above, but in a cell array
 
 by Nathan Lewis 02/16/08
 edited 04/05/09 (MUCH faster now -- NL)
 edited 06/11/10 (yet even faster now -- NL)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [results ListResults] = findRxnsFromGenes(model, genes, humanFlag,ListResultsFlag)
0002 %findRxnsFromGenes print every reaction associated with a gene of interest
0003 %
0004 % [results ListResults] = findRxnsFromGenes(model, genes, humanFlag,ListResultsFlag)
0005 %
0006 %INPUTS
0007 % model                 COBRA model structure
0008 % genes                 string of single gene or cell array of multiple
0009 %                       genes for which rxns are desired.
0010 %
0011 %OPTIONAL INPUTS
0012 % humanFlag             1 if using Human Recon  (Default = 0)
0013 % ListResultsFlag       1 if you want to output ListResults (Default = 0)
0014 %
0015 %OPUTPUTS
0016 % results               structure containing cell arrays for each gene.
0017 %                       Each cell array has one column of rxn abbreviations
0018 %                       and one column containing the reaction formulae
0019 % ListResults           same as above, but in a cell array
0020 %
0021 % by Nathan Lewis 02/16/08
0022 % edited 04/05/09 (MUCH faster now -- NL)
0023 % edited 06/11/10 (yet even faster now -- NL)
0024 
0025 if nargin< 3
0026     humanFlag = 0;
0027     ListResultsFlag = 0;
0028 end
0029 
0030 if ~iscell(genes)
0031     gene = genes;
0032     clear genes
0033     genes{1} = gene;
0034     clear gene
0035 end
0036 if iscell(genes{1})
0037     for i = 1:length(genes)
0038         gene(i) = genes{i};
0039     end
0040     clear genes
0041     genes = gene;
0042     clear gene
0043 end
0044 model.genes = regexprep(model.genes,'-','_DASH_');
0045 model.genes = regexprep(model.genes,'\.','_POINT_');
0046 genes = regexprep(genes,'-','_DASH_');
0047 genes = regexprep(genes,'\.','_POINT_');
0048 
0049 %find where the genes are located in the rxnGeneMat
0050 GeneID(1) = 0;
0051 for j = 1:length(genes)
0052     Ind = find(~cellfun('isempty', regexp(model.genes,cat(2,'^',genes{j},'$'))));
0053     
0054             if ~isempty(Ind)
0055                 GeneID(j) = Ind;
0056             end
0057 
0058 end
0059 if min(GeneID) == 0
0060     warning('A gene was not found in the model!')
0061     results = struct([]);
0062     if max(GeneID) ==0,results = struct([]);ListResults = {};
0063     return
0064     end
0065     Ind = find(GeneID==0);
0066     GeneID(Ind) = [];
0067     genes(Ind) = [];
0068 end
0069 results = struct([]);
0070 for i = 1:length(GeneID)
0071     
0072     k=1;
0073     Ind_rxns = find(model.rxnGeneMat(:,GeneID(i))==1);
0074     for j=1:length(Ind_rxns)
0075 %         if model.rxnGeneMat(j,GeneID(i))==1
0076             if isempty(results)
0077                 results = struct;
0078             end
0079             if humanFlag == 1
0080                 tempGene = cat(2,'gene_',genes{i});
0081             else tempGene = genes{i};
0082             end
0083             results.(tempGene){k,1} = model.rxns(Ind_rxns(j));
0084             results.(tempGene)(k,2) = printRxnFormula(model,model.rxns(Ind_rxns(j)),0);
0085             if isfield(model,'subSystems')
0086                 results.(tempGene)(k,3) = model.subSystems(Ind_rxns(j));
0087             end
0088             if isfield(model,'rxnNames')
0089             results.(tempGene){k,4} = model.rxnNames{Ind_rxns(j)};
0090             end
0091             k=k+1;
0092 %         end
0093     end
0094 end
0095 ListResults = {};
0096 if isempty(results)
0097     warning('Your gene was not associated with any reactions!')
0098     ListResults = {};
0099 else
0100     if ListResultsFlag ==1
0101     tmp = fieldnames(results);
0102     
0103     for i = 1:length(tmp) 
0104         tmp2 = results.(tmp{i});
0105         ListResults(end+1:end+length(tmp2(:,1)),1:4) = tmp2;
0106         ListResults(end-length(tmp2(:,1))+1:end,5) = tmp(i);
0107     end
0108     
0109    
0110     for j = 1:length(ListResults(:,1))
0111         ListResults(j,1) = ListResults{j,1};
0112     end
0113     
0114     end
0115     
0116 end
0117

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003