コード例 #1
0
        /// <summary>
        /// Gets the scan range for the peaks that need to be correlated together
        /// </summary>
        /// <param name="referencePeak"></param>
        /// <param name="startScan"></param>
        /// <param name="stopScan"></param>
        private void GetBaseScanRange(ChromPeak referencePeak, out int startScan, out int stopScan)
        {
            var baseWidth = (4 * (referencePeak.Width / 2.35));

            startScan = Convert.ToInt32(Math.Floor(referencePeak.XValue - (0.5 * baseWidth)));
            stopScan  = Convert.ToInt32(Math.Ceiling(referencePeak.XValue + (0.5 * baseWidth)));
        }
コード例 #2
0
ファイル: CacheFormat.cs プロジェクト: laeubisoft/pwiz
        public static CacheFormat FromVersion(CacheFormatVersion formatVersion)
        {
            if (formatVersion > CacheFormatVersion.CURRENT)
            {
                throw new NotSupportedException();
            }
            CacheFormatVersion versionRequired;

            if (formatVersion.CompareTo(CacheHeaderStruct.WithStructSizes) >= 0)
            {
                versionRequired = CacheHeaderStruct.WithStructSizes;
            }
            else
            {
                versionRequired = formatVersion;
            }
            return(new CacheFormat
            {
                FormatVersion = formatVersion,
                VersionRequired = versionRequired,
                ChromPeakSize = ChromPeak.GetStructSize(formatVersion),
                ChromTransitionSize = ChromTransition.GetStructSize(formatVersion),
                CachedFileSize = CachedFileHeaderStruct.GetStructSize(formatVersion),
                ChromGroupHeaderSize = ChromGroupHeaderInfo.GetStructSize(formatVersion)
            });
        }
コード例 #3
0
ファイル: GraphSpectrum.cs プロジェクト: tomas-pluskal/pwiz
        public static void MakeChromatogramInfo(SignedMz precursorMz, LibraryChromGroup chromGroup, LibraryChromGroup.ChromData chromData, out ChromatogramInfo chromatogramInfo, out TransitionChromInfo transitionChromInfo)
        {
            var crawPeakFinder = Crawdads.NewCrawdadPeakFinder();

            crawPeakFinder.SetChromatogram(chromGroup.Times, chromData.Intensities);
            var crawdadPeak =
                crawPeakFinder.GetPeak(
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.StartTime),
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.EndTime));
            var chromPeak = new ChromPeak(crawPeakFinder, crawdadPeak, 0, chromGroup.Times, chromData.Intensities, null);

            transitionChromInfo = new TransitionChromInfo(null, 0, chromPeak, new float?[0], Annotations.EMPTY,
                                                          UserSet.FALSE);
            var peaks  = new[] { chromPeak };
            var header = new ChromGroupHeaderInfo(precursorMz,
                                                  0,                       // file index
                                                  1,                       // numTransitions
                                                  0,                       // startTransitionIndex
                                                  peaks.Length,            // numPeaks
                                                  0,                       // startPeakIndex
                                                  0,                       // startscoreindex
                                                  0,                       // maxPeakIndex
                                                  chromGroup.Times.Length, // numPoints
                                                  0,                       // compressedSize
                                                  0,                       // uncompressedsize
                                                  0,                       //location
                                                  0, -1, -1, null, null);

            chromatogramInfo = new ChromatogramInfo(header,
                                                    new Dictionary <Type, int>(), 0,
                                                    new ChromCachedFile[0],
                                                    new[] { new ChromTransition(chromData.Mz, 0, 0, 0, ChromSource.unknown), },
                                                    peaks, null,
                                                    chromGroup.Times, new[] { chromData.Intensities }, null, null);
        }
コード例 #4
0
        public void ChromPeakAnalyzerWorkflowTest()
        {
            //Reference JIRA: https://jira.pnnl.gov/jira/browse/OMCS-884

            string testFile      = UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1;
            string peaksTestFile = UnitTesting2.FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500;
            Run    run           = new RunFactory().CreateRun(testFile);
            TargetedWorkflowParameters parameters      = new BasicTargetedWorkflowParameters();
            ChromPeakIqTarget          testTarget      = new ChromPeakIqTarget();
            ITheorFeatureGenerator     TheorFeatureGen = new JoshTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005);

            ChromPeak testPeak = new ChromPeak(5184, 840963, 50, 0);

            testTarget.SetWorkflow(new ChromPeakAnalyzerIqWorkflow(run, parameters));

            testTarget.Code                 = "NGIIMMENR";
            testTarget.EmpiricalFormula     = "C43H76N14O14S2";
            testTarget.MonoMassTheor        = 1076.510631;
            testTarget.ChromPeak            = testPeak;
            testTarget.ChargeState          = 1;
            testTarget.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(testTarget.EmpiricalFormula, testTarget.ChargeState);

            testTarget.DoWorkflow();

            IqResult result = testTarget.GetResult();

            Console.WriteLine("Fit Score: " + result.FitScore + " Flagged: " + result.IsIsotopicProfileFlagged);
        }
コード例 #5
0
        public static void MakeChromatogramInfo(double precursorMz, LibraryChromGroup chromGroup, LibraryChromGroup.ChromData chromData, out ChromatogramInfo chromatogramInfo, out TransitionChromInfo transitionChromInfo)
        {
            var crawPeakFinder = new CrawdadPeakFinder();

            crawPeakFinder.SetChromatogram(chromGroup.Times, chromData.Intensities);
            var crawdadPeak =
                crawPeakFinder.GetPeak(
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.StartTime),
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.EndTime));
            var chromPeak = new ChromPeak(crawPeakFinder, crawdadPeak, 0, chromGroup.Times, chromData.Intensities, null);

            transitionChromInfo = new TransitionChromInfo(null, 0, chromPeak, new float?[0], Annotations.EMPTY,
                                                          UserSet.FALSE);
            var peaks  = new[] { chromPeak };
            var header = new ChromGroupHeaderInfo5(new ChromGroupHeaderInfo(
                                                       (float)precursorMz, 0, 1, 0, peaks.Length, 0, 0,
                                                       chromGroup.Times.Length, 0, 0));

            chromatogramInfo = new ChromatogramInfo(header,
                                                    new Dictionary <Type, int>(), 0,
                                                    new ChromCachedFile[0],
                                                    new[] { new ChromTransition(chromData.Mz, 0, 0, 0, ChromSource.unknown), },
                                                    peaks, null,
                                                    chromGroup.Times, new[] { chromData.Intensities }, null, null);
        }
