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 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(); } }