Home > RAVEN > removeGenes.m

removeGenes

PURPOSE ^

removeGenes

SYNOPSIS ^

function [reducedModel,notDeleted]=removeGenes(model,genesToRemove, removeUnusedMets, removeRxnsWithComplexes)

DESCRIPTION ^

 removeGenes
   Deletes a set of genes and all reactions corresponding to them from a model

   model                     a model structure
   genesToRemove             either a cell array of gene IDs, a logical vector 
                             with the same number of elements as genes in the model,
                             or a vector of indexes to remove
   removeUnusedMets          remove metabolites that are no longer in use (opt, default
                             false)
   removeRxnsWithComplexes   remove reactions that are dependent on a
                             complex if only part of the complex is in genesToRemove 
                             (opt, default false)

   reducedModel              an updated model structure
   notDeleted                a cell array with the genes that couldn't be
                             deleted. This is an empty cell if removeRxnsWithComplexes 
                             is true

   Usage: [reducedModel,notDeleted]=removeGenes(model,genesToRemove,
           removeUnusedMets, removeRxnsWithComplexes)

   Rasmus Agren, 2010-12-16

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [reducedModel,notDeleted]=removeGenes(model,genesToRemove, removeUnusedMets, removeRxnsWithComplexes)
0002 % removeGenes
0003 %   Deletes a set of genes and all reactions corresponding to them from a model
0004 %
0005 %   model                     a model structure
0006 %   genesToRemove             either a cell array of gene IDs, a logical vector
0007 %                             with the same number of elements as genes in the model,
0008 %                             or a vector of indexes to remove
0009 %   removeUnusedMets          remove metabolites that are no longer in use (opt, default
0010 %                             false)
0011 %   removeRxnsWithComplexes   remove reactions that are dependent on a
0012 %                             complex if only part of the complex is in genesToRemove
0013 %                             (opt, default false)
0014 %
0015 %   reducedModel              an updated model structure
0016 %   notDeleted                a cell array with the genes that couldn't be
0017 %                             deleted. This is an empty cell if removeRxnsWithComplexes
0018 %                             is true
0019 %
0020 %   Usage: [reducedModel,notDeleted]=removeGenes(model,genesToRemove,
0021 %           removeUnusedMets, removeRxnsWithComplexes)
0022 %
0023 %   Rasmus Agren, 2010-12-16
0024 %
0025 
0026 if nargin<3
0027     removeUnusedMets=false;
0028 end
0029 
0030 if nargin<4
0031     removeRxnsWithComplexes=false;
0032 end
0033 
0034 notDeleted={};
0035 
0036 reducedModel=model;
0037 
0038 if ~isempty(genesToRemove)
0039     indexesToDelete=getIndexes(reducedModel,genesToRemove,'genes');
0040 
0041     %Find all reactions for these genes
0042     if ~isempty(indexesToDelete) && isfield(reducedModel,'rxnGeneMat')
0043         [a crap crap]=find(reducedModel.rxnGeneMat(:,indexesToDelete));
0044         a=unique(a);
0045         if removeRxnsWithComplexes==true
0046             %Delete those reactions even if they use complexes
0047             reducedModel=removeRxns(reducedModel,a,removeUnusedMets,true);
0048         else
0049             %First check that all part of the complex should be removed
0050             rxnsToRemove=false(numel(a),1);
0051             
0052             %Loop through the reactions that could possibly be removed
0053             for i=1:numel(a)
0054                 [crap geneIndexes crap]=find(reducedModel.rxnGeneMat(a(i),:));
0055                 
0056                 %Check to see if all should be removed
0057                 if numel(geneIndexes)>1
0058                     if all(ismember(geneIndexes,indexesToDelete))
0059                         rxnsToRemove(i)=true;
0060                     else
0061                         %Don't remove the reaction
0062                     end
0063                 else
0064                    %Only one gene, remove the reaction
0065                    rxnsToRemove(i)=true;
0066                 end
0067             end
0068             
0069             %Get the genes that will be deleted (any involved in the
0070             %reactions to be deleted
0071             [crap geneIndexes crap]=find(reducedModel.rxnGeneMat(a(rxnsToRemove),:));
0072             if ~isempty(setdiff(indexesToDelete,geneIndexes))
0073                 notDeleted=reducedModel.genes(setdiff(indexesToDelete,geneIndexes));
0074             end
0075             
0076             %Delete the reactions
0077             reducedModel=removeRxns(reducedModel,a(rxnsToRemove),removeUnusedMets,true);
0078         end
0079     end
0080 else
0081     reducedModel=model;
0082 end
0083 end

Generated on Tue 16-Jul-2013 21:50:02 by m2html © 2005