alignpairedend: fixed the worst memory leak and the handling of the case

where 0 common kmers are found
This commit is contained in:
Celine Mercier
2019-03-29 11:16:25 +01:00
parent ceaafca427
commit ee9947217c
5 changed files with 46 additions and 43 deletions

View File

@ -2,7 +2,6 @@
from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport
from obitools3.dms import DMS
from obitools3.dms.view import RollbackException
from obitools3.dms.view.typed_view.view_NUC_SEQS cimport View_NUC_SEQS
from obitools3.dms.column.column cimport Column
from obitools3.dms.capi.obiview cimport QUALITY_COLUMN
@ -201,26 +200,23 @@ def run(config):
pb(i)
consensus = view[i]
if not two_views:
seqF = entries[i]
else:
seqF = forward[i]
if smin > 0:
if (ali.score > smin) :
buildConsensus(ali, consensus, seqF)
else:
if not two_views:
seqR = Nuc_Seq(seqF.id, seqF[REVERSE_SEQ_COLUMN_NAME], quality = seqF[REVERSE_QUALITY_COLUMN_NAME])
else:
seqR = reverse[i]
buildJoinedSequence(ali, seqR, consensus, forward=seqF)
consensus[b"smin"] = smin
else:
if ali.score > smin and ali.consensus_len > 0 :
buildConsensus(ali, consensus, seqF)
else:
if not two_views:
seqR = Nuc_Seq(seqF.id, seqF[REVERSE_SEQ_COLUMN_NAME], quality = seqF[REVERSE_QUALITY_COLUMN_NAME])
else:
seqR = reverse[i]
buildJoinedSequence(ali, seqR, consensus, forward=seqF)
consensus[b"smin"] = smin
if kmer_ali :
ali.free()

View File

@ -35,10 +35,10 @@ cdef extern from "kmer_similarity.h" nogil:
OBIDMS_column_p qual_col1,
OBIDMS_column_p qual_col2,
uint8_t kmer_size,
int32_t* kmer_pos_array,
int32_t** kmer_pos_array,
int32_t* kmer_pos_array_height_p,
int32_t* shift_array,
int32_t** shift_array,
int32_t* shift_array_height_p,
int32_t* shift_count_array,
int32_t** shift_count_array,
int32_t* shift_count_array_height_p,
bint build_consensus)

View File

@ -112,9 +112,9 @@ cdef class Kmer_similarity:
self.view2_p, self.column2_p, seq2.index, 0, \
self.qual_col1_p, self.qual_col2_p, \
self.kmer_size, \
self.kmer_pos_array_p, self.kmer_pos_array_height_a, \
self.shift_array_p, self.shift_array_height_a, \
self.shift_count_array_p, self.shift_count_array_height_a,
&(self.kmer_pos_array_p), self.kmer_pos_array_height_a, \
&(self.shift_array_p), self.shift_array_height_a, \
&(self.shift_count_array_p), self.shift_count_array_height_a,
self.build_consensus)
ali = Ali_shifted.new_ali(ali_p)