function [rxnDist,uComp]=findCmptmtRxnDistribution(model,rxns,rxnCompartments)
%[geneDist,compDist,uComp]=findCmptmtGeneDistribution(model,genes,geneCompartments)
% This function generates the compartment distribution (compDist)of genes and gene
% distribution (geneDist) of compartments
% INPUT:
% % model:    model in question
% % rxns (optional): rxns in questions, model.rxns(default)
% % rxnCompartments (optional):  compartmetns to which rxns belong to,
%                               compute it now (default)
% OUTPUT:
% % rxnDist: distribution of rxns among the compartments
% % uComp:     unique compartments that belonging to this set of genes

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % Written By Chintan Joshi on 7/4/2014 % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %


if (nargin<2)
    rxns=model.rxns;
end
if (nargin<3)
    [rxnCompartments,~]=findCompartmentOfRxns(model,rxns);
end

uComp=unique(linearizeCellString(rxnCompartments));
rxnCompartments=linearizeCellString(rxnCompartments);
for i=1:length(uComp)
    rxnDist(i,1)=length(find(strcmp(uComp(i,1),rxnCompartments)==1));
end