private void GetModsAfterDeserialization(Dictionary <string, Modification> idToMod)
        {
            _allModsOneIsNterminus = new Dictionary <int, Modification>();
            int  currentModStart             = 0;
            int  currentModificationLocation = 1;
            bool currentlyReadingMod         = false;
            int  bracketCount = 0;

            for (int r = 0; r < FullSequence.Length; r++)
            {
                char c = FullSequence[r];
                if (c == '[')
                {
                    currentlyReadingMod = true;
                    if (bracketCount == 0)
                    {
                        currentModStart = r + 1;
                    }
                    bracketCount++;
                }
                else if (c == ']')
                {
                    string modId = null;
                    bracketCount--;
                    if (bracketCount == 0)
                    {
                        try
                        {
                            //remove the beginning section (e.g. "Fixed", "Variable", "Uniprot")
                            string modString  = FullSequence.Substring(currentModStart, r - currentModStart);
                            int    splitIndex = modString.IndexOf(':');
                            string modType    = modString.Substring(0, splitIndex);
                            modId = modString.Substring(splitIndex + 1, modString.Length - splitIndex - 1);
                        }
                        catch (Exception e)
                        {
                            throw new MzLibUtil.MzLibException(
                                      "Error while trying to parse string into peptide: " + e.Message);
                        }
                        if (!idToMod.TryGetValue(modId, out Modification mod))
                        {
                            throw new MzLibUtil.MzLibException(
                                      "Could not find modification while reading string: " + FullSequence);
                        }
                        if (mod.LocationRestriction.Contains("C-terminal.") && r == FullSequence.Length - 1)
                        {
                            currentModificationLocation = BaseSequence.Length + 2;
                        }
                        _allModsOneIsNterminus.Add(currentModificationLocation, mod);
                        currentlyReadingMod = false;
                    }
                }
                else if (!currentlyReadingMod)
                {
                    currentModificationLocation++;
                }
                //else do nothing
            }
        }
 public override int GetHashCode()
 {
     if (DigestionParams == null)
     {
         return(FullSequence.GetHashCode());
     }
     else
     {
         return(FullSequence.GetHashCode() + DigestionParams.Protease.GetHashCode());
     }
 }
Beispiel #3
0
 public T GetSegmentValue(int segmentIndex)
 {
     string[] parts = FullSequence.GetParts(SegmentLength);
     return(Converter.Decode(parts[segmentIndex]));
 }