static void Wiff2() { string wiffPath = @"C:\Users\david\Documents\BioInfo\47_praktikum\data\task7.wiff"; string runID = "sample=0"; System.Diagnostics.Stopwatch time = new System.Diagnostics.Stopwatch(); time.Start(); Console.Out.WriteLine(time.Elapsed.TotalMinutes); using (var reader = new WiffFileReader(wiffPath)) using (ITransactionScope txn = reader.BeginTransaction()) { System.Collections.Generic.IEnumerable <string> Items() { foreach (var ms in reader.ReadMassSpectra(runID)) { //var peaks = reader.ReadSpectrumPeaks(ms.ID); yield return(ms.ID); } } txn.Commit(); Console.Out.WriteLine(Items().ToArray().Length); Console.Out.WriteLine(time.Elapsed.TotalMinutes); } }
static void WiffToMzML() { string wiffPath = @"C:\Work\primaqdev\testdata\C2 Sol SWATH4.wiff"; string runID = "sample=0"; string mzMLOutPath = @"C:\Work\primaqdev\testdata\test.mzML"; using (var wiff = new WiffFileReader(wiffPath)) using (ITransactionScope txn = wiff.BeginTransaction()) using (var mzML = new MzMLWriter(mzMLOutPath)) { mzML.BeginMzML(wiff.Model); mzML.BeginRun(wiff.Model.Runs[runID]); var spectra = wiff.ReadMassSpectra(runID).Take(1); int spectrumCount = spectra.Count(); int specIdx = 0; mzML.BeginSpectrumList(spectrumCount); foreach (var ms in spectra) { var bd = wiff.ReadSpectrumPeaks(ms.ID); mzML.WriteSpectrum(ms, bd, specIdx); specIdx++; } mzML.EndSpectrumList(); mzML.EndRun(); mzML.EndMzML(); mzML.Close(); } }
static void WiffToSQLite() { string wiffPath = @"C:\Work\primaqdev\testdata\C2 Sol SWATH4.wiff"; string mzLitePath = Path.Combine(Path.GetDirectoryName(wiffPath), Path.GetFileNameWithoutExtension(wiffPath) + ".mzlite"); string runID = "sample=0"; if (File.Exists(mzLitePath)) { File.Delete(mzLitePath); } using (IMzLiteDataReader reader = new WiffFileReader(wiffPath)) using (ITransactionScope inTxn = reader.BeginTransaction()) using (MzLiteSQL writer = new MzLiteSQL(mzLitePath)) using (ITransactionScope outTxn = writer.BeginTransaction()) { foreach (var ms in reader.ReadMassSpectra(runID)) { var peaks = reader.ReadSpectrumPeaks(ms.ID); var clonedMS = MzLiteJson.JsonCloneModelItem("#1", ms); writer.Insert(runID, clonedMS, peaks); break; } foreach (var ms in writer.ReadMassSpectra(runID)) { var peaks = writer.ReadSpectrumPeaks(ms.ID); var ms1 = writer.ReadMassSpectrum(ms.ID); break; } outTxn.Commit(); } }
static void Wiff() { string wiffPath = @"C:\Users\david\Documents\BioInfo\47_praktikum\data\task7.wiff"; string runID = "sample=0"; using (var reader = new WiffFileReader(wiffPath)) using (ITransactionScope txn = reader.BeginTransaction()) { foreach (var ms in reader.ReadMassSpectra(runID)) { //var peaks = reader.ReadSpectrumPeaks(ms.ID); Console.Out.WriteLine(ms.ID); } } }
static void WiffToSQLite() { string wiffPath = @"C:\Work\primaqdev\testdata\Für Alex\20160212_MS_DHpsan006.wiff"; string mzLitePath = Path.Combine(Path.GetDirectoryName(wiffPath), Path.GetFileNameWithoutExtension(wiffPath) + ".mzlite"); string runID = "sample=0"; int msLevel; if (File.Exists(mzLitePath)) { File.Delete(mzLitePath); } using (IMzLiteDataReader reader = new WiffFileReader(wiffPath)) using (ITransactionScope inTxn = reader.BeginTransaction()) using (MzLiteSQL writer = new MzLiteSQL(mzLitePath)) using (ITransactionScope outTxn = writer.BeginTransaction()) { foreach (var ms in reader.ReadMassSpectra(runID)) { if (ms.TryGetMsLevel(out msLevel) && msLevel != 1) { continue; } var peaks = reader.ReadSpectrumPeaks(ms.ID); //var clonedMS = MzLiteJson.JsonCloneModelItem("#1", ms); //var max = peaks.Peaks.GroupBy(x => x.Intensity); writer.Insert(runID, ms, peaks); //break; } //foreach (var ms in writer.ReadMassSpectra(runID)) //{ // var peaks = writer.ReadSpectrumPeaks(ms.ID); // var ms1 = writer.ReadMassSpectrum(ms.ID); // break; //} outTxn.Commit(); } }