drep 4.0.2__tar.gz → 4.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {drep-4.0.2 → drep-4.0.3}/PKG-INFO +1 -1
  2. drep-4.0.3/drep/VERSION +1 -0
  3. {drep-4.0.2 → drep-4.0.3}/drep/argumentParser.py +12 -0
  4. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/compare_utils.py +5 -2
  5. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/union_find.py +31 -2
  6. {drep-4.0.2 → drep-4.0.3}/drep.egg-info/PKG-INFO +1 -1
  7. drep-4.0.2/drep/VERSION +0 -1
  8. {drep-4.0.2 → drep-4.0.3}/README.md +0 -0
  9. {drep-4.0.2 → drep-4.0.3}/bin/dRep +0 -0
  10. {drep-4.0.2 → drep-4.0.3}/drep/WorkDirectory.py +0 -0
  11. {drep-4.0.2 → drep-4.0.3}/drep/__init__.py +0 -0
  12. {drep-4.0.2 → drep-4.0.3}/drep/controller.py +0 -0
  13. {drep-4.0.2 → drep-4.0.3}/drep/d_adjust.py +0 -0
  14. {drep-4.0.2 → drep-4.0.3}/drep/d_analyze.py +0 -0
  15. {drep-4.0.2 → drep-4.0.3}/drep/d_bonus.py +0 -0
  16. {drep-4.0.2 → drep-4.0.3}/drep/d_choose.py +0 -0
  17. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/__init__.py +0 -0
  18. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/cluster_utils.py +0 -0
  19. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/controller.py +0 -0
  20. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/external.py +0 -0
  21. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/greedy_clustering.py +0 -0
  22. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/parsers.py +0 -0
  23. {drep-4.0.2 → drep-4.0.3}/drep/d_cluster/utils.py +0 -0
  24. {drep-4.0.2 → drep-4.0.3}/drep/d_evaluate.py +0 -0
  25. {drep-4.0.2 → drep-4.0.3}/drep/d_filter.py +0 -0
  26. {drep-4.0.2 → drep-4.0.3}/drep/d_workflows.py +0 -0
  27. {drep-4.0.2 → drep-4.0.3}/drep.egg-info/SOURCES.txt +0 -0
  28. {drep-4.0.2 → drep-4.0.3}/drep.egg-info/dependency_links.txt +0 -0
  29. {drep-4.0.2 → drep-4.0.3}/drep.egg-info/not-zip-safe +0 -0
  30. {drep-4.0.2 → drep-4.0.3}/drep.egg-info/requires.txt +0 -0
  31. {drep-4.0.2 → drep-4.0.3}/drep.egg-info/top_level.txt +0 -0
  32. {drep-4.0.2 → drep-4.0.3}/helper_scripts/ScaffoldLevel_dRep.py +0 -0
  33. {drep-4.0.2 → drep-4.0.3}/helper_scripts/parse_stb.py +0 -0
  34. {drep-4.0.2 → drep-4.0.3}/pyproject.toml +0 -0
  35. {drep-4.0.2 → drep-4.0.3}/setup.cfg +0 -0
  36. {drep-4.0.2 → drep-4.0.3}/setup.py +0 -0
  37. {drep-4.0.2 → drep-4.0.3}/tests/test_suite.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drep
3
- Version: 4.0.2
3
+ Version: 4.0.3
4
4
  Summary: De-replication of microbial genomes assembled from multiple samples
5
5
  Home-page: https://github.com/MrOlm/drep
6
6
  Author: Matt Olm
@@ -0,0 +1 @@
1
+ 4.0.3
@@ -147,6 +147,18 @@ def parse_args(args):
147
147
  "partition closely; lower it only if you have very fragmented genomes "
148
148
  "and understand the chaining risk.",
149
149
  default=15, type=float)
150
+ Clustflags.add_argument("--primary_skani_min_af_both",
151
+ help="Require --primary_skani_min_af in both directions of a pair, "
152
+ "not just one, for it to form a primary-clustering edge "
153
+ "(--primary_algorithm skani only). Recommended for plasmids and "
154
+ "other small genomes: a small genome that is mostly a shared "
155
+ "element (e.g. a transposon) aligns ~100%% to every larger genome "
156
+ "carrying it, and single linkage then chains unrelated genomes "
157
+ "into one huge primary cluster. Secondary clustering only groups "
158
+ "pairs that align in both directions, so setting "
159
+ "--primary_skani_min_af to at most 100 x --cov_thresh does not "
160
+ "change which genomes can end up in the same secondary cluster.",
161
+ action='store_true', default=False)
150
162
  Clustflags.add_argument("-ms", "--MASH_sketch", help="MASH sketch size", default=1000)
151
163
  Clustflags.add_argument("--SkipMash", help="Skip primary clustering entirely and run secondary\
152
164
  clustering on all genomes at once. (Named for when primary clustering was\
@@ -194,6 +194,8 @@ def primary_cluster_skani_sparse(Bdb, data_folder, **kwargs):
194
194
  # region become edges and single linkage chains them into one huge cluster.
195
195
  # See run_skani_triangle_sparse for the measurements behind the default.
196
196
  min_af = kwargs.get('primary_skani_min_af', 15)
197
+ # Require min_af in both directions rather than either (issue #311)
198
+ min_af_both = kwargs.get('primary_skani_min_af_both', False)
197
199
 
198
200
  # Secondary applies its own coverage filter at cov_thresh, so the single pass
199
201
  # has to emit anything secondary might still care about. Ask skani for the
@@ -206,14 +208,15 @@ def primary_cluster_skani_sparse(Bdb, data_folder, **kwargs):
206
208
 
207
209
  logging.info(f" Running sparse skani primary clustering on {len(genome_list):,} genomes "
208
210
  f"(ANI threshold {ani_threshold:.1f}%, screen {screen:.1f}%, "
209
- f"min-af {min_af}%, emitting min-af {emit_min_af:.1f}%)")
211
+ f"min-af {min_af}%{' in both directions' if min_af_both else ''}, "
212
+ f"emitting min-af {emit_min_af:.1f}%)")
210
213
  sparse_file = drep.d_cluster.external.run_skani_triangle_sparse(
211
214
  genome_list, skani_folder, screen, min_af=emit_min_af, **kwargs)
212
215
 
213
216
  all_genomes = list(Bdb['genome'].unique())
214
217
  edges = drep.d_cluster.union_find.load_skani_sparse_edges(sparse_file)
215
218
  Cdb, stats = drep.d_cluster.union_find.cluster_edges(
216
- edges, P_ani, all_genomes, cov_threshold=min_af / 100.0)
219
+ edges, P_ani, all_genomes, cov_threshold=min_af / 100.0, cov_both=min_af_both)
217
220
 
218
221
  logging.info(f" Sparse skani primary clustering: {stats['edges_kept']:,} edges above "
219
222
  f"threshold, {stats['primary_clusters']:,} primary clusters "
@@ -386,7 +386,25 @@ def load_skani_sparse_edges(sparse_files):
386
386
  return edges[edges['genome1'] != edges['genome2']].reset_index(drop=True)
387
387
 
388
388
 
389
- def cluster_edges(edges, ani_threshold, all_genomes, cov_threshold=0.0):
389
+ def _reverse_coverage(edges):
390
+ """
391
+ For each row of an edge table, the alignment_coverage of the same pair in
392
+ the other direction (genome2's aligned fraction), or NaN if that row is
393
+ missing.
394
+ """
395
+ g1 = edges['genome1'].values
396
+ g2 = edges['genome2'].values
397
+ names = pd.Index(pd.unique(np.concatenate([g1, g2])))
398
+ n = len(names)
399
+ a = names.get_indexer(g1).astype(np.int64)
400
+ b = names.get_indexer(g2).astype(np.int64)
401
+
402
+ cov = pd.Series(edges['alignment_coverage'].values, index=a * n + b)
403
+ cov = cov[~cov.index.duplicated(keep='last')]
404
+ return cov.reindex(b * n + a).values
405
+
406
+
407
+ def cluster_edges(edges, ani_threshold, all_genomes, cov_threshold=0.0, cov_both=False):
390
408
  """
391
409
  Union-find clustering of an in-memory edge table (see load_skani_sparse_edges).
392
410
 
@@ -397,6 +415,13 @@ def cluster_edges(edges, ani_threshold, all_genomes, cov_threshold=0.0):
397
415
  cov_threshold: minimum alignment_coverage (0-1) for a pair to be an edge.
398
416
  See run_skani_triangle_sparse for why this matters -- without it,
399
417
  genomes sharing a small conserved region chain together.
418
+ cov_both: require cov_threshold in both directions rather than either.
419
+ With either, a small genome that is mostly one shared element (e.g.
420
+ a plasmid that is mostly a transposon) aligns ~100% to every larger
421
+ genome carrying that element and chains them all together (issue
422
+ #311). Secondary clustering only joins pairs that align in both
423
+ directions anyway, so this splits primary clusters without changing
424
+ which genomes secondary clustering can put together.
400
425
 
401
426
  Returns:
402
427
  (Cdb, stats)
@@ -407,7 +432,11 @@ def cluster_edges(edges, ani_threshold, all_genomes, cov_threshold=0.0):
407
432
 
408
433
  keep = edges['ani'].values >= ani_threshold
409
434
  if cov_threshold > 0:
410
- keep &= edges['alignment_coverage'].values >= cov_threshold
435
+ cov = edges['alignment_coverage'].values
436
+ if cov_both:
437
+ # A missing other direction gives NaN, which fails the comparison
438
+ cov = np.minimum(cov, _reverse_coverage(edges))
439
+ keep &= cov >= cov_threshold
411
440
 
412
441
  g1 = edges['genome1'].values[keep]
413
442
  g2 = edges['genome2'].values[keep]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drep
3
- Version: 4.0.2
3
+ Version: 4.0.3
4
4
  Summary: De-replication of microbial genomes assembled from multiple samples
5
5
  Home-page: https://github.com/MrOlm/drep
6
6
  Author: Matt Olm
drep-4.0.2/drep/VERSION DELETED
@@ -1 +0,0 @@
1
- 4.0.2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes