public override ComparisonKey Cache(ValueCache valueCache) { var comparisonKey = this; if (valueCache.TryGetCachedValue(ref comparisonKey)) { return(comparisonKey); } ImmutableList <string> modificationNames = ModificationNames; if (ModificationNames != null) { if (!valueCache.TryGetCachedValue(ref modificationNames)) { modificationNames = ImmutableList.ValueOf(modificationNames.Select(valueCache.CacheValue)); modificationNames = valueCache.CacheValue(modificationNames); } } comparisonKey = new Peptide(LibraryKey.ValueFromCache(valueCache)) { ModificationIndexes = valueCache.CacheValue(ModificationIndexes), ModificationNames = modificationNames }; return(valueCache.CacheValue(comparisonKey)); }
private static SmallMoleculeLibraryAttributes Normalize( ValueCache valueCache, SmallMoleculeLibraryAttributes smallMoleculeLibraryAttributes) { if (smallMoleculeLibraryAttributes == null) { return(SmallMoleculeLibraryAttributes.EMPTY); } if (null == smallMoleculeLibraryAttributes.MoleculeName || null == smallMoleculeLibraryAttributes.ChemicalFormula || null == smallMoleculeLibraryAttributes.InChiKey || null == smallMoleculeLibraryAttributes.OtherKeys) { smallMoleculeLibraryAttributes = SmallMoleculeLibraryAttributes.Create( smallMoleculeLibraryAttributes.MoleculeName ?? string.Empty, smallMoleculeLibraryAttributes.ChemicalFormula ?? string.Empty, smallMoleculeLibraryAttributes.InChiKey ?? string.Empty, smallMoleculeLibraryAttributes.OtherKeys ?? string.Empty); } if (valueCache != null) { if (!valueCache.TryGetCachedValue(ref smallMoleculeLibraryAttributes)) { smallMoleculeLibraryAttributes = valueCache.CacheValue(SmallMoleculeLibraryAttributes.Create( valueCache.CacheValue(smallMoleculeLibraryAttributes.MoleculeName), valueCache.CacheValue(smallMoleculeLibraryAttributes.ChemicalFormula), valueCache.CacheValue(smallMoleculeLibraryAttributes.InChiKey), valueCache.CacheValue(smallMoleculeLibraryAttributes.OtherKeys) )); } } return(smallMoleculeLibraryAttributes); }
public override LibraryKey ValueFromCache(ValueCache valueCache) { var libraryKey = this; if (valueCache.TryGetCachedValue(ref libraryKey)) { return(libraryKey); } libraryKey = new PeptideLibraryKey { ModifiedSequence = valueCache.CacheValue(ModifiedSequence), UnmodifiedSequence = valueCache.CacheValue(UnmodifiedSequence), Charge = Charge, }; return(valueCache.CacheValue(libraryKey)); }