/// <summary> /// Constructor /// </summary> /// <param name="tolerance"></param> public MzComparerWithTolerance(Tolerance tolerance) { if (tolerance.GetUnit() == ToleranceUnit.Ppm) { _equalityComparer = new MzComparerWithPpmTolerance(tolerance.GetValue()); } else if (tolerance.GetUnit() == ToleranceUnit.Mz) { _equalityComparer = new MzComparerWithToleranceMz(tolerance.GetValue()); } else { throw new NotSupportedException("The tolerance unite must be ppm or Th."); } }
public FeatureSet GetFeatures(double mz, Tolerance tolerance, DataReader.FrameType frameType) { var intensityBlock = _uimfUtil.GetXic(mz, tolerance.GetValue(), frameType, tolerance.GetUnit() == ToleranceUnit.Ppm ? DataReader.ToleranceType.PPM : DataReader.ToleranceType.Thomson); var features = new FeatureSet(intensityBlock); return features; }
public Dictionary<int,FeatureSet> GetFeaturesMultiThreading(int minTargetBin, int maxTargetBin, Tolerance tolerance, DataReader.FrameType frameType) { var featureDictionary = new Dictionary<int, FeatureSet>(); var targetMzList = Enumerable.Range(minTargetBin, maxTargetBin - minTargetBin + 1).Select(targetBin => _uimfUtil.GetMzFromBin(targetBin)).ToList(); var featureStatisticsDictionary = _featureDetectionUtil.GetFeatureStatistics(targetMzList, tolerance.GetValue(), frameType, tolerance.GetUnit() == ToleranceUnit.Ppm ? DataReader.ToleranceType.PPM : DataReader.ToleranceType.Thomson); foreach (var entry in featureStatisticsDictionary) { var targetBin = _uimfUtil.GetBinFromMz(entry.Key); var featureStats = entry.Value; featureDictionary.Add(targetBin, new FeatureSet(featureStats)); } return featureDictionary; }
public void TestPpmErrorCalculation(string seqText, string rawFilePath, int scanNum) { var methodName = MethodBase.GetCurrentMethod().Name; ShowStarting(methodName, rawFilePath); var tolerance = new Tolerance(10, ToleranceUnit.Ppm); const int maxCharge = 15; const double relIntThres = 0.1; if (!File.Exists(rawFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rawFilePath); } // init var sequence = Sequence.GetSequenceFromMsGfPlusPeptideStr(seqText); var lcms = PbfLcMsRun.GetLcMsRun(rawFilePath); var spectrum = lcms.GetSpectrum(scanNum); var ionTypeFactory = new IonTypeFactory(maxCharge); var iontypes = ionTypeFactory.GetAllKnownIonTypes(); foreach (var iontype in iontypes) { var ion = iontype.GetIon(sequence.Composition); var obsPeaks = spectrum.GetAllIsotopePeaks(ion, tolerance, relIntThres); if (obsPeaks == null) continue; var isotopes = ion.GetIsotopes(relIntThres).ToArray(); for (int i = 0; i < isotopes.Length; i++) { if (obsPeaks[i] == null) continue; var obsMz = obsPeaks[i].Mz; var theoMz = ion.GetIsotopeMz(isotopes[i].Index); var ppmError = (obsMz - theoMz)/theoMz*1e6; Assert.True(ppmError <= tolerance.GetValue()); } } }
private Dictionary<MSDeconvNode, List<MSDeconvNode>> GetEdges(List<MSDeconvNode> nodeList, Tolerance tol, double elutionInterval) { var edgeDict = new Dictionary<MSDeconvNode, List<MSDeconvNode>>(); var currentNode = nodeList[0]; var currentIndex = GetIndexRange(nodeList, elutionInterval, currentNode); foreach (var n1 in nodeList) { if (n1.ScanNumber != currentNode.ScanNumber) { currentNode = n1; currentIndex = GetIndexRange(nodeList, elutionInterval, currentNode); if (currentIndex.Item2 == -1) break; } edgeDict.Add(n1 ,new List<MSDeconvNode>()); for (var i = currentIndex.Item1 ; i < currentIndex.Item2; i++) { var deltaMass = Math.Abs(nodeList[i].RealMonoMass - n1.RealMonoMass); if(deltaMass <= tol.GetValue()) edgeDict[n1].Add(nodeList[i]); } } return edgeDict; }