Skip to content

Commit

Permalink
[MISC] rename seqan3::{alignment => sam}_file_header*
Browse files Browse the repository at this point in the history
  • Loading branch information
marehr committed Feb 24, 2021
1 parent 49d8b30 commit 0b8026a
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions include/seqan3/io/alignment_file/format_bam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class format_bam : private detail::format_sam_base
void read_alignment_record(stream_type & stream,
alignment_file_input_options<seq_legal_alph_type> const & SEQAN3_DOXYGEN_ONLY(options),
ref_seqs_type & ref_seqs,
alignment_file_header<ref_ids_type> & header,
sam_file_header<ref_ids_type> & header,
seq_type & seq,
qual_type & qual,
id_type & id,
Expand Down Expand Up @@ -289,7 +289,7 @@ template <typename stream_type, // constraints checked by file
inline void format_bam::read_alignment_record(stream_type & stream,
alignment_file_input_options<seq_legal_alph_type> const & SEQAN3_DOXYGEN_ONLY(options),
ref_seqs_type & ref_seqs,
alignment_file_header<ref_ids_type> & header,
sam_file_header<ref_ids_type> & header,
seq_type & seq,
qual_type & qual,
id_type & id,
Expand Down
6 changes: 3 additions & 3 deletions include/seqan3/io/alignment_file/format_sam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class format_sam : private detail::format_sam_base
void read_alignment_record(stream_type & stream,
alignment_file_input_options<seq_legal_alph_type> const & SEQAN3_DOXYGEN_ONLY(options),
ref_seqs_type & ref_seqs,
alignment_file_header<ref_ids_type> & header,
sam_file_header<ref_ids_type> & header,
seq_type & seq,
qual_type & qual,
id_type & id,
Expand Down Expand Up @@ -245,7 +245,7 @@ class format_sam : private detail::format_sam_base
static constexpr std::string_view dummy{};

//!\brief The default header for the alignment format.
alignment_file_header<> default_header{};
sam_file_header<> default_header{};

//!\brief Tracks whether reference information (\@SR tag) were found in the SAM header
bool ref_info_present_in_header{false};
Expand Down Expand Up @@ -384,7 +384,7 @@ template <typename stream_type, // constraints checked by file
inline void format_sam::read_alignment_record(stream_type & stream,
alignment_file_input_options<seq_legal_alph_type> const & SEQAN3_DOXYGEN_ONLY(options),
ref_seqs_type & ref_seqs,
alignment_file_header<ref_ids_type> & header,
sam_file_header<ref_ids_type> & header,
seq_type & seq,
qual_type & qual,
id_type & id,
Expand Down
10 changes: 5 additions & 5 deletions include/seqan3/io/alignment_file/format_sam_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ class format_sam_base

template <typename stream_view_type, typename ref_ids_type, typename ref_seqs_type>
void read_header(stream_view_type && stream_view,
alignment_file_header<ref_ids_type> & hdr,
sam_file_header<ref_ids_type> & hdr,
ref_seqs_type & /*ref_id_to_pos_map*/);

template <typename stream_t, typename ref_ids_type>
void write_header(stream_t & stream,
alignment_file_output_options const & options,
alignment_file_header<ref_ids_type> & header);
sam_file_header<ref_ids_type> & header);
};

/*!\brief Checks for known reference ids or adds a new reference is and assigns a reference id to `ref_id`.
Expand Down Expand Up @@ -455,7 +455,7 @@ inline void format_sam_base::read_field(stream_view_type && stream_view, std::op
*/
template <typename stream_view_type, typename ref_ids_type, typename ref_seqs_type>
inline void format_sam_base::read_header(stream_view_type && stream_view,
alignment_file_header<ref_ids_type> & hdr,
sam_file_header<ref_ids_type> & hdr,
ref_seqs_type & /*ref_id_to_pos_map*/)
{
auto it = std::ranges::begin(stream_view);
Expand Down Expand Up @@ -569,7 +569,7 @@ inline void format_sam_base::read_header(stream_view_type && stream_view,

case 'P': /* PG (program) tag */
{
typename alignment_file_header<ref_ids_type>::program_info_t tmp{};
typename sam_file_header<ref_ids_type>::program_info_t tmp{};

parse_tag_value(tmp.id); // read required ID tag

Expand Down Expand Up @@ -650,7 +650,7 @@ inline void format_sam_base::read_header(stream_view_type && stream_view,
template <typename stream_t, typename ref_ids_type>
inline void format_sam_base::write_header(stream_t & stream,
alignment_file_output_options const & options,
alignment_file_header<ref_ids_type> & header)
sam_file_header<ref_ids_type> & header)
{
// -----------------------------------------------------------------
// Check Header
Expand Down
20 changes: 10 additions & 10 deletions include/seqan3/io/alignment_file/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// -----------------------------------------------------------------------------------------------------

/*!\file
* \brief Provides the seqan3::alignment_file_header class.
* \brief Provides the seqan3::sam_file_header class.
* \author Svenja Mehringer <svenja.mehringer AT fu-berlin.de>
*/

Expand All @@ -29,36 +29,36 @@ namespace seqan3
//!\brief Stores the header information of alignment files.
//!\ingroup alignment_file
template <std::ranges::forward_range ref_ids_type = std::deque<std::string>>
class alignment_file_header
class sam_file_header
{
public:
/*!\name Constructors, destructor and assignment
* \{
*/
//!\brief Default constructor is defaulted.
alignment_file_header() = default;
sam_file_header() = default;
//!\brief Copy construction is defaulted.
alignment_file_header(alignment_file_header const &) = default;
sam_file_header(sam_file_header const &) = default;
//!\brief Copy assignment is defaulted.
alignment_file_header & operator=(alignment_file_header const &) = default;
sam_file_header & operator=(sam_file_header const &) = default;
//!\brief Move construction is defaulted.
alignment_file_header(alignment_file_header &&) = default;
sam_file_header(sam_file_header &&) = default;
//!\brief Move assignment is defaulted.
alignment_file_header & operator=(alignment_file_header &&) = default;
sam_file_header & operator=(sam_file_header &&) = default;
//!\brief Destructor is defaulted.
~alignment_file_header() = default;
~sam_file_header() = default;

/*!\brief Construct from a range of reference ids which redirects the `ref_ids_ptr` member (non-owning).
* \param[in] ref_ids The range over reference ids to redirect the pointer at.
*/
alignment_file_header(ref_ids_type & ref_ids) :
sam_file_header(ref_ids_type & ref_ids) :
ref_ids_ptr{&ref_ids, ref_ids_deleter_noop}
{}

/*!\brief Construct from a rvalue range of reference ids which is moved into the `ref_ids_ptr` (owning).
* \param[in] ref_ids The range over reference ids to own.
*/
alignment_file_header(ref_ids_type && ref_ids) :
sam_file_header(ref_ids_type && ref_ids) :
ref_ids_ptr{new ref_ids_type{std::move(ref_ids)}, ref_ids_deleter_default}
{}
//!\}
Expand Down
8 changes: 4 additions & 4 deletions include/seqan3/io/alignment_file/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ class alignment_file_input
using e_value_type = double;
//!\brief The type of field::bitscore is fixed to double.
using bitscore_type = double;
//!\brief The type of field::header_ptr (default: alignment_file_header<typename traits_type::ref_ids>).
using header_type = alignment_file_header<typename traits_type::ref_ids>;
//!\brief The type of field::header_ptr (default: sam_file_header<typename traits_type::ref_ids>).
using header_type = sam_file_header<typename traits_type::ref_ids>;

private:
//!\brief The type of the aligned query sequence (second type of the pair of alignment_type).
Expand Down Expand Up @@ -488,7 +488,7 @@ class alignment_file_input
*
* There exists one more field for alignment files, the seqan3::field::header_ptr, but this field is mostly used
* internally. Please see the seqan3::alignment_file_output::header member function for details on how to access
* the seqan3::alignment_file_header of the file.)
* the seqan3::sam_file_header of the file.)
*/
using field_ids = fields<field::seq,
field::id,
Expand Down Expand Up @@ -825,7 +825,7 @@ class alignment_file_input
*
* \include test/snippet/io/alignment_file/alignment_file_input_get_header.cpp
*
* \sa seqan3::alignment_file_header
* \sa seqan3::sam_file_header
*/
header_type & header()
{
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/io/alignment_file/input_format_concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SEQAN3_CONCEPT alignment_file_input_format =
std::ifstream & stream,
alignment_file_input_options<dna5> & options,
std::vector<dna5_vector> & ref_sequences,
alignment_file_header<> & header,
sam_file_header<> & header,
dna5_vector & seq,
std::vector<phred42> & qual,
std::string & id,
Expand Down Expand Up @@ -186,7 +186,7 @@ SEQAN3_CONCEPT alignment_file_input_format =
* \param[in,out] stream The input stream to read from.
* \param[in] options File specific options passed to the format.
* \param[out] ref_seqs The reference sequences to the corresponding alignments.
* \param[out] header A pointer to the seqan3::alignment_file_header object.
* \param[out] header A pointer to the seqan3::sam_file_header object.
* \param[out] seq The buffer for seqan3::field::seq input.
* \param[out] qual The buffer for seqan3::field::qual input.
* \param[out] id The buffer for seqan3::field::id input.
Expand Down
10 changes: 5 additions & 5 deletions include/seqan3/io/alignment_file/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ class alignment_file_output
*
* \include test/snippet/io/alignment_file/alignment_file_output_set_header.cpp
*
* \sa seqan3::alignment_file_header
* \sa seqan3::sam_file_header
*/
auto & header()
{
Expand Down Expand Up @@ -728,9 +728,9 @@ class alignment_file_output
//!\}

//!\brief The header type, which specilised with ref_ids_type if reference information are given.
using header_type = alignment_file_header<std::conditional_t<std::same_as<ref_ids_type, ref_info_not_given>,
std::vector<std::string>,
ref_ids_type>>;
using header_type = sam_file_header<std::conditional_t<std::same_as<ref_ids_type, ref_info_not_given>,
std::vector<std::string>,
ref_ids_type>>;

//!\brief The file header object (will be set on construction).
std::unique_ptr<header_type> header_ptr;
Expand All @@ -741,7 +741,7 @@ class alignment_file_output
{
assert(std::ranges::size(ref_ids) == std::ranges::size(ref_lengths));

header_ptr = std::make_unique<alignment_file_header<ref_ids_type>>(std::forward<ref_ids_type_>(ref_ids));
header_ptr = std::make_unique<sam_file_header<ref_ids_type>>(std::forward<ref_ids_type_>(ref_ids));

for (int32_t idx = 0; idx < std::ranges::distance(ref_ids); ++idx)
{
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/io/alignment_file/output_format_concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ SEQAN3_CONCEPT alignment_file_output_format =
requires (detail::alignment_file_output_format_exposer<t> & v,
std::ofstream & stream,
alignment_file_output_options & options,
alignment_file_header<> & header,
sam_file_header<> & header,
dna5_vector & seq,
std::vector<phred42> & qual,
std::string & id,
Expand Down Expand Up @@ -125,7 +125,7 @@ SEQAN3_CONCEPT alignment_file_output_format =

/*!\fn void write_alignment_record(stream_type & stream,
alignment_file_output_options const & options,
alignment_file_header<> & header,
sam_file_header<> & header,
seq_type && seq,
qual_type && qual,
id_type && id,
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/io/record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum class field
ref_id, //!< The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
ref_seq, //!< The (reference) "sequence" information, usually a range of nucleotides or amino acids.
ref_offset, //!< Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
header_ptr, //!< A pointer to the seqan3::alignment_file_header object storing header information.
header_ptr, //!< A pointer to the seqan3::sam_file_header object storing header information.

flag, //!< The alignment flag (bit information), `uint16_t` value.
mate, //!< The mate pair information given as a std::tuple of reference name, offset and template length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct alignment_file_data : public ::testing::Test
{
ref_sequences = std::vector<seqan3::dna5_vector>{ref_seq};
ref_ids = std::vector<std::string>{ref_id};
header = seqan3::alignment_file_header{ref_ids};
header = seqan3::sam_file_header{ref_ids};
header.ref_id_info.emplace_back(ref_seq.size(), "");
header.ref_dict[header.ref_ids()[0]] = 0; // set up header which is otherwise done on file level
}
Expand Down Expand Up @@ -128,7 +128,7 @@ struct alignment_file_data : public ::testing::Test

std::vector<seqan3::dna5_vector> ref_sequences{};
std::vector<std::string> ref_ids{};
seqan3::alignment_file_header<std::vector<std::string>> header{};
seqan3::sam_file_header<std::vector<std::string>> header{};
};

template <typename format_t>
Expand Down Expand Up @@ -497,7 +497,7 @@ TYPED_TEST_P(alignment_file_write, write_ref_id_with_different_types)

TYPED_TEST_P(alignment_file_write, with_header)
{
seqan3::alignment_file_header header{std::vector<std::string>{this->ref_id}};
seqan3::sam_file_header header{std::vector<std::string>{this->ref_id}};
header.sorting = "unknown";
header.grouping = "none";
header.ref_id_info.push_back({this->ref_seq.size(), "AN:other_name"});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/io/alignment_file/alignment_file_output_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ TEST(row, print_header_in_record)
std::vector<std::string> const ref_ids{"ref1", "ref2"};
std::vector<int32_t> const ref_len{234511, 243243};

seqan3::alignment_file_header header{ref_ids};
seqan3::sam_file_header header{ref_ids};

header.ref_id_info.push_back({ref_len[0], ""});
header.ref_id_info.push_back({ref_len[1], ""});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/io/alignment_file/format_bam_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ TEST_F(bam_format, too_long_cigar_string_write)

std::ostringstream os{};

seqan3::alignment_file_header header{std::vector<std::string>{this->ref_id}};
seqan3::sam_file_header header{std::vector<std::string>{this->ref_id}};
header.ref_id_info.push_back({ref.size(), ""});
header.ref_dict[this->ref_id] = 0;

Expand Down

0 comments on commit 0b8026a

Please sign in to comment.