예제 #1
0
        /// <summary>
        /// Generates a hash code.
        /// </summary>
        /// <returns>Hash code based on stored data.</returns>
        public override int GetHashCode()
        {
            var hashCode =
                PrecursorMz.GetHashCode() ^
                PrecursorChargeState.GetHashCode() ^
                Scan.GetHashCode() ^
                Id.GetHashCode() ^
                GroupId.GetHashCode() ^
                TotalIonCurrent.GetHashCode() ^
                RetentionTime.GetHashCode();

            return(hashCode);
        }
예제 #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Label != null ? Label.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Cohort != null ? Cohort.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sample != null ? Sample.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PrecursorPool != null ? PrecursorPool.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ TimePoint.GetHashCode();
         hashCode = (hashCode * 397) ^ (Times != null ? Times.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TotalIonCurrent != null ? TotalIonCurrent.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #3
0
        /// <summary>
        /// Compares two objects' values.
        /// </summary>
        /// <param name="obj">Other to compare with.</param>
        /// <returns>True if values are the same, false if not.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            var other = obj as MSSpectra;

            if (other == null)
            {
                return(false);
            }

            if (!GroupId.Equals(other.GroupId))
            {
                return(false);
            }
            if (!MsLevel.Equals(other.MsLevel))
            {
                return(false);
            }
            if (!PrecursorChargeState.Equals(other.PrecursorChargeState))
            {
                return(false);
            }
            if (!PrecursorMz.Equals(other.PrecursorMz))
            {
                return(false);
            }
            if (!Net.Equals(other.Net))
            {
                return(false);
            }
            if (!Scan.Equals(other.Scan))
            {
                return(false);
            }
            if (!TotalIonCurrent.Equals(other.TotalIonCurrent))
            {
                return(false);
            }
            if (!CollisionType.Equals(other.CollisionType))
            {
                return(false);
            }
            return(true);
        }
