public TopDownProteoform(string accession, List <SpectrumMatch> hits) : base(accession, null, true) { SpectrumMatch root = hits[0]; this.name = root.name; this.pfr_accession = root.pfr_accession; this.topdown_ptm_set = new PtmSet(root.ptm_list); this.uniprot_id = root.uniprot_id; this.sequence = root.sequence; this.topdown_begin = root.begin; this.theoretical_mass = root.theoretical_mass; this.topdown_end = root.end; this.topdown_hits = hits; this.accession = accession + "_" + topdown_begin + "to" + topdown_end + "_1TD"; this.calculate_td_properties(); this.lysine_count = sequence.Count(s => s == 'K'); this.topdown_id = true; }
private IEnumerable <LabeledMs1DataPoint> SearchMS1Spectra(double[] originalMasses, double[] originalIntensities, int ms2spectrumIndex, int direction, List <int> scansAdded, HashSet <Tuple <double, int> > peaksAddedHashSet, int proteinCharge, SpectrumMatch identification) { int theIndex = direction == 1 ? ms2spectrumIndex : ms2spectrumIndex - 1; bool addedAscan = true; int highestKnownChargeForThisPeptide = proteinCharge; while (theIndex >= 1 && theIndex <= myMsDataFile.NumSpectra && addedAscan) { if (scansAdded.Contains(theIndex)) { theIndex += direction; continue; } scansAdded.Add(theIndex); int countForThisScan = 0; if (myMsDataFile.GetOneBasedScan(theIndex).MsnOrder > 1) { theIndex += direction; continue; } addedAscan = false; var fullMS1scan = myMsDataFile.GetOneBasedScan(theIndex); int ms1ScanNumber = fullMS1scan.OneBasedScanNumber; var scanWindowRange = fullMS1scan.ScanWindowRange; var fullMS1spectrum = fullMS1scan.MassSpectrum; if (fullMS1spectrum.Size == 0) { break; } //look in both charge state directions for proteins -- likely to have multiple charge states. for (int i = -1; i <= 1; i += 2) { bool startingToAddCharges = false; bool continueAddingCharges = false; int chargeToLookAt = i == 1 ? proteinCharge : (proteinCharge - 1); do { //if m/z too big or small and going in correct direction, increase or decrease charge state. otherwise break. if (originalMasses[0].ToMz(chargeToLookAt) > scanWindowRange.Maximum) { if (i == 1) { chargeToLookAt++; continue; } else { break; } } if (originalMasses[0].ToMz(chargeToLookAt) < scanWindowRange.Minimum) { if (i == -1) { chargeToLookAt--; continue; } else { break; } } var trainingPointsToAverage = new List <LabeledMs1DataPoint>(); foreach (double a in originalMasses) { double theMZ = a.ToMz(chargeToLookAt); if (Sweet.lollipop.neucode_labeled) { theMZ = Sweet.lollipop.get_neucode_mass(theMZ.ToMass(chargeToLookAt), identification.sequence.Count(s => s == 'K')).ToMz(chargeToLookAt); } double mass_tolerance = theMZ / 1e6 * Sweet.lollipop.cali_mass_tolerance; var npwr = fullMS1spectrum.NumPeaksWithinRange(theMZ - mass_tolerance, theMZ + mass_tolerance); if (npwr == 0) { break; } if (npwr > 1) { continue; } var closestPeak = fullMS1spectrum.GetClosestPeakXvalue(theMZ); var closestPeakMZ = closestPeak; var theTuple = closestPeakMZ != null?Tuple.Create((double)closestPeakMZ, ms1ScanNumber) : null; if (theTuple == null) { continue; } if (!peaksAddedHashSet.Contains(theTuple)) { peaksAddedHashSet.Add(theTuple); highestKnownChargeForThisPeptide = Math.Max(highestKnownChargeForThisPeptide, chargeToLookAt); trainingPointsToAverage.Add(new LabeledMs1DataPoint((double)closestPeakMZ, double.NaN, double.NaN, double.NaN, (double)closestPeakMZ - theMZ, (double)fullMS1scan.RetentionTime - identification.calibrated_retention_time, null)); } else { break; } } // If started adding and suddnely stopped, go to next one, no need to look at higher charges if (trainingPointsToAverage.Count == 0 && startingToAddCharges == true) { break; } if ((trainingPointsToAverage.Count == 0 || (trainingPointsToAverage.Count == 1 && originalIntensities[0] < 0.65)) && (proteinCharge <= chargeToLookAt)) { break; } if (trainingPointsToAverage.Count < Math.Min(5, originalIntensities.Count())) { } else { continueAddingCharges = true; addedAscan = true; startingToAddCharges = true; countForThisScan++; yield return(new LabeledMs1DataPoint(trainingPointsToAverage.Select(b => b.mz).Average(), fullMS1scan.RetentionTime, Math.Log(fullMS1scan.TotalIonCurrent), fullMS1scan.InjectionTime.HasValue ? Math.Log(fullMS1scan.InjectionTime.Value) : double.NaN, trainingPointsToAverage.Select(b => b.massError).Median(), trainingPointsToAverage.OrderBy(b => b.retentionTime).First().RTError, identification)); } chargeToLookAt += i; } while (continueAddingCharges); } theIndex += direction; } }