drep 3.5.0__tar.gz → 3.6.2__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 (36) hide show
  1. {drep-3.5.0 → drep-3.6.2}/PKG-INFO +1 -1
  2. {drep-3.5.0 → drep-3.6.2}/README.md +1 -1
  3. drep-3.6.2/drep/VERSION +1 -0
  4. {drep-3.5.0 → drep-3.6.2}/drep/argumentParser.py +3 -1
  5. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/cluster_utils.py +58 -19
  6. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/compare_utils.py +3 -1
  7. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/utils.py +1 -1
  8. {drep-3.5.0 → drep-3.6.2}/drep.egg-info/PKG-INFO +1 -1
  9. {drep-3.5.0 → drep-3.6.2}/drep.egg-info/SOURCES.txt +1 -0
  10. drep-3.6.2/pyproject.toml +3 -0
  11. drep-3.5.0/drep/VERSION +0 -1
  12. {drep-3.5.0 → drep-3.6.2}/bin/dRep +0 -0
  13. {drep-3.5.0 → drep-3.6.2}/drep/WorkDirectory.py +0 -0
  14. {drep-3.5.0 → drep-3.6.2}/drep/__init__.py +0 -0
  15. {drep-3.5.0 → drep-3.6.2}/drep/controller.py +0 -0
  16. {drep-3.5.0 → drep-3.6.2}/drep/d_adjust.py +0 -0
  17. {drep-3.5.0 → drep-3.6.2}/drep/d_analyze.py +0 -0
  18. {drep-3.5.0 → drep-3.6.2}/drep/d_bonus.py +0 -0
  19. {drep-3.5.0 → drep-3.6.2}/drep/d_choose.py +0 -0
  20. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/__init__.py +0 -0
  21. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/controller.py +0 -0
  22. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/external.py +0 -0
  23. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/greedy_clustering.py +0 -0
  24. {drep-3.5.0 → drep-3.6.2}/drep/d_cluster/parsers.py +0 -0
  25. {drep-3.5.0 → drep-3.6.2}/drep/d_evaluate.py +0 -0
  26. {drep-3.5.0 → drep-3.6.2}/drep/d_filter.py +0 -0
  27. {drep-3.5.0 → drep-3.6.2}/drep/d_workflows.py +0 -0
  28. {drep-3.5.0 → drep-3.6.2}/drep.egg-info/dependency_links.txt +0 -0
  29. {drep-3.5.0 → drep-3.6.2}/drep.egg-info/not-zip-safe +0 -0
  30. {drep-3.5.0 → drep-3.6.2}/drep.egg-info/requires.txt +0 -0
  31. {drep-3.5.0 → drep-3.6.2}/drep.egg-info/top_level.txt +0 -0
  32. {drep-3.5.0 → drep-3.6.2}/helper_scripts/ScaffoldLevel_dRep.py +0 -0
  33. {drep-3.5.0 → drep-3.6.2}/helper_scripts/parse_stb.py +0 -0
  34. {drep-3.5.0 → drep-3.6.2}/setup.cfg +0 -0
  35. {drep-3.5.0 → drep-3.6.2}/setup.py +0 -0
  36. {drep-3.5.0 → drep-3.6.2}/tests/test_suite.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: drep
