public static void LoopOverEveryScan()
 {
     using (ThermoRawFile rawFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw"))
     {
         rawFile.Open();
         foreach (var scan in rawFile)
         {
             Console.WriteLine("{0,-4} {1,3} {2,-6:F4} {3,-5} {4,7} {5,-10} {6} {7}", scan.SpectrumNumber, scan.MsnOrder, scan.RetentionTime,
               scan.Polarity, scan.MassSpectrum.Count, scan.MzAnalyzer, scan.MzRange, scan.MassSpectrum.IsHighResolution);
         }
     }
 }
 public static void RecalibrateThermoRawFile()
 {
     List<ISpectrum> spectra = new List<ISpectrum>();
     using (ThermoRawFile rawFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw"))
     {
         rawFile.Open();
         for (int i = rawFile.FirstSpectrumNumber; i <= rawFile.LastSpectrumNumber; i++)
         {
             ThermoSpectrum spectrum = rawFile.GetLabeledSpectrum(i);
             ThermoSpectrum correctedSpectrum = spectrum.CorrectMasses((mz) => mz - 5); // shift all masses 5 Th lower
             spectra.Add(correctedSpectrum);
         }
     }
 }
Example #3
0
        private void LoadRawFile(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
                return;

            _rawFile = new ThermoRawFile(filePath);
            _rawFile.Open();

             _scanNumbers.Clear();
            _scanNumbers.RaiseListChangedEvents = false;
            for (int i = _rawFile.FirstSpectrumNumber; i < _rawFile.LastSpectrumNumber; i++)
            {
                if (_rawFile.GetMsnOrder(i) > 1)
                {
                    _scanNumbers.Add(i);
                }
            }
            _scanNumbers.RaiseListChangedEvents = true;
            _scanNumbers.ResetBindings();

            textBox1.Text = filePath;
        }
Example #4
0
        private void UpdatePsmInformation(IList<InputFile> csvFiles, string rawFolder, bool useMedian = true)
        {
            Log("Reading MS data...");
            MSDataFile.CacheScans = false;
            List<string> rawFileNames = Directory.EnumerateFiles(rawFolder, "*.raw", SearchOption.AllDirectories).ToList();

            foreach (InputFile csvFile in csvFiles)
            {
                string rawFileName = csvFile.RawFileName;
                if (string.IsNullOrEmpty(rawFileName))
                {
                    throw new ArgumentException("Cannot parse the file name for: " + csvFile.FilePath);
                }
                csvFile.RawFilePath = "";
                foreach (string file in rawFileNames)
                {
                    string name = Path.GetFileNameWithoutExtension(file);

                    if (name != null && !rawFileName.Equals(name))
                        continue;
                    csvFile.RawFilePath = file;
                    break;
                }
                if (string.IsNullOrEmpty(csvFile.RawFilePath))
                {
                    throw new ArgumentException("Cannot find the associated raw file for: " + csvFile.FilePath);
                }
            }

            // update the precursor mass error
            foreach (InputFile csvFile in csvFiles)
            {
                using (MSDataFile dataFile = new ThermoRawFile(csvFile.RawFilePath))
                {
                    dataFile.Open();
                    csvFile.UpdatePsmInformation(dataFile, _is2DFDR, useMedian, _evalueThresholdPPMError);
                }
                if (_is2DFDR)
                {
                    Log(string.Format("{0:F2} ppm {1} precursor mass error in {2}",
                        csvFile.SystematicPrecursorMassError, useMedian ? "median" : "average", csvFile.Name));
                }
            }
        }
Example #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="argFullPath"></param>
 /// <param name="argFileType">ThermoRawFile</param>
 public ThermoRawReader(string argFullPath)
 {
     _fullFilePath = argFullPath;
     _raw = new CSMSL.IO.Thermo.ThermoRawFile(_fullFilePath);
     _raw.Open();
 }