예제 #1
0
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()));
    }
}
예제 #2
0
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'
}
예제 #3
0
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;
}
예제 #4
0
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()));
    }
}
예제 #5
0
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);
}
예제 #6
0
파일: format.hpp 프로젝트: arrrrrrr/ebftpd
 boost::format CustomFormat(const char* s)
 {
   using namespace boost::io;
   boost::format format(s);
   format.exceptions(all_error_bits ^ (too_many_args_bit | too_few_args_bit));
   return format;
 }
int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
  ros::NodeHandle nh;
  image_transport::ImageTransport it(nh);
  //std::string topic = nh.resolveName("image");
//  std::string topic = "/ardrone/image_raw";
  std::string topic = "/ardrone/kinect/image_raw";
  std::string topic_depth = "/ardrone/kinect/depth/image_raw";

  Callbacks callbacks;
  //callbacks.control ="10000000";
  //callbacks.path = "/home/jay/data/";
  //obtain saving location
  std::string saving_location = nh.resolveName("generated_set");
  //if(saving_location.compare("generated_set")) saving_location = "remote_images/set_online";
  callbacks.path = "/home/jay/data/"+saving_location;
  boost::filesystem::path dir(callbacks.path);
  boost::filesystem::remove_all(dir);
  if(boost::filesystem::create_directory(dir)) {
    callbacks.path_depth = callbacks.path+"/depth";
    boost::filesystem::path dir_depth(callbacks.path_depth);
    if(boost::filesystem::create_directory(dir_depth)) {
      std::cout << "Success in creating: "<<callbacks.path_depth << "\n";
    }
    callbacks.path = callbacks.path+"/RGB";
    boost::filesystem::path dir_rgb(callbacks.path);
    if(boost::filesystem::create_directory(dir_rgb)) {
      std::cout << "Success in creating: "<<callbacks.path << "\n";
    }
  }else{
    std::cout <<"Failed to make saving direction "<<callbacks.path <<"\n";
  }
  
  // Useful when CameraInfo is being published
  /*image_transport::CameraSubscriber sub_image_and_camera = it.subscribeCamera(topic, 1,
                                                                              &Callbacks::callbackWithCameraInfo,
                                                                              &callbacks);*/
  // Useful when CameraInfo is not being published
  image_transport::Subscriber sub_image = it.subscribe(
      topic, 1, boost::bind(&Callbacks::callbackWithoutCameraInfo, &callbacks, _1));
  //depth
  image_transport::Subscriber sub_image_depth = it.subscribe(
      topic_depth, 1, boost::bind(&Callbacks::callbackWithoutCameraInfoWithDepth, &callbacks, _1));

  // Make subscriber to cmd_vel in order to set the name.
  ros::Subscriber takeOff = nh.subscribe("/ardrone/takeoff",1,&Callbacks::callbackTakeoff, &callbacks);
  ros::Subscriber subControl = nh.subscribe("/dagger_vel",1,&Callbacks::callbackCmd, &callbacks);
  // [hover, back, forward, turn right, turn left, down, up, clockwise, ccw]
  // Adapt name instead of left0000.jpg it should be 00000-gt1.jpg when receiving control 1 ~ straight
  ros::NodeHandle local_nh("~");
  std::string format_string;
  local_nh.param("filename_format", format_string, std::string("%s/%010i-gt%s.%s"));
  local_nh.param("encoding", encoding, std::string("bgr8"));
  local_nh.param("save_all_image", save_all_image, true);
  g_format.parse(format_string);
  ros::ServiceServer save = local_nh.advertiseService ("save", service);

  ros::spin();
} 
예제 #8
0
	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;
		}
예제 #9
0
 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 ) {}
예제 #10
0
파일: Log.cpp 프로젝트: hjanetzek/SFCGAL
void Logger::log(
    const Level& level,
    const boost::format& message,
    const std::string& filename,
    const int& lineNumber
)
{
    log( level, message.str(), filename, lineNumber );
}
예제 #11
0
  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
  }
