Commit ce7af325 authored by Armin Sobhani's avatar Armin Sobhani
Browse files

add sc example

parent 3cf33fdb
......@@ -18,6 +18,8 @@ if(${BOOST_BIOSEQ_BUILD_OPENCL_SAMPLES})
include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
# find Boost
find_package(Boost 1.53 REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
......@@ -70,6 +72,11 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4838") # Warning C4838: conversion from 'double' to 'float' requires a narrowing conversion
endif()
option(BOOST_BIOSEQ_BUILD_EXAMPLES "Build the Boost.Bioseq examples" ON)
if(${BOOST_BIOSEQ_BUILD_EXAMPLES})
add_subdirectory(example)
endif()
option(BOOST_BIOSEQ_BUILD_TESTS "Build the Boost.Bioseq tests" ON)
if(${BOOST_BIOSEQ_BUILD_TESTS})
enable_testing()
......
# ----------------------------------------------------------------------------
# Copyright (c) 2018 Armin Sobhani <arminms@gmail.com>
#
# Distributed under the Boost Software License Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http:www.boost.org/LICENSE_1_0.txt)
#
# ----------------------------------------------------------------------------
include_directories(../include)
set(BOOST_COMPONENTS system program_options)
if(BOOST_COMPONENTS)
list(REMOVE_DUPLICATES BOOST_COMPONENTS)
endif()
find_package(Boost 1.53 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
set(EXAMPLES
sc
)
foreach(EXAMPLE ${EXAMPLES})
add_executable(${EXAMPLE} ${EXAMPLE}.cpp)
target_link_libraries(${EXAMPLE} ${Boost_LIBRARIES})
endforeach()
//----------------------------------------------------------------------------//
// Copyright (c) 2018 Armin Sobhani <arminms@gmail.com>
//
// Distributed under the Boost Software License Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//----------------------------------------------------------------------------//
#include <fstream>
#include <iostream>
#include <iomanip>
#include <vector>
// #include <algorithm>
// #include <numeric>
#include <boost/bioseq/type_traits.hpp>
#include <boost/bioseq/sequence.hpp>
#include <boost/bioseq/io_format.hpp>
#include <boost/bioseq/components/name.hpp>
#include <boost/bioseq/components/description.hpp>
#include <boost/bioseq/io_formats/fasta.hpp>
namespace bsq = boost::bioseq;
typedef bsq::sequence_host
<
char
, std::allocator
, std::vector
// , bsq::component::name<>
// , bsq::component::description<>
> seq;
typedef bsq::ioformat
< char
, std::char_traits<char>
, seq
, bsq::fasta_format
> format;
#if BOOST_WORKAROUND(BOOST_GCC, < 70000)
namespace boost { namespace bioseq {
template<> struct io_format_traits<seq> { typedef format type; };
}}
#else
template<> struct bsq::io_format_traits<seq> { typedef format type; };
#endif // BOOST_GCC < 70000
int main(int argc, char *argv[])
{
std::ios::sync_with_stdio(false);
size_t seq_count = 0, base_count = 0;
seq s;
if (argc > 1)
{
for (size_t i = 1; i < argc; ++i)
{
std::ifstream in(argv[i]);
while (in >> s)
{
++seq_count;
base_count += s.size();
}
std::cout << seq_count << '\t' << base_count << std::endl;
}
}
else
{
// std::cin.sync_with_stdio(false);
// char buffer[1048576];
// std::cin.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
while (std::cin >> s)
{
++seq_count;
base_count += s.size();
}
std::cout << seq_count << '\t' << base_count << std::endl;
}
}
\ No newline at end of file
......@@ -121,11 +121,16 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(read_multi_fasta, T, seq_types)
// auto start = std::chrono::high_resolution_clock::now();
std::vector<T> reads
{
std::istream_iterator<T>(in)
, std::istream_iterator<T>()
};
// std::vector<T> reads
// {
// std::istream_iterator<T>(in)
// , std::istream_iterator<T>()
// };
std::vector<T> reads(
std::istream_iterator<T>{in}
, std::istream_iterator<T>{}
);
BOOST_CHECK_EQUAL(reads.size(), 4);
BOOST_CHECK_EQUAL(reads[0].size(), 150);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment