PyamilySeq 1.0.0__tar.gz → 1.1.0__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 (32) hide show
  1. pyamilyseq-1.1.0/PKG-INFO +342 -0
  2. pyamilyseq-1.1.0/README.md +326 -0
  3. {pyamilyseq-1.0.0 → pyamilyseq-1.1.0}/pyproject.toml +1 -0
  4. pyamilyseq-1.1.0/setup.cfg +48 -0
  5. pyamilyseq-1.1.0/src/PyamilySeq/Cluster_Summary.py +163 -0
  6. pyamilyseq-1.1.0/src/PyamilySeq/Group_Extractor.py +83 -0
  7. pyamilyseq-1.1.0/src/PyamilySeq/Group_Sizes.py +87 -0
  8. pyamilyseq-1.1.0/src/PyamilySeq/Group_Splitter.py +571 -0
  9. pyamilyseq-1.1.0/src/PyamilySeq/PyamilySeq.py +321 -0
  10. pyamilyseq-1.1.0/src/PyamilySeq/PyamilySeq_Genus.py +242 -0
  11. pyamilyseq-1.1.0/src/PyamilySeq/PyamilySeq_Species.py +309 -0
  12. pyamilyseq-1.1.0/src/PyamilySeq/Seq_Combiner.py +83 -0
  13. pyamilyseq-1.1.0/src/PyamilySeq/Seq_Extractor.py +64 -0
  14. pyamilyseq-1.1.0/src/PyamilySeq/Seq_Finder.py +56 -0
  15. pyamilyseq-1.1.0/src/PyamilySeq/__init__.py +0 -0
  16. pyamilyseq-1.1.0/src/PyamilySeq/clusterings.py +452 -0
  17. pyamilyseq-1.1.0/src/PyamilySeq/constants.py +2 -0
  18. pyamilyseq-1.1.0/src/PyamilySeq/utils.py +598 -0
  19. pyamilyseq-1.1.0/src/PyamilySeq.egg-info/PKG-INFO +342 -0
  20. pyamilyseq-1.1.0/src/PyamilySeq.egg-info/SOURCES.txt +24 -0
  21. pyamilyseq-1.1.0/src/PyamilySeq.egg-info/entry_points.txt +13 -0
  22. pyamilyseq-1.1.0/src/PyamilySeq.egg-info/requires.txt +1 -0
  23. pyamilyseq-1.1.0/src/PyamilySeq.egg-info/top_level.txt +1 -0
  24. pyamilyseq-1.0.0/PKG-INFO +0 -17
  25. pyamilyseq-1.0.0/README.md +0 -2
  26. pyamilyseq-1.0.0/setup.cfg +0 -35
  27. pyamilyseq-1.0.0/src/PyamilySeq.egg-info/PKG-INFO +0 -17
  28. pyamilyseq-1.0.0/src/PyamilySeq.egg-info/SOURCES.txt +0 -9
  29. pyamilyseq-1.0.0/src/PyamilySeq.egg-info/entry_points.txt +0 -2
  30. pyamilyseq-1.0.0/src/PyamilySeq.egg-info/top_level.txt +0 -1
  31. {pyamilyseq-1.0.0 → pyamilyseq-1.1.0}/LICENSE +0 -0
  32. {pyamilyseq-1.0.0 → pyamilyseq-1.1.0}/src/PyamilySeq.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,342 @@
1
+ Metadata-Version: 2.2
2
+ Name: PyamilySeq
3
+ Version: 1.1.0
4
+ Summary: PyamilySeq - A a tool to investigate sequence-based gene groups identified by clustering methods such as CD-HIT, DIAMOND, BLAST or MMseqs2.
5
+ Home-page: https://github.com/NickJD/PyamilySeq
6
+ Author: Nicholas Dimonaco
7
+ Author-email: nicholas@dimonaco.co.uk
8
+ Project-URL: Bug Tracker, https://github.com/NickJD/PyamilySeq/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: levenshtein
16
+
17
+ # PyamilySeq
18
+ **PyamilySeq** is a Python tool for clustering gene sequences into groups based on sequence similarity identified by tools such as CD-HIT, BLAST, DIAMOND or MMseqs2.
19
+ This work is an extension of the gene family / pangenome tool developed for the StORF-Reporter publication in NAR (https://doi.org/10.1093/nar/gkad814).
20
+
21
+ ## Features
22
+ - **End-to-End**: PyamilySeq can take a directory of GFF+FASTA files, run CD-HIT for clustering and process the results.
23
+ - **Clustering input**: Supports input from CD-HIT formatted files as well as CSV and TSV node-edge lists (MMseqs2 and -outfmt 6 from BLAST/DIAMOND).
24
+ - **Reclustering**: Allows for the addition of new sequences post-initial clustering - Ensures continuity of contemporary clustering results and highlights impact of novel gene predictions.
25
+ - **'Genus Mode'**: Unlike other 'pangenome' tools, PyamilySeq can identify gene groups found across multiple genera as unique entities (see below).
26
+ - **Output**: Generates a 'Roary/Panaroo' formatted presence-absence CSV formatted file for downstream analysis.
27
+ - User-define species-/genus-wide gene groups - User has control over grouping parameters (core = 99/95% or min 6 genera etc).
28
+ - Aligns representative sequences using MAFFT.
29
+ - Output concatenated aligned sequences for tree building.
30
+ - Optionally output sequences of each separate identified gene group.
31
+ - Group-Splitter tool to split multi-copy gene groups.
32
+ - Numerous additional tools to assist in the pre- and post-processing of data.
33
+
34
+ ## Installation
35
+ PyamilySeq probably requires Python 3.6 or higher and the levenshtein library (https://pypi.org/project/Levenshtein/) - \
36
+ If levenshtein is not available, a Python implementation is utilised which is significantly slower.
37
+ #### Install using pip:
38
+
39
+ ```bash
40
+ pip install PyamilySeq [optionally add -U]
41
+ ```
42
+ PyamilySeq is currently still under active development so expect 'regular' updates with bugfixes and new features. \
43
+ To update to the newest version add '-U' to end of the pip install command.
44
+ ## Example usage: Below are two examples of running PyamilySeq in its two main modes.
45
+ ```commandline
46
+ usage: PyamilySeq.py [-h] {Full,Partial} ...
47
+
48
+ PyamilySeq v1.1.0: A tool for gene clustering and analysis.
49
+
50
+ positional arguments:
51
+ {Full,Partial} Choose a mode: 'Full' or 'Partial'.
52
+ Full Full mode: PyamilySeq to cluster with CD-HIT and process output.
53
+ Partial Partial mode: PyamilySeq to process pre-clustered data.
54
+
55
+ options:
56
+ -h, --help show this help message and exit
57
+
58
+ ```
59
+ ### 'Full Mode': Will conduct clustering of sequences with CD-HIT as part of PyamilySeq run
60
+ ```
61
+ PyamilySeq Full -output_dir .../PyamilySeq_10_AA_90_80_Full_GFFs -input_type combined -input_dir .../genomes/ -name_split_gff _combined.gff3
62
+ ```
63
+ ### 'Partial Mode': Will process the output of a sequence clustering from MMseqs, BLAST, DIAMOND etc.
64
+ ```
65
+ PyamilySeq Partial -clustering_format CD-HIT -cluster_file .../all_10_combined_pep_CD-HIT_90_80.clstr -original_fasta .../all_10_combined_pep.fasta -output_dir .../PyamilySeq_10_AA_90_80_Partial -write_groups 99 -align
66
+ ```
67
+
68
+
69
+ #### Note: using a '-clustering_format' other than the default CD-HIT, requires input to be two in two columns as below (Same format as MMseqs2 tsv and BLAST outfmt 6) - Genome name and sequence name are separated by '|'.
70
+ ```
71
+ Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno
72
+ Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno Escherichia_coli_113290|ENSB_2fj4rJ8e8Z9PNdX
73
+ Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno Escherichia_coli_b185|ENSB_G_PVe28-ej8q-3S
74
+ Escherichia_coli_110957|ENSB_TIZS9kbTvShDvyX Escherichia_coli_110957|ENSB_TIZS9kbTvShDvyX
75
+ ```
76
+ ### Example output:
77
+ ```
78
+ Running PyamilySeq v1.1.0
79
+ Calculating Groups
80
+ Number of Genomes: 10
81
+ Gene Groups
82
+ First_core_99: 2994
83
+ First_core_95: 0
84
+ First_core_15: 3266
85
+ First_core_0: 5466
86
+ Total Number of First Gene Groups (Including Singletons): 11726
87
+ Outputting gene_presence_absence file
88
+ Outputting gene group FASTA files
89
+ Combined FASTA file saved to: ../combined_group_sequences_dna.fasta
90
+ Processing gene group alignment
91
+ Thank you for using PyamilySeq -- A detailed user manual can be found at https://github.com/NickJD/PyamilySeq
92
+ Please report any issues to: https://github.com/NickJD/PyamilySeq/issues
93
+ ```
94
+
95
+
96
+ ## Reclustering:
97
+ ### Reclustering can be used to see where additional sequences/genes lay in relation to a contemporary pangenome/gene grouping.
98
+ ```
99
+ PyamilySeq Partial -clustering_format CD-HIT -cluster_file .../all_10_combined_pep_CD-HIT_90_80.clstr -reclustered .../all_10_combined_pep_CD-HIT_90_80_AND_StORFs_CD-HIT_90_80.clstr -original_fasta .../all_10_combined_pep_AND_StORFs.fasta -output_dir .../PyamilySeq_10_AA_90_80_Partial_Reclustered_StORFs -write_groups 99 -align
100
+ ```
101
+ #### As can be seen below, the additional sequences recovered by the StORF-Reporter annotation tool have 'extended' contemporary or created entirely new gene groups. 'First' corresponds to the groups identified from the first clustering round and 'Second' for the second. In 'reclustering' mode, First_core_# groups are unaffected thus retaining the initial grouping information.
102
+ ```commandline
103
+ Number of Genomes: 10
104
+ Gene Groups
105
+ First_core_99: 2994
106
+ First_core_95: 0
107
+ First_core_15: 3266
108
+ First_core_0: 5466
109
+ extended_core_99: 3
110
+ extended_core_95: 0
111
+ extended_core_15: 49
112
+ extended_core_0: 0
113
+ combined_core_99: 0
114
+ combined_core_95: 0
115
+ combined_core_15: 3
116
+ combined_core_0: 0
117
+ Second_core_99: 0
118
+ Second_core_95: 0
119
+ Second_core_15: 20
120
+ Second_core_0: 39
121
+ only_Second_core_99: 768
122
+ only_Second_core_95: 0
123
+ only_Second_core_15: 4472
124
+ only_Second_core_0: 8395
125
+ Total Number of First Gene Groups (Including Singletons): 11726
126
+ Total Number of Second Gene Groups (Including Singletons): 25359
127
+ Total Number of First Gene Groups That Had Additional Second Sequences But Not New Genomes: 5
128
+ ```
129
+
130
+ ## PyamilySeq is separated into two main 'run modes', Full and Partial. They each have their own set of required and optional arguments.
131
+ ### PyamilySeq - Full Menu:
132
+ ```
133
+ usage: PyamilySeq.py Full [-h] -output_dir OUTPUT_DIR -input_type {separate,combined,fasta} [-input_dir INPUT_DIR] [-input_fasta INPUT_FASTA] [-name_split_gff NAME_SPLIT_GFF] [-name_split_fasta NAME_SPLIT_FASTA] [-sequence_type {AA,DNA}] [-gene_ident GENE_IDENT] [-c PIDENT] [-s LEN_DIFF] [-fast_mode]
134
+ [-group_mode {Species,Genus}] [-species_groups SPECIES_GROUPS] [-genus_groups GENUS_GROUPS] [-write_groups WRITE_GROUPS] [-write_individual_groups] [-align] [-align_aa] [-no_gpa] [-M MEM] [-T THREADS] [-verbose] [-v]
135
+
136
+ options:
137
+ -h, --help show this help message and exit
138
+ -output_dir OUTPUT_DIR
139
+ Directory for all output files.
140
+ -input_type {separate,combined,fasta}
141
+ Type of input files: 'separate' for matching FASTA and GFF files, 'combined' for GFF+FASTA, or 'fasta' for a prepared FASTA file.
142
+ -input_dir INPUT_DIR Directory containing GFF/FASTA files - Use with -input_type separate/combined.
143
+ -input_fasta INPUT_FASTA
144
+ Input FASTA file - Use with - input_type fasta.
145
+ -name_split_gff NAME_SPLIT_GFF
146
+ Substring to split filenames and extract genome names for gff files (e.g., '_combined.gff3') - Use with -input_type separate/combined.
147
+ -name_split_fasta NAME_SPLIT_FASTA
148
+ Substring to split filenames and extract genome names for fasta files if named differently to paired gff files (e.g., '_dna.fasta') - Use with -input_type separate/combined.
149
+ -sequence_type {AA,DNA}
150
+ Clustering mode: 'DNA' or 'AA'.
151
+ -gene_ident GENE_IDENT
152
+ Gene identifiers to extract sequences (e.g., 'CDS, tRNA').
153
+ -c PIDENT Sequence identity threshold for clustering (default: 0.90) - CD-HIT parameter '-c'.
154
+ -s LEN_DIFF Length difference threshold for clustering (default: 0.80) - CD-HIT parameter '-s'.
155
+ -fast_mode Enable fast mode for CD-HIT (not recommended) - CD-HIT parameter '-g'.
156
+ -group_mode {Species,Genus}
157
+ Grouping mode: 'Species' or 'Genus'.
158
+ -species_groups SPECIES_GROUPS
159
+ Gene groupings for 'Species' mode (default: '99,95,15').
160
+ -genus_groups GENUS_GROUPS
161
+ Gene groupings for 'Genus' mode (default: '1-10').
162
+ -write_groups WRITE_GROUPS
163
+ Output gene groups as a single FASTA file (specify levels: e.g., '-w 99,95'). - triggers '-wig'.
164
+ -write_individual_groups
165
+ Output individual FASTA files for each group.
166
+ -align Align and concatenate sequences for 'core' groups specified with '-w'.
167
+ -align_aa Align sequences as amino acids.
168
+ -no_gpa Skip creation of gene_presence_absence.csv.
169
+ -M MEM Memory allocation for clustering (MB) - CD-HIT parameter '-M'.
170
+ -T THREADS Number of threads for clustering/alignment - CD-HIT parameter '-T' | MAFFT parameter '--thread'.
171
+ -verbose Print verbose output.
172
+ -v, --version Print version number and exit.
173
+
174
+ ```
175
+ ### PyamilySeq - Partial Menu:
176
+ ```commandline
177
+ usage: PyamilySeq.py Partial [-h] -clustering_format {CD-HIT,MMseqs,BLAST} -cluster_file CLUSTER_FILE -original_fasta ORIGINAL_FASTA -output_dir OUTPUT_DIR [-reclustered RECLUSTERED] [-seq_tag SEQUENCE_TAG] [-group_mode {Species,Genus}] [-species_groups SPECIES_GROUPS] [-genus_groups GENUS_GROUPS]
178
+ [-write_groups WRITE_GROUPS] [-write_individual_groups] [-align] [-align_aa] [-no_gpa] [-M MEM] [-T THREADS] [-verbose] [-v]
179
+
180
+ options:
181
+ -h, --help show this help message and exit
182
+ -clustering_format {CD-HIT,MMseqs,BLAST}
183
+ Clustering format used: CD-HIT, MMseqs2, or BLAST.
184
+ -cluster_file CLUSTER_FILE
185
+ Cluster file containing pre-clustered groups from CD-HIT, MMseqs, BLAST etc.
186
+ -original_fasta ORIGINAL_FASTA
187
+ FASTA file used in pre-clustering (Provide sequences in DNA form).
188
+ -output_dir OUTPUT_DIR
189
+ Directory for all output files.
190
+ -reclustered RECLUSTERED
191
+ Clustering output file from a second round of clustering.
192
+ -seq_tag SEQUENCE_TAG
193
+ Tag for distinguishing reclustered sequences.
194
+ -group_mode {Species,Genus}
195
+ Grouping mode: 'Species' or 'Genus'.
196
+ -species_groups SPECIES_GROUPS
197
+ Gene groupings for 'Species' mode (default: '99,95,15').
198
+ -genus_groups GENUS_GROUPS
199
+ Gene groupings for 'Genus' mode (default: '1-10').
200
+ -write_groups WRITE_GROUPS
201
+ Output gene groups as a single FASTA file (specify levels: e.g., '-w 99,95'). - triggers '-wig'.
202
+ -write_individual_groups
203
+ Output individual FASTA files for each group.
204
+ -align Align and concatenate sequences for 'core' groups specified with '-w'.
205
+ -align_aa Align sequences as amino acids.
206
+ -no_gpa Skip creation of gene_presence_absence.csv.
207
+ -M MEM Memory allocation for clustering (MB) - CD-HIT parameter '-M'.
208
+ -T THREADS Number of threads for clustering/alignment - CD-HIT parameter '-T' | MAFFT parameter '--thread'.
209
+ -verbose Print verbose output.
210
+ -v, --version Print version number and exit.
211
+
212
+ ```
213
+
214
+ ## Seq-Combiner: This tool is provided to enable the pre-processing of multiple GFF/FASTA files together ready to be clustered by the user.
215
+ ### Example:
216
+ ```bash
217
+ Seq-Combiner -input_dir .../test_data/genomes -name_split_gff .gff3 -output_dir .../test_data/genomes -output_name combine_fasta_seqs.fa -input_type combined
218
+ ```
219
+ ### Seq-Combiner Menu:
220
+ ```
221
+ usage: Seq_Combiner.py [-h] -input_dir INPUT_DIR -input_type {separate,combined,fasta} [-name_split_gff NAME_SPLIT_GFF] [-name_split_fasta NAME_SPLIT_FASTA] -output_dir OUTPUT_DIR -output_name OUTPUT_FILE [-gene_ident GENE_IDENT] [-translate] [-v]
222
+
223
+ PyamilySeq v1.1.0: Seq-Combiner - A tool to extract sequences from GFF/FASTA files and prepare them for PyamilySeq.
224
+
225
+ options:
226
+ -h, --help show this help message and exit
227
+
228
+ Required Arguments:
229
+ -input_dir INPUT_DIR Directory location where the files are located.
230
+ -input_type {separate,combined,fasta}
231
+ Type of input files: "separate" for separate FASTA and GFF files, "combined" for GFF files with embedded FASTA sequences and "fasta" for combining multiple FASTA files together.
232
+ -name_split_gff NAME_SPLIT_GFF
233
+ Substring used to split the filename and extract the genome name ('_combined.gff3' or '.gff'). - Not needed with -input_type fasta
234
+ -name_split_fasta NAME_SPLIT_FASTA
235
+ Substring used to split filenames and extract genome names for fasta files if named differently to paired gff files (e.g., '_dna.fasta').
236
+ -output_dir OUTPUT_DIR
237
+ Directory for all output files.
238
+ -output_name OUTPUT_FILE
239
+ Output file name.
240
+
241
+ Optional Arguments:
242
+ -gene_ident GENE_IDENT
243
+ Default - "CDS": Identifier used for extraction of sequences such as "misc_RNA,gene,mRNA,CDS,rRNA,tRNA,tmRNA,CRISPR,ncRNA,regulatory_region,oriC,pseudo" - Not compatible with "fasta" input mode.
244
+ -translate Default - False: Translate extracted sequences to their AA counterpart? - appends _aa.fasta to given output_name
245
+
246
+ Misc Arguments:
247
+ -v, --version Print out version number and exit
248
+
249
+
250
+ ```
251
+
252
+ ## Group-Splitter: This tool can split multi-copy gene groups using CD-HIT after initial PyamilySeq analysis.
253
+ ### Example:
254
+ ```bash
255
+ Group-Splitter -genome_num 10 -input_fasta .../test/species/ -output_dir .../test/species/ -sequence_type AA
256
+ ```
257
+ ### Group-Splitter Menu:
258
+ ```
259
+ usage: Group_Splitter.py [-h] -input_fasta INPUT_FASTA -sequence_type {AA,DNA}
260
+ -genome_num GENOME_NUM -output_dir OUTPUT_DIR
261
+ [-groups GROUPS] [-group_threshold GROUP_THRESHOLD]
262
+ [-c PIDENT] [-s LEN_DIFF] [-T CLUSTERING_THREADS]
263
+ [-M CLUSTERING_MEMORY] [-no_delete_temp_files]
264
+ [-verbose] [-v]
265
+
266
+ PyamilySeq v1.1.0: Group-Splitter - A tool to split multi-copy gene groups
267
+ identified by PyamilySeq.
268
+
269
+ options:
270
+ -h, --help show this help message and exit
271
+
272
+ Required Parameters:
273
+ -input_fasta INPUT_FASTA
274
+ Input FASTA file containing gene groups.
275
+ -sequence_type {AA,DNA}
276
+ Default - DNA: Are groups "DNA" or "AA" sequences?
277
+ -genome_num GENOME_NUM
278
+ The total number of genomes must be provide
279
+ -output_dir OUTPUT_DIR
280
+ Output directory.
281
+
282
+ Regrouping Parameters:
283
+ -groups GROUPS Default - auto: Detect groups to be split (see
284
+ -group_threshold). Provide "-groups 1,2,3,4" with
285
+ group IDs to split specific groups.
286
+ -group_threshold GROUP_THRESHOLD
287
+ Minimum percentage of genomes with multi-copy
288
+ (default: 80.0) - Does not work with "-groups"
289
+
290
+ CD-HIT Reclustering Parameters:
291
+ -c PIDENT Sequence identity threshold (default: 0.8) - Probably
292
+ should be higher than what was used in initial
293
+ clustering.
294
+ -s LEN_DIFF Length difference cutoff (default: 0.20) - Often the
295
+ most impactful parameter to split 'multi-copy' gene
296
+ groups.
297
+ -T CLUSTERING_THREADS
298
+ Number of threads for clustering (default: 4)
299
+ -M CLUSTERING_MEMORY Memory limit in MB for clustering (default: 2000)
300
+
301
+ Misc Parameters:
302
+ -no_delete_temp_files
303
+ Default: Delete all temporary files after processing.
304
+ -verbose Print verbose output.
305
+ -v, --version Print out version number and exit
306
+
307
+ ```
308
+
309
+ ## Cluster-Summary menu: This tool can be used to summarise CD-HIT .clstr files:
310
+ ### Example:
311
+ ```bash
312
+ Cluster-Summary -genome_num 10 -input_clstr .../test_data/species/E-coli/E-coli_extracted_pep_cd-hit_80.clstr -output_tsv .../test_data/species/E-coli/E-coli_extracted_pep_cd-hit_80_Summary.tsv
313
+ ```
314
+ ### Cluster-Summary Menu:
315
+ ```
316
+ usage: Cluster_Summary.py [-h] -input_clstr INPUT_CLSTR -output OUTPUT -genome_num GENOME_NUM
317
+ [-output_dir OUTPUT_DIR] [-verbose] [-v]
318
+
319
+ PyamilySeq v1.1.0: Cluster-Summary - A tool to summarise CD-HIT clustering files.
320
+
321
+ options:
322
+ -h, --help show this help message and exit
323
+
324
+ Required Parameters:
325
+ -input_clstr INPUT_CLSTR
326
+ Input CD-HIT .clstr file
327
+ -output OUTPUT Output TSV file to store cluster summaries - Will add '.tsv' if not
328
+ provided by user
329
+ -genome_num GENOME_NUM
330
+ The total number of genomes must be provide
331
+
332
+ Optional Arguments:
333
+ -output_dir OUTPUT_DIR
334
+ Default: Same as input file
335
+
336
+ Misc Parameters:
337
+ -verbose Print verbose output.
338
+ -v, --version Print out version number and exit
339
+
340
+ ```
341
+
342
+ ### All example input and output data can be found in the 'test_data' directory.
@@ -0,0 +1,326 @@
1
+ # PyamilySeq
2
+ **PyamilySeq** is a Python tool for clustering gene sequences into groups based on sequence similarity identified by tools such as CD-HIT, BLAST, DIAMOND or MMseqs2.
3
+ This work is an extension of the gene family / pangenome tool developed for the StORF-Reporter publication in NAR (https://doi.org/10.1093/nar/gkad814).
4
+
5
+ ## Features
6
+ - **End-to-End**: PyamilySeq can take a directory of GFF+FASTA files, run CD-HIT for clustering and process the results.
7
+ - **Clustering input**: Supports input from CD-HIT formatted files as well as CSV and TSV node-edge lists (MMseqs2 and -outfmt 6 from BLAST/DIAMOND).
8
+ - **Reclustering**: Allows for the addition of new sequences post-initial clustering - Ensures continuity of contemporary clustering results and highlights impact of novel gene predictions.
9
+ - **'Genus Mode'**: Unlike other 'pangenome' tools, PyamilySeq can identify gene groups found across multiple genera as unique entities (see below).
10
+ - **Output**: Generates a 'Roary/Panaroo' formatted presence-absence CSV formatted file for downstream analysis.
11
+ - User-define species-/genus-wide gene groups - User has control over grouping parameters (core = 99/95% or min 6 genera etc).
12
+ - Aligns representative sequences using MAFFT.
13
+ - Output concatenated aligned sequences for tree building.
14
+ - Optionally output sequences of each separate identified gene group.
15
+ - Group-Splitter tool to split multi-copy gene groups.
16
+ - Numerous additional tools to assist in the pre- and post-processing of data.
17
+
18
+ ## Installation
19
+ PyamilySeq probably requires Python 3.6 or higher and the levenshtein library (https://pypi.org/project/Levenshtein/) - \
20
+ If levenshtein is not available, a Python implementation is utilised which is significantly slower.
21
+ #### Install using pip:
22
+
23
+ ```bash
24
+ pip install PyamilySeq [optionally add -U]
25
+ ```
26
+ PyamilySeq is currently still under active development so expect 'regular' updates with bugfixes and new features. \
27
+ To update to the newest version add '-U' to end of the pip install command.
28
+ ## Example usage: Below are two examples of running PyamilySeq in its two main modes.
29
+ ```commandline
30
+ usage: PyamilySeq.py [-h] {Full,Partial} ...
31
+
32
+ PyamilySeq v1.1.0: A tool for gene clustering and analysis.
33
+
34
+ positional arguments:
35
+ {Full,Partial} Choose a mode: 'Full' or 'Partial'.
36
+ Full Full mode: PyamilySeq to cluster with CD-HIT and process output.
37
+ Partial Partial mode: PyamilySeq to process pre-clustered data.
38
+
39
+ options:
40
+ -h, --help show this help message and exit
41
+
42
+ ```
43
+ ### 'Full Mode': Will conduct clustering of sequences with CD-HIT as part of PyamilySeq run
44
+ ```
45
+ PyamilySeq Full -output_dir .../PyamilySeq_10_AA_90_80_Full_GFFs -input_type combined -input_dir .../genomes/ -name_split_gff _combined.gff3
46
+ ```
47
+ ### 'Partial Mode': Will process the output of a sequence clustering from MMseqs, BLAST, DIAMOND etc.
48
+ ```
49
+ PyamilySeq Partial -clustering_format CD-HIT -cluster_file .../all_10_combined_pep_CD-HIT_90_80.clstr -original_fasta .../all_10_combined_pep.fasta -output_dir .../PyamilySeq_10_AA_90_80_Partial -write_groups 99 -align
50
+ ```
51
+
52
+
53
+ #### Note: using a '-clustering_format' other than the default CD-HIT, requires input to be two in two columns as below (Same format as MMseqs2 tsv and BLAST outfmt 6) - Genome name and sequence name are separated by '|'.
54
+ ```
55
+ Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno
56
+ Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno Escherichia_coli_113290|ENSB_2fj4rJ8e8Z9PNdX
57
+ Escherichia_coli_110957|ENSB_lL-zIKt-gh0oSno Escherichia_coli_b185|ENSB_G_PVe28-ej8q-3S
58
+ Escherichia_coli_110957|ENSB_TIZS9kbTvShDvyX Escherichia_coli_110957|ENSB_TIZS9kbTvShDvyX
59
+ ```
60
+ ### Example output:
61
+ ```
62
+ Running PyamilySeq v1.1.0
63
+ Calculating Groups
64
+ Number of Genomes: 10
65
+ Gene Groups
66
+ First_core_99: 2994
67
+ First_core_95: 0
68
+ First_core_15: 3266
69
+ First_core_0: 5466
70
+ Total Number of First Gene Groups (Including Singletons): 11726
71
+ Outputting gene_presence_absence file
72
+ Outputting gene group FASTA files
73
+ Combined FASTA file saved to: ../combined_group_sequences_dna.fasta
74
+ Processing gene group alignment
75
+ Thank you for using PyamilySeq -- A detailed user manual can be found at https://github.com/NickJD/PyamilySeq
76
+ Please report any issues to: https://github.com/NickJD/PyamilySeq/issues
77
+ ```
78
+
79
+
80
+ ## Reclustering:
81
+ ### Reclustering can be used to see where additional sequences/genes lay in relation to a contemporary pangenome/gene grouping.
82
+ ```
83
+ PyamilySeq Partial -clustering_format CD-HIT -cluster_file .../all_10_combined_pep_CD-HIT_90_80.clstr -reclustered .../all_10_combined_pep_CD-HIT_90_80_AND_StORFs_CD-HIT_90_80.clstr -original_fasta .../all_10_combined_pep_AND_StORFs.fasta -output_dir .../PyamilySeq_10_AA_90_80_Partial_Reclustered_StORFs -write_groups 99 -align
84
+ ```
85
+ #### As can be seen below, the additional sequences recovered by the StORF-Reporter annotation tool have 'extended' contemporary or created entirely new gene groups. 'First' corresponds to the groups identified from the first clustering round and 'Second' for the second. In 'reclustering' mode, First_core_# groups are unaffected thus retaining the initial grouping information.
86
+ ```commandline
87
+ Number of Genomes: 10
88
+ Gene Groups
89
+ First_core_99: 2994
90
+ First_core_95: 0
91
+ First_core_15: 3266
92
+ First_core_0: 5466
93
+ extended_core_99: 3
94
+ extended_core_95: 0
95
+ extended_core_15: 49
96
+ extended_core_0: 0
97
+ combined_core_99: 0
98
+ combined_core_95: 0
99
+ combined_core_15: 3
100
+ combined_core_0: 0
101
+ Second_core_99: 0
102
+ Second_core_95: 0
103
+ Second_core_15: 20
104
+ Second_core_0: 39
105
+ only_Second_core_99: 768
106
+ only_Second_core_95: 0
107
+ only_Second_core_15: 4472
108
+ only_Second_core_0: 8395
109
+ Total Number of First Gene Groups (Including Singletons): 11726
110
+ Total Number of Second Gene Groups (Including Singletons): 25359
111
+ Total Number of First Gene Groups That Had Additional Second Sequences But Not New Genomes: 5
112
+ ```
113
+
114
+ ## PyamilySeq is separated into two main 'run modes', Full and Partial. They each have their own set of required and optional arguments.
115
+ ### PyamilySeq - Full Menu:
116
+ ```
117
+ usage: PyamilySeq.py Full [-h] -output_dir OUTPUT_DIR -input_type {separate,combined,fasta} [-input_dir INPUT_DIR] [-input_fasta INPUT_FASTA] [-name_split_gff NAME_SPLIT_GFF] [-name_split_fasta NAME_SPLIT_FASTA] [-sequence_type {AA,DNA}] [-gene_ident GENE_IDENT] [-c PIDENT] [-s LEN_DIFF] [-fast_mode]
118
+ [-group_mode {Species,Genus}] [-species_groups SPECIES_GROUPS] [-genus_groups GENUS_GROUPS] [-write_groups WRITE_GROUPS] [-write_individual_groups] [-align] [-align_aa] [-no_gpa] [-M MEM] [-T THREADS] [-verbose] [-v]
119
+
120
+ options:
121
+ -h, --help show this help message and exit
122
+ -output_dir OUTPUT_DIR
123
+ Directory for all output files.
124
+ -input_type {separate,combined,fasta}
125
+ Type of input files: 'separate' for matching FASTA and GFF files, 'combined' for GFF+FASTA, or 'fasta' for a prepared FASTA file.
126
+ -input_dir INPUT_DIR Directory containing GFF/FASTA files - Use with -input_type separate/combined.
127
+ -input_fasta INPUT_FASTA
128
+ Input FASTA file - Use with - input_type fasta.
129
+ -name_split_gff NAME_SPLIT_GFF
130
+ Substring to split filenames and extract genome names for gff files (e.g., '_combined.gff3') - Use with -input_type separate/combined.
131
+ -name_split_fasta NAME_SPLIT_FASTA
132
+ Substring to split filenames and extract genome names for fasta files if named differently to paired gff files (e.g., '_dna.fasta') - Use with -input_type separate/combined.
133
+ -sequence_type {AA,DNA}
134
+ Clustering mode: 'DNA' or 'AA'.
135
+ -gene_ident GENE_IDENT
136
+ Gene identifiers to extract sequences (e.g., 'CDS, tRNA').
137
+ -c PIDENT Sequence identity threshold for clustering (default: 0.90) - CD-HIT parameter '-c'.
138
+ -s LEN_DIFF Length difference threshold for clustering (default: 0.80) - CD-HIT parameter '-s'.
139
+ -fast_mode Enable fast mode for CD-HIT (not recommended) - CD-HIT parameter '-g'.
140
+ -group_mode {Species,Genus}
141
+ Grouping mode: 'Species' or 'Genus'.
142
+ -species_groups SPECIES_GROUPS
143
+ Gene groupings for 'Species' mode (default: '99,95,15').
144
+ -genus_groups GENUS_GROUPS
145
+ Gene groupings for 'Genus' mode (default: '1-10').
146
+ -write_groups WRITE_GROUPS
147
+ Output gene groups as a single FASTA file (specify levels: e.g., '-w 99,95'). - triggers '-wig'.
148
+ -write_individual_groups
149
+ Output individual FASTA files for each group.
150
+ -align Align and concatenate sequences for 'core' groups specified with '-w'.
151
+ -align_aa Align sequences as amino acids.
152
+ -no_gpa Skip creation of gene_presence_absence.csv.
153
+ -M MEM Memory allocation for clustering (MB) - CD-HIT parameter '-M'.
154
+ -T THREADS Number of threads for clustering/alignment - CD-HIT parameter '-T' | MAFFT parameter '--thread'.
155
+ -verbose Print verbose output.
156
+ -v, --version Print version number and exit.
157
+
158
+ ```
159
+ ### PyamilySeq - Partial Menu:
160
+ ```commandline
161
+ usage: PyamilySeq.py Partial [-h] -clustering_format {CD-HIT,MMseqs,BLAST} -cluster_file CLUSTER_FILE -original_fasta ORIGINAL_FASTA -output_dir OUTPUT_DIR [-reclustered RECLUSTERED] [-seq_tag SEQUENCE_TAG] [-group_mode {Species,Genus}] [-species_groups SPECIES_GROUPS] [-genus_groups GENUS_GROUPS]
162
+ [-write_groups WRITE_GROUPS] [-write_individual_groups] [-align] [-align_aa] [-no_gpa] [-M MEM] [-T THREADS] [-verbose] [-v]
163
+
164
+ options:
165
+ -h, --help show this help message and exit
166
+ -clustering_format {CD-HIT,MMseqs,BLAST}
167
+ Clustering format used: CD-HIT, MMseqs2, or BLAST.
168
+ -cluster_file CLUSTER_FILE
169
+ Cluster file containing pre-clustered groups from CD-HIT, MMseqs, BLAST etc.
170
+ -original_fasta ORIGINAL_FASTA
171
+ FASTA file used in pre-clustering (Provide sequences in DNA form).
172
+ -output_dir OUTPUT_DIR
173
+ Directory for all output files.
174
+ -reclustered RECLUSTERED
175
+ Clustering output file from a second round of clustering.
176
+ -seq_tag SEQUENCE_TAG
177
+ Tag for distinguishing reclustered sequences.
178
+ -group_mode {Species,Genus}
179
+ Grouping mode: 'Species' or 'Genus'.
180
+ -species_groups SPECIES_GROUPS
181
+ Gene groupings for 'Species' mode (default: '99,95,15').
182
+ -genus_groups GENUS_GROUPS
183
+ Gene groupings for 'Genus' mode (default: '1-10').
184
+ -write_groups WRITE_GROUPS
185
+ Output gene groups as a single FASTA file (specify levels: e.g., '-w 99,95'). - triggers '-wig'.
186
+ -write_individual_groups
187
+ Output individual FASTA files for each group.
188
+ -align Align and concatenate sequences for 'core' groups specified with '-w'.
189
+ -align_aa Align sequences as amino acids.
190
+ -no_gpa Skip creation of gene_presence_absence.csv.
191
+ -M MEM Memory allocation for clustering (MB) - CD-HIT parameter '-M'.
192
+ -T THREADS Number of threads for clustering/alignment - CD-HIT parameter '-T' | MAFFT parameter '--thread'.
193
+ -verbose Print verbose output.
194
+ -v, --version Print version number and exit.
195
+
196
+ ```
197
+
198
+ ## Seq-Combiner: This tool is provided to enable the pre-processing of multiple GFF/FASTA files together ready to be clustered by the user.
199
+ ### Example:
200
+ ```bash
201
+ Seq-Combiner -input_dir .../test_data/genomes -name_split_gff .gff3 -output_dir .../test_data/genomes -output_name combine_fasta_seqs.fa -input_type combined
202
+ ```
203
+ ### Seq-Combiner Menu:
204
+ ```
205
+ usage: Seq_Combiner.py [-h] -input_dir INPUT_DIR -input_type {separate,combined,fasta} [-name_split_gff NAME_SPLIT_GFF] [-name_split_fasta NAME_SPLIT_FASTA] -output_dir OUTPUT_DIR -output_name OUTPUT_FILE [-gene_ident GENE_IDENT] [-translate] [-v]
206
+
207
+ PyamilySeq v1.1.0: Seq-Combiner - A tool to extract sequences from GFF/FASTA files and prepare them for PyamilySeq.
208
+
209
+ options:
210
+ -h, --help show this help message and exit
211
+
212
+ Required Arguments:
213
+ -input_dir INPUT_DIR Directory location where the files are located.
214
+ -input_type {separate,combined,fasta}
215
+ Type of input files: "separate" for separate FASTA and GFF files, "combined" for GFF files with embedded FASTA sequences and "fasta" for combining multiple FASTA files together.
216
+ -name_split_gff NAME_SPLIT_GFF
217
+ Substring used to split the filename and extract the genome name ('_combined.gff3' or '.gff'). - Not needed with -input_type fasta
218
+ -name_split_fasta NAME_SPLIT_FASTA
219
+ Substring used to split filenames and extract genome names for fasta files if named differently to paired gff files (e.g., '_dna.fasta').
220
+ -output_dir OUTPUT_DIR
221
+ Directory for all output files.
222
+ -output_name OUTPUT_FILE
223
+ Output file name.
224
+
225
+ Optional Arguments:
226
+ -gene_ident GENE_IDENT
227
+ Default - "CDS": Identifier used for extraction of sequences such as "misc_RNA,gene,mRNA,CDS,rRNA,tRNA,tmRNA,CRISPR,ncRNA,regulatory_region,oriC,pseudo" - Not compatible with "fasta" input mode.
228
+ -translate Default - False: Translate extracted sequences to their AA counterpart? - appends _aa.fasta to given output_name
229
+
230
+ Misc Arguments:
231
+ -v, --version Print out version number and exit
232
+
233
+
234
+ ```
235
+
236
+ ## Group-Splitter: This tool can split multi-copy gene groups using CD-HIT after initial PyamilySeq analysis.
237
+ ### Example:
238
+ ```bash
239
+ Group-Splitter -genome_num 10 -input_fasta .../test/species/ -output_dir .../test/species/ -sequence_type AA
240
+ ```
241
+ ### Group-Splitter Menu:
242
+ ```
243
+ usage: Group_Splitter.py [-h] -input_fasta INPUT_FASTA -sequence_type {AA,DNA}
244
+ -genome_num GENOME_NUM -output_dir OUTPUT_DIR
245
+ [-groups GROUPS] [-group_threshold GROUP_THRESHOLD]
246
+ [-c PIDENT] [-s LEN_DIFF] [-T CLUSTERING_THREADS]
247
+ [-M CLUSTERING_MEMORY] [-no_delete_temp_files]
248
+ [-verbose] [-v]
249
+
250
+ PyamilySeq v1.1.0: Group-Splitter - A tool to split multi-copy gene groups
251
+ identified by PyamilySeq.
252
+
253
+ options:
254
+ -h, --help show this help message and exit
255
+
256
+ Required Parameters:
257
+ -input_fasta INPUT_FASTA
258
+ Input FASTA file containing gene groups.
259
+ -sequence_type {AA,DNA}
260
+ Default - DNA: Are groups "DNA" or "AA" sequences?
261
+ -genome_num GENOME_NUM
262
+ The total number of genomes must be provide
263
+ -output_dir OUTPUT_DIR
264
+ Output directory.
265
+
266
+ Regrouping Parameters:
267
+ -groups GROUPS Default - auto: Detect groups to be split (see
268
+ -group_threshold). Provide "-groups 1,2,3,4" with
269
+ group IDs to split specific groups.
270
+ -group_threshold GROUP_THRESHOLD
271
+ Minimum percentage of genomes with multi-copy
272
+ (default: 80.0) - Does not work with "-groups"
273
+
274
+ CD-HIT Reclustering Parameters:
275
+ -c PIDENT Sequence identity threshold (default: 0.8) - Probably
276
+ should be higher than what was used in initial
277
+ clustering.
278
+ -s LEN_DIFF Length difference cutoff (default: 0.20) - Often the
279
+ most impactful parameter to split 'multi-copy' gene
280
+ groups.
281
+ -T CLUSTERING_THREADS
282
+ Number of threads for clustering (default: 4)
283
+ -M CLUSTERING_MEMORY Memory limit in MB for clustering (default: 2000)
284
+
285
+ Misc Parameters:
286
+ -no_delete_temp_files
287
+ Default: Delete all temporary files after processing.
288
+ -verbose Print verbose output.
289
+ -v, --version Print out version number and exit
290
+
291
+ ```
292
+
293
+ ## Cluster-Summary menu: This tool can be used to summarise CD-HIT .clstr files:
294
+ ### Example:
295
+ ```bash
296
+ Cluster-Summary -genome_num 10 -input_clstr .../test_data/species/E-coli/E-coli_extracted_pep_cd-hit_80.clstr -output_tsv .../test_data/species/E-coli/E-coli_extracted_pep_cd-hit_80_Summary.tsv
297
+ ```
298
+ ### Cluster-Summary Menu:
299
+ ```
300
+ usage: Cluster_Summary.py [-h] -input_clstr INPUT_CLSTR -output OUTPUT -genome_num GENOME_NUM
301
+ [-output_dir OUTPUT_DIR] [-verbose] [-v]
302
+
303
+ PyamilySeq v1.1.0: Cluster-Summary - A tool to summarise CD-HIT clustering files.
304
+
305
+ options:
306
+ -h, --help show this help message and exit
307
+
308
+ Required Parameters:
309
+ -input_clstr INPUT_CLSTR
310
+ Input CD-HIT .clstr file
311
+ -output OUTPUT Output TSV file to store cluster summaries - Will add '.tsv' if not
312
+ provided by user
313
+ -genome_num GENOME_NUM
314
+ The total number of genomes must be provide
315
+
316
+ Optional Arguments:
317
+ -output_dir OUTPUT_DIR
318
+ Default: Same as input file
319
+
320
+ Misc Parameters:
321
+ -verbose Print verbose output.
322
+ -v, --version Print out version number and exit
323
+
324
+ ```
325
+
326
+ ### All example input and output data can be found in the 'test_data' directory.
@@ -2,6 +2,7 @@
2
2
  requires = [
3
3
  "setuptools",
4
4
  "wheel",
5
+ "levenshtein",
5
6
  ]
6
7
  build-backend = "setuptools.build_meta"
7
8