public static Dictionary <string, CompoundThresholdData> LoadCompoundThresholds(this ISettingsData settings)
        {
            if (string.IsNullOrWhiteSpace(settings.CompoundThresholdFilePath) || !File.Exists(settings.CompoundThresholdFilePath))
            {
                return(null);
            }

            var thresholds = CompoundThresholdData.ReadFromFile(settings.CompoundThresholdFilePath).ToList();

            return(CompoundThresholdData.ConvertToSearchMap(thresholds));
        }
Exemplo n.º 2
0
        private void CreateThresholdsFile(IOptions options, List <CompoundData> fullResults)
        {
            Console.WriteLine("Creating per-compound thresholds file...");

            // Group the passing results
            var grouped    = fullResults.Where(x => x.PassesIntensity).GroupBy(x => x.CompoundName);
            var thresholds = new List <CompoundThresholdData>();

            foreach (var group in grouped)
            {
                var groupData = group.ToList();
                var threshold = new CompoundThresholdData();
                threshold.CompoundName = group.Key;
                threshold.PrecursorMz  = groupData[0].PrecursorMz;
                var averageTotalIntensity = groupData.Average(x => x.TotalIntensitySum);
                threshold.Threshold = averageTotalIntensity * options.CreatedThresholdsFileThresholdLevel;
                thresholds.Add(threshold);
            }

            CompoundThresholdData.WriteToFile(options.CompoundThresholdOutputFilePath, thresholds);
            Console.WriteLine("Created per-compound thresholds file.");
        }