Exemplo n.º 1
0
 public bool Equals(IsolationWindow other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.Start.Equals(Start) && other.End.Equals(End) && other.Target.Equals(Target) &&
            other.StartMargin.Equals(StartMargin) && other.EndMargin.Equals(EndMargin) &&
            other.CERange.Equals(CERange));
 }
Exemplo n.º 2
0
        public IsolationWindow GetIsolationWindow(double targetMz, double matchTolerance)
        {
            IsolationWindow isolationWindow = null;

            if (!FromResults)
            {
                // Match pre-specified targets.
                if (PrespecifiedIsolationWindows[0].Target.HasValue)
                {
                    foreach (var window in PrespecifiedIsolationWindows)
                    {
                        if (!window.TargetMatches(targetMz, matchTolerance))
                        {
                            continue;
                        }
                        if (isolationWindow != null)
                        {
                            throw new InvalidDataException(
                                      string.Format(Resources.SpectrumFilter_FindFilterPairs_Two_isolation_windows_contain_targets_which_match_the_isolation_target__0__,
                                                    targetMz));
                        }
                        isolationWindow = window;
                    }
                }
                // Find containing window.
                else
                {
                    double?bestDeltaMz = null;
                    // find the window with center closest to the target m/z
                    foreach (var window in PrespecifiedIsolationWindows)
                    {
                        if (!window.Contains(targetMz))
                        {
                            continue;
                        }
                        var winCenter = (window.IsolationStart + window.IsolationEnd) / 2.0;
                        var deltaMz   = Math.Abs(winCenter - targetMz);
                        if (isolationWindow == null || deltaMz < bestDeltaMz)
                        {
                            isolationWindow = window;
                            bestDeltaMz     = deltaMz;
                        }
                    }
                }
            }
            return(isolationWindow);
        }
Exemplo n.º 3
0
        private IEnumerable <IsolationWindow> GetDisjointRanges(IList <IsolationWindow> isolationWindows)
        {
            var listIsolationWindows = new List <IsolationWindow>(isolationWindows);

            listIsolationWindows.Sort((w1, w2) => Comparer <double> .Default.Compare(w1.Start, w2.Start));
            int iDisjoint = 0;

            for (int i = 1; i < listIsolationWindows.Count; i++)
            {
                var disjointWindow = listIsolationWindows[iDisjoint];
                var nextWindow     = listIsolationWindows[i];
                if (disjointWindow.End >= nextWindow.Start)
                {
                    listIsolationWindows[iDisjoint] = new IsolationWindow(disjointWindow.Start, nextWindow.End);
                }
                else
                {
                    iDisjoint++;
                    listIsolationWindows[iDisjoint] = nextWindow;
                }
            }
            return(listIsolationWindows.Take(iDisjoint + 1));
        }
Exemplo n.º 4
0
 private IEnumerable<IsolationWindow> GetDisjointRanges(IList<IsolationWindow> isolationWindows)
 {
     var listIsolationWindows = new List<IsolationWindow>(isolationWindows);
     listIsolationWindows.Sort((w1, w2) => Comparer<double>.Default.Compare(w1.Start, w2.Start));
     int iDisjoint = 0;
     for (int i = 1; i < listIsolationWindows.Count; i++)
     {
         var disjointWindow = listIsolationWindows[iDisjoint];
         var nextWindow = listIsolationWindows[i];
         if (disjointWindow.End >= nextWindow.Start)
         {
             listIsolationWindows[iDisjoint] = new IsolationWindow(disjointWindow.Start, nextWindow.End);
         }
         else
         {
             iDisjoint++;
             listIsolationWindows[iDisjoint] = nextWindow;
         }
     }
     return listIsolationWindows.Take(iDisjoint + 1);
 }
Exemplo n.º 5
0
 public bool Equals(IsolationWindow other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Start.Equals(Start) && other.End.Equals(End) && other.Target.Equals(Target) &&
         other.StartMargin.Equals(StartMargin) && other.EndMargin.Equals(EndMargin) &&
         other.CERange.Equals(CERange);
 }
Exemplo n.º 6
0
 protected virtual void WriteIsolationWindow(TextWriter writer, IsolationWindow isolationWindow)
 {
     double target = isolationWindow.Target ?? isolationWindow.MethodCenter;
     writer.WriteLine(SequenceMassCalc.PersistentMZ(target).ToString(CultureInfo.InvariantCulture));
 }