Skip to content

Commit 6b35140

Browse files
committed
[FEATURE] map_io reader and SAM input.
1 parent 0d99ece commit 6b35140

18 files changed

+3525
-13
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// -----------------------------------------------------------------------------------------------------
2+
// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3+
// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4+
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5+
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6+
// -----------------------------------------------------------------------------------------------------
7+
8+
/*!\file
9+
* \brief Provides seqan3::add_enum_bitwise_operators.
10+
* \author Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de>
11+
*/
12+
13+
#pragma once
14+
15+
#include <type_traits>
16+
17+
#include <seqan3/core/platform.hpp>
18+
19+
namespace bio::map_io
20+
{
21+
/*!\interface seqan3::enum_bitwise_operators
22+
* \brief You can expect these functions on all types that overload seqan3::add_enum_bitwise_operators.
23+
*/
24+
/*!\name Requirements for seqan3::enum_bitwise_operators
25+
* \relates seqan3::enum_bitwise_operators
26+
* \brief You can expect these member functions.
27+
* \{
28+
* \fn operator&(t lhs, t rhs)
29+
* \brief Returns the binary `&` operator of lhs and rhs.
30+
* \param lhs First enum.
31+
* \param rhs Second enum.
32+
*
33+
* \returns the binary conjunction of `lhs` and `rhs`.
34+
*
35+
* \fn operator|(t lhs, t rhs)
36+
* \brief Returns the binary `|` operator of lhs and rhs.
37+
* \param lhs First enum.
38+
* \param rhs Second enum.
39+
*
40+
* \returns the binary disjunction of `lhs` and `rhs`.
41+
*
42+
* \fn operator^(t lhs, t rhs)
43+
* \brief Returns the binary `^` operator of lhs and rhs.
44+
* \param lhs First enum.
45+
* \param rhs Second enum.
46+
*
47+
* \returns the binary XOR operation on `lhs` and `rhs`.
48+
*
49+
* \fn operator~(t lhs)
50+
* \brief Returns the binary `~` operator of lhs.
51+
* \param lhs First enum.
52+
*
53+
* \returns the binary NOT operation on `lhs`.
54+
*
55+
* \fn operator&=(t & lhs, t rhs)
56+
* \brief Returns the binary `&=` operator of lhs and rhs.
57+
* \param lhs First enum.
58+
* \param rhs Second enum.
59+
*
60+
* \returns the binary AND assigment on `lhs`.
61+
*
62+
* \fn operator|=(t & lhs, t rhs)
63+
* \brief Returns the binary `|=` operator of lhs and rhs.
64+
* \param lhs First enum.
65+
* \param rhs Second enum.
66+
*
67+
* \returns the binary OR assignment on `lhs`.
68+
*
69+
* \fn operator^=(t & lhs, t rhs)
70+
* \brief Returns the binary `^=` operator of lhs and rhs.
71+
* \param lhs First enum.
72+
* \param rhs Second enum.
73+
*
74+
* \returns the binary XOR assignment on `lhs`.
75+
* \}
76+
*/
77+
78+
//!\cond DEV
79+
/*!\brief Set to true for a scoped enum to have binary operators overloaded.
80+
* \ingroup core
81+
*
82+
* \details
83+
*
84+
* If this type trait is specialised for an enum, the binary operators `&`, `|`, `^`, `~`, `&=`, `|=`, `^=` will be
85+
* added and behave just like for ints or unscoped enums.
86+
*
87+
* ### Example
88+
*
89+
* \include test/snippet/core/add_enum_bitwise_operators.cpp
90+
*/
91+
template <typename t>
92+
constexpr bool add_enum_bitwise_operators = false;
93+
94+
/*!\name Binary operators for scoped enums
95+
* \brief Perform binary operations like on ints or weak enums. These overloads are available if
96+
* seqan3::add_enum_bitwise_operators is defined for your type.
97+
* \ingroup core
98+
*
99+
* \details
100+
*
101+
* \see seqan3::add_enum_bitwise_operators
102+
* \{
103+
*/
104+
template <typename t>
105+
constexpr t operator&(t lhs, t rhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
106+
{
107+
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) & static_cast<std::underlying_type_t<t>>(rhs));
108+
}
109+
110+
template <typename t>
111+
constexpr t operator|(t lhs, t rhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
112+
{
113+
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) | static_cast<std::underlying_type_t<t>>(rhs));
114+
}
115+
116+
template <typename t>
117+
constexpr t operator^(t lhs, t rhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
118+
{
119+
return static_cast<t>(static_cast<std::underlying_type_t<t>>(lhs) ^ static_cast<std::underlying_type_t<t>>(rhs));
120+
}
121+
122+
template <typename t>
123+
constexpr t operator~(t lhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
124+
{
125+
return static_cast<t>(~static_cast<std::underlying_type_t<t>>(lhs));
126+
}
127+
128+
template <typename t>
129+
constexpr t & operator&=(t & lhs, t rhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
130+
{
131+
lhs = lhs & rhs;
132+
return lhs;
133+
}
134+
135+
template <typename t>
136+
constexpr t & operator|=(t & lhs, t rhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
137+
{
138+
lhs = lhs | rhs;
139+
return lhs;
140+
}
141+
142+
template <typename t>
143+
constexpr t & operator^=(t & lhs, t rhs) noexcept requires std::is_enum_v<t> && add_enum_bitwise_operators<t>
144+
{
145+
lhs = lhs ^ rhs;
146+
return lhs;
147+
}
148+
//!\}
149+
//!\endcond
150+
151+
} // namespace bio::map_io

include/bio/format/sam.hpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// -----------------------------------------------------------------------------------------------------
2+
// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3+
// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4+
// Copyright (c) 2020-2021, deCODE Genetics
5+
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6+
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
7+
// -----------------------------------------------------------------------------------------------------
8+
9+
/*!\file
10+
* brief Provides the seqan3::format_sam.
11+
* \author Hannes Hauswedell <hannes.hauswedell AT decode.is>
12+
*/
13+
14+
#pragma once
15+
16+
#include <string>
17+
#include <vector>
18+
19+
#include <bio/platform.hpp>
20+
21+
namespace bio
22+
{
23+
24+
/*!\brief The sam format.
25+
* \ingroup format
26+
*
27+
* \details
28+
*
29+
* This is the sam format tag. If you want to read sam files, use bio::map_io::reader, and if you want
30+
* to write sam files, use bio::map_io::writer.
31+
*
32+
* ### Introduction
33+
*
34+
* sam is the de-facto-standard for mapping storage in bionformatics. See the
35+
* [article on wikipedia](todo) for a an in-depth description of the format.
36+
*
37+
* ### Fields
38+
*
39+
* todo
40+
*
41+
* ### Implementation notes
42+
*
43+
* todo
44+
*
45+
*/
46+
struct sam
47+
{
48+
//!\brief The valid file extensions for this format; note that you can modify this value.
49+
static inline std::vector<std::string> file_extensions{{"sam"}};
50+
};
51+
52+
} // namespace bio

0 commit comments

Comments
 (0)