Skip to content

Commit

Permalink
Update q2_moshpit/dereplication/derep.py
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Ziemski <[email protected]>
  • Loading branch information
VinzentRisch and misialq authored Nov 4, 2024
1 parent ee666c0 commit 7e1e59d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions q2_moshpit/dereplication/derep.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,15 @@ def _get_representatives(mags, busco_results, bin_clusters):
# Choose by BUSCO results
if busco_results is not None:
bin_completeness = busco_results['complete']

representative_bins = []
for bins in bin_clusters:
# Get bins with the highest completeness values in cluster
completest_bins = (completeness_values := bin_completeness[bins])[
completeness_values == completeness_values.max()].index

completest_bins = bin_completeness[bins].idxmax()

# If there's a tie, resolve by selecting the longest bin
if len(completest_bins) > 1:
lengths_of_best_bins = bin_lengths[completest_bins]
representative_bins.append(lengths_of_best_bins.idxmax())
representative_bins.append(bin_lengths[completest_bins].idxmax())
else:
representative_bins.append(completest_bins[0])

Expand Down

0 comments on commit 7e1e59d

Please sign in to comment.