예제 #12
0
파일: Trace.cpp 프로젝트: Agilack/vle
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);
}
예제 #13
0
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());
        }
    }
}
예제 #14
0
파일: Log.cpp 프로젝트: J0nath4n/mxoemu
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());
	}
}
예제 #15
0
파일: Log.cpp 프로젝트: J0nath4n/mxoemu
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());
	}
}
예제 #16
0
파일: Log.cpp 프로젝트: J0nath4n/mxoemu
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());
	}
}
예제 #17
0
int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
  ros::NodeHandle nh;
  g_format.parse("left%04i.%s");
  image_transport::ImageTransport it(nh);
  std::string topic = nh.resolveName("image");
  image_transport::CameraSubscriber sub = it.subscribeCamera(topic, 1, &callback);

  ros::spin();
}
  bool saveImage(cv::Mat image, std::string &filename, bool depth = false) {
    if (!image.empty()) {
      try {
        filename = (g_format).str();
      } catch (...) { g_format.clear(); }
      try {
        filename = (g_format % path).str();
      } catch (...) { g_format.clear(); }
      try {
        filename = (g_format % path % count_).str();
      } catch (...) { g_format.clear(); }
      try { 
        filename = (g_format % path % count_ % "jpg").str();
      } catch (...) { g_format.clear(); }
      try {
	if(!depth){
	  filename = (g_format % path % count_ % control % "jpg").str();
	}else{
	  filename = (g_format % path_depth % count_ % control % "jpg").str();
	}
      } catch (...) { g_format.clear(); }
      
      if ( save_all_image || save_image_service ) {
        try{
	  cv::imwrite(filename, image);
	  ROS_INFO("Saved image %s", filename.c_str());

	  save_image_service = false;
	}catch(runtime_error& ex){
	  fprintf(stderr, "Exception converting image to PNG format: %s\n", ex.what());
	  return false;
	}
      } else {
        return false;
      }
    } else {
      ROS_WARN("Couldn't save image, no data!");
      return false;
    }
    return true;
  }
예제 #19
0
void ImageNodelet::onInit()
{
  ros::NodeHandle nh = getNodeHandle();
  ros::NodeHandle local_nh = getPrivateNodeHandle();

  // Command line argument parsing
  const std::vector<std::string>& argv = getMyArgv();
  // First positional argument is the transport type
  std::string transport;
  local_nh.param("image_transport", transport, std::string("raw"));
  for (int i = 0; i < (int)argv.size(); ++i)
  {
    if (argv[i][0] != '-')
    {
      transport = argv[i];
      break;
    }
  }
  NODELET_INFO_STREAM("Using transport \"" << transport << "\"");
  // Internal option, should be used only by the image_view node
  bool shutdown_on_close = std::find(argv.begin(), argv.end(),
                                     "--shutdown-on-close") != argv.end();

  // Default window name is the resolved topic name
  std::string topic = nh.resolveName("image");
  local_nh.param("window_name", window_name_, topic);

  bool autosize;
  local_nh.param("autosize", autosize, false);
  
  std::string format_string;
  local_nh.param("filename_format", format_string, std::string("frame%04i.jpg"));
  filename_format_.parse(format_string);

  cv::namedWindow(window_name_, autosize ? cv::WND_PROP_AUTOSIZE : 0);
  cv::setMouseCallback(window_name_, &ImageNodelet::mouseCb, this);
  
#ifdef HAVE_GTK
  // Register appropriate handler for when user closes the display window
  GtkWidget *widget = GTK_WIDGET( cvGetWindowHandle(window_name_.c_str()) );
  if (shutdown_on_close)
    g_signal_connect(widget, "destroy", G_CALLBACK(destroyNode), NULL);
  else
    g_signal_connect(widget, "destroy", G_CALLBACK(destroyNodelet), &sub_);
#endif

  // Start the OpenCV window thread so we don't have to waitKey() somewhere
  startWindowThread();

  image_transport::ImageTransport it(nh);
  image_transport::TransportHints hints(transport, ros::TransportHints(), getPrivateNodeHandle());
  sub_ = it.subscribe(topic, 1, &ImageNodelet::imageCb, this, hints);
}
예제 #20
0
  formatter()
  {
    try{
      fmt_ = boost::format(getenv("IPI_LOG_FORMAT") ? getenv("IPI_LOG_FORMAT") : "[%1%] ");
    }catch(const std::exception& e){
      std::cerr << "Could not used IPI_LOG_FORMAT!\n" << fmt_ << "\n" << e.what() << std::endl;
      abort();
    }

    fmt_.exceptions( boost::io::all_error_bits ^ ( boost::io::too_many_args_bit
                                                   | boost::io::too_few_args_bit )  );
  }
