private void LoadResultsV1Data(string dataFileName) { _saveStructsInMemory = true; _dataInMemoryIsIncomplete = false; ClearPeaksAndIso(); using ( var fin = new BinaryReader(new FileStream(dataFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) ) { _fileName = fin.ReadString(); var versionStr = fin.ReadString(); // how many peaks do we need to read ? _numPeaksStored = fin.ReadInt32(); //var numRead = 0; var totalRead = 0; while (totalRead < _numPeaksStored) { var peak = LcmsPeak.ReadFromBinaryStream(fin); if (_peaksList.Count + 1 > _peaksList.Capacity && _peaksList.Capacity > int.MaxValue / 2) { _peaksList.Capacity = int.MaxValue - 150; } _peaksList.Add(peak); totalRead++; } var readTransforms = true; if (readTransforms) { _numIsoStored = fin.ReadInt32(); while (_transforms.Count < _numIsoStored) { var record = new clsHornTransformResults(IsotopeFitRecord.ReadFromBinaryStream(fin)); if (_transforms.Count + 1 > _transforms.Capacity && _transforms.Capacity > int.MaxValue / 2) { _transforms.Capacity = int.MaxValue - 150; } _transforms.Add(record); } } if (_numPeaksStored != 0) { _minScan = _peaksList[0].ScanNum; _maxScan = _peaksList[_peaksList.Count - 1].ScanNum; _lastScanAdded = _maxScan; } else { _minScan = _maxScan = _lastScanAdded = -1; } } CreateIndexesOnData(); }
public IsotopeFitRecord(clsHornTransformResults a) { PeakIndex = a.PeakIndex; ScanNum = a.ScanNum; ChargeState = a.ChargeState; //AbundanceInt = a.AbundanceInt; Abundance = a.Abundance; Mz = a.Mz; Fit = a.Fit; FitCountBasis = a.FitCountBasis; AverageMw = a.AverageMw; MonoMw = a.MonoMw; MostIntenseMw = a.MostIntenseMw; FWHM = a.FWHM; SignalToNoise = a.SignalToNoise; MonoIntensity = a.MonoIntensity; MonoPlus2Intensity = a.MonoPlus2Intensity; DeltaMz = a.DeltaMz; NumIsotopesObserved = a.NumIsotopesObserved; IsotopePeakIndices = new int[MaxIsotopes]; for (var i = 0; i < NumIsotopesObserved; i++) { IsotopePeakIndices[i] = a.IsotopePeakIndices[i]; } }
public void AddTransforms(List <clsHornTransformResults> fitResults) { try { if (fitResults.Count == 0) { return; } _numIsoStored += fitResults.Count; if (fitResults.Count != 0) { _isoFile.Flush(); using (var bWriter = new BinaryWriter(_isoFile, Encoding.ASCII, true)) { foreach (var record in fitResults) { var result = new clsHornTransformResults(record); // result.WriteToBinaryStream(bWriter); new IsotopeFitRecord(record).WriteToBinaryStream(bWriter); } } } if (!_saveStructsInMemory) { return; } if (_transforms.Count + fitResults.Count > _transforms.Capacity && _transforms.Capacity > int.MaxValue / 2) { _transforms.Capacity = int.MaxValue - 150; } _transforms.AddRange(fitResults); } catch (OutOfMemoryException) { if (_saveStructsInMemory) { _peaksList.Clear(); _transforms.Clear(); } _dataInMemoryIsIncomplete = true; #if DEBUG throw; #endif } }