Skip to content

Instantly share code, notes, and snippets.

@brentp
Created May 11, 2022 13:32
Show Gist options
  • Save brentp/eccdb076a48d98b091ae6201b8add971 to your computer and use it in GitHub Desktop.
Save brentp/eccdb076a48d98b091ae6201b8add971 to your computer and use it in GitHub Desktop.
import futhark
import std/typetraits
type CFile* = typeof(File.pointerBase)
importc:
sysPath "/usr/lib/clang/13/include"
path "./WFA2-lib"
"wavefront/wavefront_align.h"
rename FILE, CFile
converter toCint(x: int): cint =
x.cint
var attr = wavefront_aligner_attr_default
attr.distance_metric = gap_affine
attr.affine_penalties.match = 0
attr.affine_penalties.mismatch = 2
attr.affine_penalties.gap_opening = 2
attr.affine_penalties.gap_extension = 1
attr.alignment_scope = compute_alignment
attr.memory_mode = wavefront_memory_high
attr.heuristic.strategy = wf_heuristic_wfadaptive;
attr.heuristic.min_wavefront_length = 10;
attr.heuristic.max_distance_threshold = 50;
attr.heuristic.steps_between_cutoffs = 1;
attr.alignment_form.span = alignment_endsfree;
attr.alignment_form.pattern_begin_free = 7
attr.alignment_form.pattern_end_free = 0
attr.alignment_form.text_begin_free = 11
attr.alignment_form.text_end_free = 0
attr.system.max_alignment_score = 1_000_000
attr.system.check_alignment_correct = false
attr.system.probe_interval_global = 3000
attr.system.probe_interval_compact = 6000
attr.system.max_memory_compact = uint64.high
attr.system.max_num_threads = 1
attr.system.max_memory_resident = uint64.high # Automatically set based on memory-mode
attr.system.max_memory_abort = uint64.high # Unlimited
attr.system.verbose = 0
let wf = wavefront_aligner_new(attr.addr)
# 0123456789012345678901234567890
var p = "AAAAAAACCGGTTGGAAAAAAAAAAAAAAAAAA".cstring;
# 0123456788901234
var t = "AAAAAAAAAAAACCGGTTGGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA".cstring;
discard wavefront_align(wf, p, p.len, t, t.len)
echo "OK"
cigar_print_pretty(stderr, p, p.len, t, t.len,
wf.cigar.addr, wf.mm_allocator)
wavefront_aligner_delete(wf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment