Skip to content

Commit 6eea5d3

Browse files
committed
Remove redundant iterators in referenceless
1 parent cdf16f2 commit 6eea5d3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

micall/utils/referenceless_contig_stitcher.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def filter_extensions(existing: MutableMapping[str, ContigsPath],
302302
yield from ret.values()
303303

304304

305-
def calculate_all_paths(contigs: Sequence[ContigWithAligner]) -> Iterator[ContigsPath]:
305+
def calculate_all_paths(contigs: Sequence[ContigWithAligner]) -> SortedList[ContigsPath]:
306306
max_acceptable_prob = MaximumAcceptableProbability.empty()
307307
existing: MutableMapping[str, ContigsPath] = {}
308308
finder = OverlapFinder.make('ACTG')
@@ -313,7 +313,6 @@ def calculate_all_paths(contigs: Sequence[ContigWithAligner]) -> Iterator[Contig
313313
logger.debug("Calculating all paths...")
314314
cycle = 1
315315
while paths:
316-
yield from paths
317316
logger.debug("Cycle %s started with %s paths.", cycle, len(paths))
318317

319318
calc_multiple_extensions(finder, max_acceptable_prob, paths, contigs)
@@ -328,12 +327,12 @@ def calculate_all_paths(contigs: Sequence[ContigWithAligner]) -> Iterator[Contig
328327
cycle, len(paths), size, parts)
329328

330329
cycle += 1
331-
yield from paths
330+
331+
return max_acceptable_prob.paths
332332

333333

334334
def find_most_probable_path(contigs: Sequence[ContigWithAligner]) -> ContigsPath:
335-
paths = calculate_all_paths(contigs)
336-
return max(paths)
335+
return calculate_all_paths(contigs)[-1]
337336

338337

339338
def stitch_consensus(contigs: Iterable[ContigWithAligner]) -> Iterator[ContigWithAligner]:

0 commit comments

Comments
 (0)