private void ExportGroupNode(PeptideDocNode peptideNode, TransitionGroupDocNode groupNode, ChromatogramSet chromatograms, ICollection <string> filesToExport, ICollection <ChromSource> chromSources, TextWriter writer, CultureInfo cultureInfo) { string peptideModifiedSequence = _settings.GetDisplayName(peptideNode); var precursorCharge = groupNode.TransitionGroup.PrecursorAdduct; string labelType = groupNode.TransitionGroup.LabelType.Name; var filesInChrom = chromatograms.MSDataFilePaths.Select(path => path.GetFileName()).ToList(); // Don't load the chromatogram group if none of its files are being exported if (!filesInChrom.Where(filesToExport.Contains).Any()) { return; } ChromatogramGroupInfo[] arrayChromInfo; if (!_measuredResults.TryLoadChromatogram(chromatograms, peptideNode, groupNode, _matchTolerance, true, out arrayChromInfo)) { // TODO: Determine if this is a real error or just a missing node for this file // If the former throw an exception, if the latter continue return; } if (arrayChromInfo.Length != chromatograms.FileCount) { throw new InvalidDataException(string.Format(Resources.ChromatogramExporter_ExportGroupNode_One_or_more_missing_chromatograms_at_charge_state__0__of__1_, precursorCharge, peptideModifiedSequence)); } foreach (var chromGroupInfo in arrayChromInfo) { string fileName = chromGroupInfo.FilePath.GetFileName(); // Skip the files that have not been selected for export if (!filesToExport.Contains(fileName)) { continue; } foreach (var nodeTran in groupNode.Transitions) { // TODO: Check a source attribute on the transition chrom info bool isMs1 = nodeTran.Transition.IsPrecursor() && !nodeTran.HasLoss; if (isMs1 && !chromSources.Contains(ChromSource.ms1)) { continue; } if (!isMs1 && !chromSources.Contains(ChromSource.fragment)) { continue; } int productCharge = nodeTran.Transition.Charge; float productMz = (float)nodeTran.Mz; var chromInfo = chromGroupInfo.GetTransitionInfo(nodeTran, _matchTolerance, chromatograms.OptimizationFunction); // Sometimes a transition in the transition group does not have results for a particular file // If this happens just skip it for that file if (chromInfo == null) { continue; } IList <float> times = chromInfo.Times; IList <float> intensities = chromInfo.Intensities; if (times.Count != intensities.Count || intensities.Count == 0) { throw new InvalidDataException(string.Format(Resources.ChromatogramExporter_Export_Bad_chromatogram_data_for_charge__0__state_of_peptide__1_, precursorCharge, peptideModifiedSequence)); } float tic = CalculateTic(times, intensities); string[] fieldArray = { fileName, peptideModifiedSequence, System.Convert.ToString(precursorCharge, cultureInfo), System.Convert.ToString(productMz, cultureInfo), nodeTran.GetFragmentIonName(CultureInfo.InvariantCulture), System.Convert.ToString(productCharge, cultureInfo), labelType, System.Convert.ToString(tic, cultureInfo) }; FormatChromLine(writer, fieldArray, times, intensities, cultureInfo); } } }