Skip to content

Commit

Permalink
Solved a couple of bugs in picker
Browse files Browse the repository at this point in the history
  • Loading branch information
lucventurini committed Aug 15, 2019
1 parent d2a6717 commit 57f8035
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Mikado/picking/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ def __test_sortedness(self, row, coords):
else:
chrom, start, end = coords.chrom, coords.start, coords.end

if chrom is None:
if any(_ is True for _ in coords):
return True
if chrom > row.chrom:
test = False
Expand Down Expand Up @@ -974,6 +974,7 @@ def __check_max_intron(self, current, invalids, row, max_intron):
previous = exon
break

current["transcripts"][row.transcript]["exon_lines"].append((row.start, row.end, row.feature, row.phase))
if previous:
# I have to compare like with like.
intron_length = (row.start - 1) - (previous[1] + 1) + 1
Expand All @@ -984,14 +985,15 @@ def __check_max_intron(self, current, invalids, row, max_intron):
)
del current["transcripts"][row.transcript]
invalids.add(row.transcript)
current["start"] = min([
min([exon[0] for exon in current["transcripts"][trans]["exon_lines"]])
for trans in current["transcripts"]])
current["end"] = max([
max([exon[1] for exon in current["transcripts"][trans]["exon_lines"]])
for trans in current["transcripts"]])
current["transcripts"][row.transcript]["exon_lines"].append(
(row.start, row.end, row.feature, row.phase))
if current["transcripts"]:
current["start"] = min([
min([exon[0] for exon in current["transcripts"][trans]["exon_lines"]])
for trans in current["transcripts"]])
current["end"] = max([
max([exon[1] for exon in current["transcripts"][trans]["exon_lines"]])
for trans in current["transcripts"]])
else:
current["start"], current["end"] = None, None
return current, invalids

def __parse_multithreaded(self, locus_queue, conn, cursor):
Expand All @@ -1004,11 +1006,11 @@ def __parse_multithreaded(self, locus_queue, conn, cursor):
max_intron = self.json_conf["prepare"]["max_intron_length"]
for row in input_annotation:
if row.is_exon is True:
if row.transcript not in current["transcripts"]:
self.logger.error("Transcript %s is invalid", row.id)
invalids.add(row.transcript)
elif row.transcript in invalids:
if row.transcript in invalids:
continue
elif row.transcript not in current["transcripts"]:
self.logger.error("Transcript %s is invalid", row.transcript)
invalids.add(row.transcript)
else:
# Check max intron length. We presume that exons are sorted correctly.
current, invalids = self.__check_max_intron(current, invalids, row, max_intron=max_intron)
Expand Down

0 comments on commit 57f8035

Please sign in to comment.