cleaning stage 2

This commit is contained in:
2019-03-29 16:46:17 +01:00
46 changed files with 240 additions and 2223 deletions

1
python/.gitignore vendored
View File

@ -1 +1,2 @@
/.DS_Store
/OBITools3.egg-info/

View File

@ -1,71 +0,0 @@
#!/usr/local/bin/python3.4
'''
obi -- shortdesc
obi is a description
It defines classes_and_methods
@author: user_name
@copyright: 2014 organization_name. All rights reserved.
@license: license
@contact: user_email
@deffield updated: Updated
'''
default_config = { 'software' : "The OBITools",
'log' : False,
'loglevel' : 'INFO',
'progress' : True,
'inputURI' : None,
'outputURI' : None,
'defaultdms' : None,
'inputview' : None,
'outputview' : None,
'skip' : 0,
'only' : None,
'fileformat' : None,
'skiperror' : True,
'qualityformat' : b'sanger',
'offset' : -1,
'noquality' : False,
'seqtype' : b'nuc',
"header" : False,
"sep" : None,
"quote" : [b"'",b'"'],
"dec" : b".",
"nastring" : b"NA",
"stripwhite" : True,
"blanklineskip" : True,
"commentchar" : b"#",
"nocreatedms" : False
}
root_config_name='obi'
from obitools3.apps.config import getConfiguration # @UnresolvedImport
from obitools3.version import version
__all__ = []
__version__ = version
__date__ = '2014-09-28'
__updated__ = '2014-09-28'
DEBUG = 1
TESTRUN = 0
PROFILE = 0
if __name__ =="__main__":
config = getConfiguration(root_config_name,
default_config)
config[root_config_name]['module'].run(config)

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

@ -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 :

View File

@ -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

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

@ -113,7 +113,7 @@ cdef class Taxonomy(OBIWrapper) :
raise NotImplementedError()
cpdef Taxon get_taxon_by_taxid(self, int taxid): # TODO check deleted taxon behavior (403122)
cpdef Taxon get_taxon_by_taxid(self, int taxid):
cdef ecotx_t* taxon_p
cdef object taxon_capsule
taxon_p = obi_taxo_get_taxon_with_taxid(self.pointer(), taxid)
@ -256,13 +256,13 @@ cdef class Taxonomy(OBIWrapper) :
cdef Taxon taxon
try:
taxon = self.get_taxon_by_taxid(taxid)
except: # TODO error handling (related to deleted taxon thing)
except:
raise StopIteration
if taxon is not None:
while taxon.parent.taxid != 1: # TODO was 0 before?
while taxon.taxid != 1:
yield taxon
taxon = taxon.parent
yield self[1]
yield taxon
else:
raise StopIteration

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)