public void CalculateIntensityForThisFeature(bool integrate) { if (IsotopicEnvelopes.Any()) { double maxIntensity = IsotopicEnvelopes.Max(p => p.Intensity); Apex = IsotopicEnvelopes.Where(p => p.Intensity == maxIntensity).First(); if (integrate) { Intensity = IsotopicEnvelopes.Sum(p => p.Intensity); } else { Intensity = Apex.Intensity; } MassError = Identifications.Min(p => ((ClassExtensions.ToMass(Apex.IndexedPeak.Mz, Apex.ChargeState) - p.monoisotopicMass) / p.monoisotopicMass) * 1e6); NumChargeStatesObserved = IsotopicEnvelopes.Select(p => p.ChargeState).Distinct().Count(); } else { Intensity = 0; MassError = double.NaN; NumChargeStatesObserved = 0; Apex = null; } }
/// <summary> /// Get all the key=value pairs (pins) exposed by the implementor. /// </summary> /// <param name="item">The optional item. The item with its parts /// can optionally be passed to this method for those parts requiring /// to access further data.</param> /// <returns>The pins.</returns> public override IEnumerable <DataPin> GetDataPins(IItem item) { DataPinBuilder builder = new DataPinBuilder( new StandardDataPinTextFilter()); builder.AddValue("id", GraffitiId); if (!string.IsNullOrEmpty(Language)) { builder.AddValue("language", Language); } if (!string.IsNullOrEmpty(Verse)) { builder.AddValue("verse", Verse); } if (!string.IsNullOrEmpty(Author)) { builder.AddValue("author", Author, filter: true, filterOptions: true); } if (Identifications?.Count > 0) { builder.AddValues("pid", Identifications.Select(i => i.Id)); } if (Date != null) { builder.AddValue("date-value", Date.GetSortValue()); } return(builder.Build(this)); }
private void SetIdentifications(IEnumerable <IdentifyFromFile> identifications) { foreach (var detectFromFile in identifications) { var image = Identifications.First(model => model.Source.Name == detectFromFile.Source.Name); image.Identifications = detectFromFile.Identifications; } }
public static void SetPep(Identifications identifications, BayesianInversion2D bi) { int n = identifications.Count; for (int i = 0; i < n; i++) { MascotPeptide p = identifications.GetPeptidesAt(i)[0]; p.Pep = bi.GetValue(p.AltScore, Math.Log(p.Sequence.Length)); } identifications.Write(); }
/// <summary> /// Sets all default fields of the screen instance. /// </summary> /// <param name="identification">The ID of the screen.</param> /// <param name="mouseVisible">Sets if the mouse is visible on the screen.</param> /// <param name="canBePaused">Sets if the PauseScreen can be opened by pressing Escape.</param> /// <param name="canMuteMusic">Sets if the M button (default) can mute the music.</param> /// <param name="canChat">Sets if the T button (default) can open the chat screen.</param> /// <param name="canTakeScreenshot">Sets if the F2 button (default) can take a screenshot.</param> /// <param name="canDrawDebug">Sets if the debug information can be drawn on this screen.</param> /// <param name="canGoFullscreen">Sets if the F11 button (default) can sets the game to fullscreen (or back).</param> private void Setup(Identifications identification, bool mouseVisible, bool canBePaused, bool canMuteMusic, bool canChat, bool canTakeScreenshot, bool canDrawDebug, bool canGoFullscreen) { Identification = identification; MouseVisible = mouseVisible; CanBePaused = canBePaused; CanChat = canChat; CanDrawDebug = canDrawDebug; CanGoFullscreen = canGoFullscreen; CanMuteMusic = canMuteMusic; CanTakeScreenshot = canTakeScreenshot; }
public static void CollectSequences(Identifications identifications, double peptidePep, HashSet <string> sequences) { int n = identifications.Count; for (int i = 0; i < n; i++) { MascotPeptide p = identifications.GetPeptidesAt(i)[0]; if ((p.Pep <= peptidePep) || (double.IsNaN(p.Pep) && double.IsNaN(peptidePep))) { sequences.Add(p.Sequence); } } }
private static void LimitPep(string[] rawFiles, MascotQueryType type, IIdentificationProvider ip) { for (int i = 0; i < rawFiles.Length; i++) { Identifications ident = ip.GetIdentifications(rawFiles[i], type); int n = ident.Count; for (int j = 0; j < n; j++) { MascotPeptide p = ident.GetPeptidesAt(j)[0]; p.Pep = Math.Min(p.Pep, 1); } ident.Write(); ip.Dispose(); } }
public static void ApplyReverseHitThreshold(Identifications identifications, double pepThreshold) { int n = identifications.Count; List <int> o = new List <int>(); for (int i = 0; i < n; i++) { MascotPeptide p = identifications.GetPeptidesAt(i)[0]; if (p.Pep <= pepThreshold) { o.Add(i); } } identifications.Extract(o.ToArray()); identifications.Write(); }
public static void FilterBySequence(Identifications identifications, HashSet <string> sequences) { int n = identifications.Count; List <int> oo = new List <int>(); for (int i = 0; i < n; i++) { MascotPeptide p = identifications.GetPeptidesAt(i)[0]; if (sequences.Contains(p.Sequence)) { oo.Add(i); } } identifications.Extract(oo.ToArray()); identifications.Write(); }
private static void CalcFdr(string[] rawFiles, string decoyPrefix, MascotQueryType type, IProteinSet proteinSet, bool debug, IIdentificationProvider ip) { List <bool> correct = new List <bool>(); List <double> scores = new List <double>(); List <double> seqLen = new List <double>(); for (int i = 0; i < rawFiles.Length; i++) { Identifications ident = ip.GetIdentifications(rawFiles[i], type); int n = ident.Count; for (int j = 0; j < n; j++) { bool c = ident.IsHighestScoringCorrect(j, decoyPrefix, proteinSet); double s = ident.GetHighestAltScore(j); double l = Math.Log(ident.GetBestSequence(j).Length); if (!double.IsNaN(s) && !double.IsInfinity(s)) { correct.Add(c); scores.Add(s); seqLen.Add(l); } } ip.Dispose(); if (correct.Count > 10000000) { break; } } if (correct.Count == 0) { return; } bool write = debug && (type == MascotQueryType.Silac); BayesianInversion2D bi = new BayesianInversion2D(scores.ToArray(), seqLen.ToArray(), correct.ToArray(), write); if (write) { Write(rawFiles, bi); } for (int i = 0; i < rawFiles.Length; i++) { SetPep(ip.GetIdentifications(rawFiles[i], type), bi); ip.Dispose(); } }
public static double FindReverseHitThresholdValue(Identifications identifications, double totalPeptideFDR, string reverseStr, IProteinSet proteinSet) { int n = identifications.Count; if (n == 0) { return(1); } double[] peps = new double[n]; bool[] correct = new bool[n]; for (int i = 0; i < n; i++) { MascotPeptide p = identifications.GetPeptidesAt(i)[0]; peps[i] = p.Pep; correct[i] = !p.HasOnlyReverseHits(reverseStr, proteinSet); } int[] o = ArrayUtil.Order(peps); double forwardCount = 0; List <double> validPeps = new List <double>(); for (int i = 0; i < n; i++) { int index = o[i]; if (correct[index]) { forwardCount++; } double reverseCount = (i + 1) - forwardCount; if (reverseCount / forwardCount <= totalPeptideFDR) { validPeps.Add(peps[index]); } } if (validPeps.Count > 0) { return(ArrayUtil.Max(validPeps.ToArray())); } return(0); }
public LoginViewModel(ILoggerFacade logger, IUnityContainer unityContainer, IRegionManager regionManager, IEventAggregator eventAggregator, ITrackSuccessConnectionService trackService) { if (null == logger) { throw new ArgumentNullException("logger"); } if (null == unityContainer) { throw new ArgumentNullException("unityContainer"); } if (null == regionManager) { throw new ArgumentNullException("regionManager"); } if (null == eventAggregator) { throw new ArgumentNullException("eventAggregator"); } if (null == trackService) { throw new ArgumentNullException("trackService"); } this.m_Logger = logger; this.m_UnityContainer = unityContainer; this.m_RegionManager = regionManager; this.m_EventAggregator = eventAggregator; this.LoginModel = new LoginModel(); this.LoginCommand = new DelegateCommand <UIElement>(ExecuteLogin, CanExecuteLogin); this.TextChangedCommand = new DelegateCommand(ExecuteTextChanged); this.NavigateToCommand = new DelegateCommand <Uri>(ExecuteNavigateTo); this.InitialFocusCommand = new DelegateCommand <UIElement>(ExecuteInitialFocusCommand); this.InitialLoadedCommand = new DelegateCommand <SmoothBusyIndicator>(ExecuteInitialLoadedCommand); this.NavigateRequiredInfoViewCommand = new DelegateCommand(ExecuteNavigateRequiredInfoViewCommand); this.ConnectedIdentifications = trackService.GetListOfSuccessConnections(); }
public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(SpectraFileInfo.FilenameWithoutExtension + "\t"); sb.Append(string.Join("|", Identifications.Select(p => p.BaseSequence).Distinct()) + '\t'); sb.Append(string.Join("|", Identifications.Select(p => p.ModifiedSequence).Distinct()) + '\t'); var t = Identifications.SelectMany(p => p.ProteinGroups.Select(v => v.ProteinGroupName)).Distinct().OrderBy(p => p); if (t.Any()) { sb.Append(string.Join(";", t) + '\t'); } else { sb.Append("" + '\t'); } sb.Append("" + Identifications.First().MonoisotopicMass + '\t'); if (!IsMbrPeak) { sb.Append("" + Identifications.First().Ms2RetentionTimeInMinutes + '\t'); } else { sb.Append("" + '\t'); } sb.Append("" + Identifications.First().PrecursorChargeState + '\t'); sb.Append("" + ClassExtensions.ToMz(Identifications.First().MonoisotopicMass, Identifications.First().PrecursorChargeState) + '\t'); sb.Append("" + Intensity + "\t"); if (Apex != null) { sb.Append("" + IsotopicEnvelopes.Min(p => p.IndexedPeak.RetentionTime) + "\t"); sb.Append("" + Apex.IndexedPeak.RetentionTime + "\t"); sb.Append("" + IsotopicEnvelopes.Max(p => p.IndexedPeak.RetentionTime) + "\t"); sb.Append("" + Apex.IndexedPeak.Mz + "\t"); sb.Append("" + Apex.ChargeState + "\t"); } else { sb.Append("" + "-" + "\t"); sb.Append("" + "-" + "\t"); sb.Append("" + "-" + "\t"); sb.Append("" + "-" + "\t"); sb.Append("" + "-" + "\t"); } sb.Append("" + NumChargeStatesObserved + "\t"); if (IsMbrPeak) { sb.Append("" + "MBR" + "\t"); } else { sb.Append("" + "MSMS" + "\t"); } sb.Append("" + (IsMbrPeak ? MbrScore.ToString() : "") + "\t"); sb.Append("" + Identifications.Count + "\t"); sb.Append("" + NumIdentificationsByBaseSeq + "\t"); sb.Append("" + NumIdentificationsByFullSeq + "\t"); sb.Append("" + SplitRT + "\t"); sb.Append("" + MassError + "\t"); return(sb.ToString()); }
public void ResolveIdentifications() { this.NumIdentificationsByBaseSeq = Identifications.Select(v => v.BaseSequence).Distinct().Count(); this.NumIdentificationsByFullSeq = Identifications.Select(v => v.ModifiedSequence).Distinct().Count(); }