/// <summary> /// Remove all SpectrumIdentificationItems that have a specEValue greater than the best specEValue in the list. /// </summary> public void RemoveMatchesNotBestSpecEValue() { ReRankBySpecEValue(); var best = SpectrumIdentificationItems.First().GetSpecEValue(); SpectrumIdentificationItems.RemoveAll(item => item.GetSpecEValue() > best); }
/// <summary> /// Object hash code /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { var hashCode = PeptideEvidence != null?PeptideEvidence.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (SpectrumIdentificationItems != null ? SpectrumIdentificationItems.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Changes the rank so that items are ranked by specEValue, ascending /// Also re-writes the ids /// </summary> public void ReRankBySpecEValue() { var siiIdBase = Id.ToUpper().Replace("SIR", "SII") + "_"; SpectrumIdentificationItems.Sort((a, b) => a.GetSpecEValue().CompareTo(b.GetSpecEValue())); for (var i = 0; i < SpectrumIdentificationItems.Count; i++) { var rank = i + 1; SpectrumIdentificationItems[i].Rank = rank; SpectrumIdentificationItems[i].Id = siiIdBase + rank; } Sort(); }
/// <summary> /// Object hash code /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { var hashCode = Name != null?Name.GetHashCode() : 0; hashCode = (hashCode * 397) ^ (SpectrumID != null ? SpectrumID.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SpectrumIdentificationItems != null ? SpectrumIdentificationItems.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SpectraData != null ? SpectraData.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CVParams != null ? CVParams.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (UserParams != null ? UserParams.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// The lowest specEvalue in the SpectrumIdentificationItems /// </summary> /// <returns></returns> public double BestSpecEVal() { Sort(); return(SpectrumIdentificationItems.First().GetSpecEValue()); }
/// <summary> /// Sort the SpectrumIdentificationItems by rank, ascending /// </summary> public void Sort() { SpectrumIdentificationItems.Sort((a, b) => a.Rank.CompareTo(b.Rank)); }