3
- Version: 3.5.0
3
+ Version: 3.6.2
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
@@ -9,7 +9,7 @@ Manual, installation instructions, and API are at available at
9
9
  [ReadTheDocs](https://drep.readthedocs.io/en/latest/)
10
10
 
11
11
  Publication is available at
12
- [ISMEJ](http://www.nature.com/ismej/journal/vaop/ncurrent/full/ismej2017126a.html)
12
+ [ISMEJ](https://doi.org/10.1038/ismej.2017.126)
13
13
 
14
14
  Open source pre-print publication is available at
15
15
  [bioRxiv](https://doi.org/10.1101/108142)
@@ -0,0 +1 @@
1
+ 3.6.2
@@ -44,7 +44,7 @@ def printHelp():
44
44
  print(' ...::: dRep v' + VERSION + ' :::...''')
45
45
  print('''\
46
46
 
47
- Matt Olm. MIT License. Banfield Lab, UC Berkeley. 2017 (last updated 2024)
47
+ Matt Olm. MIT License. Banfield Lab, UC Berkeley. 2017 (last updated 2025)
48
48
 
49
49
  See https://drep.readthedocs.io/en/latest/index.html for documentation
50
50
  Choose one of the operations below for more detailed help.
@@ -149,6 +149,8 @@ def parse_args(args):
149
149
  Compflags.add_argument("--clusterAlg", help="Algorithm used to cluster genomes (passed\
150
150
  to scipy.cluster.hierarchy.linkage", default='average',
151
151
  choices={'single', 'complete', 'average', 'weighted', 'centroid', 'median', 'ward'})
152
+ Compflags.add_argument("--low_ram_primary_clustering", help="Use a memory-efficient algorithm for primary clustering. This only affects primary clustering and not secondary clustering.",
153
+ action='store_true', default=False)
152
154
 
153
155
  GRflags = cluster_parent.add_argument_group('GREEDY CLUSTERING OPTIONS\n'
154
156
  'These decrease RAM use and runtime at the expense of a minor loss in '
@@ -6,6 +6,7 @@ import numpy as np
6
6
  import pandas as pd
7
7
  import scipy.cluster
8
8
  from scipy.spatial import distance as ssd
9
+ import networkx as nx
9
10
 
10
11
  import drep.d_cluster.utils
11
12
 
@@ -87,7 +88,33 @@ def iteratre_clusters(Bdb, Cdb, id='primary_cluster'):
87
88
  yield d, cluster
88
89
 
89
90
 
90
- def cluster_hierarchical(db, linkage_method= 'single', linkage_cutoff= 0.10):
91
+ def cluster_threshold_graph_optimized(db, linkage_cutoff=0.10, linkage_method='single'):
92
+ # Filter distances below threshold first
93
+ filtered_edges = db[db['dist'] <= linkage_cutoff]
94
+
95
+ # Create graph directly from filtered edges
96
+ G = nx.Graph()
97
+ G.add_edges_from(filtered_edges[['genome1', 'genome2']].values)
98
+
99
+ # Log that we're using the optimized method
100
+ logging.debug("Using low-RAM optimized clustering method with {0} edges".format(len(filtered_edges)))
101
+
102
+ # Find connected components
103
+ clusters = {}
104
+ for cluster_id, component in enumerate(nx.connected_components(G)):
105
+ for genome in component:
106
+ clusters[genome] = cluster_id + 1
107
+
108
+ # Add isolated nodes (if needed)
109
+ all_genomes = set(db['genome1']).union(set(db['genome2']))
110
+ for genome in all_genomes:
111
+ if genome not in clusters:
112
+ clusters[genome] = len(clusters)
113
+
114
+ # Return clusters and a special value indicating we used the optimized method
115
+ return clusters, "optimized_method_used"
116
+
117
+ def cluster_hierarchical(db, linkage_method= 'single', linkage_cutoff= 0.10, low_ram=False):
91
118
  '''
92
119
  Perform hierarchical clustering on a symmetrical distiance matrix
93
120
 
@@ -95,6 +122,7 @@ def cluster_hierarchical(db, linkage_method= 'single', linkage_cutoff= 0.10):
95
122
  db: result of db.pivot usually
96
123
  linkage_method: passed to scipy.cluster.hierarchy.fcluster
97
124
  linkage_cutoff: distance to draw the clustering line (default = .1)
125
+ low_ram: whether to use the memory-efficient algorithm
98
126
 
99
127
  Returns:
100
128
  list: [Cdb, linkage]
@@ -102,21 +130,32 @@ def cluster_hierarchical(db, linkage_method= 'single', linkage_cutoff= 0.10):
102
130
  # Save names
103
131
  names = list(db.columns)
104
132
 
105
- # Generate linkage dataframe
106
- arr = np.asarray(db)
107
- try:
108
- arr = ssd.squareform(arr)
109
- except:
110
- logging.error("The database passed in is not symmetrical!")
111
- logging.error(arr)
112
- logging.error(names)
113
- sys.exit()
114
- linkage = scipy.cluster.hierarchy.linkage(arr, method= linkage_method)
115
-
116
- # Form clusters
117
- fclust = scipy.cluster.hierarchy.fcluster(linkage,linkage_cutoff, \
118
- criterion='distance')
119
- # Make Cdb
120
- Cdb = drep.d_cluster.utils._gen_cdb_from_fclust(fclust,names)
121
-
122
- return Cdb, linkage
133
+ if low_ram:
134
+ # Convert to long format for optimized clustering
135
+ db_long = db.stack().reset_index()
136
+ db_long.columns = ['genome1', 'genome2', 'dist']
137
+ clusters, _ = cluster_threshold_graph_optimized(db_long, linkage_cutoff, linkage_method)
138
+
139
+ # Convert clusters to Cdb format
140
+ Cdb = pd.DataFrame({'genome': list(clusters.keys()),
141
+ 'cluster': list(clusters.values())})
142
+ return Cdb, _
143
+ else:
144
+ # Generate linkage dataframe
145
+ arr = np.asarray(db)
146
+ try:
147
+ arr = ssd.squareform(arr)
148
+ except:
149
+ logging.error("The database passed in is not symmetrical!")
150
+ logging.error(arr)
151
+ logging.error(names)
152
+ sys.exit()
153
+ linkage = scipy.cluster.hierarchy.linkage(arr, method= linkage_method)
154
+
155
+ # Form clusters
156
+ fclust = scipy.cluster.hierarchy.fcluster(linkage,linkage_cutoff, \
157
+ criterion='distance')
158
+ # Make Cdb
159
+ Cdb = drep.d_cluster.utils._gen_cdb_from_fclust(fclust,names)
160
+
161
+ return Cdb, linkage
@@ -264,6 +264,7 @@ def cluster_mash_database(db, **kwargs):
264
264
  Keyword arguments:
265
265
  clusterAlg: how to cluster database (default = single)
266
266
  P_ani: threshold to cluster at (default = 0.9)
267
+ low_ram_primary_clustering: whether to use memory-efficient algorithm
267
268
 
268
269
  Returns:
269
270
  list: [Cdb, [linkage, linkage_db, arguments]]
@@ -273,12 +274,13 @@ def cluster_mash_database(db, **kwargs):
273
274
  # Load key words
274
275
  P_Lmethod = kwargs.get('clusterAlg','single')
275
276
  P_Lcutoff = 1 - kwargs.get('P_ani',.9)
277
+ low_ram = kwargs.get('low_ram_primary_clustering', False)
276
278
 
277
279
  # Do the actual clustering
278
280
  db['dist'] = 1 - db['similarity']
279
281
  linkage_db = db.pivot(index="genome1", columns="genome2", values="dist")
280
282
  Cdb, linkage = drep.d_cluster.cluster_utils.cluster_hierarchical(linkage_db, linkage_method= P_Lmethod, \
281
- linkage_cutoff= P_Lcutoff)
283
+ linkage_cutoff= P_Lcutoff, low_ram=low_ram)
282
284
  Cdb = Cdb.rename(columns={'cluster':'primary_cluster'})
283
285
  Cdb['primary_cluster'] = Cdb['primary_cluster'].astype(int)
284
286
 
@@ -354,7 +354,7 @@ def gen_goANI_cmd(file, g1, g2, exe):
354
354
  return []
355
355
 
356
356
  else:
357
- cmd = [exe,'--om','TABX', g1, g2, file]
357
+ cmd = [exe,'--om','TABX', '--rpq', '1', g1, g2, file]
358
358
  return cmd
359
359
 
360
360
  def process_deltafiles(deltafiles, org_lengths, logger=None, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: drep
3
- Version: 3.5.0
3
+ Version: 3.6.2
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
@@ -1,4 +1,5 @@
1
1
  README.md
2
+ pyproject.toml
2
3
  setup.py
3
4
  bin/dRep
4
5
  drep/VERSION
@@ -0,0 +1,3 @@
1
+ [tool.pytest.ini_options]
2
+ testpaths = ["tests"]
3
+ addopts = "-v"
drep-3.5.0/drep/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.5.0
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