Example #1
0
                protected override int CompareSpecific(ComparisonKey that, ComparisonLevel level)
                {
                    var thisPreferredKey = ((MoleculeLibraryKey)LibraryKey).PreferredKey;
                    var thatPreferredKey = ((MoleculeLibraryKey)that.LibraryKey).PreferredKey;

                    return(string.CompareOrdinal(thisPreferredKey, thatPreferredKey));
                }
Example #2
0
                protected override int CompareSpecific(ComparisonKey that, ComparisonLevel level)
                {
                    var thisMz = ((PrecursorLibraryKey)LibraryKey).Mz;
                    var thatMz = ((PrecursorLibraryKey)that.LibraryKey).Mz;

                    return(thisMz.CompareTo(thatMz));
                }
Example #3
0
        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;
        }
Example #4
0
        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));
        }
Example #5
0
 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();
 }
Example #6
0
        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));
        }
Example #7
0
        public ListViewHelper(ListView listView, ComparisonKey defaultKey)
        {
            _listView = listView;

            _listView.SmallImageList = ImageLists.FileImages_Small;
            _listView.LargeImageList = ImageLists.FileImages_Large;

            LoadImageDictionary();

            _comparison = defaultKey;
        }
Example #8
0
                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);
                }
Example #9
0
            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);
            }
Example #10
0
                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);
                }
Example #11
0
 public virtual bool AllModificationsMatch(ComparisonKey that)
 {
     return(true);
 }
Example #12
0
 /// <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);
 }
Example #13
0
 private RangeList SearchEntries(ComparisonKey comparisonKey, ComparisonLevel level)
 {
     return(new RangeList(CollectionUtil.BinarySearch(_allEntries, item => item.Key.Compare(comparisonKey, level))));
 }
Example #14
0
 protected RangeList SearchEntries(LibraryKey libraryKey, ComparisonLevel level)
 {
     return(SearchEntries(ComparisonKey.Get(libraryKey), level));
 }
Example #15
0
 public bool Equals(ComparisonKey other)
 {
     return(string.Equals(Id, other.Id) && string.Equals(Value, other.Value));
 }