Commit 86bfa96f authored by Celine Mercier's avatar Celine Mercier

C: kmer similarity: small improvements

parent f765c6f4
...@@ -78,8 +78,7 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1 ...@@ -78,8 +78,7 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1
Obi_ali_p ali = NULL; Obi_ali_p ali = NULL;
int i, j; int i, j;
bool switched_seqs; bool switched_seqs;
bool left_ali; int score = 0;
double score = 0.0;
Obi_blob_p blob1 = NULL; Obi_blob_p blob1 = NULL;
Obi_blob_p blob2 = NULL; Obi_blob_p blob2 = NULL;
Obi_blob_p temp_blob = NULL; Obi_blob_p temp_blob = NULL;
...@@ -397,8 +396,6 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1 ...@@ -397,8 +396,6 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1
keep_seq2_end = true; keep_seq2_end = true;
} }
score = max_common_kmers + kmer_size - 1;
ali = (Obi_ali_p) malloc(sizeof(Obi_ali_t)); ali = (Obi_ali_p) malloc(sizeof(Obi_ali_t));
if (ali == NULL) if (ali == NULL)
{ {
...@@ -407,6 +404,7 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1 ...@@ -407,6 +404,7 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1
return NULL; return NULL;
} }
score = max_common_kmers + kmer_size - 1; // aka the number of nucleotides in the longest stretch of kmers perfectly matching
abs_shift = abs(best_shift); abs_shift = abs(best_shift);
// Save result in Obi_ali structure // Save result in Obi_ali structure
...@@ -417,15 +415,9 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1 ...@@ -417,15 +415,9 @@ Obi_ali_p kmer_similarity(Obiview_p view1, OBIDMS_column_p column1, index_t idx1
ali->consensus_seq = NULL; ali->consensus_seq = NULL;
ali->consensus_qual = NULL; ali->consensus_qual = NULL;
if (((best_shift <= 0) && (!switched_seqs)) || ((best_shift > 0) && switched_seqs)) if (((best_shift <= 0) && (!switched_seqs)) || ((best_shift > 0) && switched_seqs))
{
left_ali = true;
strcpy(ali->direction, "left"); strcpy(ali->direction, "left");
}
else else
{
left_ali = false;
strcpy(ali->direction, "right"); strcpy(ali->direction, "right");
}
// Build the consensus sequence if asked // Build the consensus sequence if asked
if (build_consensus) if (build_consensus)
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* @brief Alignment structure, with informations about the similarity and to rebuild the alignment. * @brief Alignment structure, with informations about the similarity and to rebuild the alignment.
*/ */
typedef struct Obi_ali { typedef struct Obi_ali {
double score; /**< Alignment score. int score; /**< Alignment score, corresponding to the number of matches (identical nucleotides aligned).
*/ */
int consensus_length; /**< Length of the final consensus sequence. int consensus_length; /**< Length of the final consensus sequence.
*/ */
...@@ -37,10 +37,10 @@ typedef struct Obi_ali { ...@@ -37,10 +37,10 @@ typedef struct Obi_ali {
*/ */
uint8_t* consensus_qual; /**< Consensus quality built as to reconstruct a pairedend read. uint8_t* consensus_qual; /**< Consensus quality built as to reconstruct a pairedend read.
*/ */
int shift; /**< Shift chosen to align the sequences (for shifted alignment). int shift; /**< Shift chosen to align the sequences.
*/ */
char direction[6]; /**< Alignement direction (positive/right or negative/left shift) (for shifted alignment). char direction[6]; /**< Alignment direction (positive/right or negative/left shift).
*/ // TODO but sequences switched around depending on size..... discuss */
} Obi_ali_t, *Obi_ali_p; } Obi_ali_t, *Obi_ali_p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment