cleaning stage 2
This commit is contained in:
@ -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()
|
||||
|
||||
|
@ -266,7 +266,7 @@ def run(config):
|
||||
new_nb_elements_per_line=new_nb_elements_per_line,
|
||||
new_elements_names=new_elements_names,
|
||||
rewrite_last_line=False),
|
||||
value_obitype)
|
||||
new_type)
|
||||
|
||||
# Update the dictionary:
|
||||
for t in dcols :
|
||||
|
@ -283,7 +283,8 @@ cdef tuple annotate(sequences, infos, verbose=False):
|
||||
if pattern == MAX_PATTERN:
|
||||
new_seq = True
|
||||
pattern = 0
|
||||
directmatch.append((p, p(seq, same_sequence=not new_seq, pattern=pattern), seq))
|
||||
# Saving original primer as 4th member of the tuple to serve as correct key in infos dict even if it might be reversed complemented (not here)
|
||||
directmatch.append((p, p(seq, same_sequence=not new_seq, pattern=pattern), seq, p))
|
||||
new_seq = False
|
||||
pattern+=1
|
||||
|
||||
@ -329,10 +330,11 @@ cdef tuple annotate(sequences, infos, verbose=False):
|
||||
# Keep only paired reverse primer
|
||||
infos = infos[directmatch[0]]
|
||||
|
||||
# If not aligned, look for other match in already computed match (choose the one that makes the biggest amplicon)
|
||||
# If not aligned, look for other match in already computed matches (choose the one that makes the biggest amplicon)
|
||||
if not_aligned:
|
||||
i=1
|
||||
while all_direct_matches[i][1] is None and all_direct_matches[i][0].forward and i<len(all_direct_matches):
|
||||
# TODO comment
|
||||
while i<len(all_direct_matches) and (all_direct_matches[i][1] is None or all_direct_matches[i][0].forward == directmatch[0].forward or all_direct_matches[i][0] == directmatch[0]):
|
||||
i+=1
|
||||
if i < len(all_direct_matches):
|
||||
reversematch = all_direct_matches[i]
|
||||
@ -341,7 +343,7 @@ cdef tuple annotate(sequences, infos, verbose=False):
|
||||
|
||||
# Look for other primer in the other direction on the sequence, or
|
||||
# If sequences are not already aligned and reverse primer not found in most likely sequence (the one without the forward primer), try matching on the same sequence than the first match (primer in the other direction)
|
||||
if not not_aligned or (not_aligned and reversematch[1] is None):
|
||||
if not not_aligned or (not_aligned and (reversematch is None or reversematch[1] is None)):
|
||||
if not not_aligned:
|
||||
sequence_to_match = second_matched_seq
|
||||
else:
|
||||
@ -360,7 +362,9 @@ cdef tuple annotate(sequences, infos, verbose=False):
|
||||
primer=p.revcomp
|
||||
else:
|
||||
primer=p
|
||||
reversematch.append((primer, primer(sequence_to_match, same_sequence=not new_seq, pattern=pattern, begin=begin)))
|
||||
# Saving original primer as 4th member of the tuple to serve as correct key in infos dict even if it might have been reversed complemented
|
||||
# (3rd member already used by directmatch)
|
||||
reversematch.append((primer, primer(sequence_to_match, same_sequence=not new_seq, pattern=pattern, begin=begin), None, p))
|
||||
new_seq = False
|
||||
pattern+=1
|
||||
# Choose match closer to the end of the sequence
|
||||
@ -416,7 +420,7 @@ cdef tuple annotate(sequences, infos, verbose=False):
|
||||
if tags[1] is not None:
|
||||
final_sequence[b'reverse_tag'] = tags[1]
|
||||
|
||||
samples = infos[reversematch[0]]
|
||||
samples = infos[reversematch[3]]
|
||||
|
||||
if not directmatch[0].forward and not not_aligned: # don't reverse complement if not_aligned
|
||||
final_sequence = final_sequence.reverse_complement
|
||||
|
Reference in New Issue
Block a user