private ChromatogramRequestDocument GetChromatogramRequestDocument(SpectrumFilter spectrumFilter) { ChromatogramRequestDocument chromatogramRequestDocument = spectrumFilter.ToChromatogramRequestDocument(); if (null == _retentionTimePredictor) { return(chromatogramRequestDocument); } var peptidesBySequence = new Dictionary <string, PeptideDocNode>(); foreach (var peptide in _srmDocument.Molecules) { peptidesBySequence[peptide.RawTextId] = peptide; } var chromatogramGroups = new List <ChromatogramRequestDocumentChromatogramGroup>(); foreach (var chromatogramGroup in chromatogramRequestDocument.ChromatogramGroup) { PeptideDocNode peptideDocNode = null; if (!string.IsNullOrEmpty(chromatogramGroup.ModifiedSequence)) { peptidesBySequence.TryGetValue(chromatogramGroup.ModifiedSequence, out peptideDocNode); } bool isFirstPassPeptide = peptideDocNode != null && _retentionTimePredictor.IsFirstPassPeptide(peptideDocNode); if (_firstPass == isFirstPassPeptide) { chromatogramGroups.Add(chromatogramGroup); } } chromatogramRequestDocument.ChromatogramGroup = chromatogramGroups.ToArray(); return(chromatogramRequestDocument); }
public ChromatogramGeneratorTask(ChromTaskList chromTaskList, ChorusAccount chorusAccount, ChorusUrl chorusUrl, ChromatogramRequestDocument chromatogramRequestDocument) { ChromTaskList = chromTaskList; ChorusAccount = chorusAccount; ChorusUrl = chorusUrl; ChromatogramRequestDocument = chromatogramRequestDocument; }
public ChromatogramCache GenerateChromatograms(ChorusAccount chorusAccount, ChorusUrl chorusUrl, ChromatogramRequestDocument chromatogramRequestDocument) { var webRequest = (HttpWebRequest)WebRequest.Create(chorusUrl.GetChromExtractionUri()); AddAuthHeader(chorusAccount, webRequest); webRequest.Method = "POST"; // Not L10N var xmlSerializer = new XmlSerializer(typeof(ChromatogramRequestDocument)); xmlSerializer.Serialize(webRequest.GetRequestStream(), chromatogramRequestDocument); webRequest.GetRequestStream().Close(); return(SendRequest(webRequest, response => { MemoryStream memoryStream = new MemoryStream(); var responseStream = response.GetResponseStream(); if (responseStream != null) { byte[] buffer = new byte[65536]; int count; while ((count = responseStream.Read(buffer, 0, buffer.Length)) != 0) { memoryStream.Write(buffer, 0, count); } } if (0 == memoryStream.Length) { if (response.StatusCode != HttpStatusCode.OK) { throw new IOException(string.Format("Empty response: status = {0}", response.StatusCode)); // Not L10N } Debug.WriteLine("Zero byte response"); // Not L10N return null; } ChromatogramCache.RawData rawData; ChromatogramCache.LoadStructs(memoryStream, out rawData); var chromCacheFile = rawData.ChromCacheFiles[0]; rawData.ChromCacheFiles = new[] { new ChromCachedFile(chorusUrl, chromCacheFile.Flags, chromCacheFile.FileWriteTime, chromCacheFile.RunStartTime, chromCacheFile.MaxRetentionTime, chromCacheFile.MaxIntensity, chromCacheFile.InstrumentInfoList), }; return new ChromatogramCache(string.Empty, rawData, new ChromatogramGeneratorTask.MemoryPooledStream(memoryStream)); })); }
internal static IEnumerable <ChromKey> ListChromKeys(ChromatogramRequestDocument chromatogramRequestDocument) { foreach (var chromatogramGroup in chromatogramRequestDocument.ChromatogramGroup) { ChromSource chromSource; switch (chromatogramGroup.Source) { case GeneratedCode.ChromSource.Ms1: chromSource = ChromSource.ms1; break; case GeneratedCode.ChromSource.Ms2: chromSource = ChromSource.fragment; break; case GeneratedCode.ChromSource.Sim: chromSource = ChromSource.sim; break; default: chromSource = ChromSource.unknown; break; } ChromExtractor chromExtractor; switch (chromatogramGroup.Extractor) { case GeneratedCode.ChromExtractor.BasePeak: chromExtractor = ChromExtractor.base_peak; break; default: chromExtractor = ChromExtractor.summed; break; } foreach (var chromatogram in chromatogramGroup.Chromatogram) { yield return(new ChromKey(chromatogramGroup.ModifiedSequence, new SignedMz(chromatogramGroup.PrecursorMz), null, 0, new SignedMz(chromatogram.ProductMz), 0, chromatogram.MzWindow, chromSource, chromExtractor, false, false, null, null)); // Optional retention and drift times not used in this provider } } }
public static List <ChromatogramRequestDocument> ChunkChromatogramRequest(ChromatogramRequestDocument chromatogramRequestDocument, int targetChromatogramCount) { var chunks = new List <ChromatogramRequestDocument>(); List <ChromatogramRequestDocumentChromatogramGroup> currentGroups = new List <ChromatogramRequestDocumentChromatogramGroup>(); int currentChromatogramCount = 0; foreach (var chromatogramGroup in chromatogramRequestDocument.ChromatogramGroup) { currentGroups.Add(chromatogramGroup); currentChromatogramCount += chromatogramGroup.Chromatogram.Length; if (currentChromatogramCount >= targetChromatogramCount) { chunks.Add(chromatogramRequestDocument.CloneWithChromatogramGroups(currentGroups)); currentGroups.Clear(); currentChromatogramCount = 0; } } if (currentGroups.Any()) { chunks.Add(chromatogramRequestDocument.CloneWithChromatogramGroups(currentGroups)); } return(chunks); }
public ChromatogramRequestDocument ToChromatogramRequestDocument() { var document = new ChromatogramRequestDocument { MaxMz = _instrument.MaxMz, MinMz = _instrument.MinMz, MzMatchTolerance = _instrument.MzMatchTolerance, }; if (_minTime.HasValue) { document.MinTime = _minTime.Value; document.MinTimeSpecified = true; } if (_maxTime.HasValue) { document.MaxTime = _maxTime.Value; document.MaxTimeSpecified = true; } switch (_acquisitionMethod) { case FullScanAcquisitionMethod.DIA: document.Ms2FullScanAcquisitionMethod = Ms2FullScanAcquisitionMethod.DIA; break; case FullScanAcquisitionMethod.None: document.Ms2FullScanAcquisitionMethod = Ms2FullScanAcquisitionMethod.None; break; case FullScanAcquisitionMethod.Targeted: document.Ms2FullScanAcquisitionMethod = Ms2FullScanAcquisitionMethod.Targeted; break; } if (null != _filterMzValues) { var chromatogramGroups = new List <ChromatogramRequestDocumentChromatogramGroup>(); var sources = new HashSet <RemoteApi.GeneratedCode.ChromSource>(); if (EnabledMs) { sources.Add(RemoteApi.GeneratedCode.ChromSource.Ms1); } if (EnabledMsMs) { sources.Add(RemoteApi.GeneratedCode.ChromSource.Ms2); } foreach (var filterPair in _filterMzValues) { foreach (var chromatogramGroup in filterPair.ToChromatogramRequestDocumentChromatogramGroups()) { if (chromatogramGroup.PrecursorMz == 0 || sources.Contains(chromatogramGroup.Source)) { chromatogramGroups.Add(chromatogramGroup); } } } document.ChromatogramGroup = chromatogramGroups.ToArray(); } var isolationScheme = _fullScan.IsolationScheme; if (null != _fullScan.IsolationScheme) { document.IsolationScheme = new ChromatogramRequestDocumentIsolationScheme(); if (_fullScan.IsolationScheme.PrecursorFilter.HasValue) { document.IsolationScheme.PrecursorFilter = _fullScan.IsolationScheme.PrecursorFilter.Value; document.IsolationScheme.PrecursorFilterSpecified = true; } if (isolationScheme.PrecursorRightFilter.HasValue) { document.IsolationScheme.PrecursorRightFilter = isolationScheme.PrecursorRightFilter.Value; document.IsolationScheme.PrecursorRightFilterSpecified = true; } if (null != isolationScheme.SpecialHandling) { document.IsolationScheme.SpecialHandling = isolationScheme.SpecialHandling; } if (isolationScheme.WindowsPerScan.HasValue) { document.IsolationScheme.WindowsPerScan = isolationScheme.WindowsPerScan.Value; document.IsolationScheme.WindowsPerScanSpecified = true; } document.IsolationScheme.IsolationWindow = isolationScheme.PrespecifiedIsolationWindows.Select( isolationWindow => { var result = new ChromatogramRequestDocumentIsolationSchemeIsolationWindow { Start = isolationWindow.Start, End = isolationWindow.End, }; if (isolationWindow.Target.HasValue) { result.Target = isolationWindow.Target.Value; } if (isolationWindow.StartMargin.HasValue) { result.StartMargin = isolationWindow.StartMargin.Value; } if (isolationWindow.EndMargin.HasValue) { result.EndMargin = isolationWindow.EndMargin.Value; } return(result); }).ToArray(); } return(document); }
internal static IEnumerable <ChromKey> ListChromKeys(ChromatogramRequestDocument chromatogramRequestDocument) { return(ChromatogramRequestProvider.ListChromKeys(chromatogramRequestDocument)); }