private void setEnrichment(DbTracerDef tracerDef) { tbxTracerSymbol.Text = tracerDef.TracerSymbol; tbxMassDifference.Text = tracerDef.DeltaMass.ToString(); tbxAtomCount.Text = tracerDef.AtomCount.ToString(); tbxAtomicPercentEnrichment.Text = tracerDef.AtomPercentEnrichment.ToString(); cbxEluteEarlier.Checked = tracerDef.IsotopesEluteEarlier; cbxEluteLater.Checked = tracerDef.IsotopesEluteLater; }
public TracerDefData(DbTracerDef dbTracerDef) { Name = dbTracerDef.Name; TracerSymbol = dbTracerDef.TracerSymbol; DeltaMass = dbTracerDef.DeltaMass; AtomCount = dbTracerDef.AtomCount; AtomPercentEnrichment = dbTracerDef.AtomPercentEnrichment; InitialEnrichment = dbTracerDef.InitialEnrichment; FinalEnrichment = dbTracerDef.FinalEnrichment; IsotopesEluteEarlier = dbTracerDef.IsotopesEluteEarlier; IsotopesEluteLater = dbTracerDef.IsotopesEluteLater; }
private void UpdateDbTracerDef(DbTracerDef dbTracerDef, TracerDefData tracerDefData) { dbTracerDef.AtomCount = tracerDefData.AtomCount; dbTracerDef.AtomPercentEnrichment = tracerDefData.AtomPercentEnrichment; dbTracerDef.DeltaMass = tracerDefData.DeltaMass; dbTracerDef.FinalEnrichment = tracerDefData.FinalEnrichment; dbTracerDef.InitialEnrichment = tracerDefData.InitialEnrichment; dbTracerDef.IsotopesEluteEarlier = tracerDefData.IsotopesEluteEarlier; dbTracerDef.IsotopesEluteLater = tracerDefData.IsotopesEluteLater; dbTracerDef.Name = tracerDefData.Name; dbTracerDef.TracerSymbol = tracerDefData.TracerSymbol; }
protected Workspace CreateWorkspace(string path, DbTracerDef dbTracerDef) { using (var sessionFactory = SessionFactoryFactory.CreateSessionFactory(path, SessionFactoryFlags.CreateSchema)) { using (var session = sessionFactory.OpenSession()) { var transaction = session.BeginTransaction(); var dbWorkspace = new DbWorkspace { ModificationCount = 1, TracerDefCount = dbTracerDef == null ? 0 : 1, SchemaVersion = WorkspaceUpgrader.CurrentVersion, }; session.Save(dbWorkspace); if (dbTracerDef != null) { dbTracerDef.Workspace = dbWorkspace; dbTracerDef.Name = "Tracer"; session.Save(dbTracerDef); } var modification = new DbModification { DeltaMass = 57.021461, Symbol = "C", Workspace = dbWorkspace }; session.Save(modification); transaction.Commit(); } } var workspace = new Workspace(path); workspace.SetTaskScheduler(TaskScheduler.Default); workspace.DatabasePoller.LoadAndMergeChanges(null); return(workspace); }
// TODO(nicksh): 2013-10-03: Re-enable this test once it reliably passes //[TestMethod] public void TestPeakFinder() { String dbPath = Path.Combine(TestContext.TestDir, "PeakFinderTest.tpg"); using (var sessionFactory = SessionFactoryFactory.CreateSessionFactory(dbPath, SessionFactoryFlags.CreateSchema)) { using (var session = sessionFactory.OpenSession()) { session.BeginTransaction(); DbWorkspace dbWorkspace = new DbWorkspace { TracerDefCount = 1, SettingCount = 2, SchemaVersion = WorkspaceUpgrader.CurrentVersion }; session.Save(dbWorkspace); DbTracerDef dbTracerDef = TracerDef.GetD3LeuEnrichment(); dbTracerDef.Workspace = dbWorkspace; dbTracerDef.Name = "Tracer"; session.Save(dbTracerDef); session.Save(new DbSetting { Workspace = dbWorkspace, Name = SettingEnum.data_directory.ToString(), Value = GetDataDirectory() }); session.Save(new DbSetting { Workspace = dbWorkspace, Name = SettingEnum.mass_accuracy.ToString(), Value = "100000" }); session.Transaction.Commit(); } } Workspace workspace = new Workspace(dbPath); workspace.SetTaskScheduler(TaskScheduler.Default); workspace.DatabasePoller.LoadAndMergeChanges(null); foreach (var peakFinderPeptide in peptides) { AddPeptide(workspace, peakFinderPeptide); } while (true) { string statusMessage; int progress; workspace.ChromatogramGenerator.GetProgress(out statusMessage, out progress); if ("Idle" == statusMessage) { break; } Thread.Sleep(100); } workspace.DatabasePoller.LoadAndMergeChanges(null); var exceptions = new List <Exception>(); foreach (var peptide in peptides) { try { TestPeptide(workspace, peptide); } catch (Exception exception) { exceptions.Add(exception); Trace.TraceError("{0}:{1}", peptide.PeptideSequence, exception); } } CollectionAssert.AreEqual(new Exception[0], exceptions); }
private TracerDefData GetTracerDef() { string name = NormalizeName(tbxTracerName.Text); if (_originalTracerDef == null || name != _originalTracerDef.Name) { if (Workspace.GetTracerDefs().Any(pair => pair.Name == name)) { ShowError("There is already a label defined with this name.", tbxTracerName); return(null); } } foreach (var ch in name.ToLower()) { if (ch < 'a' || ch > 'z') { ShowError("Name can consist only of alphabetic characters", tbxTracerName); return(null); } } if (IsotopeAbundances.Default.ContainsKey(name) || AminoAcidFormulas.LongNames.ContainsKey(name)) { ShowError("Name cannot be the same as a 3 letter amino acid code, or an atomic element", tbxTracerName); return(null); } string tracerSymbol = NormalizeName(tbxTracerSymbol.Text); if (string.IsNullOrEmpty(tracerSymbol)) { ShowError("Symbol cannot be blank", tbxTracerSymbol); return(null); } if (!IsotopeAbundances.Default.ContainsKey(tracerSymbol) && !AminoAcidFormulas.LongNames.ContainsKey(tracerSymbol)) { ShowError("Symbol must be either a three letter amino acid code, or an atomic element", tbxTracerSymbol); return(null); } double deltaMass; try { deltaMass = double.Parse(tbxMassDifference.Text); } catch { ShowError("This must be a number", tbxMassDifference); return(null); } if (deltaMass == 0) { ShowError("Mass cannot be 0", tbxMassDifference); return(null); } int atomCount; try { atomCount = int.Parse(tbxAtomCount.Text); } catch { ShowError("This must be a positive integer", tbxAtomCount); return(null); } if (atomCount <= 0) { ShowError("This must be a positive integer", tbxAtomCount); return(null); } double atomicPercentEnrichment, initialApe, finalApe; if (!ValidatePercent(tbxAtomicPercentEnrichment, out atomicPercentEnrichment) || !ValidatePercent(tbxInitialApe, out initialApe) || !ValidatePercent(tbxFinalApe, out finalApe)) { return(null); } var dbTracerDef = new DbTracerDef { AtomCount = atomCount, AtomPercentEnrichment = atomicPercentEnrichment, DeltaMass = deltaMass, InitialEnrichment = initialApe, FinalEnrichment = finalApe, IsotopesEluteEarlier = cbxEluteEarlier.Checked, IsotopesEluteLater = cbxEluteLater.Checked, Name = name, TracerSymbol = tracerSymbol, }; return(new TracerDefData(dbTracerDef)); }
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); } }
protected Workspace CreateWorkspace(string path, DbTracerDef dbTracerDef) { using (var sessionFactory = SessionFactoryFactory.CreateSessionFactory(path, SessionFactoryFlags.CreateSchema)) { using (var session = sessionFactory.OpenSession()) { var transaction = session.BeginTransaction(); var dbWorkspace = new DbWorkspace { ModificationCount = 1, TracerDefCount = dbTracerDef == null ? 0 : 1, SchemaVersion = WorkspaceUpgrader.CurrentVersion, }; session.Save(dbWorkspace); if (dbTracerDef != null) { dbTracerDef.Workspace = dbWorkspace; dbTracerDef.Name = "Tracer"; session.Save(dbTracerDef); } var modification = new DbModification { DeltaMass = 57.021461, Symbol = "C", Workspace = dbWorkspace }; session.Save(modification); transaction.Commit(); } } var workspace = new Workspace(path); workspace.SetTaskScheduler(TaskScheduler.Default); workspace.DatabasePoller.LoadAndMergeChanges(null); return workspace; }
private TracerDefData GetTracerDef() { string name = NormalizeName(tbxTracerName.Text); if (_originalTracerDef == null || name != _originalTracerDef.Name) { if (Workspace.GetTracerDefs().Any(pair=>pair.Name == name)) { ShowError("There is already a label defined with this name.", tbxTracerName); return null; } } foreach (var ch in name.ToLower()) { if (ch < 'a' || ch > 'z') { ShowError("Name can consist only of alphabetic characters", tbxTracerName); return null; } } if (IsotopeAbundances.Default.ContainsKey(name) || AminoAcidFormulas.LongNames.ContainsKey(name)) { ShowError("Name cannot be the same as a 3 letter amino acid code, or an atomic element", tbxTracerName); return null; } string tracerSymbol = NormalizeName(tbxTracerSymbol.Text); if (string.IsNullOrEmpty(tracerSymbol)) { ShowError("Symbol cannot be blank", tbxTracerSymbol); return null; } if (!IsotopeAbundances.Default.ContainsKey(tracerSymbol) && !AminoAcidFormulas.LongNames.ContainsKey(tracerSymbol)) { ShowError("Symbol must be either a three letter amino acid code, or an atomic element", tbxTracerSymbol); return null; } double deltaMass; try { deltaMass = double.Parse(tbxMassDifference.Text); } catch { ShowError("This must be a number", tbxMassDifference); return null; } if (deltaMass == 0) { ShowError("Mass cannot be 0", tbxMassDifference); return null; } int atomCount; try { atomCount = int.Parse(tbxAtomCount.Text); } catch { ShowError("This must be a positive integer", tbxAtomCount); return null; } if (atomCount <= 0) { ShowError("This must be a positive integer", tbxAtomCount); return null; } double atomicPercentEnrichment, initialApe, finalApe; if (!ValidatePercent(tbxAtomicPercentEnrichment, out atomicPercentEnrichment) || !ValidatePercent(tbxInitialApe, out initialApe) || !ValidatePercent(tbxFinalApe, out finalApe)) { return null; } var dbTracerDef = new DbTracerDef { AtomCount = atomCount, AtomPercentEnrichment = atomicPercentEnrichment, DeltaMass = deltaMass, InitialEnrichment = initialApe, FinalEnrichment = finalApe, IsotopesEluteEarlier = cbxEluteEarlier.Checked, IsotopesEluteLater = cbxEluteLater.Checked, Name = name, TracerSymbol = tracerSymbol, }; return new TracerDefData(dbTracerDef); }