コード例 #6
0
 public TransitionChromInfo(ChromFileInfoId fileId, int optimizationStep, ChromPeak peak,
                            IList <float?> ratios, Annotations annotations, UserSet userSet)
     : this(fileId, optimizationStep, peak.MassError, peak.RetentionTime, peak.StartTime, peak.EndTime,
            peak.Area, peak.BackgroundArea, peak.Height, peak.Fwhm,
            peak.IsFwhmDegenerate, peak.IsTruncated, peak.Identified,
            ratios, annotations, userSet)
 {
 }
コード例 #7
0
        //TODO: remove code duplication (see DeconToolsPeakDetector)
        public override List <Peak> FindPeaks(XYData xyData, double xMin = 0, double xMax = 0)
        {
            var peakList = new List <Peak>();

            if (xyData == null)
            {
                return(peakList);
            }

            if (UseNewPeakDetector)
            {
                _peakDetectorV2.FindPeaks(xyData, xMin, xMax);
            }
            else
            {
                var xVals = xyData.Xvalues.ToList();
                var yVals = xyData.Yvalues.ToList();

                if (_oldPeakProcessor == null)
                {
                    _oldPeakProcessor = new PeakProcessor();
                }

                BackgroundIntensity = _oldPeakProcessor.GetBackgroundIntensity(yVals);
                _oldPeakProcessor.SetOptions(SigNoise, BackgroundIntensity * PeakBackgroundRatio, false, PeakFitType.Quadratic);

                //Find peaks using DeconEngine
                var largestXValue = xyData.Xvalues[xyData.Xvalues.Length - 1];

                try
                {
                    _oldPeakProcessor.DiscoverPeaks(xVals, yVals, 0, largestXValue);
                }
                catch (Exception ex)
                {
                    Logger.Instance.AddEntry("ChromPeakDetector failed: " + ex.Message, true);
                    throw;
                }

                _oldDeconEnginePeaklist = _oldPeakProcessor.PeakData.PeakTops;
                foreach (var peak in _oldDeconEnginePeaklist)
                {
                    var chromPeak = new ChromPeak
                    {
                        XValue        = peak.Mz, // here,  mz is actually the scan / or NET
                        Height        = (float)peak.Intensity,
                        SignalToNoise = peak.SignalToNoise,
                        Width         = (float)peak.FWHM
                    };

                    peakList.Add(chromPeak);
                }
            }

            //resultList.Run.PeakList = new List<IPeak>();

            return(peakList);
        }
コード例 #8
0
 public ChromPeakQualityData(ChromPeak peak)
 {
     InterferenceScore = 1; // worst possible
     FitScore          = 1; // worst possible
     Abundance         = 0;
     Peak = peak;
     IsotopicProfileFound     = false;
     IsIsotopicProfileFlagged = false;
 }
コード例 #9
0
ファイル: ChromData.cs プロジェクト: suchp-max/proteowizard
 private static short AddMassError(ICollection <short> massErrors10X, double massError)
 {
     if (massErrors10X != null)
     {
         short massError10X = ChromPeak.To10x(massError);
         massErrors10X.Add(massError10X);
         return(massError10X);
     }
     return(0);
 }
コード例 #10
0
        public static XYData GetXYDataForChromPeak(ChromPeak peak, Run run)
        {
            var    apex           = peak.XValue;
            double width          = peak.Width;
            var    peakWidthSigma = width / 2.35;       // width@half-height = 2.35σ (Gaussian peak theory)
            var    sixSigma       = 6 * peakWidthSigma; // width@base = 4σ (Gaussian peak theory)
            var    halfSixSigma   = sixSigma / 2.0;

            var minScan = apex - halfSixSigma;
            var maxScan = apex + halfSixSigma;

            var filteredXYData = run.XYData.TrimData(minScan, maxScan);

            return(filteredXYData);
        }
コード例 #11
0
 public void TestChromPeakOffsets()
 {
     Assert.AreEqual((IntPtr)0, Marshal.OffsetOf <ChromPeak>("_retentionTime"));
     Assert.AreEqual((IntPtr)4, Marshal.OffsetOf <ChromPeak>("_startTime"));
     Assert.AreEqual((IntPtr)8, Marshal.OffsetOf <ChromPeak>("_endTime"));
     Assert.AreEqual((IntPtr)12, Marshal.OffsetOf <ChromPeak>("_area"));
     Assert.AreEqual((IntPtr)16, Marshal.OffsetOf <ChromPeak>("_backgroundArea"));
     Assert.AreEqual((IntPtr)20, Marshal.OffsetOf <ChromPeak>("_height"));
     Assert.AreEqual((IntPtr)24, Marshal.OffsetOf <ChromPeak>("_fwhm"));
     Assert.AreEqual((IntPtr)28, Marshal.OffsetOf <ChromPeak>("_flagBits"));
     Assert.AreEqual((IntPtr)32, Marshal.OffsetOf <ChromPeak>("_pointsAcross"));
     Assert.AreEqual(32, ChromPeak.GetStructSize(CacheFormatVersion.Eleven));
     Assert.AreEqual(36, ChromPeak.GetStructSize(CacheFormatVersion.Twelve));
     Assert.AreEqual(Marshal.SizeOf <ChromPeak>(), ChromPeak.GetStructSize(CacheFormatVersion.CURRENT));
 }
コード例 #12
0
 public bool Equivalent(ChromFileInfoId fileId, int step, ChromPeak peak)
 {
     return(ReferenceEquals(fileId, FileId) &&
            step == OptimizationStep &&
            Equals(peak.MassError, MassError) &&
            peak.RetentionTime == RetentionTime &&
            peak.StartTime == StartRetentionTime &&
            peak.EndTime == EndRetentionTime &&
            peak.Area == Area &&
            peak.BackgroundArea == BackgroundArea &&
            peak.Height == Height &&
            peak.Fwhm == Fwhm &&
            peak.IsFwhmDegenerate == IsFwhmDegenerate &&
            Equals(peak.IsTruncated, IsTruncated) &&
            Equals(peak.Identified, Identified));
 }
コード例 #13
0
        public bool EquivalentTolerant(ChromFileInfoId fileId, int step, ChromPeak peak)
        {
            const double tol = 1e-4;

            return(ReferenceEquals(fileId, FileId) &&
                   step == OptimizationStep &&
                   Equals(peak.MassError, MassError) &&
                   IsEqualTolerant(peak.RetentionTime, RetentionTime, tol) &&
                   IsEqualTolerant(peak.StartTime, StartRetentionTime, tol) &&
                   IsEqualTolerant(peak.EndTime, EndRetentionTime, tol) &&
                   IsEqualTolerant(peak.Area, Area, tol * Area) &&
                   IsEqualTolerant(peak.BackgroundArea, BackgroundArea, tol * BackgroundArea) &&
                   IsEqualTolerant(peak.Height, Height, tol * Height) &&
                   (IsEqualTolerant(peak.Fwhm, Fwhm, tol * Fwhm) || Equals(peak.Fwhm, Fwhm)) &&
                   Equals(peak.IsFwhmDegenerate, IsFwhmDegenerate) &&
                   Equals(peak.IsTruncated, IsTruncated) &&
                   Equals(peak.Identified, Identified));
        }
コード例 #14
0
ファイル: GraphSpectrum.cs プロジェクト: rfellers/pwiz
        public static void MakeChromatogramInfo(SignedMz precursorMz, LibraryChromGroup chromGroup, LibraryChromGroup.ChromData chromData, out ChromatogramInfo chromatogramInfo, out TransitionChromInfo transitionChromInfo)
        {
            var timeIntensities = new TimeIntensities(chromGroup.Times, chromData.Intensities, null, null);
            var crawPeakFinder  = Crawdads.NewCrawdadPeakFinder();

            crawPeakFinder.SetChromatogram(chromGroup.Times, chromData.Intensities);
            var crawdadPeak =
                crawPeakFinder.GetPeak(
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.StartTime),
                    FindNearestIndex(chromGroup.Times, (float)chromGroup.EndTime));
            var chromPeak = new ChromPeak(crawPeakFinder, crawdadPeak, 0, timeIntensities, null);

            transitionChromInfo = new TransitionChromInfo(null, 0, chromPeak,
                                                          IonMobilityFilter.EMPTY, // CONSIDER(bspratt) IMS in chromatogram libraries?
                                                          new float?[0], Annotations.EMPTY,
                                                          UserSet.FALSE);
            var peaks  = new[] { chromPeak };
            var header = new ChromGroupHeaderInfo(precursorMz,
                                                  0,                                                    // file index
                                                  1,                                                    // numTransitions
                                                  0,                                                    // startTransitionIndex
                                                  peaks.Length,                                         // numPeaks
                                                  0,                                                    // startPeakIndex
                                                  0,                                                    // startscoreindex
                                                  0,                                                    // maxPeakIndex
                                                  chromGroup.Times.Length,                              // numPoints
                                                  0,                                                    // compressedSize
                                                  0,                                                    // uncompressedsize
                                                  0,                                                    //location
                                                  0, -1, -1, null, null, null, eIonMobilityUnits.none); // CONSIDER(bspratt) IMS in chromatogram libraries?
            var driftTimeFilter = IonMobilityFilter.EMPTY;                                              // CONSIDER(bspratt) IMS in chromatogram libraries?
            var groupInfo       = new ChromatogramGroupInfo(header,
                                                            new Dictionary <Type, int>(),
                                                            new byte[0],
                                                            new ChromCachedFile[0],
                                                            new[] { new ChromTransition(chromData.Mz, 0, (float)(driftTimeFilter.IonMobility.Mobility ?? 0), (float)(driftTimeFilter.IonMobilityExtractionWindowWidth ?? 0), ChromSource.unknown), },
                                                            peaks,
                                                            null)
            {
                TimeIntensitiesGroup = TimeIntensitiesGroup.Singleton(timeIntensities)
            };

            chromatogramInfo = new ChromatogramInfo(groupInfo, 0);
        }
コード例 #15
0
        public void ChromPeakAnalyzerWorkflowTest()
        {
            //Reference JIRA: https://jira.pnnl.gov/jira/browse/OMCS-884

            var testFile      = UnitTesting2.FileRefs.RawDataMSFiles.OrbitrapStdFile1;
            var peaksTestFile = UnitTesting2.FileRefs.PeakDataFiles.OrbitrapPeakFile_scans5500_6500;
            var run           = new RunFactory().CreateRun(testFile);
            TargetedWorkflowParameters parameters = new BasicTargetedWorkflowParameters();
            var testTarget = new ChromPeakIqTarget();
            ITheorFeatureGenerator TheorFeatureGen = new JoshTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005);

            var testPeak = new ChromPeak(5184, 840963, 50, 0);

            var executorBaseParameters = new BasicTargetedWorkflowExecutorParameters();
            var executor = new TopDownMSAlignExecutor(executorBaseParameters, run);

            executor.ChromSourceDataFilePath = peaksTestFile;

            var workflow = new ChromPeakAnalyzerIqWorkflow(run, parameters);

            testTarget.SetWorkflow(workflow);

            testTarget.ID                   = 1;
            testTarget.Code                 = "NGIIMMENR";
            testTarget.EmpiricalFormula     = "C43H76N14O14S2";
            testTarget.MonoMassTheor        = 1076.510631;
            testTarget.ChromPeak            = testPeak;
            testTarget.ChargeState          = 1;
            testTarget.TheorIsotopicProfile = TheorFeatureGen.GenerateTheorProfile(testTarget.EmpiricalFormula, testTarget.ChargeState);

            var      testTargetList = new List <IqTarget>();
            IqTarget testParent     = new IqChargeStateTarget();

            testParent.AddTarget(testTarget);
            testTargetList.Add(testTarget);

            executor.Execute(testTargetList);

            var result = testTarget.GetResult();

            Assert.NotNull(result.LCScanSetSelected);
            Assert.AreNotEqual(1, result.FitScore);
            Assert.AreEqual(true, result.IsotopicProfileFound);
        }
コード例 #16
0
ファイル: PeakIntegrator.cs プロジェクト: laeubisoft/pwiz
        /// <summary>
        /// Returns a ChromPeak and IFoundPeak that match the start and end times a particular other IFoundPeak
        /// that was found by Crawdad.
        /// </summary>
        public Tuple <ChromPeak, IFoundPeak> IntegrateFoundPeak(IFoundPeak peakMax, ChromPeak.FlagValues flags)
        {
            Assume.IsNotNull(PeakFinder);
            var interpolatedPeak = PeakFinder.GetPeak(peakMax.StartIndex, peakMax.EndIndex);

            if ((flags & ChromPeak.FlagValues.forced_integration) != 0 && ChromData.AreCoeluting(peakMax, interpolatedPeak))
            {
                flags &= ~ChromPeak.FlagValues.forced_integration;
            }

            var chromPeak = new ChromPeak(PeakFinder, interpolatedPeak, flags, InterpolatedTimeIntensities, RawTimeIntensities?.Times);

            if (TimeIntervals != null)
            {
                chromPeak = IntegratePeakWithoutBackground(InterpolatedTimeIntensities.Times[peakMax.StartIndex], InterpolatedTimeIntensities.Times[peakMax.EndIndex], flags);
            }

            return(Tuple.Create(chromPeak, interpolatedPeak));
        }
コード例 #17
0
ファイル: ChromGraphItem.cs プロジェクト: mdcallah/pwiz
        private void AddOriginalPeakAnnotation(ChromPeak bestPeak, GraphObjList annotations, GraphPane graphPane)
        {
            var start  = ScaleRetentionTime(bestPeak.StartTime);
            var end    = ScaleRetentionTime(bestPeak.EndTime);
            var width  = end.DisplayTime - start.DisplayTime;
            var height = graphPane.YAxis.Scale.Max;
            var originalPeakShadingBox = new BoxObj(start.DisplayTime, graphPane.YAxis.Scale.Max, width, height)
            {
                Fill   = new Fill(Color.FromArgb(30, COLOR_ORIGINAL_PEAK_SHADE)),
                ZOrder = ZOrder.F_BehindGrid,
                Border = new Border {
                    IsVisible = false
                },
                IsClippedToChartRect = true,
                Tag = new GraphObjTag(this, GraphObjType.original_peak_shading, start, end)
            };

            annotations.Add(originalPeakShadingBox);
        }
コード例 #18
0
ファイル: ChromPeakTest.cs プロジェクト: laeubisoft/pwiz
        public void TestChromPeakIntegration()
        {
            var times           = Enumerable.Range(0, 12).Select(i => (float)i).ToArray();
            var timeIntensities = new TimeIntensities(times, times.Select(t => 36 - (t - 6) * (t - 6)), null, null);
            var chromPeak       = new ChromPeak(timeIntensities, 1, 11, 0);

            Assert.AreEqual(36f, chromPeak.Height);
            Assert.AreEqual(11, timeIntensities.Intensities[1]);
            Assert.AreEqual(20, timeIntensities.Intensities[2]);
            var fwhmStart = (7 * 2 + 2 * 1) / 9.0;

            Assert.AreEqual(20, timeIntensities.Intensities[10]);
            Assert.AreEqual(11, timeIntensities.Intensities[11]);
            var fwhmEnd = (7 * 10 + 2 * 11) / 9.0;

            Assert.AreEqual(fwhmEnd - fwhmStart, chromPeak.Fwhm, .00001);
            Assert.AreEqual(false, chromPeak.IsFwhmDegenerate);
            var chromPeak2 = new ChromPeak(timeIntensities, 2, 10, 0);

            Assert.AreEqual(8, chromPeak2.Fwhm);
            Assert.AreEqual(true, chromPeak2.IsFwhmDegenerate);
        }
コード例 #19
0
        public TransitionChromInfo ChangePeak(ChromPeak peak, UserSet userSet)
        {
            var chromInfo = ImClone(this);

            chromInfo.MassError          = peak.MassError;
            chromInfo.RetentionTime      = peak.RetentionTime;
            chromInfo.StartRetentionTime = peak.StartTime;
            chromInfo.EndRetentionTime   = peak.EndTime;
            chromInfo.Area           = peak.Area;
            chromInfo.BackgroundArea = peak.BackgroundArea;
            chromInfo.Height         = peak.Height;
            chromInfo.Fwhm           = peak.Fwhm;
            // Crawdad can set FWHM to NaN. Need to protect against that here.
            if (float.IsNaN(peak.Fwhm))
            {
                chromInfo.Fwhm = 0;
            }
            chromInfo.IsFwhmDegenerate = peak.IsFwhmDegenerate;
            chromInfo.IsTruncated      = peak.IsTruncated;
            chromInfo.Identified       = peak.Identified;
            chromInfo.UserSet          = userSet;
            return(chromInfo);
        }
コード例 #20
0
        private static bool IntersectPeaks(ChromPeak peak, TransitionChromInfo chromInfo)
        {
            if (chromInfo == null)
                return false;

            // Allow start and end to share the same time, but nothing more.
            return Math.Min(chromInfo.EndRetentionTime, peak.EndTime) -
                   Math.Max(chromInfo.StartRetentionTime, peak.StartTime) > 0;
        }
コード例 #21
0
            public void WriteChromGroup(ChromatogramGroupInfo originalChromGroup, MinimizedChromGroup minimizedChromGroup)
            {
                if (minimizedChromGroup.RetainedTransitionIndexes.Count == 0)
                {
                    return;
                }

                var originalHeader       = originalChromGroup.Header;
                int fileIndex            = originalHeader.FileIndex;
                int startTransitionIndex = _transitions.Count;
                int startPeakIndex       = _peakCount;
                int startScoreIndex      = _scoreCount;

                for (int iPeak = 0; iPeak < originalHeader.NumPeaks; iPeak++)
                {
                    int iScores = originalHeader.StartScoreIndex + iPeak * _scoreTypes.Count;
                    var scores  = _originalCache.GetCachedScores(iScores).ToArray();
                    PrimitiveArrays.Write(_outputStreamScores, scores);
                    _scoreCount += scores.Length;
                }
                int numPoints           = minimizedChromGroup.OptimizedLastScan - minimizedChromGroup.OptimizedFirstScan + 1;
                var retainedPeakIndexes = new HashSet <int>();

                if (minimizedChromGroup.OptimizedStartTime.HasValue && minimizedChromGroup.OptimizedEndTime.HasValue)
                {
                    for (int iPeak = 0; iPeak < originalHeader.NumPeaks; iPeak++)
                    {
                        bool outsideRange = false;
                        for (var transitionIndex = 0; transitionIndex < originalHeader.NumTransitions; transitionIndex++)
                        {
                            if (!minimizedChromGroup.RetainedTransitionIndexes.Contains(transitionIndex))
                            {
                                continue;
                            }

                            var peak = _originalCache.GetPeak(originalHeader.StartPeakIndex +
                                                              transitionIndex * originalHeader.NumPeaks + iPeak);
                            if (peak.StartTime < minimizedChromGroup.OptimizedStartTime.Value ||
                                peak.EndTime > minimizedChromGroup.OptimizedEndTime.Value)
                            {
                                outsideRange = true;
                                break;
                            }
                        }
                        if (!outsideRange)
                        {
                            retainedPeakIndexes.Add(iPeak);
                        }
                    }
                }
                else
                {
                    retainedPeakIndexes.UnionWith(Enumerable.Range(0, originalHeader.NumPeaks));
                }
                int numPeaks = retainedPeakIndexes.Count;
                int maxPeakIndex;

                if (retainedPeakIndexes.Contains(originalHeader.MaxPeakIndex))
                {
                    maxPeakIndex = retainedPeakIndexes.Count(index => index < originalHeader.MaxPeakIndex);
                }
                else
                {
                    maxPeakIndex = -1;
                }
                long location = _outputStream.Position;

                float[]        times         = originalChromGroup.Times.Skip(minimizedChromGroup.OptimizedFirstScan).Take(numPoints).ToArray();
                List <float[]> intensities   = new List <float[]>();
                List <short[]> massError10Xs = originalChromGroup.MassError10XArray != null
                                                  ? new List <short[]>()
                                                  : null;

                int[][] scanIndexes = null;
                if (originalChromGroup.ScanIndexes != null)
                {
                    scanIndexes = new int[originalChromGroup.ScanIndexes.Length][];
                    for (int i = 0; i < scanIndexes.Length; i++)
                    {
                        if (originalChromGroup.ScanIndexes[i] != null)
                        {
                            scanIndexes[i] =
                                originalChromGroup.ScanIndexes[i].Skip(minimizedChromGroup.OptimizedFirstScan)
                                .Take(numPoints)
                                .ToArray();
                        }
                    }
                }

                foreach (var originalIndex in minimizedChromGroup.RetainedTransitionIndexes)
                {
                    _transitions.Add(_originalCache.GetTransition(originalIndex + originalHeader.StartTransitionIndex));
                    for (int originalPeakIndex = 0; originalPeakIndex < originalHeader.NumPeaks; originalPeakIndex++)
                    {
                        if (!retainedPeakIndexes.Contains(originalPeakIndex))
                        {
                            continue;
                        }

                        var originalPeak = _originalCache.GetPeak(originalHeader.StartPeakIndex +
                                                                  originalIndex * originalHeader.NumPeaks +
                                                                  originalPeakIndex);
                        _peakCount++;
                        ChromPeak.WriteArray(_outputStreamPeaks.SafeFileHandle, new[] { originalPeak });
                    }
                    intensities.Add(originalChromGroup.IntensityArray[originalIndex]
                                    .Skip(minimizedChromGroup.OptimizedFirstScan)
                                    .Take(numPoints).ToArray());
                    if (massError10Xs != null)
                    {
                        massError10Xs.Add(originalChromGroup.MassError10XArray[originalIndex]
                                          .Skip(minimizedChromGroup.OptimizedFirstScan)
                                          .Take(numPoints).ToArray());
                    }
                }
                var massError10XArray = massError10Xs != null?massError10Xs.ToArray() : null;

                byte[] points = ChromatogramCache.TimeIntensitiesToBytes(times, intensities.ToArray(), massError10XArray, scanIndexes);
                // Compress the data (can be huge for AB data with lots of zeros)
                byte[] pointsCompressed = points.Compress(3);
                int    lenCompressed    = pointsCompressed.Length;

                _outputStream.Write(pointsCompressed, 0, lenCompressed);
                var header = new ChromGroupHeaderInfo5(originalHeader.Precursor,
                                                       originalHeader.TextIdIndex,
                                                       originalHeader.TextIdLen,
                                                       fileIndex,
                                                       _transitions.Count - startTransitionIndex,
                                                       startTransitionIndex,
                                                       numPeaks,
                                                       startPeakIndex,
                                                       startScoreIndex,
                                                       maxPeakIndex,
                                                       numPoints,
                                                       pointsCompressed.Length,
                                                       location,
                                                       originalHeader.Flags,
                                                       originalHeader.StatusId,
                                                       originalHeader.StatusRank);

                _chromGroupHeaderInfos.Add(header);
            }
コード例 #22
0
ファイル: ChromData.cs プロジェクト: suchp-max/proteowizard
 public ChromPeak CalcChromPeak(CrawdadPeak peakMax, ChromPeak.FlagValues flags)
 {
     _chromPeak = Data.CalcChromPeak(peakMax, flags, out _crawPeak);
     return(_chromPeak);
 }
コード例 #23
0
 private static void WriteMassErrors(Stream stream, IList <float> values)
 {
     PrimitiveArrays.Write(stream, values.Select(value => ChromPeak.To10x(value)).ToArray());
 }
コード例 #24
0
        public static long CacheSize(SrmDocument docInitial, long format3Size, int groupCount, int tranCount, int peakCount)
        {
            long cacheSize       = format3Size;
            int  fileCachedCount = docInitial.Settings.MeasuredResults.MSDataFileInfos.Count();

            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_3)
            {
                // Cache version 4 stores instrument information, and is bigger in size.
                cacheSize += sizeof(int) * fileCachedCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_4)
            {
                // Cache version 5 adds an int for flags for each file
                // Allow for a difference in sizes due to the extra information.
                int fileFlagsSize = sizeof(int) * fileCachedCount;
                // And SeqIndex, SeqCount, StartScoreIndex and padding
                var deltaSize5 = ChromGroupHeaderInfo.GetStructSize(CacheFormatVersion.Five) -
                                 ChromGroupHeaderInfo.GetStructSize(CacheFormatVersion.Four);
                int groupHeadersSize = deltaSize5 * groupCount;
                // And flags for each transition
                int transitionFlagsSize = ChromTransition5.DeltaSize5 * tranCount;
                // And num seq byte count, seq location, score types, num scores and score location
                const int headerScoreSize = sizeof(int) + sizeof(long) + sizeof(int) + sizeof(int) + sizeof(long);
                cacheSize += groupHeadersSize + fileFlagsSize + transitionFlagsSize + headerScoreSize;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_5)
            {
                // Cache version 6 adds status graph dimensions for every file
                cacheSize += sizeof(float) * 2 * fileCachedCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_6)
            {
                // Cache version 7 adds ion mobility information
                cacheSize += sizeof(float) * 2 * tranCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_8)
            {
                // Cache version 9 adds scan id values for every file
                cacheSize += (sizeof(int) + sizeof(long)) * fileCachedCount;
                // And scan ids location to global header
                cacheSize += sizeof(long);
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE >= ChromatogramCache.FORMAT_VERSION_CACHE_11)
            {
                // Version 11 adds uncompressed buffer size for convenience, and some time span metadata
                cacheSize += ChromGroupHeaderInfo.DeltaSize11 * groupCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE >= CacheFormatVersion.Twelve)
            {
                cacheSize += peakCount * (ChromPeak.GetStructSize(CacheFormatVersion.Twelve) -
                                          ChromPeak.GetStructSize(CacheFormatVersion.Eleven));
                cacheSize += tranCount *
                             (ChromTransition.GetStructSize(CacheFormatVersion.Twelve) -
                              ChromTransition.GetStructSize(CacheFormatVersion.Eleven));
            }
            cacheSize += fileCachedCount *
                         (CachedFileHeaderStruct.GetStructSize(ChromatogramCache.FORMAT_VERSION_CACHE) -
                          CachedFileHeaderStruct.GetStructSize(CacheFormatVersion.Nine));
            cacheSize += CacheHeaderStruct.GetStructSize(ChromatogramCache.FORMAT_VERSION_CACHE) -
                         CacheHeaderStruct.GetStructSize(ChromatogramCache.FORMAT_VERSION_CACHE_11);
            return(cacheSize);
        }
コード例 #25
0
ファイル: ChromGraphItem.cs プロジェクト: mdcallah/pwiz
        public ChromGraphItem(TransitionGroupDocNode transitionGroupNode,
                              TransitionDocNode transition,
                              ChromatogramInfo chromatogram,
                              TransitionChromInfo tranPeakInfo,
                              IRegressionFunction timeRegressionFunction,
                              bool[] annotatePeaks,
                              double[] dotProducts,
                              double bestProduct,
                              bool isFullScanMs,
                              bool isSummary,
                              RawTimesInfoItem?displayRawTimes,
                              int step,
                              Color color,
                              float fontSize,
                              int width,
                              FullScanInfo fullScanInfo = null)
        {
            TransitionGroupNode    = transitionGroupNode;
            TransitionNode         = transition;
            Chromatogram           = chromatogram;
            TransitionChromInfo    = tranPeakInfo;
            TimeRegressionFunction = timeRegressionFunction;
            Color        = color;
            FullScanInfo = fullScanInfo;

            _step     = step;
            _fontSpec = CreateFontSpec(color, fontSize);
            _width    = width;

            _dotProducts     = dotProducts;
            _bestProduct     = bestProduct;
            _isFullScanMs    = isFullScanMs;
            _isSummary       = isSummary;
            _displayRawTimes = displayRawTimes;

            _arrayLabelIndexes = new int[annotatePeaks.Length];

            if (chromatogram == null)
            {
                _measuredTimes = new double[0];
                _displayTimes  = _measuredTimes;
                _intensities   = new double[0];
            }
            else
            {
                // Cache values early to avoid accessing slow enumerators
                // which show up under profiling.
                Chromatogram.AsArrays(out _measuredTimes, out _intensities);
                if (TimeRegressionFunction == null)
                {
                    _displayTimes = _measuredTimes;
                }
                else
                {
                    _displayTimes = _measuredTimes.Select(TimeRegressionFunction.GetY).ToArray();
                }
                // Add peak times to hash set for labeling
                int iLastStart = 0;
                for (int i = 0; i < chromatogram.NumPeaks; i++)
                {
                    int maxIndex = -1;
                    if (annotatePeaks[i])
                    {
                        ChromPeak peak = chromatogram.GetPeak(i);
                        maxIndex = GetMaxIndex(peak.StartTime, peak.EndTime, ref iLastStart);
                    }
                    _arrayLabelIndexes[i] = maxIndex;
                    if (maxIndex != -1 && !_annotatedTimes.ContainsKey(maxIndex))
                    {
                        _annotatedTimes.Add(maxIndex, i);
                    }
                }

                // Calculate best peak index
                if (tranPeakInfo != null)
                {
                    iLastStart         = 0;
                    _bestPeakTimeIndex = GetMaxIndex(tranPeakInfo.StartRetentionTime, tranPeakInfo.EndRetentionTime, ref iLastStart);
                }
            }
        }