예제 #21
0
int main(int argc, char **argv)
{
  ros::init(argc, argv, "image_view", ros::init_options::AnonymousName);
  if (ros::names::remap("image") == "image") {
    ROS_WARN("Topic 'image' has not been remapped! Typical command-line usage:\n"
             "\t$ rosrun image_view image_view image:=<image topic> [transport]");
  }

  ros::NodeHandle nh;
  ros::NodeHandle local_nh("~");

  // Default window name is the resolved topic name
  std::string topic = nh.resolveName("image");
  local_nh.param("window_name", g_window_name, topic);

  std::string format_string;
  local_nh.param("filename_format", format_string, std::string("frame%04i.jpg"));
  g_filename_format.parse(format_string);

  // Handle window size
  bool autosize;
  local_nh.param("autosize", autosize, false);
  cv::namedWindow(g_window_name, autosize ? (CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO | CV_GUI_EXPANDED) : 0);
  cv::setMouseCallback(g_window_name, &mouseCb);

  // Start the OpenCV window thread so we don't have to waitKey() somewhere
  cv::startWindowThread();

  // Handle transport
  // priority:
  //    1. command line argument
  //    2. rosparam '~image_transport'
  std::string transport;
  local_nh.param("image_transport", transport, std::string("raw"));
  ros::V_string myargv;
  ros::removeROSArgs(argc, argv, myargv);
  for (size_t i = 1; i < myargv.size(); ++i) {
    if (myargv[i][0] != '-') {
      transport = myargv[i];
      break;
    }
  }
  ROS_INFO_STREAM("Using transport \"" << transport << "\"");
  image_transport::ImageTransport it(nh);
  image_transport::TransportHints hints(transport, ros::TransportHints(), local_nh);
  image_transport::Subscriber sub = it.subscribe(topic, 1, imageCb, hints);

  ros::spin();

  cv::destroyWindow(g_window_name);
  return 0;
}
예제 #22
0
  bool saveImage(const sensor_msgs::ImageConstPtr& image_msg, std::string &filename) {
    cv::Mat image;
    try
    {
      image = cv_bridge::toCvShare(image_msg, encoding)->image;
    } catch(cv_bridge::Exception)
    {
      ROS_ERROR("Unable to convert %s image to bgr8", image_msg->encoding.c_str());
      return false;
    }

    if (!image.empty()) {
      try {
        filename = (g_format).str();
      } catch (...) { g_format.clear(); }
      try {
        filename = (g_format % count_).str();
      } catch (...) { g_format.clear(); }
      try { 
        filename = (g_format % count_ % "jpg").str();
      } catch (...) { g_format.clear(); }

      if ( save_all_image || save_image_service ) {
        cv::imwrite(filename, image);
        ROS_INFO("Saved image %s", filename.c_str());

        save_image_service = false;
      } else {
        return false;
      }
    } else {
      ROS_WARN("Couldn't save image, no data!");
      return false;
    }
    return true;
  }
예제 #23
0
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;
    }
}
예제 #24
0
  ExtractImages(const ros::NodeHandle& nh, const std::string& transport)
    : filename_format_(""), count_(0), _time(ros::Time::now().toSec())
  {
    std::string topic = nh.resolveName("image");
    ros::NodeHandle local_nh("~");

    std::string format_string;
    local_nh.param("filename_format", format_string, std::string("frame%05i.png"));
    filename_format_.parse(format_string);

    local_nh.param("sec_per_frame", sec_per_frame_, 0.1);

    image_transport::ImageTransport it(nh);
    sub_ = it.subscribe(topic, 1, &ExtractImages::image_cb, this, transport);

#if defined(_VIDEO)
    video_writer = 0;
#endif

    ROS_INFO("Initialized sec per frame to %f", sec_per_frame_);
  }
예제 #25
0
int main(int argc, char** argv)
{
  ros::init(argc, argv, "image_saver", ros::init_options::AnonymousName);
  ros::NodeHandle nh;
  image_transport::ImageTransport it(nh);
  std::string topic = nh.resolveName("image");

  Callbacks callbacks;
  // Useful when CameraInfo is being published
  image_transport::CameraSubscriber sub_image_and_camera = it.subscribeCamera(topic, 1,
                                                                              &Callbacks::callbackWithCameraInfo,
                                                                              &callbacks);
  // Useful when CameraInfo is not being published
  image_transport::Subscriber sub_image = it.subscribe(
      topic, 1, boost::bind(&Callbacks::callbackWithoutCameraInfo, &callbacks, _1));

  ros::NodeHandle local_nh("~");
  std::string format_string;
  local_nh.param("filename_format", format_string, std::string("left%04i.%s"));
  local_nh.param("encoding", encoding, std::string("bgr8"));
  local_nh.param("save_all_image", save_all_image, true);
  local_nh.param("request_start_end", request_start_end, false);
  g_format.parse(format_string);
  ros::ServiceServer save = local_nh.advertiseService ("save", service);

  if (request_start_end && !save_all_image)
    ROS_WARN("'request_start_end' is true, so overwriting 'save_all_image' as true");

  // FIXME(unkown): This does not make services appear
  // if (request_start_end) {
    ros::ServiceServer srv_start = local_nh.advertiseService(
      "start", &Callbacks::callbackStartSave, &callbacks);
    ros::ServiceServer srv_end = local_nh.advertiseService(
      "end", &Callbacks::callbackEndSave, &callbacks);
  // }

  ros::spin();
}
예제 #26
0
 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;
 }
예제 #27
0
 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;
 }
예제 #28
0
 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;
 }
예제 #29
0
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;
}
예제 #30
0
파일: exception.hpp 프로젝트: rhysd/Dachs
 code_generation_error(std::string const& generator_name, boost::format const& format) noexcept
     : code_generation_error(generator_name, format.str())
 {}