Embryo of code for openMP parallelization of LCS alignment but
deactivated for now because can't make it compile with cython/clang
This commit is contained in:
@ -147,6 +147,13 @@ def addOptions(parser):
|
|||||||
default=False,
|
default=False,
|
||||||
help="Sequence counts are written in the output view. Default: they are not written.")
|
help="Sequence counts are written in the output view. Default: they are not written.")
|
||||||
|
|
||||||
|
group.add_argument('--thread-count','-p', # TODO should probably be in a specific option group
|
||||||
|
action="store", dest="align:threadcount",
|
||||||
|
metavar='<THREAD COUNT>',
|
||||||
|
default=1,
|
||||||
|
type=int,
|
||||||
|
help="Number of threads to use for the computation. Default: one.")
|
||||||
|
|
||||||
|
|
||||||
cpdef align(str dms_n,
|
cpdef align(str dms_n,
|
||||||
str input_view_1_n, str output_view_n,
|
str input_view_1_n, str output_view_n,
|
||||||
@ -157,7 +164,8 @@ cpdef align(str dms_n,
|
|||||||
double threshold=0.0, bint normalize=True,
|
double threshold=0.0, bint normalize=True,
|
||||||
int reference=0, bint similarity_mode=True,
|
int reference=0, bint similarity_mode=True,
|
||||||
bint print_seq=False, bint print_count=False,
|
bint print_seq=False, bint print_count=False,
|
||||||
comments="") :
|
comments="",
|
||||||
|
int thread_count=1) :
|
||||||
|
|
||||||
cdef OBIDMS d
|
cdef OBIDMS d
|
||||||
d = OBIDMS(dms_n)
|
d = OBIDMS(dms_n)
|
||||||
@ -172,7 +180,8 @@ cpdef align(str dms_n,
|
|||||||
str2bytes(comments), \
|
str2bytes(comments), \
|
||||||
print_seq, \
|
print_seq, \
|
||||||
print_count, \
|
print_count, \
|
||||||
threshold, normalize, reference, similarity_mode) < 0 :
|
threshold, normalize, reference, similarity_mode,
|
||||||
|
thread_count) < 0 :
|
||||||
raise Exception("Error aligning sequences")
|
raise Exception("Error aligning sequences")
|
||||||
else :
|
else :
|
||||||
if obi_lcs_align_two_columns(d._pointer, \
|
if obi_lcs_align_two_columns(d._pointer, \
|
||||||
@ -216,7 +225,8 @@ def run(config):
|
|||||||
similarity_mode = config['align']['similarity'], \
|
similarity_mode = config['align']['similarity'], \
|
||||||
print_seq = config['align']['printseq'], \
|
print_seq = config['align']['printseq'], \
|
||||||
print_count = config['align']['printcount'], \
|
print_count = config['align']['printcount'], \
|
||||||
comments = comments)
|
comments = comments, \
|
||||||
|
thread_count = config['align']['threadcount'])
|
||||||
|
|
||||||
print("Done.")
|
print("Done.")
|
||||||
|
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
* @brief Functions handling LCS sequence alignments.
|
* @brief Functions handling LCS sequence alignments.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#define OMP_SUPPORT // TODO
|
||||||
|
#ifdef OMP_SUPPORT
|
||||||
|
#include <omp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -389,7 +393,8 @@ int obi_lcs_align_one_column(OBIDMS_p dms, const char* seq_view_name, const char
|
|||||||
const char* id_column_name,
|
const char* id_column_name,
|
||||||
const char* output_view_name, const char* output_view_comments,
|
const char* output_view_name, const char* output_view_comments,
|
||||||
bool print_seq, bool print_count,
|
bool print_seq, bool print_count,
|
||||||
double threshold, bool normalize, int reference, bool similarity_mode)
|
double threshold, bool normalize, int reference, bool similarity_mode,
|
||||||
|
int thread_count)
|
||||||
{
|
{
|
||||||
index_t i, j, k;
|
index_t i, j, k;
|
||||||
index_t seq_count;
|
index_t seq_count;
|
||||||
@ -537,6 +542,11 @@ int obi_lcs_align_one_column(OBIDMS_p dms, const char* seq_view_name, const char
|
|||||||
|
|
||||||
seq_count = (seq_view->infos)->line_count;
|
seq_count = (seq_view->infos)->line_count;
|
||||||
|
|
||||||
|
#ifdef OMP_SUPPORT
|
||||||
|
omp_set_num_threads(thread_count);
|
||||||
|
#pragma omp parallel for
|
||||||
|
#endif
|
||||||
|
|
||||||
for (i=0; i < (seq_count - 1); i++)
|
for (i=0; i < (seq_count - 1); i++)
|
||||||
{
|
{
|
||||||
if (i%100 == 0)
|
if (i%100 == 0)
|
||||||
|
@ -92,7 +92,8 @@ int obi_lcs_align_one_column(OBIDMS_p dms,
|
|||||||
const char* id_column_name,
|
const char* id_column_name,
|
||||||
const char* output_view_name, const char* output_view_comments,
|
const char* output_view_name, const char* output_view_comments,
|
||||||
bool print_seq, bool print_count,
|
bool print_seq, bool print_count,
|
||||||
double threshold, bool normalize, int reference, bool similarity_mode);
|
double threshold, bool normalize, int reference, bool similarity_mode,
|
||||||
|
int thread_count);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user