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

add long_name() to sequence_host with unit tests

parent 4a55aca2
......@@ -10,6 +10,8 @@
#ifndef BOOST_BIOSEQ_SEQUENCE_HPP
#define BOOST_BIOSEQ_SEQUENCE_HPP
#include <boost/algorithm/string/replace.hpp>
#ifndef BOOST_BIOSEQ_HAS_COMPONENT_HPP
#include <boost/bioseq/has_component.hpp>
#endif // BOOST_BIOSEQ_HAS_COMPONENT_HPP
......@@ -96,7 +98,15 @@ public:
return get_name(has_name_component<self_type>());
}
private:
std::basic_string<CharT> long_name() const
{
return (
boost::replace_all_copy(
get_name(has_name_component<self_type>()), " ", "_")
+ get_dscr(has_description_component<self_type>() ) );
}
private:
void copy_name(const sequence_host& other, std::true_type)
{ self_type::_name = other._name; }
void copy_name(const sequence_host& other, std::false_type)
......@@ -119,6 +129,16 @@ public:
{ return self_type::_name; }
std::basic_string<CharT> get_name(std::false_type) const
{ return {}; }
std::basic_string<CharT> get_dscr(std::true_type) const
{
return
self_type::_description.empty()
? std::basic_string<CharT>()
: std::basic_string<CharT>(" ") + self_type::_description;
}
std::basic_string<CharT> get_dscr(std::false_type) const
{ return {}; }
};
//----------------------------------------------------------------------------//
......
......@@ -119,6 +119,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(read_single_fasta, T, seq_types)
BOOST_CHECK_EQUAL(mt.name(), "gi|113200490|gb|J01415.2|HUMMTCG");
BOOST_CHECK_EQUAL(mt.description(), "Homo sapiens mitochondrion, complete genome");
BOOST_CHECK_EQUAL(mt.long_name(), "gi|113200490|gb|J01415.2|HUMMTCG Homo sapiens mitochondrion, complete genome");
// BOOST_CHECK( mt.short_name() == "gi|113200490|gb|J01415.2|HUMMTCG" );
// BOOST_CHECK( mt.long_name()
......@@ -159,6 +160,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(read_multi_fasta, T, seq_types)
BOOST_CHECK( reads[2].description().empty() );
BOOST_CHECK( reads[3].description().empty() );
BOOST_CHECK_EQUAL(reads[0].long_name(), "gi|406593966|ref|NC_018627.1|-40485/1");
// T copy(reads[0]);
// BOOST_CHECK_EQUAL(copy.name(), "gi|406593966|ref|NC_018627.1|-40485/1");
// BOOST_CHECK_EQUAL(copy.data(), "ACACCAGAAGCATCGTCTGTTGTGGTGATATATGCGGGCTCTTCTGTTATCTCGTTAAGATCGAGATGGAGATTCTTTACTGAGATGTTGTTGGTAGTTTGAAACTTCGTCCCAGGATGCATGCAGAGTATAGATTGAAGATTTTCATCA");
......
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