void BitsetSaver::save( const std::vector<bool> &bits) { char byte = 0; for (size_t i = 0; i < bits.size(); ++ i) { const unsigned shift = i % 8; const char positionHasNeighbors = bits[i]; byte |= positionHasNeighbors << shift; if (7 == shift) { if (!os_.write(&byte, sizeof(byte))) { const boost::format message = boost::format("Failed to write bits into %s: %s") % filePath_.string() % strerror(errno); BOOST_THROW_EXCEPTION(common::IoException(errno, message.str())); } byte = 0; } } if (!os_.write(&byte, sizeof(byte))) { const boost::format message = boost::format("Failed to write final bits byte into %s: %s") % filePath_.string() % strerror(errno); BOOST_THROW_EXCEPTION(common::IoException(errno, message.str())); } }
static std::vector<std::string > expandUseBasesMask ( const std::vector<unsigned int> &readLengths, const std::string &useBasesMask, const boost::filesystem::path &baseCallsDirectory) { std::vector<std::string > result; std::string::const_iterator parseIt(useBasesMask.begin()); const std::string::const_iterator parseEnd(useBasesMask.end()); UseBasesMaskGrammar<std::string::const_iterator> parser(readLengths); if (!boost::spirit::qi::parse(parseIt, parseEnd, parser, result) || parseEnd != parseIt) { const boost::format message = boost::format("\n *** Could not parse the use-bases-mask '%s' for '%s' at: %s ***\n") % useBasesMask % baseCallsDirectory.string() % useBasesMask.substr(parseIt - useBasesMask.begin()); BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str())); } ISAAC_THREAD_CERR << "use bases mask: " << boost::algorithm::join(result, ",") << "\n"; ISAAC_THREAD_CERR << "reads parsed: " << parser.currentRead_ << "\n"; if (result.size() != readLengths.size()) { const boost::format message = boost::format("\n *** use-bases-mask '%s' is incompatible with number of reads (%d) in %s ***\n") % useBasesMask % readLengths.size() % baseCallsDirectory.string(); BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str())); } return result; }
void ExtractNeighborsWorkflow::scanMaskFile( const reference::SortedReferenceMetadata::MaskFile &maskFile, const std::vector<uint64_t> &contigOffsets, const std::vector<unsigned> &karyotypes, std::vector<bool> &neighbors, std::vector<bool> &highRepeats) { if (!exists(maskFile.path)) { const boost::format message = boost::format("Mask file %s does not exist: %s") % maskFile.path; BOOST_THROW_EXCEPTION(common::IoException(ENOENT, message.str())); } std::ifstream maskInput(maskFile.path.c_str()); if (!maskInput) { const boost::format message = boost::format("Failed to open mask file %s for reading: %s") % maskFile.path % strerror(errno); BOOST_THROW_EXCEPTION(common::IoException(errno, message.str())); } std::size_t scannedKmers = 0, maskNeighbors = 0, maskNonHighRepeats = 0; while(maskInput) { reference::ReferenceKmer<KmerT> referenceKmer; if (maskInput.read(reinterpret_cast<char *>(&referenceKmer), sizeof(referenceKmer))) { ++scannedKmers; const reference::ReferencePosition pos = referenceKmer.getReferencePosition(); if (!pos.isTooManyMatch()) { const reference::ReferencePosition translatedPos = pos.translateContig(karyotypes); if (translatedPos.hasNeighbors()) { neighbors.at(contigOffsets.at(translatedPos.getContigId()) + translatedPos.getPosition()) = true; ++maskNeighbors; } if (!highRepeats.empty()) { highRepeats.at(contigOffsets.at(translatedPos.getContigId()) + translatedPos.getPosition()) = false; } ++maskNonHighRepeats; } } } if (!maskInput.eof()) { const boost::format message = boost::format("Failed to scan %s to the end") % maskFile.path % strerror(errno); BOOST_THROW_EXCEPTION(common::IoException(errno, message.str())); } else { ISAAC_THREAD_CERR << "Scanning " << maskFile.path << " found " << scannedKmers << " kmers of which " << maskNeighbors << " neighbors and " << (scannedKmers - maskNonHighRepeats) << " high repeats" << std::endl; } }
void vfeSession::AppendStatusMessage (const boost::format& fmt, int RecommendedPause) { boost::mutex::scoped_lock lock(m_MessageMutex); m_StatusQueue.push (StatusMessage (*this, fmt.str(), RecommendedPause)); m_StatusLineMessage = fmt.str(); if (m_MaxStatusMessages != -1) while (m_StatusQueue.size() > m_MaxStatusMessages) m_StatusQueue.pop(); NotifyEvent(stStatusMessage); }
void FastaDumperOptions::postProcess(bpo::variables_map &vm) { eagle::common::OptionsHelper check(vm); if (fastaFiles.empty()) { throw bpo::validation_error(bpo::validation_error::at_least_one_value_required, "", "positional"); } check.addPathOptions(fastaFiles,"positional"); check.inputPathsExist(); if ( 1 == fastaFiles.size() && bfs::is_directory(fastaFiles[0]) ) { mode = WHOLE_DIR; } else { for (unsigned int i = 0; i < fastaFiles.size(); i++) { if (bfs::is_directory(fastaFiles[i])) { const boost::format message = boost::format("\n *** FASTA file #%d has an invalid value: ***" "\n *** It should point to a file, but a directory already exists with name %s ***\n") % i % fastaFiles[i]; BOOST_THROW_EXCEPTION(eagle::common::InvalidOptionException(message.str())); } } mode = SAFE_MODE; } check.inRange<unsigned long>(std::make_pair(size,"size"),1); // 1 <= size < inf // (size == 0) not allowed, so internally used to represent 'until the end' }
hpgl_exception::hpgl_exception( const std::string & a_where, const boost::format & what) :m_where(a_where), m_what(what.str()) { m_message = m_where + ": " + m_what; //std::cerr << m_message << std::endl; }
error::error( bool _status, long long _code, boost::format _msg, std::string _file, int _line, std::string _fcn ) : error::error( _status, _code, _msg.str(), _file, _line, _fcn ) {}
void Logger::log( const Level& level, const boost::format& message, const std::string& filename, const int& lineNumber ) { log( level, message.str(), filename, lineNumber ); }
bs_exception::bs_exception (const std::string &who, const boost::format &message) : who_ (who), what_ (who_ + ": " + message.str ()), m_err_ (user_defined) { #ifdef BS_EXCEPTION_COLLECT_BACKTRACE what_ += detail::collect_backtrace (); #endif }
void Log::Debug( boost::format &fmt ) { int ConsoleLogLevel = sConfig.GetIntDefault("Log.ConsoleLogLevel",LOGLEVEL_INFO); int FileLogLevel = sConfig.GetIntDefault("Log.FileLogLevel",LOGLEVEL_WARNING); if (ConsoleLogLevel >= LOGLEVEL_DEBUG || FileLogLevel >= LOGLEVEL_DEBUG) { Debug(fmt.str()); } }
void Trace::send(const boost::format& str, TraceLevelOptions level) { if (not Trace::Pimpl::mTrace) { Trace::init(); } boost::mutex::scoped_lock lock(Trace::Pimpl::mTrace->getMutex()); Pimpl::mTrace->send(str.str(), level); }
void chronometer_t::event_dumb(boost::format const& params) { if (is_dumb) { if (!log_ptr) { log_ptr = logger::instance(); } if (log_ptr) { log_ptr->debug("raw/begin/" + name, params.str()); } } }
void Log::Critical( boost::format &fmt ) { int ConsoleLogLevel = sConfig.GetIntDefault("Log.ConsoleLogLevel",LOGLEVEL_INFO); int FileLogLevel = sConfig.GetIntDefault("Log.FileLogLevel",LOGLEVEL_WARNING); if (ConsoleLogLevel >= LOGLEVEL_CRITICAL || FileLogLevel >= LOGLEVEL_CRITICAL) { Critical(fmt.str()); } }
void Log::Error( boost::format &fmt ) { int ConsoleLogLevel = sConfig.GetIntDefault("Log.ConsoleLogLevel",LOGLEVEL_INFO); int FileLogLevel = sConfig.GetIntDefault("Log.FileLogLevel",LOGLEVEL_WARNING); if (ConsoleLogLevel >= LOGLEVEL_ERROR || FileLogLevel >= LOGLEVEL_ERROR) { Error(fmt.str()); } }
BitsetSaver::BitsetSaver(const boost::filesystem::path filePath) : filePath_(filePath), os_(filePath.c_str()) { if (!os_) { const boost::format message = boost::format("Failed to open file %s for writing: %s") % filePath_ % strerror(errno); BOOST_THROW_EXCEPTION(common::IoException(errno, message.str())); } }
flowcell::Layout FastqFlowcell::createFilteredFlowcell( const std::string &tilesFilter, const boost::filesystem::path &baseCallsDirectory, const bool compressed, const unsigned laneNumberMax, const unsigned readNameLength, std::string useBasesMask, const bool allowVariableFastqLength, const char fastqQ0, const std::string &seedDescriptor, const unsigned seedLength, const reference::ReferenceMetadataList &referenceMetadataList, unsigned &firstPassSeeds) { FastqPathPairList flowcellFilePaths = findFastqPathPairs(compressed, laneNumberMax, baseCallsDirectory); if (flowcellFilePaths.empty()) { const boost::format message = boost::format("\n *** Could not find any fastq lanes in: %s ***\n") % baseCallsDirectory; BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str())); } FastqFlowcellInfo flowcellInfo = parseFastqFlowcellInfo(flowcellFilePaths, allowVariableFastqLength, fastqQ0, readNameLength); std::vector<unsigned int> readLengths; if (flowcellInfo.readLengths_.first) { readLengths.push_back(flowcellInfo.readLengths_.first); } if (flowcellInfo.readLengths_.second) { readLengths.push_back(flowcellInfo.readLengths_.second); } if ("default" == useBasesMask) { if (readLengths.size() == 1) { useBasesMask = "y*n"; } else if (readLengths.size() == 2) { useBasesMask = "y*n,y*n"; } else { const boost::format message = boost::format("\n *** Could not guess the use-bases-mask for '%s', please supply the explicit value ***\n") % baseCallsDirectory.string(); BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str())); } } std::vector<unsigned int> readFirstCycles; ParsedUseBasesMask parsedUseBasesMask; alignment::SeedMetadataList seedMetadataList; if (!readLengths.empty()) { parsedUseBasesMask = parseUseBasesMask(readFirstCycles, readLengths, seedLength, useBasesMask, baseCallsDirectory); seedMetadataList = parseSeedDescriptor(parsedUseBasesMask.dataReads_, seedDescriptor, seedLength, firstPassSeeds); } flowcell::Layout fc(baseCallsDirectory, flowcell::Layout::Fastq, flowcell::FastqFlowcellData(compressed, fastqQ0), laneNumberMax, flowcellInfo.readNameLength_, std::vector<unsigned>(), parsedUseBasesMask.dataReads_, seedMetadataList, flowcellInfo.flowcellId_); std::string regexString(tilesFilter); std::replace(regexString.begin(), regexString.end(), ',', '|'); boost::regex re(regexString); BOOST_FOREACH(const unsigned int lane, flowcellInfo.getLanes()) { std::string laneString((boost::format("s_%d") % lane).str()); if (boost::regex_search(laneString, re)) { fc.addTile(lane, 1); } } return fc; }
code_generation_error(std::string const& generator_name, boost::format const& format) noexcept : code_generation_error(generator_name, format.str()) {}
// error processing void ObjectManager::error(boost::format err) { cout << err.str() << endl; assert(false); }
std::string String() const { return format.str(); }
void NextArg() { if (output) output(format.str()); }
void debug(const boost::format &msg) { category.debug(msg.str()); }
void notice(const boost::format &msg) { category.notice(msg.str()); }
bs_kernel_exception::bs_kernel_exception (const std::string &who, error_code ec, const boost::format &message) : bs_exception (who, message.str () + ". BlueSky error: " + bs_error_message (ec)) { m_err_ = ec; }
LoadException(const boost::format &msg) : Exception(msg.str()) { }
bs_dynamic_lib_exception::bs_dynamic_lib_exception (const boost::format &who) : bs_exception (who.str (), "System error: " + dynamic_lib_error_message ()) { m_err_ = user_defined; }
CUException(const boost::format &format) : Exception(format.str()) { }
inline LogManagerItem(Level level, Time time, const std::string &sender, const boost::format &format) : m_level(level), m_time(time), m_sender(sender), m_content(format.str()) { }
void info(const boost::format &msg) { category.info(msg.str()); }
bs_system_exception::bs_system_exception (const std::string &who, error_code ec, const boost::format &message) : bs_exception (who, message.str () + ". System error: " + system_message (ec)) { m_err_ = ec; }
Exception(const boost::format &msg) : m_msg(msg.str()) { }