示例#1
0
 /// <summary>
 /// Constructor for creating TrainingParamters from resource file stream parameter file.
 /// </summary>
 /// <param name="resourceStream"></param>
 /// <param name="config"></param>
 public TrainingParameters(Stream resourceStream, TrainerConfiguration config = null)
 {
     _charges = new HashSet<int>();
     _massSorter = new Dictionary<int, Histogram<double>>();
     _rankTables = new Dictionary<int, List<RankTable>>();
     _drankTables = new Dictionary<int, List<RankTable>>();
     _ionProbabilities = new Dictionary<int, List<IonFrequencyTable>>();
     _massErrors = new Dictionary<int, List<MassErrorTable>>();
     _precursorOffsets = new Dictionary<int, List<PrecursorOffsets>>();
     Config = config;
     ReadFromResourceFile(resourceStream);
     _computed = true;
 }
示例#2
0
 /// <summary>
 /// Constructor for creating empty TrainingParameters object.
 /// </summary>
 /// <param name="config">Configuration data read from configuration file.</param>
 public TrainingParameters(TrainerConfiguration config)
 {
     Config = config;
     _dataSet = new Queue<SpectrumMatch>();
     _massBins = new Dictionary<int, int>();
     _charges = new HashSet<int>();
     _massSorter = new Dictionary<int, Histogram<double>>();
     _rankTables = new Dictionary<int, List<RankTable>>();
     _drankTables = new Dictionary<int, List<RankTable>>();
     _ionProbabilities = new Dictionary<int, List<IonFrequencyTable>>();
     _massErrors = new Dictionary<int, List<MassErrorTable>>();
     _precursorOffsets = new Dictionary<int, List<PrecursorOffsets>>();
     _computed = false;
 }
示例#3
0
        public void RankProbability()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string configurationFile = @"\\protoapps\UserData\Wilkins\BottomUp\RankProbabilityConfig.ini";
            if (!File.Exists(configurationFile))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configurationFile);
            }
            
            var config = new TrainerConfiguration(configurationFile);

            var trainingParameters = new TrainingParameters(config);

            foreach (var dataSet in config.DataSets)
            {
                var tsvName = config.TsvPath.Replace("@", dataSet);
                var rawName = config.DataPath.Replace("@", dataSet);
                var txtFiles = new List<string>();
                var dataFiles = new List<string>();

                if (config.DataFormat == DataFileFormat.Mgf)
                {
                    dataFiles.Add(config.DataPath + dataSet + "." + config.DataFormat);
                }
                else
                {
                    // Read directory
                    var txtFilesTemp = Directory.GetFiles(tsvName).ToList();
                    txtFiles = txtFilesTemp.Where(txtFile => Path.GetExtension(txtFile) == ".tsv").ToList();
                    var dataFilesTemp = Directory.GetFiles(rawName).ToList();
                    dataFiles =
                        dataFilesTemp.Where(dataFile => Path.GetExtension(dataFile) == ".raw").ToList();
                    Assert.True(dataFiles.Count == txtFiles.Count);
                }

                // Read Data files
                for (int i = 0; i < dataFiles.Count; i++)
                {
                    SpectrumMatchList targets;

                    if (config.DataFormat == DataFileFormat.Mgf)
                    {
                        Console.WriteLine(dataSet + ".mgf");
                        targets = new SpectrumMatchList(dataFiles[i], config.PrecursorCharge);
                    }
                    else
                    {
                        string textFile = txtFiles[i];
                        string rawFile = dataFiles[i];
                        Console.WriteLine("{0}\t{1}", textFile, rawFile);
                        var lcms = new LazyLcMsRun(rawFile, 0, 0);
                        targets = new SpectrumMatchList(lcms, txtFiles[i], config.DataFormat, config.PrecursorCharge);
                    }

                    // Add PSMs
                    trainingParameters.AddMatches(targets);
                }

                // Write output file
                var outputFileName = config.OutputFileName.Replace("@", dataSet);
                trainingParameters.WriteToFile(outputFileName);
            }
        }