private void updateReferenceToIndividualParametersForSurrogateContainer(Individual individual, IndividualMolecule molecule, MoleculeExpressionContainer expressionContainer, IContainer globalMoleculeContainer)
        {
            string relExpName;

            if (expressionContainer.IsBloodCell())
            {
                relExpName = CoreConstants.Parameters.REL_EXP_BLOOD_CELL;
            }
            else if (expressionContainer.IsPlasma())
            {
                relExpName = CoreConstants.Parameters.REL_EXP_PLASMA;
            }
            else if (expressionContainer.IsVascularEndothelium())
            {
                relExpName = CoreConstants.Parameters.REL_EXP_VASC_ENDO;
            }
            else
            {
                return;
            }

            var relExpNormName = CoreConstants.Parameters.NormParameterFor(relExpName);

            updateFromIndividualParameter(globalMoleculeContainer.Parameter(relExpName), expressionContainer.RelativeExpressionParameter, individual, molecule);
            updateFromIndividualParameter(globalMoleculeContainer.Parameter(relExpNormName), expressionContainer.RelativeExpressionNormParameter, individual, molecule);
        }
        private IEnumerable <IContainer> allContainersFor(Organism organism, IndividualMolecule molecule, IEnumerable <IContainer> allContainers, MoleculeExpressionContainer expressionContainer)
        {
            if (molecule.MoleculeType == QuantityType.Transporter)
            {
                return(allContainersForTransporter(organism, molecule.DowncastTo <IndividualTransporter>(), allContainers, expressionContainer.DowncastTo <TransporterExpressionContainer>()));
            }

            var protein = molecule.DowncastTo <IndividualProtein>();

            //plasma always generated
            if (expressionContainer.IsPlasma())
            {
                return(allPlasmaCompartmentsOf(allContainers));
            }

            switch (protein.TissueLocation)
            {
            case TissueLocation.ExtracellularMembrane:
                if (expressionContainer.IsBloodCell())
                {
                    return(allPlasmaCompartmentsOf(allContainers));
                }
                if (expressionContainer.IsVascularEndothelium())
                {
                    if (protein.MembraneLocation == MembraneLocation.Apical)
                    {
                        return(allPlasmaCompartmentsOf(allContainers));
                    }

                    return(allInterstitialCompartmentsOf(allContainers));
                }
                return(compartmentFor(organism, expressionContainer, CoreConstants.Compartment.Interstitial));

            case TissueLocation.Intracellular:
                if (expressionContainer.IsBloodCell())
                {
                    return(allBloodCellsCompartmentsOf(allContainers));
                }

                if (expressionContainer.IsVascularEndothelium())
                {
                    if (protein.IntracellularVascularEndoLocation == IntracellularVascularEndoLocation.Endosomal)
                    {
                        return(allEndosomeCompartmentsOf(allContainers));
                    }

                    return(allInterstitialCompartmentsOf(allContainers));
                }
                return(compartmentFor(organism, expressionContainer, CoreConstants.Compartment.Intracellular));

            case TissueLocation.Interstitial:
                if (expressionContainer.IsBloodCell())
                {
                    return(allBloodCellsCompartmentsOf(allContainers));
                }

                if (expressionContainer.IsVascularEndothelium())
                {
                    return(allInterstitialCompartmentsOf(allContainers));
                }

                return(compartmentFor(organism, expressionContainer, CoreConstants.Compartment.Interstitial));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }