public void Start() { lock (this) { if (_started) { return; } _started = true; } Task.Factory.StartNew(() => { try { SendRequest(); } finally { lock (this) { _finished = true; ChromTaskList.OnTaskCompleted(this); } } }); }
private void SendRequest() { while (true) { try { var chromatogramCache = ChorusSession.GenerateChromatograms(ChorusAccount, ChorusUrl, ChromatogramRequestDocument); if (null == chromatogramCache) { return; } var chromKeyIndiceses = chromatogramCache.GetChromKeys(ChorusUrl).ToList(); lock (this) { _chromatogramCache = chromatogramCache; _chromKeyIndiceses = chromKeyIndiceses; } return; } catch (Exception exception) { ChromTaskList.HandleException(exception); return; } } }
//[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) { float[] times; float[] intensities; float[] massErrors; int[] scanIds; chromTaskList.GetChromatogram(chromKey, out times, out scanIds, out intensities, out massErrors); if (null == times) { 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); }
public ChromatogramGeneratorTask(ChromTaskList chromTaskList, ChorusAccount chorusAccount, ChorusUrl chorusUrl, ChromatogramRequestDocument chromatogramRequestDocument) { ChromTaskList = chromTaskList; ChorusAccount = chorusAccount; ChorusUrl = chorusUrl; ChromatogramRequestDocument = chromatogramRequestDocument; }
public ChromatogramGeneratorTask(ChromTaskList chromTaskList, ChorusAccount chorusAccount, ChorusUrl chorusUrl, ChromatogramRequestDocument chromatogramRequestDocument) { ChromTaskList = chromTaskList; ChorusAccount = chorusAccount; ChorusUrl = chorusUrl; ChromatogramRequestDocument = chromatogramRequestDocument; }
public void TestThermoDIA() { 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()); DateTime startTime = DateTime.Now; ChromTaskList chromTaskList = new ChromTaskList(()=>{}, srmDocument, TEST_ACCOUNT, chorusUrl, new[]{chromatogramRequestDocument}); chromTaskList.SetMinimumSimultaneousTasks(2); while (chromTaskList.PercentComplete < 100) { Thread.Sleep(100); } DateTime endTime = DateTime.Now; Assert.AreEqual(0, chromTaskList.ListExceptions().Count); Console.Out.WriteLine("Elapsed time {0}", endTime.Subtract(startTime)); }
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; }