Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim ID after first whitespace #112

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
-->
[4]: https://codecov.io/gh/eaasna/valik

The FASTA identifiers are trimmed after the first whitespace.

## Quick run: split and search single reference sequence
`valik split test/data/split/single_reference.fasta --ref-meta reference_metadata.txt --seg-meta segment_metadata.txt --bins 4`

Expand Down
8 changes: 3 additions & 5 deletions include/valik/split/metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <iostream>
#include <fstream>
#include <ranges>
#include <sstream>

#include <cereal/archives/binary.hpp>
#include <cereal/types/vector.hpp>
Expand All @@ -30,12 +31,9 @@ void trim_fasta_id(id_t & id)
auto first_valid = id.find_first_not_of(whitespace);
if (first_valid == std::string::npos)
throw std::runtime_error{"Sequence name can not be empty."};
id.erase(0, first_valid);

auto last_valid = id.find_last_not_of(whitespace);
if (last_valid == std::string::npos)
throw std::runtime_error{"Sequence name can not be empty."};
id.erase(last_valid + 1);
std::istringstream iss(id);
iss >> id;
}

/**
Expand Down
Loading