Skip to content

Commit

Permalink
Updated follwoing review
Browse files Browse the repository at this point in the history
  • Loading branch information
hpendry-ont committed Mar 22, 2024
1 parent cbdd51a commit 037257f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
14 changes: 3 additions & 11 deletions dorado/demux/parse_custom_sequences.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
#include "parse_custom_sequences.h"

#include "utils/bam_utils.h"
#include "utils/barcode_kits.h"
#include "utils/types.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");
dorado::HtsFilePtr 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) {
while ((sam_ret_val = sam_read1(file.get(), nullptr, record.get())) != -1) {
if (sam_ret_val < -1) {
throw std::runtime_error("Failed to parse custom sequence file " + sequences_file);
}
Expand All @@ -31,8 +25,6 @@ std::unordered_map<std::string, std::string> parse_custom_sequences(
sequences[qname] = seq;
}

hts_close(file);

return sequences;
}

Expand Down
3 changes: 0 additions & 3 deletions dorado/demux/parse_custom_sequences.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#pragma once

#include "utils/barcode_kits.h"

#include <optional>
#include <string>
#include <unordered_map>

Expand Down
2 changes: 1 addition & 1 deletion dorado/utils/barcode_kits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ const std::unordered_map<std::string, KitInfo>& get_kit_infos() { return kit_inf

const KitInfo* get_kit_info(const std::string& kit_name) {
const auto& barcode_kit_infos = get_kit_infos();
auto kit_iter = get_kit_infos().find(kit_name);
auto kit_iter = barcode_kit_infos.find(kit_name);
if (kit_iter == barcode_kit_infos.end()) {
return nullptr;
}
Expand Down
2 changes: 0 additions & 2 deletions dorado/utils/parse_custom_kit.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "parse_custom_kit.h"

//#include "utils/bam_utils.h"
//#include "utils/types.h"
#include "utils/barcode_kits.h"

#include <htslib/sam.h>
Expand Down

0 comments on commit 037257f

Please sign in to comment.