예제 #1
0
            public bool ModificationsMatch(CrosslinkItem other)
            {
                if (PeptideLibraryKeys.Count != other.PeptideLibraryKeys.Count)
                {
                    return(false);
                }

                if (Crosslinks.Count != other.Crosslinks.Count)
                {
                    return(false);
                }

                for (int i = 0; i < PeptideLibraryKeys.Count; i++)
                {
                    if (!KeysMatch(PeptideLibraryKeys[i], other.PeptideLibraryKeys[i]))
                    {
                        return(false);
                    }
                }

                for (int i = 0; i < Crosslinks.Count; i++)
                {
                    if (!LibKeyIndex.ModificationsMatch(Crosslinks[i].Name, other.Crosslinks[i].Name))
                    {
                        return(false);
                    }

                    if (!Equals(Crosslinks[i].Positions, other.Crosslinks[i].Positions))
                    {
                        return(false);
                    }
                }

                return(true);
            }
예제 #2
0
        /// <summary>
        /// Return a set of library keys that are the most general of the ones found in this and that,
        /// and which covers all of the keys.
        /// <see cref="MostGeneralPeptideKey" />
        /// </summary>
        public IList <LibraryKey> MergeKeys(LibKeyIndex that)
        {
            var keysByUnmodifiedSequence = this.Select(item => item.LibraryKey)
                                           .OfType <PeptideLibraryKey>()
                                           .ToLookup(key => key.UnmodifiedSequence)
                                           .ToDictionary(grouping => grouping.Key, grouping => grouping.ToArray());
            var result           = new List <LibraryKey>();
            var nonPeptideKeySet = new HashSet <LibraryKey>();

            foreach (var thatItem in that)
            {
                var thatPeptideKey = thatItem.LibraryKey as PeptideLibraryKey;
                if (thatPeptideKey == null)
                {
                    if (nonPeptideKeySet.Add(thatItem.LibraryKey))
                    {
                        result.Add(thatItem.LibraryKey); // First time we've seen it, add to list
                    }
                    continue;
                }
                PeptideLibraryKey[] thisKeysWithUnmodSeq;
                if (!keysByUnmodifiedSequence.TryGetValue(thatPeptideKey.UnmodifiedSequence, out thisKeysWithUnmodSeq))
                {
                    result.Add(thatPeptideKey);
                    continue;
                }
                keysByUnmodifiedSequence[thatPeptideKey.UnmodifiedSequence] =
                    MergePeptideLibraryKey(thisKeysWithUnmodSeq, thatPeptideKey).ToArray();
            }
            result.AddRange(this.Select(item => item.LibraryKey)
                            .Where(key => !(key is PeptideLibraryKey) && !nonPeptideKeySet.Contains(key)));
            result.AddRange(keysByUnmodifiedSequence.SelectMany(entry => entry.Value));
            return(result);
        }
예제 #3
0
 public LibKeyMap(ImmutableList <TItem> items, IEnumerable <LibraryKey> keys)
 {
     _allItems = items;
     _index    = new LibKeyIndex(keys);
 }