MCPcopy Create free account
hub / github.com/chrxh/alien / saveRepetitiveActiveClustersToFiles

Method saveRepetitiveActiveClustersToFiles

source/Gui/PatternAnalysisDialog.cpp:55–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void PatternAnalysisDialog::saveRepetitiveActiveClustersToFiles(std::string const& filename)
56{
57 auto const partitionClassDataByDescription = calcPartitionData();
58
59 std::ofstream file;
60 file.open(filename, std::ios_base::out);
61 if (!file) {
62 GenericMessageDialog::get().information("Pattern analysis", "The analysis result could not be saved to the specified file.");
63 return;
64 }
65
66 int sum = 0;
67 std::vector<PartitionClassData> partitionData;
68 for (auto const& [analysisDesc, partitionClassData] : partitionClassDataByDescription) {
69 if (partitionClassData.numberOfElements > 1) {
70 partitionData.emplace_back(partitionClassData);
71 }
72 }
73 std::sort(partitionData.begin(), partitionData.end());
74
75 file << "number of repetitive active cell networks: " << partitionData.size() << std::endl << std::endl;
76 for (auto const& [index, partitionClassData] : partitionData | boost::adaptors::reversed | boost::adaptors::indexed(1)) {
77
78 file << "cell network " << index << ": " << partitionClassData.numberOfElements << " exemplars" << std::endl;
79
80 std::stringstream clusterNameStream;
81 clusterNameStream << "cell network" << std::setfill('0') << std::setw(6) << index << ".sim";
82
83 std::filesystem::path clusterFilename(filename);
84 clusterFilename.remove_filename();
85 clusterFilename /= clusterNameStream.str();
86
87 ClusteredDataDescription pattern;
88 pattern.clusters = std::vector<ClusterDescription>{partitionClassData.representant};
89
90 SerializerService::get().serializeContentToFile(clusterFilename.string(), pattern);
91 }
92 file.close();
93
94 std::stringstream messageStream;
95 messageStream << partitionData.size() << " repetitive active cell network found. A summary is saved to " << filename << "." << std::endl;
96 if (!partitionData.empty()) {
97 messageStream << "Representative cell networks are save from `cluster" << std::setfill('0') << std::setw(6) << 0 << ".sim` to `cluster" << std::setfill('0')
98 << std::setw(6) << partitionData.size() - 1 << ".sim`.";
99 }
100 GenericMessageDialog::get().information("Analysis result", messageStream.str());
101}
102
103auto PatternAnalysisDialog::calcPartitionData() const -> std::map<ClusterAnalysisDescription, PartitionClassData>
104{

Callers

nothing calls this directly

Calls 7

informationMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
sizeMethod · 0.80
closeMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected