private void UpdateBinary(ISession session, DbMsDataFile dbMsDataFile) { if (null != Data.Times && null == dbMsDataFile.Times) { dbMsDataFile.Times = Data.Times.ToArray(); } if (null != Data.TotalIonCurrent && null == dbMsDataFile.TotalIonCurrent) { dbMsDataFile.TotalIonCurrent = Data.TotalIonCurrent.ToArray(); } if (null != Data.MsLevels) { var msLevels = Data.MsLevels.ToArray(); if (null != dbMsDataFile.MsLevels && dbMsDataFile.MsLevels.Length == msLevels.Length) { for (int i = 0; i < msLevels.Length; i++) { if (0 == msLevels[i]) { msLevels[i] = dbMsDataFile.MsLevels[i]; } } } } }
protected override void OnShown(EventArgs e) { base.OnShown(e); new PeptideInfoForm(PeptideAnalysis).Show(dockPanel, DockState.Document); DbPeptideAnalysis dbPeptideAnalysis; List <AnalysisChromatograms> analyses = new List <AnalysisChromatograms>(); using (ISession session = Workspace.OpenSession()) { dbPeptideAnalysis = session.Get <DbPeptideAnalysis>(PeptideAnalysis.Id); } if (dbPeptideAnalysis.HasChromatograms) { HasChromatograms = true; return; } DbMsDataFile msDataFile = TurnoverForm.Instance.EnsureMsDataFile(dbPeptideAnalysis.MsDataFile); if (msDataFile == null) { return; } WaitingForChromatograms = true; tbxStatus.Text = "Generating chromatograms"; progressBar1.Visible = true; new Action <DbMsDataFile>(GenerateChromatogramsBackground).BeginInvoke(msDataFile, null, null); }
public MsDataFileData(DbMsDataFile dbMsDataFile) { Name = dbMsDataFile.Name; Label = dbMsDataFile.Label; Cohort = dbMsDataFile.Cohort; Sample = dbMsDataFile.Sample; PrecursorPool = PrecursorPoolValue.ParsePersistedString(dbMsDataFile.PrecursorPool); TimePoint = dbMsDataFile.TimePoint; Times = ImmutableList.ValueOf(dbMsDataFile.Times); TotalIonCurrent = ImmutableList.ValueOf(dbMsDataFile.TotalIonCurrent); MsLevels = ImmutableList.ValueOf(dbMsDataFile.MsLevels); }
private void GenerateChromatogramsBackground(DbMsDataFile msDataFile) { ChromatogramGenerator chromatogramGenerator = new ChromatogramGenerator(Workspace); chromatogramGenerator.GenerateChromatograms(msDataFile, new List <AnalysisChromatograms> { new AnalysisChromatograms(PeptideAnalysis) }, UpdateChromatogramProgress); SafeBeginInvoke(delegate { HasChromatograms = true; WaitingForChromatograms = false; progressBar1.Visible = false; tbxStatus.Text = ""; }); }
public void TestDbMsDataFile() { var dbMsDataFile = new DbMsDataFile { Name = "Foo", MsLevels = new byte[] {0x1, 0x2, 0x1, 0x2}, Times = new [] {0.1, 0.2, 0.3, 0.4} }; var serializer = new DataContractJsonSerializer(typeof (DbMsDataFile)); var stream = new MemoryStream(); serializer.WriteObject(stream, dbMsDataFile); var streamAsString = Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int) stream.Length); Trace.TraceInformation("Serialed as {0}", streamAsString); stream.Seek(0, SeekOrigin.Begin); var dbMsDataFile2 = (DbMsDataFile) serializer.ReadObject(stream); Assert.AreEqual(dbMsDataFile.Name, dbMsDataFile2.Name); CollectionAssert.AreEqual(dbMsDataFile.MsLevels, dbMsDataFile2.MsLevels); CollectionAssert.AreEqual(dbMsDataFile.Times, dbMsDataFile2.Times); }
public void TestDbMsDataFile() { var dbMsDataFile = new DbMsDataFile { Name = "Foo", MsLevels = new byte[] { 0x1, 0x2, 0x1, 0x2 }, Times = new [] { 0.1, 0.2, 0.3, 0.4 } }; var serializer = new DataContractJsonSerializer(typeof(DbMsDataFile)); var stream = new MemoryStream(); serializer.WriteObject(stream, dbMsDataFile); var streamAsString = Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length); Trace.TraceInformation("Serialed as {0}", streamAsString); stream.Seek(0, SeekOrigin.Begin); var dbMsDataFile2 = (DbMsDataFile)serializer.ReadObject(stream); Assert.AreEqual(dbMsDataFile.Name, dbMsDataFile2.Name); CollectionAssert.AreEqual(dbMsDataFile.MsLevels, dbMsDataFile2.MsLevels); CollectionAssert.AreEqual(dbMsDataFile.Times, dbMsDataFile2.Times); }
public void Merge(DbMsDataFile dbMsDataFile) { Merge(new MsDataFileData(dbMsDataFile)); }
public SearchResultKey(DbMsDataFile msDataFile, DbPeptide peptide, double retentionTime) : this(msDataFile.Id.GetValueOrDefault(), peptide.Id.GetValueOrDefault(), retentionTime) { }
private void AddSearchResults(IList<SearchResult> searchResults, Dictionary<string,DbPeptide> peptides, Dictionary<string,DbMsDataFile> dataFiles) { String baseMessage = _message; if (searchResults == null) { return; } var dbPeptideSearchResults = GetSearchResults(); var modifiedPeptides = new HashSet<DbPeptide>(); var searchResultsToInsert = new Dictionary<SearchResultKey, DbPeptideSpectrumMatch>(); var searchResultsToUpdate = new Dictionary<SearchResultKey, DbPeptideSpectrumMatch>(); using (var session = Workspace.OpenWriteSession()) { var statementBuilder = new SqlStatementBuilder(session.GetSessionImplementation().Factory.Dialect); var dbWorkspace = Workspace.LoadDbWorkspace(session); session.BeginTransaction(); var newPeptides = new Dictionary<String, Dictionary<String, object>>(); foreach (var searchResult in searchResults) { var trimmedSequence = Peptide.TrimSequence(searchResult.Sequence); if (peptides.ContainsKey(trimmedSequence) || newPeptides.ContainsKey(trimmedSequence)) { continue; } newPeptides.Add(trimmedSequence, new Dictionary<string, object> { {"Sequence", trimmedSequence}, {"FullSequence", searchResult.Sequence}, {"Version",1}, {"ValidationStatus",0} }); } if (newPeptides.Count > 0) { long maxPeptideId = (long?) session.CreateQuery("SELECT Max(T.Id) FROM DbPeptide T").UniqueResult() ?? 0; var insertStatements = new List<String>(); foreach (var dict in newPeptides.Values) { insertStatements.Add(statementBuilder.GetInsertStatement("DbPeptide", dict)); } statementBuilder.ExecuteStatements(session, insertStatements); var criteria = session.CreateCriteria(typeof (DbPeptide)) .Add(Restrictions.Gt("Id", maxPeptideId)); foreach (DbPeptide dbPeptide in criteria.List()) { peptides.Add(dbPeptide.Sequence, dbPeptide); } } foreach (var searchResult in searchResults) { var trimmedSequence = Peptide.TrimSequence(searchResult.Sequence); DbPeptide dbPeptide; if (!peptides.TryGetValue(trimmedSequence, out dbPeptide)) { // should not happen continue; } if (searchResult.Filename == null) { continue; } DbMsDataFile dbMsDataFile; if (!dataFiles.TryGetValue(searchResult.Filename, out dbMsDataFile)) { dbMsDataFile = new DbMsDataFile { Name = searchResult.Filename, Label = searchResult.Filename, }; session.Save(dbMsDataFile); dataFiles.Add(dbMsDataFile.Name, dbMsDataFile); } var key = new SearchResultKey(dbMsDataFile, dbPeptide, searchResult.RetentionTime); DbPeptideSpectrumMatch dbPeptideSpectrumMatch; if (dbPeptideSearchResults.TryGetValue(key, out dbPeptideSpectrumMatch)) { bool changed = false; if (dbPeptideSpectrumMatch.ModifiedSequence == null && searchResult.ModifiedSequence != null) { dbPeptideSpectrumMatch.ModifiedSequence = searchResult.ModifiedSequence; changed = true; } if (!dbPeptideSpectrumMatch.PrecursorMz.HasValue && searchResult.PrecursorMz.HasValue) { dbPeptideSpectrumMatch.PrecursorMz = searchResult.PrecursorMz; dbPeptideSpectrumMatch.PrecursorCharge = searchResult.PrecursorCharge; changed = true; } if (!changed) { continue; } searchResultsToUpdate[key] = dbPeptideSpectrumMatch; } else { if (!searchResultsToInsert.TryGetValue(key, out dbPeptideSpectrumMatch)) { dbPeptideSpectrumMatch = new DbPeptideSpectrumMatch { MsDataFile = dbMsDataFile, Peptide = dbPeptide, RetentionTime = searchResult.RetentionTime, PrecursorCharge = searchResult.PrecursorCharge, PrecursorMz = searchResult.PrecursorMz, ModifiedSequence = searchResult.ModifiedSequence, }; searchResultsToInsert.Add(key, dbPeptideSpectrumMatch); if (!newPeptides.ContainsKey(trimmedSequence)) { modifiedPeptides.Add(dbPeptide); } } } } var statements = new List<string>(); foreach (var dbPeptideSearchResult in searchResultsToInsert.Values) { statements.Add(statementBuilder.GetInsertStatement("DbPeptideSpectrumMatch", new Dictionary<string, object> { {"MsDataFile", dbPeptideSearchResult.MsDataFile.Id}, {"Peptide", dbPeptideSearchResult.Peptide.Id}, {"RetentionTime", dbPeptideSearchResult.RetentionTime}, {"ModifiedSequence", dbPeptideSearchResult.ModifiedSequence}, {"PrecursorMz", dbPeptideSearchResult.PrecursorMz}, {"PrecursorCharge", dbPeptideSearchResult.PrecursorCharge}, {"Version", 1}, })); } foreach (var dbPeptideSearchResult in searchResultsToUpdate.Values) { statements.Add(statementBuilder.GetUpdateStatement("DbPeptideSearchResult", new Dictionary<string, object> { {"RetentionTime", dbPeptideSearchResult.RetentionTime}, {"ModifiedSequence", dbPeptideSearchResult.ModifiedSequence}, {"PrecursorMz", dbPeptideSearchResult.PrecursorMz}, {"PrecursorCharge", dbPeptideSearchResult.PrecursorCharge}, {"Version", dbPeptideSearchResult.Version + 1}, }, new Dictionary<string, object> { { "Id", dbPeptideSearchResult.Id.GetValueOrDefault() } } )); } statementBuilder.ExecuteStatements(session, statements); UpdateProgress(baseMessage + "(Committing transaction)", 99); session.Transaction.Commit(); } }
private void AddPeptide(Workspace workspace, PeakFinderPeptide peakFinderPeptide) { var msDataFile = GetMsDataFile(workspace, peakFinderPeptide.DataFile); Peptide peptide; using (var session = workspace.OpenWriteSession()) { var dbMsDataFile = new DbMsDataFile { Name = peakFinderPeptide.DataFile, Label = peakFinderPeptide.DataFile, }; if (msDataFile == null) { session.BeginTransaction(); session.Save(dbMsDataFile); session.Transaction.Commit(); } workspace.DatabasePoller.LoadAndMergeChanges(null); msDataFile = workspace.MsDataFiles.FindByKey(dbMsDataFile.GetId()); var dbPeptide = (DbPeptide) session.CreateCriteria <DbPeptide>().Add(Restrictions.Eq("Sequence", peakFinderPeptide.PeptideSequence)). UniqueResult(); if (dbPeptide == null) { dbPeptide = new DbPeptide { FullSequence = peakFinderPeptide.PeptideSequence, Sequence = peakFinderPeptide.PeptideSequence, }; session.BeginTransaction(); session.Save(dbPeptide); session.Transaction.Commit(); } session.BeginTransaction(); session.Save(new DbPeptideSpectrumMatch { RetentionTime = peakFinderPeptide.FirstDetectedTime * 60, PrecursorCharge = peakFinderPeptide.MinCharge, Peptide = dbPeptide, MsDataFile = session.Load <DbMsDataFile>(msDataFile.Id), }); if (peakFinderPeptide.LastDetectedTime != peakFinderPeptide.FirstDetectedTime) { session.Save(new DbPeptideSpectrumMatch { RetentionTime = peakFinderPeptide.LastDetectedTime * 60, PrecursorCharge = peakFinderPeptide.MaxCharge, Peptide = dbPeptide, MsDataFile = session.Load <DbMsDataFile>(msDataFile.Id), }); } session.Transaction.Commit(); peptide = new Peptide(workspace, dbPeptide); } MsDataFileUtil.InitMsDataFile(workspace, msDataFile); var peptideAnalysis = peptide.EnsurePeptideAnalysis(); if (peptideAnalysis == null) { Assert.Fail(); } PeptideFileAnalysis.EnsurePeptideFileAnalysis(peptideAnalysis, msDataFile); }
public void TestChromatogramGenerator() { String dbPath = Path.Combine(TestContext.TestDir, "test" + Guid.NewGuid() + ".tpg"); using (var sessionFactory = SessionFactoryFactory.CreateSessionFactory(dbPath, SessionFactoryFlags.CreateSchema)) { using (var session = sessionFactory.OpenSession()) { session.BeginTransaction(); DbWorkspace dbWorkspace = new DbWorkspace { TracerDefCount = 1, }; session.Save(dbWorkspace); DbTracerDef dbTracerDef = TracerDef.GetN15Enrichment(); dbTracerDef.Workspace = dbWorkspace; dbTracerDef.Name = "Tracer"; session.Save(dbTracerDef); session.Save(new DbSetting { Workspace = dbWorkspace, Name = SettingEnum.data_directory.ToString(), Value = GetDataDirectory() }); session.Transaction.Commit(); } } Workspace workspace = new Workspace(dbPath); workspace.SetTaskScheduler(TaskScheduler.Default); var dbMsDataFile = new DbMsDataFile { Name = "20090724_HT3_0", }; using (var session = workspace.OpenWriteSession()) { session.BeginTransaction(); session.Save(dbMsDataFile); session.Transaction.Commit(); } workspace.DatabasePoller.LoadAndMergeChanges(null); var msDataFile = workspace.MsDataFiles.FindByKey(dbMsDataFile.GetId()); Assert.IsTrue(MsDataFileUtil.InitMsDataFile(workspace, msDataFile)); DbPeptide dbPeptide; using (var session = workspace.OpenWriteSession()) { session.BeginTransaction(); dbPeptide = new DbPeptide { Protein = "TestProtein", Sequence = "YLAAYLLLVQGGNAAPSAADIK", FullSequence = "K.YLAAYLLLVQGGNAAPSAADIK.A", }; session.Save(dbPeptide); var searchResult = new DbPeptideSpectrumMatch { Peptide = dbPeptide, MsDataFile = session.Load <DbMsDataFile>(msDataFile.Id), PrecursorCharge = 3, RetentionTime = 20.557 * 60, }; session.Save(searchResult); session.Transaction.Commit(); } var peptide = new Peptide(workspace, dbPeptide); var peptideAnalysis = peptide.EnsurePeptideAnalysis(); peptideAnalysis.IncChromatogramRefCount(); var peptideFileAnalysis = PeptideFileAnalysis.EnsurePeptideFileAnalysis(peptideAnalysis, msDataFile); workspace.DatabasePoller.LoadAndMergeChanges(null); peptideAnalysis.IncChromatogramRefCount(); var chromatogramGenerator = new ChromatogramGenerator(workspace); chromatogramGenerator.Start(); while (peptideFileAnalysis.ChromatogramSet == null) { Thread.Sleep(100); } var chromatogramDatas = peptideFileAnalysis.GetChromatograms(); Assert.IsFalse(chromatogramDatas.Chromatograms.Count == 0); chromatogramGenerator.Stop(); while (chromatogramGenerator.IsThreadAlive) { Thread.Sleep(100); } }
private void AddSearchResults(IList <SearchResult> searchResults, Dictionary <string, DbPeptide> peptides, Dictionary <string, DbMsDataFile> dataFiles) { String baseMessage = _message; if (searchResults == null) { return; } var dbPeptideSearchResults = GetSearchResults(); var modifiedPeptides = new HashSet <DbPeptide>(); var searchResultsToInsert = new Dictionary <SearchResultKey, DbPeptideSpectrumMatch>(); var searchResultsToUpdate = new Dictionary <SearchResultKey, DbPeptideSpectrumMatch>(); using (var session = Workspace.OpenWriteSession()) { var statementBuilder = new SqlStatementBuilder(session.GetSessionImplementation().Factory.Dialect); var dbWorkspace = Workspace.LoadDbWorkspace(session); session.BeginTransaction(); var newPeptides = new Dictionary <String, Dictionary <String, object> >(); foreach (var searchResult in searchResults) { var trimmedSequence = Peptide.TrimSequence(searchResult.Sequence); if (peptides.ContainsKey(trimmedSequence) || newPeptides.ContainsKey(trimmedSequence)) { continue; } newPeptides.Add(trimmedSequence, new Dictionary <string, object> { { "Sequence", trimmedSequence }, { "FullSequence", searchResult.Sequence }, { "Version", 1 }, { "ValidationStatus", 0 } }); } if (newPeptides.Count > 0) { long maxPeptideId = (long?)session.CreateQuery("SELECT Max(T.Id) FROM DbPeptide T").UniqueResult() ?? 0; var insertStatements = new List <String>(); foreach (var dict in newPeptides.Values) { insertStatements.Add(statementBuilder.GetInsertStatement("DbPeptide", dict)); } statementBuilder.ExecuteStatements(session, insertStatements); var criteria = session.CreateCriteria(typeof(DbPeptide)) .Add(Restrictions.Gt("Id", maxPeptideId)); foreach (DbPeptide dbPeptide in criteria.List()) { peptides.Add(dbPeptide.Sequence, dbPeptide); } } foreach (var searchResult in searchResults) { var trimmedSequence = Peptide.TrimSequence(searchResult.Sequence); DbPeptide dbPeptide; if (!peptides.TryGetValue(trimmedSequence, out dbPeptide)) { // should not happen continue; } if (searchResult.Filename == null) { continue; } DbMsDataFile dbMsDataFile; if (!dataFiles.TryGetValue(searchResult.Filename, out dbMsDataFile)) { dbMsDataFile = new DbMsDataFile { Name = searchResult.Filename, Label = searchResult.Filename, }; session.Save(dbMsDataFile); dataFiles.Add(dbMsDataFile.Name, dbMsDataFile); } var key = new SearchResultKey(dbMsDataFile, dbPeptide, searchResult.RetentionTime); DbPeptideSpectrumMatch dbPeptideSpectrumMatch; if (dbPeptideSearchResults.TryGetValue(key, out dbPeptideSpectrumMatch)) { bool changed = false; if (dbPeptideSpectrumMatch.ModifiedSequence == null && searchResult.ModifiedSequence != null) { dbPeptideSpectrumMatch.ModifiedSequence = searchResult.ModifiedSequence; changed = true; } if (!dbPeptideSpectrumMatch.PrecursorMz.HasValue && searchResult.PrecursorMz.HasValue) { dbPeptideSpectrumMatch.PrecursorMz = searchResult.PrecursorMz; dbPeptideSpectrumMatch.PrecursorCharge = searchResult.PrecursorCharge; changed = true; } if (!changed) { continue; } searchResultsToUpdate[key] = dbPeptideSpectrumMatch; } else { if (!searchResultsToInsert.TryGetValue(key, out dbPeptideSpectrumMatch)) { dbPeptideSpectrumMatch = new DbPeptideSpectrumMatch { MsDataFile = dbMsDataFile, Peptide = dbPeptide, RetentionTime = searchResult.RetentionTime, PrecursorCharge = searchResult.PrecursorCharge, PrecursorMz = searchResult.PrecursorMz, ModifiedSequence = searchResult.ModifiedSequence, }; searchResultsToInsert.Add(key, dbPeptideSpectrumMatch); if (!newPeptides.ContainsKey(trimmedSequence)) { modifiedPeptides.Add(dbPeptide); } } } } var statements = new List <string>(); foreach (var dbPeptideSearchResult in searchResultsToInsert.Values) { statements.Add(statementBuilder.GetInsertStatement("DbPeptideSpectrumMatch", new Dictionary <string, object> { { "MsDataFile", dbPeptideSearchResult.MsDataFile.Id }, { "Peptide", dbPeptideSearchResult.Peptide.Id }, { "RetentionTime", dbPeptideSearchResult.RetentionTime }, { "ModifiedSequence", dbPeptideSearchResult.ModifiedSequence }, { "PrecursorMz", dbPeptideSearchResult.PrecursorMz }, { "PrecursorCharge", dbPeptideSearchResult.PrecursorCharge }, { "Version", 1 }, })); } foreach (var dbPeptideSearchResult in searchResultsToUpdate.Values) { statements.Add(statementBuilder.GetUpdateStatement("DbPeptideSearchResult", new Dictionary <string, object> { { "RetentionTime", dbPeptideSearchResult.RetentionTime }, { "ModifiedSequence", dbPeptideSearchResult.ModifiedSequence }, { "PrecursorMz", dbPeptideSearchResult.PrecursorMz }, { "PrecursorCharge", dbPeptideSearchResult.PrecursorCharge }, { "Version", dbPeptideSearchResult.Version + 1 }, }, new Dictionary <string, object> { { "Id", dbPeptideSearchResult.Id.GetValueOrDefault() } } )); } statementBuilder.ExecuteStatements(session, statements); UpdateProgress(baseMessage + "(Committing transaction)", 99); session.Transaction.Commit(); } }
public MsDataFile(Workspace workspace, DbMsDataFile dbMsDataFile) : this(workspace, dbMsDataFile.GetId(), new MsDataFileData(dbMsDataFile)) { }
private void AddPeptide(Workspace workspace, PeakFinderPeptide peakFinderPeptide) { var msDataFile = GetMsDataFile(workspace, peakFinderPeptide.DataFile); Peptide peptide; using (var session = workspace.OpenWriteSession()) { var dbMsDataFile = new DbMsDataFile { Name = peakFinderPeptide.DataFile, Label = peakFinderPeptide.DataFile, }; if (msDataFile == null) { session.BeginTransaction(); session.Save(dbMsDataFile); session.Transaction.Commit(); } workspace.DatabasePoller.LoadAndMergeChanges(null); msDataFile = workspace.MsDataFiles.FindByKey(dbMsDataFile.GetId()); var dbPeptide = (DbPeptide) session.CreateCriteria<DbPeptide>().Add(Restrictions.Eq("Sequence", peakFinderPeptide.PeptideSequence)). UniqueResult(); if (dbPeptide == null) { dbPeptide = new DbPeptide { FullSequence = peakFinderPeptide.PeptideSequence, Sequence = peakFinderPeptide.PeptideSequence, }; session.BeginTransaction(); session.Save(dbPeptide); session.Transaction.Commit(); } session.BeginTransaction(); session.Save(new DbPeptideSpectrumMatch { RetentionTime = peakFinderPeptide.FirstDetectedTime * 60, PrecursorCharge = peakFinderPeptide.MinCharge, Peptide = dbPeptide, MsDataFile = session.Load<DbMsDataFile>(msDataFile.Id), }); if (peakFinderPeptide.LastDetectedTime != peakFinderPeptide.FirstDetectedTime) { session.Save(new DbPeptideSpectrumMatch { RetentionTime = peakFinderPeptide.LastDetectedTime * 60, PrecursorCharge = peakFinderPeptide.MaxCharge, Peptide = dbPeptide, MsDataFile = session.Load<DbMsDataFile>(msDataFile.Id), }); } session.Transaction.Commit(); peptide = new Peptide(workspace, dbPeptide); } MsDataFileUtil.InitMsDataFile(workspace, msDataFile); var peptideAnalysis = peptide.EnsurePeptideAnalysis(); if (peptideAnalysis == null) { Assert.Fail(); } PeptideFileAnalysis.EnsurePeptideFileAnalysis(peptideAnalysis, msDataFile); }
public bool IsRejected(DbMsDataFile msDataFile) { return(_rejectedMsDataFileIds.Contains(msDataFile.Id.Value)); }
public void TestChromatogramGenerator() { String dbPath = Path.Combine(TestContext.TestDir, "test" + Guid.NewGuid() + ".tpg"); using (var sessionFactory = SessionFactoryFactory.CreateSessionFactory(dbPath, SessionFactoryFlags.CreateSchema)) { using (var session = sessionFactory.OpenSession()) { session.BeginTransaction(); DbWorkspace dbWorkspace = new DbWorkspace { TracerDefCount = 1, }; session.Save(dbWorkspace); DbTracerDef dbTracerDef = TracerDef.GetN15Enrichment(); dbTracerDef.Workspace = dbWorkspace; dbTracerDef.Name = "Tracer"; session.Save(dbTracerDef); session.Save(new DbSetting { Workspace = dbWorkspace, Name = SettingEnum.data_directory.ToString(), Value = GetDataDirectory() }); session.Transaction.Commit(); } } Workspace workspace = new Workspace(dbPath); workspace.SetTaskScheduler(TaskScheduler.Default); var dbMsDataFile = new DbMsDataFile { Name = "20090724_HT3_0", }; using (var session = workspace.OpenWriteSession()) { session.BeginTransaction(); session.Save(dbMsDataFile); session.Transaction.Commit(); } workspace.DatabasePoller.LoadAndMergeChanges(null); var msDataFile = workspace.MsDataFiles.FindByKey(dbMsDataFile.GetId()); Assert.IsTrue(MsDataFileUtil.InitMsDataFile(workspace, msDataFile)); DbPeptide dbPeptide; using (var session = workspace.OpenWriteSession()) { session.BeginTransaction(); dbPeptide = new DbPeptide { Protein = "TestProtein", Sequence = "YLAAYLLLVQGGNAAPSAADIK", FullSequence = "K.YLAAYLLLVQGGNAAPSAADIK.A", }; session.Save(dbPeptide); var searchResult = new DbPeptideSpectrumMatch { Peptide = dbPeptide, MsDataFile = session.Load<DbMsDataFile>(msDataFile.Id), PrecursorCharge = 3, RetentionTime = 20.557 * 60, }; session.Save(searchResult); session.Transaction.Commit(); } var peptide = new Peptide(workspace, dbPeptide); var peptideAnalysis = peptide.EnsurePeptideAnalysis(); peptideAnalysis.IncChromatogramRefCount(); var peptideFileAnalysis = PeptideFileAnalysis.EnsurePeptideFileAnalysis(peptideAnalysis, msDataFile); workspace.DatabasePoller.LoadAndMergeChanges(null); peptideAnalysis.IncChromatogramRefCount(); var chromatogramGenerator = new ChromatogramGenerator(workspace); chromatogramGenerator.Start(); while (peptideFileAnalysis.ChromatogramSet == null) { Thread.Sleep(100); } var chromatogramDatas = peptideFileAnalysis.GetChromatograms(); Assert.IsFalse(chromatogramDatas.Chromatograms.Count == 0); chromatogramGenerator.Stop(); while (chromatogramGenerator.IsThreadAlive) { Thread.Sleep(100); } }