-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring to move parsing custom barcodes kits functionality into u…
…tils so that bam_utils can have a dependency on it for creating the read groups
- Loading branch information
1 parent
dab78dc
commit f37cd6a
Showing
13 changed files
with
189 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "parse_custom_sequences.h" | ||
|
||
#include "utils/bam_utils.h" | ||
#include "utils/barcode_kits.h" | ||
|
||
#include <htslib/sam.h> | ||
#include <toml.hpp> | ||
#include <toml/value.hpp> | ||
|
||
#include <algorithm> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace dorado::demux { | ||
|
||
std::unordered_map<std::string, std::string> parse_custom_sequences( | ||
const std::string& sequences_file) { | ||
auto file = hts_open(sequences_file.c_str(), "r"); | ||
BamPtr record; | ||
record.reset(bam_init1()); | ||
|
||
std::unordered_map<std::string, std::string> sequences; | ||
|
||
int sam_ret_val = 0; | ||
while ((sam_ret_val = sam_read1(file, nullptr, record.get())) != -1) { | ||
if (sam_ret_val < -1) { | ||
throw std::runtime_error("Failed to parse custom sequence file " + sequences_file); | ||
} | ||
std::string qname = bam_get_qname(record.get()); | ||
std::string seq = utils::extract_sequence(record.get()); | ||
sequences[qname] = seq; | ||
} | ||
|
||
hts_close(file); | ||
|
||
return sequences; | ||
} | ||
|
||
} // namespace dorado::demux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include "utils/barcode_kits.h" | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <unordered_map> | ||
|
||
namespace dorado::demux { | ||
|
||
std::unordered_map<std::string, std::string> parse_custom_sequences( | ||
const std::string& sequences_file); | ||
|
||
} // namespace dorado::demux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.