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

Function load

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

Source from the content-addressed store, hash-verified

48 */
49 template <typename FeatureMapType>
50 void load(const String& filename, FeatureMapType& feature_map)
51 {
52 // load input
53 TextFile input(filename, false);
54
55 // reset map
56 FeatureMapType fmap;
57 feature_map = fmap;
58
59 TextFile::ConstIterator it = input.begin();
60 if (it == input.end()) return; // no data to load
61
62 // skip header line
63 ++it;
64 // process content
65 for (; it != input.end(); ++it)
66 {
67 String line = *it;
68
69 std::vector<String> parts;
70 line.split('\t', parts);
71
72 if (parts.size() < 5)
73 {
74 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "", String("Failed to convert line") + String((it - input.begin()) + 1) + "not enough columns (expected 5 or more, got " + String(parts.size()) + ")");
75 }
76
77 Feature f;
78 try
79 {
80 f.setMZ(parts[0].toDouble());
81 f.setRT(parts[1].toDouble() * 60.0);
82 f.setMetaValue("s/n", parts[2].toDouble());
83 f.setCharge(parts[3].toInt());
84 f.setIntensity(parts[4].toDouble());
85 }
86 catch ( Exception::BaseException& )
87 {
88 throw Exception::ParseError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "", String("Failed to convert value into a number (line '") + String((it - input.begin()) + 1) + ")");
89 }
90 feature_map.push_back(f);
91 }
92 }
93
94 /**
95 @brief Stores a featureXML as a SpecArray file.

Callers

nothing calls this directly

Calls 12

toDoubleMethod · 0.80
toIntMethod · 0.80
StringClass · 0.70
beginMethod · 0.45
endMethod · 0.45
splitMethod · 0.45
sizeMethod · 0.45
setMZMethod · 0.45
setRTMethod · 0.45
setMetaValueMethod · 0.45
setChargeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected