protected override int CompareSpecific(ComparisonKey that, ComparisonLevel level) { var thisPreferredKey = ((MoleculeLibraryKey)LibraryKey).PreferredKey; var thatPreferredKey = ((MoleculeLibraryKey)that.LibraryKey).PreferredKey; return(string.CompareOrdinal(thisPreferredKey, thatPreferredKey)); }
protected override int CompareSpecific(ComparisonKey that, ComparisonLevel level) { var thisMz = ((PrecursorLibraryKey)LibraryKey).Mz; var thatMz = ((PrecursorLibraryKey)that.LibraryKey).Mz; return(thisMz.CompareTo(thatMz)); }
public ListViewItem GetListViewItem(string value, ComparisonKey key) { foreach (ListViewItem item in _listView.Items) { if (key == ComparisonKey.Hash) { if ((item.Tag as FileWrapper).File.Hash == value) { return item; } } else if (key == ComparisonKey.Id) { if ((item.Tag as FileWrapper).Id == value) { return item; } } else if (key == ComparisonKey.FileFullName) { if ((item.Tag as FileWrapper).File.FileFullName == value) { return item; } } else throw new InvalidOperationException(); } return null; }
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 LibKeyIndex(ValueCache valueCache, IEnumerable <IndexItem> items) { _allEntries = ImmutableList.ValueOf(items .Select(entry => new KeyValuePair <ComparisonKey, IndexItem>( ComparisonKey.Get(entry.LibraryKey).Cache(valueCache), entry)) .OrderBy(kvp => kvp.Key, MakeComparer(ComparisonLevel.Full))); _indexByUnmodifiedSequence = MakeIndexByUnmodifiedSequence(); }
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 ListViewHelper(ListView listView, ComparisonKey defaultKey) { _listView = listView; _listView.SmallImageList = ImageLists.FileImages_Small; _listView.LargeImageList = ImageLists.FileImages_Large; LoadImageDictionary(); _comparison = defaultKey; }
protected override int CompareSpecific(ComparisonKey other, ComparisonLevel level) { var that = (Peptide)other; int result = StringComparer.Ordinal.Compare(PeptideLibraryKey.UnmodifiedSequence, that.PeptideLibraryKey.UnmodifiedSequence); if (result != 0 || level <= ComparisonLevel.UnmodifiedSequence) { return(result); } result = CompareModificationIndexes(that); if (result != 0 || level <= ComparisonLevel.PrecisionIndependentModifications) { return(result); } return(result); }
public int Compare(ComparisonKey that, ComparisonLevel level) { int result = KeyType.CompareTo(that.KeyType); if (result != 0 || level <= ComparisonLevel.KeyType) { return(result); } result = CompareSpecific(that, level); if (result != 0 || level < ComparisonLevel.Adduct) { return(result); } result = Adduct.CompareTo(that.Adduct); if (result != 0 || level <= ComparisonLevel.Adduct) { return(result); } return(result); }
public override bool AllModificationsMatch(ComparisonKey comparisonKey) { var that = (Peptide)comparisonKey; if (ModificationNames == null || that.ModificationNames == null) { return(ReferenceEquals(ModificationNames, that.ModificationNames)); } if (ModificationNames.Count != that.ModificationNames.Count) { return(false); } for (int i = 0; i < ModificationNames.Count; i++) { if (!ModificationsMatch(ModificationNames[i], that.ModificationNames[i])) { return(false); } } return(true); }
public virtual bool AllModificationsMatch(ComparisonKey that) { return(true); }
/// <summary> /// Compares the portion of the key which is specific to the type of LibraryKey. /// </summary> protected virtual int CompareSpecific(ComparisonKey other, ComparisonLevel level) { return(0); }
private RangeList SearchEntries(ComparisonKey comparisonKey, ComparisonLevel level) { return(new RangeList(CollectionUtil.BinarySearch(_allEntries, item => item.Key.Compare(comparisonKey, level)))); }
protected RangeList SearchEntries(LibraryKey libraryKey, ComparisonLevel level) { return(SearchEntries(ComparisonKey.Get(libraryKey), level)); }
public bool Equals(ComparisonKey other) { return(string.Equals(Id, other.Id) && string.Equals(Value, other.Value)); }