public int getScanNumberOfPrevOrNextSpectrumByType(int _scan, spectrumPosition _position, spectrumTypes _typeOfSpec) { double RT = 0; rawFile.RTFromScanNum(_scan, ref RT); return(getScanNumberOfPrevOrNextSpectrumByType(RT, _position, _typeOfSpec)); }
public double[,] getRTandMaxFromScanNumberOfPrevOrNextFull(int _scanNumber, double _referenceMZ, double _tolerance, spectrumPosition _position) { int direction = 0; int lastSpectrum = 0; int newScanNumber = _scanNumber; switch (_position) { case spectrumPosition.previous: { direction = -1; break; } case spectrumPosition.next: { direction = 1; break; } default: return(getRTandMaxFromScanNumber(_scanNumber, _referenceMZ, _tolerance)); } rawFile.GetLastSpectrumNumber(ref lastSpectrum); newScanNumber += direction; while (newScanNumber > 0 && newScanNumber <= lastSpectrum) { if (spectrumTypeFromScanNumber(newScanNumber) == spectrumTypes.Full) { return(getRTandMaxFromScanNumber(newScanNumber, _referenceMZ, _tolerance)); } newScanNumber += direction; } return(null); }
public int getScanNumberOfPrevOrNextSpectrumByType(double _RT, spectrumPosition _position, spectrumTypes _typeOfSpec) { int scanNumber = 0; rawFile.ScanNumFromRT(_RT, ref scanNumber); int direction = 0; int lastScanNumber = 0; rawFile.GetLastSpectrumNumber(ref lastScanNumber); switch (_position) { case spectrumPosition.next: { scanNumber++; direction = 1; break; } case spectrumPosition.sameOrNext: { direction = 1; break; } case spectrumPosition.previous: { scanNumber--; direction = -1; break; } case spectrumPosition.sameOrPrevious: { direction = -1; break; } case spectrumPosition.nearestInScanNumber: { int thisScanNumber = 0; rawFile.ScanNumFromRT(_RT, ref thisScanNumber); int previousSN = getScanNumberOfPrevOrNextSpectrumByType(_RT, spectrumPosition.sameOrPrevious, _typeOfSpec); int nextSN = getScanNumberOfPrevOrNextSpectrumByType(_RT, spectrumPosition.sameOrNext, _typeOfSpec); // usually this happens when the en of the war is reached if (nextSN == 0) { return(previousSN); } if (previousSN == 0) { return(nextSN); } if (thisScanNumber - previousSN < nextSN - thisScanNumber) { return(previousSN); } else { return(nextSN); } } case spectrumPosition.nearestInRT: { int previousSN = getScanNumberOfPrevOrNextSpectrumByType(_RT, spectrumPosition.sameOrPrevious, _typeOfSpec); int nextSN = getScanNumberOfPrevOrNextSpectrumByType(_RT, spectrumPosition.sameOrNext, _typeOfSpec); // usually this happens when the en of the war is reached if (nextSN == 0) { return(previousSN); } if (previousSN == 0) { return(nextSN); } double previousRT = 0; double nextRT = 0; rawFile.RTFromScanNum(previousSN, ref previousRT); rawFile.RTFromScanNum(nextSN, ref nextRT); if (_RT - previousRT < nextRT - _RT) { return(previousSN); } else { return(nextSN); } } case spectrumPosition.same: { // attention! this will not always be a fullScan! return(scanNumber); } } while (scanNumber > 0 && scanNumber < lastScanNumber) { if (spectrumTypeFromScanNumber(scanNumber) == _typeOfSpec) { return(scanNumber); } else { scanNumber += direction; } } return(0); }