Added function to build kmer table for 2 columns, and fixed bug (with
line count) when building kmer table of one column
This commit is contained in:
@ -8,8 +8,6 @@
|
|||||||
#include "obidmscolumn.h"
|
#include "obidmscolumn.h"
|
||||||
#include "obiview.h"
|
#include "obiview.h"
|
||||||
|
|
||||||
//#include "../libutils/utilities.h"
|
|
||||||
//#include "../libfasta/sequence.h"
|
|
||||||
|
|
||||||
|
|
||||||
inline static uchar_v hash4m128(uchar_v frag)
|
inline static uchar_v hash4m128(uchar_v frag)
|
||||||
@ -242,7 +240,7 @@ Kmer_table_p hash_seq_column(Obiview_p view, OBIDMS_column_p seq_col, index_t se
|
|||||||
|
|
||||||
fprintf(stderr,"Building kmer tables...");
|
fprintf(stderr,"Building kmer tables...");
|
||||||
|
|
||||||
seq_count = (seq_col->header)->lines_used;
|
seq_count = (view->infos)->line_count;
|
||||||
|
|
||||||
// Allocate memory for the table structure
|
// Allocate memory for the table structure
|
||||||
ktable = (Kmer_table_p) malloc(sizeof(Kmer_table_t) * seq_count);
|
ktable = (Kmer_table_p) malloc(sizeof(Kmer_table_t) * seq_count);
|
||||||
@ -267,6 +265,44 @@ Kmer_table_p hash_seq_column(Obiview_p view, OBIDMS_column_p seq_col, index_t se
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Kmer_table_p hash_two_seq_columns(Obiview_p view1, OBIDMS_column_p seq1_col, index_t seq1_idx,
|
||||||
|
Obiview_p view2, OBIDMS_column_p seq2_col, index_t seq2_idx)
|
||||||
|
{
|
||||||
|
size_t seq1_count;
|
||||||
|
size_t seq2_count;
|
||||||
|
Kmer_table_p ktable1;
|
||||||
|
Kmer_table_p ktable2;
|
||||||
|
Kmer_table_p ktable;
|
||||||
|
|
||||||
|
seq1_count = (view1->infos)->line_count;
|
||||||
|
seq2_count = (view2->infos)->line_count;
|
||||||
|
|
||||||
|
// Build the two tables then concatenate them
|
||||||
|
ktable1 = hash_seq_column(view1, seq1_col, seq1_idx);
|
||||||
|
if (ktable1 == NULL)
|
||||||
|
return NULL;
|
||||||
|
ktable2 = hash_seq_column(view2, seq2_col, seq2_idx);
|
||||||
|
if (ktable2 == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// Realloc to hold the 2 tables
|
||||||
|
ktable = realloc(ktable1, sizeof(Kmer_table_t) * (seq1_count + seq2_count));
|
||||||
|
if (ktable == NULL)
|
||||||
|
{
|
||||||
|
free_kmer_tables(ktable2, seq2_count);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Concatenate
|
||||||
|
memcpy(ktable+seq1_count, ktable2, sizeof(Kmer_table_t) * seq2_count);
|
||||||
|
|
||||||
|
// Free copied table
|
||||||
|
free(ktable2);
|
||||||
|
|
||||||
|
return ktable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void free_kmer_tables(Kmer_table_p ktable, size_t count)
|
void free_kmer_tables(Kmer_table_p ktable, size_t count)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -18,7 +18,11 @@ typedef struct {
|
|||||||
} Kmer_table_t, *Kmer_table_p;
|
} Kmer_table_t, *Kmer_table_p;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO doc
|
||||||
|
|
||||||
Kmer_table_p hash_seq_column(Obiview_p view, OBIDMS_column_p seq_col, index_t seq_idx);
|
Kmer_table_p hash_seq_column(Obiview_p view, OBIDMS_column_p seq_col, index_t seq_idx);
|
||||||
|
Kmer_table_p hash_two_seq_columns(Obiview_p view1, OBIDMS_column_p seq1_col, index_t seq1_idx,
|
||||||
|
Obiview_p view2, OBIDMS_column_p seq2_col, index_t seq2_idx);
|
||||||
void align_filters(Kmer_table_p ktable, Obi_blob_p seq1, Obi_blob_p seq2, index_t idx1, index_t idx2, double threshold, bool normalize, int reference, bool similarity_mode, double* score, int* LCSmin, bool can_be_identical);
|
void align_filters(Kmer_table_p ktable, Obi_blob_p seq1, Obi_blob_p seq2, index_t idx1, index_t idx2, double threshold, bool normalize, int reference, bool similarity_mode, double* score, int* LCSmin, bool can_be_identical);
|
||||||
void free_kmer_tables(Kmer_table_p ktable, size_t count);
|
void free_kmer_tables(Kmer_table_p ktable, size_t count);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user