Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Litre are recognized #617

Merged

Conversation

abdelr
Copy link
Member

@abdelr abdelr commented Sep 28, 2021

Fixes #616 (Litre are recognized as a unit when importing sbml files)


public IDimension TryGetDimensionCaseInsensitive(string dimensionName)
{
var dimension = Dimensions.FirstOrDefault(d => d.Name.Equals(dimensionName, StringComparison.OrdinalIgnoreCase));
return dimension ?? NoDimension;
}

public IDimension TryGetDimensionCaseInsensitiveFromUnit(string unitName)
{
var dimension = Dimensions.FirstOrDefault(d => d.FindUnit(unitName, true) != null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the method DimensionForUnit that does exactly that...

return dimension;
if (_sbmlUnitsSynonyms.ContainsKey(unitName))
{
dimension = Dimensions.FirstOrDefault(d => d.Units.Any(u => u.Name.Equals(_sbmlUnitsSynonyms[unitName], StringComparison.OrdinalIgnoreCase)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the DimensionForUnit method here as well?

msv.StartValue = _unitDefinitionImporter.ToMobiBaseUnit(sbmlUnit, new[] { sbmlSpecies.getInitialConcentration() })[0];
var startValue = _unitDefinitionImporter.ToMobiBaseUnit(sbmlUnit, new[] { sbmlSpecies.getInitialConcentration() })[0];
msv.StartValue = startValue;
msv.Formula = new ConstantFormula(startValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConstantFormula should be created using the formulaFactory and dimension needs to be set

@@ -92,4 +92,20 @@ public void SpeciesSameNameDiffCompartmentsTest()
mbb.Any(molecule => molecule.Name == "abc").ShouldBeTrue();
}
}

public class WhenSettingMoleculeStartValue : ContextForSBMLIntegration<SpeciesImporter>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When_setting_molecule_start_value

@abdelr abdelr requested a review from msevestre September 29, 2021 05:37
@msevestre msevestre merged commit 4f8a9ab into develop Sep 29, 2021
@msevestre msevestre deleted the 616_Litre_is_not_recognized_when_importing_from_sbml branch September 29, 2021 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Litre is not recognized when importing sbml file
2 participants