| 588 | } |
| 589 | |
| 590 | bool ConsensusMap::isMapConsistent(Logger::LogStream* stream) const |
| 591 | { |
| 592 | Size stats_wrongMID(0); // invalid map ID references by a feature handle |
| 593 | std::map<Size, Size> wrong_ID_count; // which IDs were given which are not valid |
| 594 | |
| 595 | // check file descriptions |
| 596 | std::set<String> maps; |
| 597 | String all_maps; // for output later |
| 598 | for (ColumnHeaders::const_iterator it = column_description_.begin(); it != column_description_.end(); ++it) |
| 599 | { |
| 600 | String s = String(" file: ") + it->second.filename + " label: " + it->second.label; |
| 601 | maps.insert(s); |
| 602 | all_maps += s; |
| 603 | } |
| 604 | |
| 605 | if (maps.size() != column_description_.size()) |
| 606 | { |
| 607 | if (stream != nullptr) |
| 608 | { |
| 609 | OPENMS_THREAD_CRITICAL(LOGSTREAM) |
| 610 | *stream << "Map descriptions (file name + label) in ConsensusMap are not unique:\n" << all_maps << std::endl; |
| 611 | } |
| 612 | return false; |
| 613 | } |
| 614 | |
| 615 | // check map IDs |
| 616 | for (Size i = 0; i < size(); ++i) |
| 617 | { |
| 618 | const ConsensusFeature& elem = (*this)[i]; |
| 619 | for (ConsensusFeature::HandleSetType::const_iterator it = elem.begin(); it != elem.end(); ++it) |
| 620 | { |
| 621 | if (column_description_.find(it->getMapIndex()) == column_description_.end()) |
| 622 | { |
| 623 | ++stats_wrongMID; |
| 624 | ++wrong_ID_count[it->getMapIndex()]; |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | if (stats_wrongMID > 0) |
| 630 | { |
| 631 | if (stream != nullptr) |
| 632 | { |
| 633 | OPENMS_THREAD_CRITICAL(LOGSTREAM) |
| 634 | *stream << "ConsensusMap contains " << stats_wrongMID << " invalid references to maps:\n"; |
| 635 | for (std::map<Size, Size>::const_iterator it = wrong_ID_count.begin(); it != wrong_ID_count.end(); ++it) |
| 636 | { |
| 637 | OPENMS_THREAD_CRITICAL(LOGSTREAM) |
| 638 | *stream << " wrong id=" << it->first << " (occurred " << it->second << "x)\n"; |
| 639 | } |
| 640 | OPENMS_THREAD_CRITICAL(LOGSTREAM) |
| 641 | *stream << std::endl; |
| 642 | } |
| 643 | return false; |
| 644 | } |
| 645 | |
| 646 | return true; |
| 647 | } |