コード例 #26
0
ファイル: ChromGraphItem.cs プロジェクト: mdcallah/pwiz
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g,
                                            MSPointList pointList, GraphObjList annotations)
        {
            if (Chromatogram == null)
            {
                return;
            }


            // Calculate maximum y for potential retention time indicators
            PointF ptTop = new PointF(0, graphPane.Chart.Rect.Top);

            if (GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                if (RetentionMsMs != null)
                {
                    foreach (double retentionTime in RetentionMsMs)
                    {
                        Color color = COLOR_MSMSID_TIME;
                        if (SelectedRetentionMsMs.HasValue && Equals((float)retentionTime, (float)SelectedRetentionMsMs))
                        {
                            color = ColorSelected;
                        }
                        AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop,
                                                   Resources.ChromGraphItem_AddAnnotations_ID, GraphObjType.ms_ms_id, color,
                                                   ScaleRetentionTime(retentionTime));
                    }
                }
                if (MidasRetentionMsMs != null)
                {
                    foreach (var retentionTime in MidasRetentionMsMs)
                    {
                        var color = SelectedRetentionMsMs.HasValue && Equals((float)retentionTime, (float)SelectedRetentionMsMs)
                            ? ColorSelected
                            : COLOR_MSMSID_TIME;
                        AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop, string.Empty, GraphObjType.midas_spectrum, color, ScaleRetentionTime(retentionTime));
                    }
                }
                if (AlignedRetentionMsMs != null)
                {
                    foreach (var time in AlignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line       = new LineObj(COLOR_ALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                                     scaledTime.DisplayTime, 1)
                        {
                            ZOrder               = ZOrder.F_BehindGrid,
                            Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.aligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
                if (UnalignedRetentionMsMs != null)
                {
                    foreach (var time in UnalignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line       = new LineObj(COLOR_UNALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                                     scaledTime.DisplayTime, 1)
                        {
                            ZOrder               = ZOrder.F_BehindGrid,
                            Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.unaligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
            }

            // Draw retention time indicator, if set
            if (RetentionPrediction.HasValue)
            {
                double time = RetentionPrediction.Value;

                // Create temporary label to calculate positions
                if (GraphChromatogram.ShowRT != ShowRTChrom.none)
                {
                    AddRetentionTimeAnnotation(graphPane,
                                               g,
                                               annotations,
                                               ptTop,
                                               Resources.ChromGraphItem_AddAnnotations_Predicted,
                                               GraphObjType.predicted_rt_window,
                                               COLOR_RETENTION_TIME,
                                               ScaleRetentionTime(time));
                }

                // Draw background for retention time window
                if (RetentionWindow > 0)
                {
                    double x1  = ScaleRetentionTime(time - RetentionWindow / 2).DisplayTime;
                    double x2  = ScaleRetentionTime(time + RetentionWindow / 2).DisplayTime;
                    BoxObj box = new BoxObj(x1, 0, x2 - x1, 1,
                                            COLOR_RETENTION_WINDOW, COLOR_RETENTION_WINDOW)
                    {
                        Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                        IsClippedToChartRect = true,
                        ZOrder = ZOrder.F_BehindGrid
                    };
                    annotations.Add(box);
                }
            }

            if (RetentionExplicit != null && GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                // Create temporary label to calculate positions
                AddRetentionTimeAnnotation(graphPane,
                                           g,
                                           annotations,
                                           ptTop,
                                           Resources.ChromGraphItem_AddAnnotations_Explicit,
                                           GraphObjType.predicted_rt_window,
                                           COLOR_RETENTION_TIME,
                                           ScaleRetentionTime(RetentionExplicit.RetentionTime));
            }

            for (int i = 0, len = Chromatogram.NumPeaks; i < len; i++)
            {
                if (_arrayLabelIndexes[i] == -1)
                {
                    continue;
                }

                double maxIntensity = _intensities[_arrayLabelIndexes[i]];

                // Show peak extent indicators, if they are far enough apart
                ChromPeak peak = Chromatogram.GetPeak(i);
                AddPeakBoundaries(graphPane, annotations, false,
                                  ScaleRetentionTime(peak.StartTime), ScaleRetentionTime(peak.EndTime), maxIntensity);
            }
        }
コード例 #27
0
ファイル: CacheFormat.cs プロジェクト: laeubisoft/pwiz
 public IItemSerializer <ChromPeak> ChromPeakSerializer()
 {
     return(ChromPeak.StructSerializer(ChromPeakSize));
 }
コード例 #28
0
        public DocNode ChangePeak(int indexSet, ChromFileInfoId fileId, int step, ChromPeak peak, int ratioCount, UserSet userSet)
        {
            if (Results == null)
            {
                return(this);
            }

            var listChromInfo    = Results[indexSet];
            var listChromInfoNew = new List <TransitionChromInfo>();

            if (listChromInfo == null)
            {
                listChromInfoNew.Add(CreateChromInfo(fileId, step, peak, ratioCount, userSet));
            }
            else
            {
                bool peakAdded = false;
                foreach (var chromInfo in listChromInfo)
                {
                    // Replace an existing entry with same index values
                    if (ReferenceEquals(chromInfo.FileId, fileId) && chromInfo.OptimizationStep == step)
                    {
                        // Something is wrong, if the value has already been added (duplicate peak? out of order?)
                        if (peakAdded)
                        {
                            throw new InvalidDataException(string.Format(Resources.TransitionDocNode_ChangePeak_Duplicate_or_out_of_order_peak_in_transition__0_,
                                                                         FragmentIonName));
                        }

                        // If the target peak is exactly the same as the proposed change and userSet is not overriding,
                        // simply return the original node unchanged
                        if (chromInfo.EquivalentTolerant(fileId, step, peak) && !chromInfo.UserSet.IsOverride(userSet))
                        {
                            return(this);
                        }

                        listChromInfoNew.Add(chromInfo.ChangePeak(peak, userSet));
                        peakAdded = true;
                    }
                    else
                    {
                        // Entries should be ordered, so if the new entry has not been added
                        // when an entry past it is seen, then add the new entry.
                        if (!peakAdded &&
                            chromInfo.FileIndex >= fileId.GlobalIndex &&
                            chromInfo.OptimizationStep > step)
                        {
                            listChromInfoNew.Add(CreateChromInfo(fileId, step, peak, ratioCount, userSet));
                            peakAdded = true;
                        }
                        listChromInfoNew.Add(chromInfo);
                    }
                }
                // Finally, make sure the peak is added
                if (!peakAdded)
                {
                    listChromInfoNew.Add(CreateChromInfo(fileId, step, peak, ratioCount, userSet));
                }
            }

            return(ChangeResults((Results <TransitionChromInfo>)
                                 Results.ChangeAt(indexSet, new ChromInfoList <TransitionChromInfo>(listChromInfoNew))));
        }
コード例 #29
0
 private static TransitionChromInfo CreateChromInfo(ChromFileInfoId fileId, int step, ChromPeak peak, int ratioCount, UserSet userSet)
 {
     return(new TransitionChromInfo(fileId, step, peak, new float?[ratioCount], Annotations.EMPTY, userSet));
 }
コード例 #30
0
        protected override void UpdateResultWithChromPeakAndLCScanInfo(TargetedResultBase result, ChromPeak bestPeak)
        {
            var uimfRun = result.Run as UIMFRun;

            result.ChromPeakSelected = bestPeak;

            result.ScanSet = new ScanSet(uimfRun.CurrentScanSet.PrimaryScanNumber);
        }
コード例 #31
0
        private bool JoinNextPart()
        {
            // Check for cancellation on every part.
            if (_loader.IsCanceled)
            {
                _loader.UpdateProgress(_status = _status.Cancel());
                Complete(null);
                return(false);
            }

            if (_currentPartIndex >= CacheFilePaths.Count)
            {
                Complete(null);
                return(false);
            }

            // If not cancelled, update progress.
            string cacheFilePath = CacheFilePaths[_currentPartIndex];
            string message       = string.Format(Resources.ChromCacheJoiner_JoinNextPart_Joining_file__0__, cacheFilePath);
            int    percent       = _currentPartIndex * 100 / CacheFilePaths.Count;

            _status = _status.ChangeMessage(message).ChangePercentComplete(percent);
            _loader.UpdateProgress(_status);

            try
            {
                using (var inStream = _loader.StreamManager.CreateStream(cacheFilePath, FileMode.Open, false))
                {
                    if (_fs.Stream == null)
                    {
                        _fs.Stream = _loader.StreamManager.CreateStream(_fs.SafeName, FileMode.Create, true);
                    }

                    ChromatogramCache.RawData rawData;
                    long bytesData = ChromatogramCache.LoadStructs(inStream, out rawData);

                    // If joining, then format version should have already been checked.
                    Assume.IsTrue(ChromatogramCache.IsVersionCurrent(rawData.FormatVersion) ||
                                  // WatersCacheTest uses older format partial caches
                                  rawData.FormatVersion == ChromatogramCache.FORMAT_VERSION_CACHE_2);

                    int  offsetFiles       = _listCachedFiles.Count;
                    int  offsetTransitions = _listTransitions.Count;
                    int  offsetPeaks       = _peakCount;
                    int  offsetScores      = _scoreCount;
                    long offsetPoints      = _fs.Stream.Position;

                    // Scan ids
                    long offsetScanIds = _fsScans.Stream.Position;
                    _listCachedFiles.AddRange(rawData.ChromCacheFiles.Select(f => f.RelocateScanIds(f.LocationScanIds + offsetScanIds)));
                    if (rawData.CountBytesScanIds > 0)
                    {
                        inStream.Seek(rawData.LocationScanIds, SeekOrigin.Begin);
                        inStream.TransferBytes(_fsScans.Stream, rawData.CountBytesScanIds);
                    }

                    _peakCount += rawData.ChromatogramPeaks.Length;
                    rawData.ChromatogramPeaks.WriteArray(block => ChromPeak.WriteArray(_fsPeaks.FileStream.SafeFileHandle, block));
                    _listTransitions.AddRange(rawData.ChromTransitions);
                    // Initialize the score types the first time through
                    if (_scoreTypesCount == -1)
                    {
                        _listScoreTypes.AddRange(rawData.ScoreTypes);
                        _scoreTypesCount = _listScoreTypes.Count;
                    }
                    else if (!ArrayUtil.EqualsDeep(_listScoreTypes, rawData.ScoreTypes))
                    {
                        // If the existing score types in the caches are not the same, the caches cannot be joined
                        if (_listScoreTypes.Intersect(rawData.ScoreTypes).Count() != _listScoreTypes.Count)
                        {
                            throw new InvalidDataException("Data cache files with different score types cannot be joined.");    // Not L10N
                        }
                    }
                    _scoreCount += rawData.Scores.Length;
                    rawData.Scores.WriteArray(block => PrimitiveArrays.Write(_fsScores.Stream, block));

                    for (int i = 0; i < rawData.ChromatogramEntries.Length; i++)
                    {
                        rawData.RecalcEntry(i,
                                            offsetFiles,
                                            offsetTransitions,
                                            offsetPeaks,
                                            offsetScores,
                                            offsetPoints,
                                            _dictTextIdToByteIndex,
                                            _listTextIdBytes);
                    }
                    _listGroups.AddRange(rawData.ChromatogramEntries);

                    inStream.Seek(0, SeekOrigin.Begin);

                    long copyBytes = bytesData;
                    while (copyBytes > 0)
                    {
                        int read = inStream.Read(_buffer, 0, (int)Math.Min(_buffer.Length, copyBytes));
                        _fs.Stream.Write(_buffer, 0, read);
                        copyBytes -= read;
                    }

                    _currentPartIndex++;
                    return(true);
                }
            }
            catch (InvalidDataException x)
            {
                Complete(x);
            }
            catch (IOException x)
            {
                Complete(x);
            }
            catch (Exception x)
            {
                Complete(new Exception(String.Format(Resources.ChromCacheJoiner_JoinNextPart_Failed_to_create_cache__0__, CachePath), x));
            }
            return(false);
        }