Skip to content

Commit

Permalink
modified skyr such that indels are represented together
Browse files Browse the repository at this point in the history
  • Loading branch information
hannespetur committed Oct 18, 2023
1 parent ee1a793 commit 55c95cd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
10 changes: 5 additions & 5 deletions include/paw/align/alignment_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ set_query(AlignmentOptions<Tuint> & opt, AlignmentCache<Tuint> & aln_cache, Tseq

// TODO add more tests
//// set free snps
//for (Event2 const & e : opt.free_edits)
//{
// assert(e.is_snp());
// aln_cache.set_free_snp(e.pos, e.alt[0]);
//}
for (Event2 const & e : opt.free_edits)
{
assert(e.is_snp());
aln_cache.set_free_snp(e.pos, e.alt[0]);
}

aln_cache.vH_up = Tvec_pack(static_cast<std::size_t>(aln_cache.num_vectors),
static_cast<Tpack>(simdpp::make_int(2 * aln_cache.gap_open_val +
Expand Down
5 changes: 5 additions & 0 deletions include/paw/align/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class Event2
return ref.size() == 0;
}

inline bool
is_indel() const
{
return is_deletion() || is_insertion();
}

};

Expand Down
28 changes: 13 additions & 15 deletions include/paw/align/skyr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,41 +335,39 @@ Skyr::find_variants_from_edits()

if (e.pos == new_var.pos)
{
if (e.is_insertion() && new_var.is_insertion())
if (e.is_indel() && new_var.is_indel())
{
// Case 1: insertions at the same position.
new_var.add_event(e);
}
else if (e.is_deletion() && new_var.is_deletion())
{
// Case 2: Deletions at the same position.
// Case 1: indel at the same position.
assert(e.ref.size() > new_var.seqs[0].size());
/// Extend all sequences.
auto begin_extend = e.ref.cbegin() + new_var.seqs[0].size();

for (auto & s : new_var.seqs)
s.append(begin_extend, e.ref.cend());
///
// Extend all variant sequences if needed
{
auto const begin_extend = std::next(e.ref.cbegin(), new_var.seqs[0].size());
auto const end_extend = e.ref.cend();

for (auto & s : new_var.seqs)
s.append(begin_extend, end_extend);
}

new_var.add_event(e);
}
else if (e.is_snp() && new_var.is_snp())
{
// Case 3: both are SNPs at the same position.
// Case 2: both are SNPs at the same position.
new_var.add_event(e);
}
else
{
// Otherwise, they are two different events.
vars.push_back(std::move(new_var));
vars.push_back(std::move(new_var)); // push old variant
new_var = {static_cast<uint32_t>(e.pos), {e.ref} };
new_var.add_event(e);
}
}
else
{
// Otherwise, they are two different events.
vars.push_back(std::move(new_var));
vars.push_back(std::move(new_var)); // push old variant
new_var = {static_cast<uint32_t>(e.pos), {e.ref} };
new_var.add_event(e);
}
Expand Down
7 changes: 7 additions & 0 deletions include/paw/align/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Variant
bool has_sequences() const;
bool is_deletion() const;
bool is_insertion() const;
bool is_indel() const;
bool is_snp() const;
long get_max_del_reach() const;
long get_max_reach() const;
Expand Down Expand Up @@ -92,6 +93,12 @@ Variant::is_insertion() const
return has_sequences() && seqs[0].size() == 0;
}

bool
Variant::is_indel() const
{
return is_deletion() || is_insertion();
}


bool
Variant::is_snp() const
Expand Down

0 comments on commit 55c95cd

Please sign in to comment.