private void button1_Click(object sender, EventArgs e) { Convertor convertor = new Convertor(); convertor.Protease = Protease.Trypsin; convertor.FastaDatabaseFile = @"C:\Users\Derek\Documents\Compass Tests\OmssaConvertor\CONCAT_Uniprot_yeast_canonicalIsoforms_20jan2013.fasta"; convertor.MissedClevages = 3; convertor.FixedMods.Add(3); ThermoRawFile rawFile = new ThermoRawFile(@"C:\Users\Derek\Documents\Compass Tests\OmssaConvertor\10sep2013_yeast_control_2.raw"); convertor.Convert(@"C:\Users\Derek\Documents\Compass Tests\OmssaConvertor\10sep2013_yeast_control_2_ITMS_HCD30.00.csv", rawFile); }
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); } } }
public static void Start(IProtease protease, int maxMissed = 3, int minLength = 5, int maxLength = 35) { Console.WriteLine("**Start Morpheus Search**"); Stopwatch watch = new Stopwatch(); watch.Start(); List<int> hashCodes = new List<int>(); // Generate peptide candidates HashSet<Peptide> peptides = new HashSet<Peptide>(); using (FastaReader reader = new FastaReader("Resources/yeast_uniprot_120226.fasta")) { foreach (Protein protein in reader.ReadNextProtein()) { foreach (Peptide peptide in protein.Digest(protease, maxMissed, minLength, maxLength)) { peptides.Add(peptide); } } } MSSearchEngine engine = new MorpheusSearchEngine(); engine.PrecursorMassTolerance = Tolerance.FromPPM(100); engine.ProductMassTolerance = Tolerance.FromPPM(10); engine.LoadPeptides(peptides); using (MSDataFile msDataFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw")) { //SortedMaxSizedContainer<PeptideSpectralMatch> psms = engine.Search(msDataFile.Where(scan => scan.MsnOrder > 1)); //foreach (MSDataScan scan in msDataFile.Where(scan => scan.MsnOrder > 1)) //{ // List<PeptideSpectralMatch> psms = engine.Search(scan); // Console.WriteLine("{0} {1}", scan.SpectrumNumber, psms.Count); //} } watch.Stop(); Console.WriteLine("Time elapsed: {0}", watch.Elapsed); Console.WriteLine("Memory used: {0:N0} MB", System.Environment.WorkingSet / (1024 * 1024)); Console.WriteLine("**End Morpheus Search**"); }
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; }
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)); } } }
/// <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(); }