private void convertTransportContainer(TransporterExpressionContainer expressionContainerToConvert, IReadOnlyList <TransporterExpressionContainer> allTransporterExpressionContainers) { //This should never happen as a tag was added in the xml conversion with the membrane location if (!expressionContainerToConvert.Tags.Any()) { return; } var membraneLocation = EnumHelper.ParseValue <MembraneLocation>(expressionContainerToConvert.Tags.ElementAt(0).Value); var matchingContainers = allTransporterExpressionContainers .Where(x => x.LogicalContainerName == expressionContainerToConvert.Name || x.CompartmentName == expressionContainerToConvert.Name) .ToList(); //only one direction to take into consideration. all good, nothing else to do if (matchingContainers.Count == 1) { return; } MembraneLocationConverter.ConvertMembraneLocationToParameterFraction(matchingContainers, membraneLocation); }
public override async Task <MoleculeExpressionContainer> MapToModel(ExpressionContainer snapshot, ExpressionContainerMapperContext snapshotContext) { if (snapshot == null) { return(null); } var molecule = snapshotContext.Molecule; var expressionParameterCache = snapshotContext.ExpressionParameters; var expressionContainerParameters = snapshotContext.MoleculeExpressionContainers; //Value was only defined for older version of the snapshot if (snapshot.Value.HasValue) { var relExp = expressionParameterCache[snapshot.Name]; if (relExp == null) { _logger.AddWarning(PKSimConstants.Error.RelativeExpressionContainerNotFound(snapshot.Name)); return(null); } await _parameterMapper.MapToModel(snapshot, new ParameterSnapshotContext(relExp, snapshotContext)); } //We do not return anything as container are created at construction time if (!(molecule is IndividualTransporter transporter)) { return(null); } var expressionsContainers = expressionContainerParameters.OfType <TransporterExpressionContainer>() .Where(queryPredicate(snapshotContext.IsV9FormatOrEarlier, snapshot)) .Where(x => x.TransportDirection != TransportDirectionId.None) .ToList(); if (expressionsContainers.Count == 0) { _logger.AddWarning(PKSimConstants.Error.RelativeExpressionContainerNotFound(snapshot.Name)); return(null); } var firstExpressionContainer = expressionsContainers[0]; //This is the new format if (!snapshotContext.IsV9FormatOrEarlier) { //we should only have one firstExpressionContainer.TransportDirection = snapshot.TransportDirection.Value; return(firstExpressionContainer); } expressionsContainers.Each(x => x.TransportDirection = TransportDirections.DefaultDirectionFor(transporter.TransportType, x)); //only one direction to take into consideration. all good, nothing else to do if (expressionsContainers.Count == 1) { return(firstExpressionContainer); } //This is the old format. Basolateral was the default var membraneLocation = ModelValueFor(snapshot.MembraneLocation, MembraneLocation.Basolateral); MembraneLocationConverter.ConvertMembraneLocationToParameterFraction(expressionsContainers, membraneLocation); return(firstExpressionContainer); }