public int LoadIndex(string FileName) { this.RawFileName = FileName; RawFile = new MSFileReader_XRawfile(); RawFile.Open(FileName); RawFile.SetCurrentController(0, 1); Spectra = 0; RawFile.GetNumSpectra(ref Spectra); if (Spectra <= 0) { return(0); } int i, lastfull = 0, total = 0; double TotalEsi = 0.0; ms2index = new int[Spectra + 1]; IndexDir = new int[Spectra + 1]; IndexRev = new int[Spectra + 1]; RawSpectra = new RawData[Spectra + 1]; for (int j = 0; j <= Spectra; j++) { RawSpectra[j] = new RawData(); } Buf = new MZData[1000000]; ESICurrents = new double[Spectra + 1]; TimeStamps = new double[Spectra + 1]; TimeCoefs = new double[Spectra + 1]; string Filter = null; LowRT = 0.0; HighRT = 0.0; int Progress = 0; for (i = 1; i <= Spectra; i++) { if ((int)(100.0 * ((double)i / (double)Spectra)) > Progress) { Progress = (int)(100.0 * ((double)i / (double)Spectra)); if (RepProgress != null) { RepProgress(Progress); } } RawFile.GetFilterForScanNum(i, ref Filter); //YL - для спектров ms-only //Заплатка для MSX спектров if ((Filter.IndexOf(" ms ") != -1) && (Filter.IndexOf("FTMS") != -1)) //is a FULL MS { TimeStamps[i] = RawSpectra[lastfull].RT; IndexDir[lastfull] = i; IndexRev[i] = lastfull; lastfull = i; ms2index[i] = lastfull; ++total; RawFile.RTFromScanNum(i, ref RawSpectra[i].RT); RawSpectra[i].Filter = Filter; TotalRT = RawSpectra[i].RT; TimeStamps[i] = RawSpectra[i].RT - TimeStamps[i]; object Labels = null; object Values = null; int ArraySize = 0; double RT = 0.0; RawFile.GetStatusLogForScanNum(i, ref RT, ref Labels, ref Values, ref ArraySize); for (int k = 0; k < ArraySize; k++) { if ((Labels as Array).GetValue(k).ToString().Contains("Source Current")) { ESICurrents[i] = Convert.ToDouble((Values as Array).GetValue(k).ToString()); TotalEsi += ESICurrents[i]; } } } else { ms2index[i] = lastfull; } Filter = null; } IndexDir[lastfull] = -1; TotalRT = RawSpectra[lastfull].RT; AverageTimeStamp = TotalRT / total; //пересчитаем временные коэффициэнты for (i = IndexDir[0]; IndexDir[i] != -1; i = IndexDir[i]) { TimeCoefs[i] = (TimeStamps[i] + TimeStamps[IndexDir[i]]) / (2.0 * AverageTimeStamp); ESICurrents[i] = ESICurrents[i] / (TotalEsi / (double)total); } TimeCoefs[i] = 1.0; return(Spectra); }
public MSFileReader_XRawfile RawFile; //instance of LC-MS run public override int LoadIndex(string FileName) { this.RawFileName = FileName; RawFile = new MSFileReader_XRawfile(); RawFile.Open(FileName); RawFile.SetCurrentController(0, 1); Spectra = 0; RawFile.GetNumSpectra(ref Spectra); if (Spectra <= 0) //if there are no spectra available { return(0); } int i, LastFull = 0, Total = 0; //there will be fake [0] spectra with no data and fake last spectra with no data //it is made to make any chromatogram start and end with zero IndexDir = new int[Spectra + 2]; IndexRev = new int[Spectra + 2]; RawSpectra = new RawSpectrum[Spectra + 2]; for (int j = 0; j <= Spectra + 1; j++) { RawSpectra[j] = new RawSpectrum(); } TimeStamps = new double[Spectra + 2]; TimeCoefs = new double[Spectra + 2]; string Filter = null; bool PosMode = false, NegMode = false; LowRT = 0.0; HighRT = 0.0; int Progress = 0; for (i = 1; i <= Spectra; i++) { if ((int)(100.0 * ((double)i / (double)Spectra)) > Progress) //report progress { Progress = (int)(100.0 * ((double)i / (double)Spectra)); RepProgress?.Invoke(Progress); } RawFile.GetFilterForScanNum(i, ref Filter); //to reveal spectra properties we parse filter string if (Filter.Contains(" Full ") && Filter.Contains(" ms ") && Filter.Contains("FTMS")) //is a FULL MS { PosMode |= Filter.Contains(" + "); NegMode |= Filter.Contains(" - "); RawFile.RTFromScanNum(i, ref RawSpectra[i].RT); RawSpectra[i].Scan = i; TimeStamps[i] = RawSpectra[i].RT - RawSpectra[LastFull].RT; IndexDir[LastFull] = i; IndexRev[i] = LastFull; LastFull = i; Total++; } Filter = null; } IndexDir[LastFull] = Spectra + 1; //boundaries of navigation arrays IndexDir[Spectra + 1] = -1; IndexRev[Spectra + 1] = LastFull; TotalRT = RawSpectra[LastFull].RT; AverageTimeStamp = TotalRT / Total; //time interval bias coefficients for (i = IndexDir[0]; IndexDir[i] != -1; i = IndexDir[i]) { TimeCoefs[i] = (TimeStamps[i] + TimeStamps[IndexDir[i]]) / (2.0 * AverageTimeStamp); } TimeCoefs[i] = 1.0; //Fake spectra number 0 has to have reasonable RT double FRT = RawSpectra[IndexDir[0]].RT; //First full spectra RT double SRT = RawSpectra[IndexDir[IndexDir[0]]].RT; //Second full spectra RT RawSpectra[0].RT = Math.Max(0, FRT - (SRT - FRT)); // 0 or make the same distance like between 1-st and 2-nd spectra //Last spectra also has to have reasonable RT FRT = RawSpectra[LastFull].RT; //the same for last spectra SRT = RawSpectra[IndexRev[LastFull]].RT; RawSpectra[Spectra + 1].RT = FRT + (FRT - SRT); RawSpectra[Spectra + 1].Scan = RawSpectra[Spectra].Scan + 1; RawSpectra[0].Data = new MZData[0]; RawSpectra[Spectra + 1].Data = new MZData[0]; if (PosMode && !NegMode) { Mode = 1; } if (!PosMode && NegMode) { Mode = -1; } return(Spectra); }
public int LoadIndex(string FileName) { this.RawFileName = FileName; RawFile = new MSFileReader_XRawfile(); RawFile.Open(FileName); RawFile.SetCurrentController(0, 1); Spectra = 0; RawFile.GetNumSpectra(ref Spectra); if( Spectra <= 0) return 0; int i, lastfull = 0, total = 0; double TotalEsi = 0.0; ms2index = new int[Spectra+1]; IndexDir = new int[Spectra+1]; IndexRev = new int[Spectra+1]; RawSpectra = new RawData[Spectra+1]; for(int j = 0 ; j <= Spectra ; j++){ RawSpectra[j] = new RawData(); } Buf = new MZData[1000000]; ESICurrents = new double[Spectra+1]; TimeStamps = new double[Spectra+1]; TimeCoefs = new double[Spectra+1]; string Filter = null; LowRT = 0.0; HighRT = 0.0; int Progress = 0; for(i = 1; i <= Spectra; i++){ if ((int)(100.0*((double)i/(double)Spectra)) > Progress) { Progress = (int)(100.0*((double)i/(double)Spectra)); if (RepProgress != null){ RepProgress(Progress); } } RawFile.GetFilterForScanNum(i, ref Filter); //YL - для спектров ms-only //Заплатка для MSX спектров if((Filter.IndexOf(" ms ") != -1) && (Filter.IndexOf("FTMS") != -1)) { //is a FULL MS TimeStamps[i] = RawSpectra[lastfull].RT; IndexDir[lastfull] = i; IndexRev[i] = lastfull; lastfull = i; ms2index[i] = lastfull; ++total; RawFile.RTFromScanNum(i, ref RawSpectra[i].RT); RawSpectra[i].Filter = Filter; TotalRT = RawSpectra[i].RT; TimeStamps[i] = RawSpectra[i].RT - TimeStamps[i]; object Labels = null; object Values = null; int ArraySize = 0; double RT = 0.0; RawFile.GetStatusLogForScanNum(i, ref RT, ref Labels, ref Values , ref ArraySize); for (int k = 0 ; k < ArraySize ; k++ ){ if ((Labels as Array).GetValue(k).ToString().Contains("Source Current")){ ESICurrents[i] = Convert.ToDouble((Values as Array).GetValue(k).ToString()); TotalEsi+=ESICurrents[i]; } } } else { ms2index[i] = lastfull; } Filter = null ; } IndexDir[lastfull] = -1; TotalRT = RawSpectra[lastfull].RT; AverageTimeStamp = TotalRT/total; //пересчитаем временные коэффициэнты for (i = IndexDir[0] ; IndexDir[i] != -1 ; i = IndexDir[i]) { TimeCoefs[i] = (TimeStamps[i]+TimeStamps[IndexDir[i]])/(2.0*AverageTimeStamp); ESICurrents[i] = ESICurrents[i]/(TotalEsi/(double)total); } TimeCoefs[i] = 1.0; return Spectra; }