/// <summary> /// Add another evidence of the ConsensusTarget /// </summary> /// <param name="evidence"></param> public void AddEvidence(Evidence evidence) { Evidences.Add(evidence); if (Sequence == null) { Sequence = evidence.Sequence; } evidence.Sequence = Sequence; if (Math.Abs(PredictedNet) < double.Epsilon) { PredictedNet = evidence.PredictedNet; } // For rebuilding and getting the predicted NET into Evidence // when reloading back into the data objects evidence.PredictedNet = PredictedNet; if (MultiProteinCount == 0) { MultiProteinCount = evidence.MultiProteinCount; } evidence.MultiProteinCount = MultiProteinCount; if (string.IsNullOrWhiteSpace(ModificationDescription)) { ModificationDescription = evidence.ModificationDescription; } evidence.ModificationDescription = ModificationDescription; if (ModificationCount == 0) { ModificationCount = evidence.ModificationCount; } evidence.ModificationCount = ModificationCount; if (evidence.Ptms.Count != 0 && Ptms.Count == 0) { foreach (var ptm in evidence.Ptms) { Ptms.Add(ptm); ptm.Parent = this; } } var tempList = Ptms.ToList(); tempList.Sort((x, y) => x.Location.CompareTo(y.Location)); // Copy sequence as is up until you hit a modification //For numeric, add a bracket add +/- and copy the mass //For non numeric, add a bracket add +/- and copy the formula var numeric = ""; var nonNumeric = ""; var cleanSeq = ""; var sequencePos = 0; var symbolsRemoved = 0; string partialSeq; foreach (var ptm in tempList) { partialSeq = Sequence.Substring(sequencePos, (ptm.Location + PreCharCount + symbolsRemoved) - sequencePos); cleanSeq += partialSeq; numeric += partialSeq + string.Format("[{0}{1}]", ((ptm.Mass > 0) ? "+" : "-"), ptm.Mass); nonNumeric += partialSeq + string.Format("[{0}{1}]", ((ptm.Mass > 0) ? "+" : "-"), ptm.Formula); sequencePos = ptm.Location + PreCharCount; // To skip over non-alphanumeric characters in the sequence such as "*" or "&" // which can be used to denote ptms in .txt files, but not skip over "." or "-" // which are standard characters in peptide sequences to separate peptide from // pre/post residues and to denote the lack of a pre/post residue respectively int indexCheck = sequencePos + symbolsRemoved; if ((Sequence[indexCheck] != 46 && Sequence[indexCheck] != 45) && (Sequence[indexCheck] < 65 || Sequence[indexCheck] > 90)) { sequencePos += ++symbolsRemoved; } } partialSeq = Sequence.Substring(sequencePos); cleanSeq += partialSeq; numeric += partialSeq; nonNumeric += partialSeq; StrippedSequence = cleanSeq; var pieces = cleanSeq.Split('.'); if (pieces.Count() != 1) { PrefixResidue = pieces[0].First(); StrippedSequence = pieces[1]; SuffixResidue = pieces[2].First(); } if (string.IsNullOrWhiteSpace(evidence.CleanPeptide)) { //evidence.CleanPeptide = cleanSeq; evidence.CleanPeptide = StrippedSequence; } CleanSequence = cleanSeq; if (string.IsNullOrWhiteSpace(evidence.EncodedNonNumericSequence)) { evidence.EncodedNonNumericSequence = nonNumeric; } EncodedNonNumericSequence = nonNumeric; if (string.IsNullOrWhiteSpace((evidence.SeqWithNumericMods))) { evidence.SeqWithNumericMods = numeric; } EncodedNumericSequence = numeric; if (!Charges.Contains(evidence.Charge)) { Charges.Add(evidence.Charge); } evidence.Parent = this; }