Skip to content
Tobias Neumann edited this page Oct 31, 2016 · 7 revisions

Dynamic loading

Building versalignLib creates shared objects for each Kernel implementation in the bin/Versalign-0.1.0/lib subfolder. These can be dynamically loaded and directly used in your program. An example how to do this can be found in the reference implementation.

Library interface

Each shared object exports the following functions.

void set_parameters(AlignmentParameters * parameters)

Sets parameters for alignment.

void set_logger(AlignmentLogger * logger)

Sets logger for alignment.

AlignmentKernel * spawn_alignment_kernel()

Creates alignment.

 void delete_alignment_kernel(AlignmentKernel * instance)

Deletes alignment.

Execution order

Caveat: Before instantiating an AlignmentKernel, all parameters and loggers have to be set using set_parameters and set_logger functions!

Library classes

All Kernels implement the AlignmentKernel interface in include/AlignmentKernel.h providing two functions:

Score alignments

This function will return an alignment score for each sequence pair.

void score_alignments(int const & opt, int const & aln_number, char const * const * const reads,
			char const * const * const refs, short * const scores)

Arguments

Argument Type Description
opt int Type of alignment (0 Smith-Waterman, 1 Needleman-Wunsch)
aln_number int Number of reads vs refs pairs
reads char * [] Array of sequences to align to refs
refs char * [] Array of sequences to align to reads
scores short [] One score for each pair in reads vs refs

Calculate alignments

This function will return an alignment struct object for each sequence pair.

void compute_alignments(int const & opt, int const & aln_number, char const * const * const reads,
			char const * const * const refs, Alignment * const alignments)

Arguments

Argument Type Description
opt int Type of alignment (0 Smith-Waterman, 1 Needleman-Wunsch)
aln_number int Number of reads vs refs pairs
reads char * [] Array of sequences to align to refs
refs char * [] Array of sequences to align to reads
alignments Alignment [] One Alignment object for each pair in reads vs refs

Setting parameters

It is required to set the alignment parameters (scoring schema, number of threads...) before instantiating any of the Kernel shared objects. This can be done using an object implementing the AlignmentParameters interface defined in include/AlignmentParameters.h. An example is shown in the reference implementation.

Available parameters

The following table lists the minimal set of parameters that needs to be available.

Parameter Type Description
score_match int Score for base match
score_mismatch int Score for base mismatch
score_gap_read int Score for introducing a gap in the first sequence
score_gap_ref int Score for introducing a gap in the second sequence
read_length int Maximum length of first sequence
ref_length int Maximum length of second sequence
num_threads int Number of threads to use

Logging

Logging of Kernels is also supported by implementing the AlignmentLogger interface defined in include/AlignmentLogger.h. An example implementation can be found in the reference implementation.