예제 #4
0
        public string ToString(IReadOnlyDictionary <string, int> ModstoWritePruned)
        {
            var sb = new StringBuilder();

            sb.Append(Path.GetFileNameWithoutExtension(FullFilePath));
            sb.Append('\t' + ScanNumber.ToString(CultureInfo.InvariantCulture));
            sb.Append('\t' + ScanRetentionTime.ToString("F5", CultureInfo.InvariantCulture));
            sb.Append('\t' + ScanExperimentalPeaks.ToString("F5", CultureInfo.InvariantCulture));
            sb.Append('\t' + TotalIonCurrent.ToString("F5", CultureInfo.InvariantCulture));
            sb.Append('\t' + (PrecursorScanNumber.HasValue ? PrecursorScanNumber.Value.ToString(CultureInfo.InvariantCulture) : "unknown"));
            sb.Append('\t' + ScanPrecursorCharge.ToString("F5", CultureInfo.InvariantCulture));
            sb.Append('\t' + ScanPrecursorMonoisotopicPeakMz.ToString("F5", CultureInfo.InvariantCulture));
            sb.Append('\t' + ScanPrecursorMass.ToString("F5", CultureInfo.InvariantCulture));
            sb.Append('\t' + Score.ToString("F3", CultureInfo.InvariantCulture));
            sb.Append("\t" + Resolve(compactPeptides.Select(b => b.Value.Item1)).Item1); // Notch
            sb.Append('\t' + NumDifferentCompactPeptides.ToString("F5", CultureInfo.InvariantCulture));

            if (compactPeptides.First().Value.Item2 != null)
            {
                sb.Append("\t" + GlobalVariables.CheckLengthOfOutput(string.Join("|", compactPeptides.Select(b => b.Value.Item2.Count.ToString(CultureInfo.InvariantCulture)))));

                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.BaseSequence)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Sequence)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.EssentialSequence(ModstoWritePruned))).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.allModsOneIsNterminus)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => string.Join("|", b.allModsOneIsNterminus.OrderBy(c => c.Key).Where(c => c.Value is ModificationWithMassAndCf).Select(c => (c.Value as ModificationWithMassAndCf).chemicalFormula.Formula)))).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.allModsOneIsNterminus.Select(c => (c.Value as ModificationWithMassAndCf)))).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.NumVariableMods)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.MissedCleavages.HasValue ? b.MissedCleavages.Value.ToString(CultureInfo.InvariantCulture) : "unknown")).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.MonoisotopicMass)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => ScanPrecursorMass - b.MonoisotopicMass)).Item1);
                sb.Append('\t' + ResolveF2(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => ((ScanPrecursorMass - b.MonoisotopicMass) / b.MonoisotopicMass * 1e6))).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.Accession)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.FullName)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => string.Join(", ", b.Protein.GeneNames.Select(d => d.Item1 + ":" + d.Item2)))).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.Organism)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.IsContaminant ? "Y" : "N")).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.Protein.IsDecoy ? "Y" : "N")).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.PeptideDescription)).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => ("[" + b.OneBasedStartResidueInProtein.ToString(CultureInfo.InvariantCulture) + " to " + b.OneBasedEndResidueInProtein.ToString(CultureInfo.InvariantCulture) + "]"))).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.PreviousAminoAcid.ToString())).Item1);
                sb.Append('\t' + Resolve(compactPeptides.SelectMany(b => b.Value.Item2).Select(b => b.NextAminoAcid.ToString())).Item1);
                if (FdrInfo != null && FdrInfo.CalculateEValue)
                {
                    int theoreticalsSearched = AllScores[0];
                    sb.Append('\t' + AllScores[0].ToString());
                    for (int i = 1; i < AllScores.Count; i++)
                    {
                        sb.Append("_" + AllScores[i]);
                        theoreticalsSearched += AllScores[i];
                    }
                    sb.Append('\t' + theoreticalsSearched.ToString());
                }
                else
                {
                    sb.Append('\t' + " " + '\t' + " ");
                }
                // Unambiguous
                if (IsDecoy)
                {
                    sb.Append("\t" + "D");
                }
                else if (compactPeptides.Any(b => b.Value.Item2.Any(c => c.Protein.IsContaminant)))
                {
                    sb.Append("\t" + "C");
                }
                else
                {
                    sb.Append("\t" + "T");
                }
            }
            else
            {
                sb.Append('\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " ");
            }

            if (MatchedIonDictOnlyMatches.Any())
            {
                //Count
                sb.Append('\t' + string.Join(";", MatchedIonDictOnlyMatches.Select(b => b.Value.Count(c => c > 0))));
                //Masses
                sb.Append('\t' + "[");
                StringBuilder sbTemp = new StringBuilder();
                foreach (var kvp in MatchedIonDictOnlyMatches)
                {
                    sbTemp.Append("[" + string.Join(",", kvp.Value.Select(b => b.ToString("F5", CultureInfo.InvariantCulture))) + "];");
                }
                sb.Append(GlobalVariables.CheckLengthOfOutput(sbTemp.ToString()));
                sb.Append("]");

                //Mass error Da
                sb.Append('\t' + "[");
                sbTemp.Clear();
                foreach (var kvp in ProductMassErrorDa)
                {
                    sbTemp.Append("[" + string.Join(",", kvp.Value.Select(b => b.ToString("F5", CultureInfo.InvariantCulture))) + "];");
                }
                sb.Append(GlobalVariables.CheckLengthOfOutput(sbTemp.ToString()));
                sb.Append("]");

                //Mass error ppm
                sb.Append('\t' + "[");
                sbTemp.Clear();
                foreach (var kvp in ProductMassErrorPpm)
                {
                    sbTemp.Append("[" + string.Join(",", kvp.Value.Select(b => b.ToString("F2", CultureInfo.InvariantCulture))) + "];");
                }
                sb.Append(GlobalVariables.CheckLengthOfOutput(sbTemp.ToString()));
                sb.Append("]");
            }
            else
            {
                sb.Append('\t' + " " + '\t' + " " + '\t' + " " + '\t' + " ");
            }

            if (LocalizedScores != null)
            {
                sb.Append('\t' + GlobalVariables.CheckLengthOfOutput(("[" + string.Join(",", LocalizedScores.Select(b => b.ToString("F3", CultureInfo.InvariantCulture))) + "]")));
                sb.Append('\t' + (LocalizedScores.Max() - Score).ToString("F3", CultureInfo.InvariantCulture));
            }
            else
            {
                sb.Append('\t' + " " + '\t' + " ");
            }

            if (FdrInfo != null)
            {
                sb.Append('\t' + FdrInfo.CumulativeTarget.ToString(CultureInfo.InvariantCulture));
                sb.Append('\t' + FdrInfo.CumulativeDecoy.ToString(CultureInfo.InvariantCulture));
                sb.Append('\t' + FdrInfo.QValue.ToString("F6", CultureInfo.InvariantCulture));
                sb.Append('\t' + FdrInfo.CumulativeTargetNotch.ToString(CultureInfo.InvariantCulture));
                sb.Append('\t' + FdrInfo.CumulativeDecoyNotch.ToString(CultureInfo.InvariantCulture));
                sb.Append('\t' + FdrInfo.QValueNotch.ToString("F6", CultureInfo.InvariantCulture));

                if (FdrInfo.CalculateEValue)
                {
                    sb.Append("\t" + FdrInfo.EValue.ToString("F6", CultureInfo.InvariantCulture));
                    sb.Append("\t" + FdrInfo.EScore.ToString("F6", CultureInfo.InvariantCulture));
                }
                else
                {
                    sb.Append('\t' + " " + '\t' + " ");
                }
            }
            else
            {
                sb.Append('\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " " + '\t' + " ");
            }

            return(sb.ToString());
        }