예제 #1
0
        public override bool GetChromatogram(
            int id,
            Target modifiedSequence,
            Color peptideColor,
            out ChromExtra extra,
            out TimeIntensities timeIntensities)
        {
            bool loaded = false;

            extra           = null;
            timeIntensities = null;
            int idRemain = id;

            for (int iTaskList = 0; iTaskList < _chromatogramRequestProviders.Length; iTaskList++)
            {
                ChromatogramRequestProvider requestProvider = _chromatogramRequestProviders[iTaskList];
                if (requestProvider.ChromKeys.Count <= idRemain)
                {
                    idRemain -= requestProvider.ChromKeys.Count;
                    continue;
                }
                ChromTaskList chromTaskList = _chromTaskLists[iTaskList];
                if (null == chromTaskList)
                {
                    chromTaskList = _chromTaskLists[iTaskList] = new ChromTaskList(CheckCancelled, _document, _chorusAccount, requestProvider.ChorusUrl, ChromTaskList.ChunkChromatogramRequest(requestProvider.GetChromatogramRequest(), 1000));
                    chromTaskList.SetMinimumSimultaneousTasks(3);
                }
                ChromKey chromKey = requestProvider.ChromKeys[idRemain];
                loaded = chromTaskList.GetChromatogram(chromKey, out timeIntensities);
                if (loaded)
                {
                    extra = new ChromExtra(id, chromKey.Precursor == 0 ? 0 : -1);
                    if (chromKey.Precursor.IsNegative)
                    {
                        _sourceHasNegativePolarityData = true;
                    }
                    else
                    {
                        _sourceHasPositivePolarityData = true;
                    }
                    if (timeIntensities.NumPoints > 0 && Status is ChromatogramLoadingStatus)
                    {
                        ((ChromatogramLoadingStatus)Status).Transitions.AddTransition(
                            modifiedSequence,
                            peptideColor,
                            extra.StatusId,
                            extra.StatusRank,
                            timeIntensities.Times,
                            timeIntensities.Intensities);
                    }
                }
                break;
            }
            int percentComplete = _chromTaskLists.Sum(taskList => taskList == null ? 0 : taskList.PercentComplete) /
                                  _chromTaskLists.Length;

            percentComplete = Math.Min(percentComplete, 99);
            SetPercentComplete(percentComplete);
            return(loaded);
        }
예제 #2
0
        //[TestMethod]
        public void TestDdaSmall()
        {
            ChorusAccount TEST_ACCOUNT = new ChorusAccount("https://chorusproject.org", "*****@*****.**", "pwd");
            var           stream       = typeof(ChromTaskListTest).Assembly.GetManifestResourceStream(typeof(ChromTaskListTest),
                                                                                                      "DdaSmall.ChorusRequest.xml");

            Assert.IsNotNull(stream);
            var chromatogramRequest = (ChromatogramRequestDocument) new XmlSerializer(typeof(ChromatogramRequestDocument)).Deserialize(stream);
            var chromTaskList       = new ChromTaskList(() => { }, new SrmDocument(SrmSettingsList.GetDefault()), TEST_ACCOUNT,
                                                        TEST_ACCOUNT.GetChorusUrl().SetFileId(28836), ChromTaskList.ChunkChromatogramRequest(chromatogramRequest, 100));

            chromTaskList.SetMinimumSimultaneousTasks(10);
            var failedTasks = new HashSet <ChromatogramGeneratorTask>();

            foreach (var chromKey in chromTaskList.ChromKeys)
            {
                TimeIntensities timeIntensities;
                chromTaskList.GetChromatogram(chromKey, out timeIntensities);
                if (null == timeIntensities)
                {
                    var task = chromTaskList.GetGeneratorTask(chromKey);
                    if (failedTasks.Add(task))
                    {
                        var memoryStream = new MemoryStream();
                        var xmlWriter    = XmlWriter.Create(memoryStream, new XmlWriterSettings {
                            Encoding = Encoding.UTF8
                        });
                        new XmlSerializer(typeof(ChromatogramRequestDocument)).Serialize(xmlWriter, task.ChromatogramRequestDocument);
                        Console.Out.WriteLine("Failed to get data for {0}", Encoding.UTF8.GetString(memoryStream.ToArray()));
                    }
                }
            }
            Assert.AreEqual(0, failedTasks.Count);
        }
// Disabled 20170131 because Skyline Chorus API is offline
//        [TestMethod] TODO(nicksh) re-enable when Chorus is reliable
        public void TestThermoDIAChunked()
        {
            if (!RunPerfTests)
            {
                return; // PerfTests only run when the global "allow perf tests" flag is set
            }
            var xmlSerializer = new XmlSerializer(typeof(ChromatogramRequestDocument));
            var stream        = typeof(PerfChorusGenerateChromatograms).Assembly.GetManifestResourceStream(
                typeof(PerfChorusGenerateChromatograms), "ThermoDIA.ChorusRequest.xml");

            Assert.IsNotNull(stream);
            var chromatogramRequestDocument = (ChromatogramRequestDocument)xmlSerializer.Deserialize(stream);
            var chorusUrl   = TEST_ACCOUNT.GetChorusUrl().SetFileId(28836);
            var srmDocument = new SrmDocument(SrmSettingsList.GetDefault());

            foreach (int chunkChromatogramCount in new[] { 50, 100, 150, 200, 300 })
            {
                ChromTaskList chromTaskList = new ChromTaskList(() => { }, srmDocument, TEST_ACCOUNT, chorusUrl, ChromTaskList.ChunkChromatogramRequest(chromatogramRequestDocument, chunkChromatogramCount));
                chromTaskList.SetMinimumSimultaneousTasks(30);
                DateTime startTime = DateTime.Now;
                while (chromTaskList.PercentComplete < 100)
                {
                    Thread.Sleep(100);
                }
                DateTime endTime = DateTime.Now;
                AssertEx.AreNoExceptions(chromTaskList.ListExceptions());
                Console.Out.WriteLine("*******************************************");
                Console.Out.WriteLine("Chromatograms per chunk: {0}", chunkChromatogramCount);
                Console.Out.WriteLine("Number of chunks: {0}", chromTaskList.TaskCount);
                Console.Out.WriteLine("Elapsed time {0}", endTime.Subtract(startTime));
                Console.Out.WriteLine("*******************************************");
            }
        }
예제 #4
0
        public override bool GetChromatogram(
            int id,
            string modifiedSequence,
            Color peptideColor,
            out ChromExtra extra,
            out float[] times,
            out int[] scanIndexes,
            out float[] intensities,
            out float[] massErrors)
        {
            bool loaded = false;

            extra       = null;
            times       = null;
            scanIndexes = null;
            intensities = null;
            massErrors  = null;
            int idRemain = id;

            for (int iTaskList = 0; iTaskList < _chromatogramRequestProviders.Length; iTaskList++)
            {
                ChromatogramRequestProvider requestProvider = _chromatogramRequestProviders[iTaskList];
                if (requestProvider.ChromKeys.Count <= idRemain)
                {
                    idRemain -= requestProvider.ChromKeys.Count;
                    continue;
                }
                ChromTaskList chromTaskList = _chromTaskLists[iTaskList];
                if (null == chromTaskList)
                {
                    chromTaskList = _chromTaskLists[iTaskList] = new ChromTaskList(CheckCancelled, _document, _chorusAccount, requestProvider.ChorusUrl, ChromTaskList.ChunkChromatogramRequest(requestProvider.GetChromatogramRequest(), 1000));
                    chromTaskList.SetMinimumSimultaneousTasks(3);
                }
                ChromKey chromKey = requestProvider.ChromKeys[idRemain];
                loaded = chromTaskList.GetChromatogram(chromKey, out times, out scanIndexes, out intensities, out massErrors);
                if (loaded)
                {
                    extra = new ChromExtra(id, chromKey.Precursor == 0 ? 0 : -1);
                    if (times.Length > 0)
                    {
                        LoadingStatus.Transitions.AddTransition(
                            modifiedSequence,
                            peptideColor,
                            extra.StatusId,
                            extra.StatusRank,
                            times,
                            intensities);
                    }
                }
                break;
            }
            int percentComplete = _chromTaskLists.Sum(taskList => taskList == null ? 0 : taskList.PercentComplete) /
                                  _chromTaskLists.Length;

            percentComplete = Math.Min(percentComplete, 99);
            SetPercentComplete(percentComplete);
            return(loaded);
        }