MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / load

Function load

src/openms/include/OpenMS/FORMAT/MS2File.h:50–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48
49 template <typename MapType>
50 void load(const String & filename, MapType & exp)
51 {
52 //startProgress(0,0,"loading DTA2D file");
53
54 if (!File::exists(filename))
55 {
56 throw Exception::FileNotFound(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
57 }
58 if (!File::readable(filename))
59 {
60 throw Exception::FileNotReadable(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename);
61 }
62
63 exp.reset();
64
65 //set DocumentIdentifier
66 exp.setLoadedFileType(filename);
67 exp.setLoadedFilePath(filename);
68
69 std::ifstream in(filename.c_str());
70
71 UInt spectrum_number = 0;
72 typename MapType::SpectrumType spec;
73 typename MapType::SpectrumType::PeakType p;
74
75 String line;
76 bool first_spec(true);
77
78 // line number counter
79 Size line_number = 0;
80
81 while (getline(in, line, '\n'))
82 {
83 ++line_number;
84
85 line.trim();
86 if (line.empty()) continue;
87
88 // header
89 if (line[0] == 'H')
90 {
91 continue;
92 }
93
94 // scan
95 if (line[0] == 'S')
96 {
97 if (!first_spec)
98 {
99 spec.setMSLevel(2);
100 spec.setNativeID(String("index=") + (spectrum_number++));
101 exp.addSpectrum(spec);
102 }
103 else
104 {
105 first_spec = false;
106 }
107 spec.clear(true);

Callers

nothing calls this directly

Calls 15

setLoadedFileTypeMethod · 0.80
setLoadedFilePathMethod · 0.80
setMSLevelMethod · 0.80
addSpectrumMethod · 0.80
getPrecursorsMethod · 0.80
toDoubleMethod · 0.80
toFloatMethod · 0.80
StringClass · 0.70
resetMethod · 0.45
emptyMethod · 0.45
setNativeIDMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected