GotOne(
false);
125 boolGotThisOne(
false);
129 if(!DTA || DTA.eof()) {
141 if(Max > 0 && Count > Max) {
142 ERR_POST(
Info<<
"LoadMultDTA: too many spectra in xml");
147 CRegexpRxpGetNum(
"\\sid\\s*=\\s*(\"(\\S+)\"|(\\S+)\b)");
149 if((Match = RxpGetNum.
GetMatch(
Line.c_str(), 0, 2)) !=
""||
150(Match = RxpGetNum.
GetMatch(
Line.c_str(), 0, 3)) !=
"") {
153MySpectrum->SetNumber(iIndex);
157 CRegexpRxpGetName(
"\\sname\\s*=\\s*(\"(\\S+)\"|(\\S+)\b)");
158 if((Match = RxpGetName.
GetMatch(
Line.c_str(), 0, 2)) !=
""||
159(Match = RxpGetName.
GetMatch(
Line.c_str(), 0, 3)) !=
"") {
165}
while(
Line.size() < 3 && !DTA.eof());
170 ERR_POST(
Info<<
"LoadMultDTA: not able to get header");
187 Set().push_back(MySpectrum);
189}
while(DTA && !DTA.eof());
196}
catch(NCBI_NS_STD::exception& e) {
197 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadMultDTA: "<< e.what());
200 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadMultDTA: ");
214 boolGotOne(
false);
218 boolGotThisOne(
false);
220 if(Max > 0 && Count > Max)
224MySpectrum->SetNumber(iIndex);
229}
while(
Line.size() < 3 && !DTA.eof());
241 if(!DTA || DTA.eof()) {
250 while(
Line.size() > 1) {
260 Set().push_back(MySpectrum);
262}
while(DTA && !DTA.eof());
267}
catch(NCBI_NS_STD::exception& e) {
268 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadMultBlankLineDTA: "<< e.what());
271 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadMultBlankLineDTA: ");
286 doubleprecursor(0.0L);
288 if(!(DTA >> precursor) || precursor < 0) {
300 if(!(DTA >>
dummy)
) {
303MySpectrum->SetCharge().push_back(
static_cast <int>(
dummy));
309MySpectrum->SetPrecursormz(
MSSCALE2INT(precursor));
329 for(
i= 0;
i< InputPeaks.size(); ++
i) {
330 if(InputPeaks[
i].Intensity > MaxI) MaxI = InputPeaks[
i].Intensity;
335 if(MaxI > 0.0) Scale = 1000000000.0/MaxI;
338Scale = pow(10.0, floor(
log10(Scale)));
339MySpectrum->SetIscale(Scale);
342 for(
i= 0;
i< InputPeaks.size(); ++
i) {
344MySpectrum->SetMz().push_back(InputPeaks[
i].mz);
346MySpectrum->SetAbundance().push_back(
static_cast <int>(InputPeaks[
i].Intensity*Scale));
368InputPeaks.push_back(InputPeak);
379 boolGotOne(
false);
386MySpectrum->SetNumber(1);
391}
while(
Line.size() < 3 && !DTA.eof());
407 Set().push_back(MySpectrum);
410}
catch(NCBI_NS_STD::exception& e) {
411 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadDTA: "<< e.what());
414 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadDTA: ");
418 if(!GotOne)
return1;
431 boolGotOne(
false);
437 if(Max > 0 && Count > Max)
440MySpectrum->SetNumber(iIndex);
447 else if(retval == 1) {
452 if(retval != -1 && retval != -2)
Set().push_back(MySpectrum);
454}
while(DTA && !DTA.eof() && retval != -1);
459}
catch(NCBI_NS_STD::exception& e) {
460 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadMGF: "<< e.what());
463 ERR_POST(
Info<<
"Exception in CSpectrumSet::LoadMGF: ");
477 boolGotMass(
false);
483 if(!DTA || DTA.eof())
490 if(!DTA || DTA.eof())
493MySpectrum->SetIds().push_back(
500 stringLastLine(
Line.substr(8,
Line.size()-8));
503 if(istr >> precursor) {
504MySpectrum->SetPrecursormz(
MSSCALE2INT(precursor));
509 stringLastLine(
Line.substr(7,
Line.size()-7));
518MySpectrum->SetCharge().clear();
523MySpectrum->SetCharge().push_back(charge);
525}
while(charge != 0);
532}
while(
Line.substr(0, 1).find_first_not_of(
"0123456789.-") == 0 ||
Line.empty());
537 if(MySpectrum->SetCharge().empty())
538MySpectrum->SetCharge().push_back(1);
541 if(!DTA || DTA.eof())
546 if(
Line.size() <= 1)
549 if(
Line.find_first_of(
"#;/!") == 0)
552 if(!
GetDTABody(istr, InputPeaks))
return1;
User-defined methods of the data storage class.
static CNcbiIstream & MyGetline(CNcbiIstream &is, string &str)
deque< TInputPeak > TInputPeaks
for holding a spectrum
int LoadFile(const EMSSpectrumFileType FileType, CNcbiIstream &DTA, int Max=0)
wrapper for various file loaders
bool GetDTAHeader(CNcbiIstream &DTA, CRef< CMSSpectrum > &MySpectrum, bool isPKL=false)
Read in the header of a DTA file.
int LoadMultDTA(CNcbiIstream &DTA, int Max=0)
load in multiple dta files with <dta> tag separators
int GetMGFBlock(CNcbiIstream &DTA, CRef< CMSSpectrum > &MySpectrum)
Read in an ms/ms block in an mgf file.
bool Peaks2Spectrum(const TInputPeaks &InputPeaks, CRef< CMSSpectrum > &MySpectrum) const
Convert peak list to spectrum.
int LoadMGF(CNcbiIstream &DTA, int Max=0)
load mgf file
bool GetDTABody(CNcbiIstream &DTA, TInputPeaks &InputPeaks)
Read in the body of a dta like file.
int LoadMultBlankLineDTA(CNcbiIstream &DTA, int Max=0, bool isPKL=false)
load multiple dta's separated by a blank line
int LoadDTA(CNcbiIstream &DTA)
load in a single dta file
Include a standard set of the NCBI C++ Toolkit most basic headers.
The NCBI C++ standard methods for dealing with std::string.
static const char * str(char *buf, int n)
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void Info(CExceptionArgs_Base &args)
CTempString GetMatch(CTempString str, size_t offset=0, size_t idx=0, TMatch flags=fMatch_default, bool noreturn=false)
Get matching pattern and subpatterns.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CNcbiIstream & NcbiGetline(CNcbiIstream &is, string &str, char delim, string::size_type *count=NULL)
Read from "is" to "str" up to the delimiter symbol "delim" (or EOF)
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static int Compare(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Compare of a substring with another string.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Tdata & Set(void)
Assign a value to data member.
EMSSpectrumFileType
Access to EMSSpectrumFileType's attributes (values, names) as defined in spec.
@ eMSSpectrumFileType_pks
@ eMSSpectrumFileType_mgf
@ eMSSpectrumFileType_sciex
@ eMSSpectrumFileType_omxbz2
bzip2 omx file
@ eMSSpectrumFileType_dtablank
@ eMSSpectrumFileType_pkl
@ eMSSpectrumFileType_omx
xml for iterative search
@ eMSSpectrumFileType_dtaxml
@ eMSSpectrumFileType_dta
@ eMSSpectrumFileType_unknown
@ eMSSpectrumFileType_asc
@ eMSSpectrumFileType_oms
asn.1 binary for iterative search
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
struct for holding a single peak
int mz
scaled m/z value for peak
float Intensity
unscaled intensity
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4