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)); }
public static bool KeysMatch(LibraryKey key1, LibraryKey key2) { var comparisonKey1 = ComparisonKey.Get(key1); var comparisonKey2 = ComparisonKey.Get(key2); return(comparisonKey1.Compare(comparisonKey2, ComparisonLevel.Full) == 0 && comparisonKey1.AllModificationsMatch(comparisonKey2)); }
public override bool IsEquivalentTo(LibraryKey other) { var that = other as MoleculeLibraryKey; if (that == null) { return(false); } return(Equals(PreferredKey, that.PreferredKey) && Equals(Adduct, that.Adduct)); }
public IEnumerable <IndexItem> ItemsMatching(LibraryKey libraryKey, bool matchAdductAlso) { var comparisonKey = ComparisonKey.Get(libraryKey); IList <int> matchingIndexes = SearchEntries(comparisonKey, matchAdductAlso ? ComparisonLevel.Adduct : ComparisonLevel.PrecisionIndependentModifications); return(matchingIndexes.Where(i => _allEntries[i].Key.AllModificationsMatch(comparisonKey)).Select(GetItem)); }
public IEnumerable <IndexItem> ItemsEqualTo(LibraryKey libraryKey) { var key = libraryKey as TKey; if (key == null) { return(IndexItem.NONE); } return(ExactMatches(key)); }
public IEnumerable <IndexItem> ItemsMatchingWithoutModifications(LibraryKey libraryKey) { var key = libraryKey as TKey; if (key == null) { return(IndexItem.NONE); } return(ItemsMatchingWithoutModifications(key)); }
public int IndexOf(LibraryKey libraryKey) { if (libraryKey == null) { return(-1); } var keyToFind = new ViewLibraryPepInfo(new LibKey(libraryKey)); var range = CollectionUtil.BinarySearch(_allEntries, entry => ComparePepInfos(entry, keyToFind)); return(range.Length > 0 ? range.Start : -1); }
public IEnumerable <IndexItem> ItemsMatching(LibraryKey libraryKey, bool matchAdductAlso) { var key = libraryKey as TKey; if (key == null) { return(IndexItem.NONE); } var matches = ItemsMatching(key); return(matchAdductAlso ? matches.Where(item => Equals(item.LibraryKey.Adduct, libraryKey.Adduct)) : matches); }
public IndexItem?Find(LibraryKey libraryKey) { var range = SearchEntries(libraryKey, ComparisonLevel.Full); foreach (var index in range) { if (Equals(libraryKey, _allEntries[index].Key.LibraryKey)) { return(GetItem(index)); } } return(null); }
public IList <IndexItem> ItemsWithUnmodifiedSequence(LibraryKey libraryKey) { var peptideLibraryKey = libraryKey as PeptideLibraryKey; if (peptideLibraryKey != null) { Range range; if (_indexByUnmodifiedSequence.TryGetValue(peptideLibraryKey.UnmodifiedSequence, out range)) { return(new IndexedSubList <IndexItem>(this, new RangeList(range))); } return(ImmutableList <IndexItem> .EMPTY); } var matchingIndexes = SearchEntries(libraryKey, ComparisonLevel.UnmodifiedSequence); return(new IndexedSubList <IndexItem>(this, matchingIndexes)); }
public static bool KeysMatch(LibraryKey key1, LibraryKey key2) { if (Equals(key1, key2)) { return(true); } if (!Equals(key1.Adduct, key2.Adduct)) { return(false); } var peptideKey1 = key1 as PeptideLibraryKey; var peptideKey2 = key2 as PeptideLibraryKey; if (peptideKey1 == null || peptideKey2 == null) { return(false); } if (!Equals(peptideKey1.UnmodifiedSequence, peptideKey2.UnmodifiedSequence)) { return(false); } var mods1 = peptideKey1.GetModifications(); var mods2 = peptideKey2.GetModifications(); if (mods1.Count != mods2.Count) { return(false); } if (!mods1.Select(mod => mod.Key).SequenceEqual(mods2.Select(mod => mod.Key))) { return(false); } for (int i = 0; i < mods1.Count; i++) { if (!ModificationsMatch(mods1[i].Value, mods2[i].Value)) { return(false); } } return(true); }
public static ComparisonKey Get(LibraryKey libraryKey) { var peptideLibraryKey = libraryKey as PeptideLibraryKey; if (peptideLibraryKey != null) { return(new Peptide(peptideLibraryKey)); } var moleculeLibraryKey = libraryKey as MoleculeLibraryKey; if (moleculeLibraryKey != null) { return(new SmallMolecule(moleculeLibraryKey)); } var precursorKey = libraryKey as PrecursorLibraryKey; if (precursorKey != null) { return(new Precursor(precursorKey)); } return(new ComparisonKey(KeyTypeEnum.unknown, libraryKey)); }
public IEnumerable <TItem> ItemsMatching(LibraryKey libraryKey, bool matchAdductAlso) { return(_index.ItemsMatching(libraryKey, matchAdductAlso).Select(GetItem)); }
public IndexItem(LibraryKey libraryKey, int originalIndex) : this() { LibraryKey = libraryKey; OriginalIndex = originalIndex; }
public IEnumerable <IndexItem> ItemsWithUnmodifiedSequence(LibraryKey libraryKey) { return(_subIndexes.SelectMany(index => index.ItemsMatchingWithoutModifications(libraryKey))); }
public IEnumerable <IndexItem> ItemsMatching(LibraryKey libraryKey, bool matchAdductAlso) { return(_subIndexes.SelectMany(index => index.ItemsMatching(libraryKey, matchAdductAlso))); }
public IndexItem?Find(LibraryKey libraryKey) { return(_subIndexes.SelectMany(index => index.ItemsEqualTo(libraryKey)).FirstOrDefault()); }
public int IndexOf(LibraryKey libraryKey) { var indexItem = _index.Find(libraryKey); return(indexItem.HasValue ? indexItem.Value.OriginalIndex : -1); }
protected RangeList SearchEntries(LibraryKey libraryKey, ComparisonLevel level) { return(SearchEntries(ComparisonKey.Get(libraryKey), level)); }
public virtual bool IsEquivalentTo(LibraryKey that) { return(Equals(that)); }
protected ComparisonKey(KeyTypeEnum keyType, LibraryKey libraryKey) { LibraryKey = libraryKey; KeyType = keyType; }
public IEnumerable <KeyValuePair <LibKey, TItem> > KeyPairsMatching(LibraryKey libraryKey, bool matchAdductAlso) { return(_index.ItemsMatching(libraryKey, matchAdductAlso).Select(GetKeyPair)); }
private Peptide(LibraryKey libraryKey) : base(KeyTypeEnum.peptide, libraryKey) { }