PyamilySeq 0.4.0__tar.gz → 0.5.1__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.
- pyamilyseq-0.5.1/PKG-INFO +163 -0
- pyamilyseq-0.5.1/README.md +148 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/setup.cfg +2 -1
- pyamilyseq-0.5.1/src/PyamilySeq/Constants.py +2 -0
- pyamilyseq-0.5.1/src/PyamilySeq/PyamilySeq.py +237 -0
- pyamilyseq-0.5.1/src/PyamilySeq/PyamilySeq_Genus.py +659 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq/PyamilySeq_Species.py +33 -115
- pyamilyseq-0.5.1/src/PyamilySeq/Seq_Combiner.py +44 -0
- pyamilyseq-0.5.1/src/PyamilySeq/utils.py +136 -0
- pyamilyseq-0.5.1/src/PyamilySeq.egg-info/PKG-INFO +163 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq.egg-info/SOURCES.txt +3 -1
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq.egg-info/entry_points.txt +1 -0
- pyamilyseq-0.4.0/PKG-INFO +0 -92
- pyamilyseq-0.4.0/README.md +0 -77
- pyamilyseq-0.4.0/src/PyamilySeq/Constants.py +0 -15
- pyamilyseq-0.4.0/src/PyamilySeq/PyamilySeq.py +0 -186
- pyamilyseq-0.4.0/src/PyamilySeq/combine_FASTA_with_genome_IDs.py +0 -49
- pyamilyseq-0.4.0/src/PyamilySeq.egg-info/PKG-INFO +0 -92
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/LICENSE +0 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/pyproject.toml +0 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq/CD-Hit_StORF-Reporter_Cross-Genera_Builder.py +0 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq/__init__.py +0 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq.egg-info/dependency_links.txt +0 -0
- {pyamilyseq-0.4.0 → pyamilyseq-0.5.1}/src/PyamilySeq.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: PyamilySeq
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Summary: PyamilySeq - A a tool to look for sequence-based gene families 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
|
+
|
|
16
|
+
# PyamilySeq - !BETA!
|
|
17
|
+
**PyamilySeq** (Family Seek) is a Python tool for clustering gene sequences into families based on sequence similarity identified by tools such as CD-HIT, BLAST, DIAMOND or MMseqs2.
|
|
18
|
+
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).
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
- **End-to-End**: PyamilySeq can take a directory of GFF+FASTA files, run CD-HIT for clustering and process the results.
|
|
22
|
+
- **Clustering**: Supports input from CD-HIT formatted files as well as CSV and TSV edge lists (-outfmt 6 from BLAST/DIAMOND).
|
|
23
|
+
- **Reclustering**: Allows for the addition of new sequences post-initial clustering.
|
|
24
|
+
- **Output**: Generates a gene 'Roary/Panaroo' formatted presence-absence CSV formatted file for downstream analysis.
|
|
25
|
+
- Align representative sequences using MAFFT.
|
|
26
|
+
- Output concatenated aligned sequences for downstream analysis.
|
|
27
|
+
- Optionally output sequences of identified families.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
PyamilySeq requires Python 3.6 or higher. Install using pip:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install PyamilySeq
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage - Menu
|
|
38
|
+
```
|
|
39
|
+
usage: PyamilySeq.py [-h] -run_mode {Full,Partial} -group_mode {Species,Genus}
|
|
40
|
+
-clust_tool {CD-HIT} -output_dir OUTPUT_DIR
|
|
41
|
+
[-input_type {separate,combined}] [-input_dir INPUT_DIR]
|
|
42
|
+
[-name_split NAME_SPLIT] [-pid PIDENT]
|
|
43
|
+
[-len_diff LEN_DIFF] [-cluster_file CLUSTER_FILE]
|
|
44
|
+
[-reclustered RECLUSTERED] [-seq_tag SEQUENCE_TAG]
|
|
45
|
+
[-groups CORE_GROUPS] [-w WRITE_FAMILIES] [-con CON_CORE]
|
|
46
|
+
[-original_fasta ORIGINAL_FASTA]
|
|
47
|
+
[-gpa GENE_PRESENCE_ABSENCE_OUT] [-verbose {True,False}]
|
|
48
|
+
[-v]
|
|
49
|
+
|
|
50
|
+
PyamilySeq v0.5.1: PyamilySeq Run Parameters.
|
|
51
|
+
|
|
52
|
+
options:
|
|
53
|
+
-h, --help show this help message and exit
|
|
54
|
+
|
|
55
|
+
Required Arguments:
|
|
56
|
+
-run_mode {Full,Partial}
|
|
57
|
+
Run Mode: Should PyamilySeq be run in "Full" or
|
|
58
|
+
"Partial" mode?
|
|
59
|
+
-group_mode {Species}
|
|
60
|
+
Group Mode: Should PyamilySeq be run in "Species" or
|
|
61
|
+
"Genus" mode? - Genus mode not currently functioning
|
|
62
|
+
-clust_tool {CD-HIT} Clustering tool to use: CD-HIT, DIAMOND, BLAST or
|
|
63
|
+
MMseqs2.
|
|
64
|
+
-output_dir OUTPUT_DIR
|
|
65
|
+
Directory for all output files.
|
|
66
|
+
|
|
67
|
+
Full-Mode Arguments - Required when "-run_mode Full" is used:
|
|
68
|
+
-input_type {separate,combined}
|
|
69
|
+
Type of input files: 'separate' for separate FASTA and
|
|
70
|
+
GFF files, 'combined' for GFF files with embedded
|
|
71
|
+
FASTA sequences.
|
|
72
|
+
-input_dir INPUT_DIR Directory containing GFF/FASTA files.
|
|
73
|
+
-name_split NAME_SPLIT
|
|
74
|
+
substring used to split the filename and extract the
|
|
75
|
+
genome name ('_combined.gff3' or '.gff').
|
|
76
|
+
-pid PIDENT Default 0.95: Pident threshold for clustering.
|
|
77
|
+
-len_diff LEN_DIFF Default 0.80: Minimum length difference between
|
|
78
|
+
clustered sequences - (-s) threshold for CD-HIT
|
|
79
|
+
clustering.
|
|
80
|
+
|
|
81
|
+
Partial-Mode Arguments - Required when "-run_mode Partial" is used:
|
|
82
|
+
-cluster_file CLUSTER_FILE
|
|
83
|
+
Clustering output file containing CD-HIT, TSV or CSV
|
|
84
|
+
Edge List
|
|
85
|
+
|
|
86
|
+
Grouping Arguments - Use to fine-tune grouping of genes after clustering:
|
|
87
|
+
-reclustered RECLUSTERED
|
|
88
|
+
Clustering output file from secondary round of
|
|
89
|
+
clustering
|
|
90
|
+
-seq_tag SEQUENCE_TAG
|
|
91
|
+
Default - "StORF": Unique identifier to be used to
|
|
92
|
+
distinguish the second of two rounds of clustered
|
|
93
|
+
sequences
|
|
94
|
+
-groups CORE_GROUPS Default - ('99,95,15'): Gene family groups to use
|
|
95
|
+
|
|
96
|
+
Output Parameters:
|
|
97
|
+
-w WRITE_FAMILIES Default - No output: Output sequences of identified
|
|
98
|
+
families (provide levels at which to output "-w 99,95"
|
|
99
|
+
- Must provide FASTA file with -fasta
|
|
100
|
+
-con CON_CORE Default - No output: Output aligned and concatinated
|
|
101
|
+
sequences of identified families - used for MSA
|
|
102
|
+
(provide levels at which to output "-w 99,95" - Must
|
|
103
|
+
provide FASTA file with -fasta
|
|
104
|
+
-original_fasta ORIGINAL_FASTA
|
|
105
|
+
FASTA file to use in conjunction with "-w" or "-con"
|
|
106
|
+
when running in Partial Mode.
|
|
107
|
+
-gpa GENE_PRESENCE_ABSENCE_OUT
|
|
108
|
+
Default - False: If selected, a Roary formatted
|
|
109
|
+
gene_presence_absence.csv will be created - Required
|
|
110
|
+
for Coinfinder and other downstream tools
|
|
111
|
+
|
|
112
|
+
Misc:
|
|
113
|
+
-verbose {True,False}
|
|
114
|
+
Default - False: Print out runtime messages
|
|
115
|
+
-v Default - False: Print out version number and exit
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Examples: Below are two examples of running PyamilySeq in its two main modes.
|
|
120
|
+
#### 'Full Mode': Will conduct clustering of sequences as part of PyamilySeq run
|
|
121
|
+
```bash
|
|
122
|
+
PyamilySeq -run_mode Full -group_mode Species -output_dir ../../test_data/testing -input_type combined -input_dir .../test_data/genomes -name_split _combined.gff3 -pid 0.99 -len_diff 0.99 -clust_tool CD-HIT -gpa True -con True -w 99 -verbose True
|
|
123
|
+
```
|
|
124
|
+
#### 'Partial Mode': Will take the output of a sequence clustering
|
|
125
|
+
```bash
|
|
126
|
+
PyamilySeq -run_mode Partial -group_mode Species -output_dir .../test_data/testing -cluster_file .../test_data/CD-HIT/combined_Ensmbl_pep_CD_90_60.clstr -clust_tool CD-HIT -original_fasta .../test_data/combined_Ensmbl_cds.fasta -gpa True -con True -w 99 -verbose True
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
Calculating Groups
|
|
131
|
+
Gene Groups:
|
|
132
|
+
first_core_99: 3103
|
|
133
|
+
first_core_95: 0
|
|
134
|
+
first_core_15: 3217
|
|
135
|
+
first_core_0: 4808
|
|
136
|
+
Total Number of Gene Groups (Including Singletons): 11128
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Seq-Combiner: This tool is provided to enable the pre-processing of multiple GFF/FASTA files together ready to be clustered by the user
|
|
140
|
+
### Example:
|
|
141
|
+
```bash
|
|
142
|
+
Seq-Combiner -input_dir .../test_data/genomes -name_split _combined.gff3 -output_dir.../test_data -output_name combine_fasta_seqs.fa -input_type combined
|
|
143
|
+
```
|
|
144
|
+
## Seq-Combiner Menu:
|
|
145
|
+
```bash
|
|
146
|
+
usage: Seq_Combiner.py [-h] -input_dir INPUT_DIR -input_type {separate,combined} -name_split NAME_SPLIT -output_dir OUTPUT_DIR -output_name OUTPUT_FILE
|
|
147
|
+
|
|
148
|
+
Seq-Combiner v0.5.1: Seq-Combiner Run Parameters.
|
|
149
|
+
|
|
150
|
+
options:
|
|
151
|
+
-h, --help show this help message and exit
|
|
152
|
+
|
|
153
|
+
Required Arguments:
|
|
154
|
+
-input_dir INPUT_DIR Directory location where the files are located.
|
|
155
|
+
-input_type {separate,combined}
|
|
156
|
+
Type of input files: 'separate' for separate FASTA and GFF files, 'combined' for GFF files with embedded FASTA sequences.
|
|
157
|
+
-name_split NAME_SPLIT
|
|
158
|
+
substring used to split the filename and extract the genome name ('_combined.gff3' or '.gff').
|
|
159
|
+
-output_dir OUTPUT_DIR
|
|
160
|
+
Directory for all output files.
|
|
161
|
+
-output_name OUTPUT_FILE
|
|
162
|
+
Output file name.
|
|
163
|
+
```
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# PyamilySeq - !BETA!
|
|
2
|
+
**PyamilySeq** (Family Seek) is a Python tool for clustering gene sequences into families 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**: Supports input from CD-HIT formatted files as well as CSV and TSV edge lists (-outfmt 6 from BLAST/DIAMOND).
|
|
8
|
+
- **Reclustering**: Allows for the addition of new sequences post-initial clustering.
|
|
9
|
+
- **Output**: Generates a gene 'Roary/Panaroo' formatted presence-absence CSV formatted file for downstream analysis.
|
|
10
|
+
- Align representative sequences using MAFFT.
|
|
11
|
+
- Output concatenated aligned sequences for downstream analysis.
|
|
12
|
+
- Optionally output sequences of identified families.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
PyamilySeq requires Python 3.6 or higher. Install using pip:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install PyamilySeq
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage - Menu
|
|
23
|
+
```
|
|
24
|
+
usage: PyamilySeq.py [-h] -run_mode {Full,Partial} -group_mode {Species,Genus}
|
|
25
|
+
-clust_tool {CD-HIT} -output_dir OUTPUT_DIR
|
|
26
|
+
[-input_type {separate,combined}] [-input_dir INPUT_DIR]
|
|
27
|
+
[-name_split NAME_SPLIT] [-pid PIDENT]
|
|
28
|
+
[-len_diff LEN_DIFF] [-cluster_file CLUSTER_FILE]
|
|
29
|
+
[-reclustered RECLUSTERED] [-seq_tag SEQUENCE_TAG]
|
|
30
|
+
[-groups CORE_GROUPS] [-w WRITE_FAMILIES] [-con CON_CORE]
|
|
31
|
+
[-original_fasta ORIGINAL_FASTA]
|
|
32
|
+
[-gpa GENE_PRESENCE_ABSENCE_OUT] [-verbose {True,False}]
|
|
33
|
+
[-v]
|
|
34
|
+
|
|
35
|
+
PyamilySeq v0.5.1: PyamilySeq Run Parameters.
|
|
36
|
+
|
|
37
|
+
options:
|
|
38
|
+
-h, --help show this help message and exit
|
|
39
|
+
|
|
40
|
+
Required Arguments:
|
|
41
|
+
-run_mode {Full,Partial}
|
|
42
|
+
Run Mode: Should PyamilySeq be run in "Full" or
|
|
43
|
+
"Partial" mode?
|
|
44
|
+
-group_mode {Species}
|
|
45
|
+
Group Mode: Should PyamilySeq be run in "Species" or
|
|
46
|
+
"Genus" mode? - Genus mode not currently functioning
|
|
47
|
+
-clust_tool {CD-HIT} Clustering tool to use: CD-HIT, DIAMOND, BLAST or
|
|
48
|
+
MMseqs2.
|
|
49
|
+
-output_dir OUTPUT_DIR
|
|
50
|
+
Directory for all output files.
|
|
51
|
+
|
|
52
|
+
Full-Mode Arguments - Required when "-run_mode Full" is used:
|
|
53
|
+
-input_type {separate,combined}
|
|
54
|
+
Type of input files: 'separate' for separate FASTA and
|
|
55
|
+
GFF files, 'combined' for GFF files with embedded
|
|
56
|
+
FASTA sequences.
|
|
57
|
+
-input_dir INPUT_DIR Directory containing GFF/FASTA files.
|
|
58
|
+
-name_split NAME_SPLIT
|
|
59
|
+
substring used to split the filename and extract the
|
|
60
|
+
genome name ('_combined.gff3' or '.gff').
|
|
61
|
+
-pid PIDENT Default 0.95: Pident threshold for clustering.
|
|
62
|
+
-len_diff LEN_DIFF Default 0.80: Minimum length difference between
|
|
63
|
+
clustered sequences - (-s) threshold for CD-HIT
|
|
64
|
+
clustering.
|
|
65
|
+
|
|
66
|
+
Partial-Mode Arguments - Required when "-run_mode Partial" is used:
|
|
67
|
+
-cluster_file CLUSTER_FILE
|
|
68
|
+
Clustering output file containing CD-HIT, TSV or CSV
|
|
69
|
+
Edge List
|
|
70
|
+
|
|
71
|
+
Grouping Arguments - Use to fine-tune grouping of genes after clustering:
|
|
72
|
+
-reclustered RECLUSTERED
|
|
73
|
+
Clustering output file from secondary round of
|
|
74
|
+
clustering
|
|
75
|
+
-seq_tag SEQUENCE_TAG
|
|
76
|
+
Default - "StORF": Unique identifier to be used to
|
|
77
|
+
distinguish the second of two rounds of clustered
|
|
78
|
+
sequences
|
|
79
|
+
-groups CORE_GROUPS Default - ('99,95,15'): Gene family groups to use
|
|
80
|
+
|
|
81
|
+
Output Parameters:
|
|
82
|
+
-w WRITE_FAMILIES Default - No output: Output sequences of identified
|
|
83
|
+
families (provide levels at which to output "-w 99,95"
|
|
84
|
+
- Must provide FASTA file with -fasta
|
|
85
|
+
-con CON_CORE Default - No output: Output aligned and concatinated
|
|
86
|
+
sequences of identified families - used for MSA
|
|
87
|
+
(provide levels at which to output "-w 99,95" - Must
|
|
88
|
+
provide FASTA file with -fasta
|
|
89
|
+
-original_fasta ORIGINAL_FASTA
|
|
90
|
+
FASTA file to use in conjunction with "-w" or "-con"
|
|
91
|
+
when running in Partial Mode.
|
|
92
|
+
-gpa GENE_PRESENCE_ABSENCE_OUT
|
|
93
|
+
Default - False: If selected, a Roary formatted
|
|
94
|
+
gene_presence_absence.csv will be created - Required
|
|
95
|
+
for Coinfinder and other downstream tools
|
|
96
|
+
|
|
97
|
+
Misc:
|
|
98
|
+
-verbose {True,False}
|
|
99
|
+
Default - False: Print out runtime messages
|
|
100
|
+
-v Default - False: Print out version number and exit
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Examples: Below are two examples of running PyamilySeq in its two main modes.
|
|
105
|
+
#### 'Full Mode': Will conduct clustering of sequences as part of PyamilySeq run
|
|
106
|
+
```bash
|
|
107
|
+
PyamilySeq -run_mode Full -group_mode Species -output_dir ../../test_data/testing -input_type combined -input_dir .../test_data/genomes -name_split _combined.gff3 -pid 0.99 -len_diff 0.99 -clust_tool CD-HIT -gpa True -con True -w 99 -verbose True
|
|
108
|
+
```
|
|
109
|
+
#### 'Partial Mode': Will take the output of a sequence clustering
|
|
110
|
+
```bash
|
|
111
|
+
PyamilySeq -run_mode Partial -group_mode Species -output_dir .../test_data/testing -cluster_file .../test_data/CD-HIT/combined_Ensmbl_pep_CD_90_60.clstr -clust_tool CD-HIT -original_fasta .../test_data/combined_Ensmbl_cds.fasta -gpa True -con True -w 99 -verbose True
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
Calculating Groups
|
|
116
|
+
Gene Groups:
|
|
117
|
+
first_core_99: 3103
|
|
118
|
+
first_core_95: 0
|
|
119
|
+
first_core_15: 3217
|
|
120
|
+
first_core_0: 4808
|
|
121
|
+
Total Number of Gene Groups (Including Singletons): 11128
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Seq-Combiner: This tool is provided to enable the pre-processing of multiple GFF/FASTA files together ready to be clustered by the user
|
|
125
|
+
### Example:
|
|
126
|
+
```bash
|
|
127
|
+
Seq-Combiner -input_dir .../test_data/genomes -name_split _combined.gff3 -output_dir.../test_data -output_name combine_fasta_seqs.fa -input_type combined
|
|
128
|
+
```
|
|
129
|
+
## Seq-Combiner Menu:
|
|
130
|
+
```bash
|
|
131
|
+
usage: Seq_Combiner.py [-h] -input_dir INPUT_DIR -input_type {separate,combined} -name_split NAME_SPLIT -output_dir OUTPUT_DIR -output_name OUTPUT_FILE
|
|
132
|
+
|
|
133
|
+
Seq-Combiner v0.5.1: Seq-Combiner Run Parameters.
|
|
134
|
+
|
|
135
|
+
options:
|
|
136
|
+
-h, --help show this help message and exit
|
|
137
|
+
|
|
138
|
+
Required Arguments:
|
|
139
|
+
-input_dir INPUT_DIR Directory location where the files are located.
|
|
140
|
+
-input_type {separate,combined}
|
|
141
|
+
Type of input files: 'separate' for separate FASTA and GFF files, 'combined' for GFF files with embedded FASTA sequences.
|
|
142
|
+
-name_split NAME_SPLIT
|
|
143
|
+
substring used to split the filename and extract the genome name ('_combined.gff3' or '.gff').
|
|
144
|
+
-output_dir OUTPUT_DIR
|
|
145
|
+
Directory for all output files.
|
|
146
|
+
-output_name OUTPUT_FILE
|
|
147
|
+
Output file name.
|
|
148
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = PyamilySeq
|
|
3
|
-
version = v0.
|
|
3
|
+
version = v0.5.1
|
|
4
4
|
author = Nicholas Dimonaco
|
|
5
5
|
author_email = nicholas@dimonaco.co.uk
|
|
6
6
|
description = PyamilySeq - A a tool to look for sequence-based gene families identified by clustering methods such as CD-HIT, DIAMOND, BLAST or MMseqs2.
|
|
@@ -28,6 +28,7 @@ include = *
|
|
|
28
28
|
[options.entry_points]
|
|
29
29
|
console_scripts =
|
|
30
30
|
PyamilySeq = PyamilySeq.PyamilySeq:main
|
|
31
|
+
Seq-Combiner = PyamilySeq.Seq_Combiner:main
|
|
31
32
|
|
|
32
33
|
[egg_info]
|
|
33
34
|
tag_build =
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import collections
|
|
3
|
+
import os
|
|
4
|
+
import glob
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
from .PyamilySeq_Species import cluster
|
|
11
|
+
from .Constants import *
|
|
12
|
+
from .utils import *
|
|
13
|
+
except (ModuleNotFoundError, ImportError, NameError, TypeError) as error:
|
|
14
|
+
from PyamilySeq_Species import cluster
|
|
15
|
+
from Constants import *
|
|
16
|
+
from utils import *
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def run_cd_hit(input_file, clustering_output, options):
|
|
22
|
+
cdhit_command = [
|
|
23
|
+
'cd-hit-est',
|
|
24
|
+
'-i', input_file,
|
|
25
|
+
'-o', clustering_output,
|
|
26
|
+
'-c', str(options.pident),
|
|
27
|
+
'-s', str(options.len_diff),
|
|
28
|
+
'-T', "20",
|
|
29
|
+
'-d', "0",
|
|
30
|
+
'-sc', "1",
|
|
31
|
+
'-sf', "1"
|
|
32
|
+
]
|
|
33
|
+
if options.verbose == True:
|
|
34
|
+
subprocess.run(cdhit_command)
|
|
35
|
+
else:
|
|
36
|
+
subprocess.run(cdhit_command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main():
|
|
40
|
+
parser = argparse.ArgumentParser(description='PyamilySeq ' + PyamilySeq_Version + ': PyamilySeq Run Parameters.')
|
|
41
|
+
### Required Arguments
|
|
42
|
+
required = parser.add_argument_group('Required Arguments')
|
|
43
|
+
required.add_argument('-run_mode', action='store', dest='run_mode', choices=['Full','Partial'],
|
|
44
|
+
help='Run Mode: Should PyamilySeq be run in "Full" or "Partial" mode?',
|
|
45
|
+
required=True)
|
|
46
|
+
required.add_argument('-group_mode', action='store', dest='group_type', choices=['Species'],
|
|
47
|
+
help='Group Mode: Should PyamilySeq be run in "Species" or "Genus" mode? - Genus mode not currently functioning',
|
|
48
|
+
required=True)
|
|
49
|
+
required.add_argument("-clust_tool", action="store", dest="clust_tool", choices=['CD-HIT'],
|
|
50
|
+
help="Clustering tool to use: CD-HIT, DIAMOND, BLAST or MMseqs2.",
|
|
51
|
+
required=True)
|
|
52
|
+
required.add_argument("-output_dir", action="store", dest="output_dir",
|
|
53
|
+
help="Directory for all output files.",
|
|
54
|
+
required=True)
|
|
55
|
+
### Full-Mode Arguments
|
|
56
|
+
full_mode_args = parser.add_argument_group('Full-Mode Arguments - Required when "-run_mode Full" is used')
|
|
57
|
+
full_mode_args.add_argument("-input_type", action="store", dest="input_type", choices=['separate', 'combined'],
|
|
58
|
+
help="Type of input files: 'separate' for separate FASTA and GFF files,"
|
|
59
|
+
" 'combined' for GFF files with embedded FASTA sequences.",
|
|
60
|
+
required=False)
|
|
61
|
+
full_mode_args.add_argument("-input_dir", action="store", dest="input_dir",
|
|
62
|
+
help="Directory containing GFF/FASTA files.",
|
|
63
|
+
required=False)
|
|
64
|
+
full_mode_args.add_argument("-name_split", action="store", dest="name_split",
|
|
65
|
+
help="substring used to split the filename and extract the genome name ('_combined.gff3' or '.gff').",
|
|
66
|
+
required=False)
|
|
67
|
+
full_mode_args.add_argument("-pid", action="store", dest="pident", type=float, default=0.95,
|
|
68
|
+
help="Default 0.95: Pident threshold for clustering.",
|
|
69
|
+
required=False)
|
|
70
|
+
full_mode_args.add_argument("-len_diff", action="store", dest="len_diff", type=float, default=0.80,
|
|
71
|
+
help="Default 0.80: Minimum length difference between clustered sequences - (-s) threshold for CD-HIT clustering.",
|
|
72
|
+
required=False)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
###Partial-Mode Arguments
|
|
76
|
+
partial_mode_args = parser.add_argument_group('Partial-Mode Arguments - Required when "-run_mode Partial" is used')
|
|
77
|
+
partial_mode_args.add_argument('-cluster_file', action='store', dest='cluster_file',
|
|
78
|
+
help='Clustering output file containing CD-HIT, TSV or CSV Edge List',
|
|
79
|
+
required=False)
|
|
80
|
+
|
|
81
|
+
###Grouping Arguments
|
|
82
|
+
grouping_args = parser.add_argument_group('Grouping Arguments - Use to fine-tune grouping of genes after clustering')
|
|
83
|
+
grouping_args.add_argument('-reclustered', action='store', dest='reclustered', help='Clustering output file from secondary round of clustering',
|
|
84
|
+
required=False)
|
|
85
|
+
grouping_args.add_argument('-seq_tag', action='store', dest='sequence_tag', default='StORF',
|
|
86
|
+
help='Default - "StORF": Unique identifier to be used to distinguish the second of two rounds of clustered sequences',
|
|
87
|
+
required=False)
|
|
88
|
+
grouping_args.add_argument('-groups', action="store", dest='core_groups', default="99,95,15",
|
|
89
|
+
help='Default - (\'99,95,15\'): Gene family groups to use',
|
|
90
|
+
required=False)
|
|
91
|
+
|
|
92
|
+
###Output Arguments
|
|
93
|
+
output_args = parser.add_argument_group('Output Parameters')
|
|
94
|
+
output_args.add_argument('-w', action="store", dest='write_families', default=None,
|
|
95
|
+
help='Default - No output: Output sequences of identified families (provide levels at which to output "-w 99,95"'
|
|
96
|
+
' - Must provide FASTA file with -fasta',
|
|
97
|
+
required=False)
|
|
98
|
+
output_args.add_argument('-con', action="store", dest='con_core', default=None,
|
|
99
|
+
help='Default - No output: Output aligned and concatinated sequences of identified families - used for MSA (provide levels at which to output "-w 99,95"'
|
|
100
|
+
' - Must provide FASTA file with -fasta',
|
|
101
|
+
required=False)
|
|
102
|
+
output_args.add_argument('-original_fasta', action='store', dest='original_fasta',
|
|
103
|
+
help='FASTA file to use in conjunction with "-w" or "-con" when running in Partial Mode.',
|
|
104
|
+
required=False)
|
|
105
|
+
output_args.add_argument('-gpa', action='store', dest='gene_presence_absence_out', help='Default - False: If selected, a Roary formatted gene_presence_absence.csv will be created - Required for Coinfinder and other downstream tools',
|
|
106
|
+
required=False)
|
|
107
|
+
|
|
108
|
+
### Misc Arguments
|
|
109
|
+
misc = parser.add_argument_group('Misc')
|
|
110
|
+
misc.add_argument('-verbose', action='store', dest='verbose', default=False, type=eval, choices=[True, False],
|
|
111
|
+
help='Default - False: Print out runtime messages',
|
|
112
|
+
required = False)
|
|
113
|
+
misc.add_argument('-v', action='store_true', dest='version',
|
|
114
|
+
help='Default - False: Print out version number and exit',
|
|
115
|
+
required=False)
|
|
116
|
+
|
|
117
|
+
options = parser.parse_args()
|
|
118
|
+
|
|
119
|
+
### Checking all required parameters are provided by user
|
|
120
|
+
if options.run_mode == 'Full':
|
|
121
|
+
required_full_mode = [options.input_type, options.input_dir, options.name_split, options.clust_tool,
|
|
122
|
+
options.pident, options.len_diff]
|
|
123
|
+
if all(required_full_mode):
|
|
124
|
+
# Proceed with the Full mode
|
|
125
|
+
pass
|
|
126
|
+
else:
|
|
127
|
+
missing_options = [opt for opt in
|
|
128
|
+
['input_type', 'input_dir', 'name_split', 'clust_tool', 'pident', 'len_diff'] if
|
|
129
|
+
not options.__dict__[opt]]
|
|
130
|
+
print(f"Missing required options for Full mode: {', '.join(missing_options)}")
|
|
131
|
+
elif options.run_mode == 'Partial':
|
|
132
|
+
required_partial_mode = [options.cluster_file, ]
|
|
133
|
+
if all(required_partial_mode):
|
|
134
|
+
# Proceed with the Partial mode
|
|
135
|
+
pass
|
|
136
|
+
else:
|
|
137
|
+
missing_options = [opt for opt in
|
|
138
|
+
['cluster_file',] if
|
|
139
|
+
not options.__dict__[opt]]
|
|
140
|
+
print(f"Missing required options for Partial mode: {', '.join(missing_options)}")
|
|
141
|
+
|
|
142
|
+
if options.clust_tool == 'CD-HIT':
|
|
143
|
+
clust_affix = '.clstr'
|
|
144
|
+
elif options.clust_tool == 'TSV':
|
|
145
|
+
clust_affix = '.tsv'
|
|
146
|
+
elif options.clust_tool == 'CSV':
|
|
147
|
+
clust_affix = '.csv'
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
###External tool checks:
|
|
152
|
+
##MAFFT
|
|
153
|
+
if options.con_core == True:
|
|
154
|
+
if is_tool_installed('mafft'):
|
|
155
|
+
if options.verbose == True:
|
|
156
|
+
print("mafft is installed. Proceeding with alignment.")
|
|
157
|
+
else:
|
|
158
|
+
exit("mafft is not installed. Please install mafft to proceed.")
|
|
159
|
+
##CD-HIT
|
|
160
|
+
if options.clust_tool == 'CD-HIT':
|
|
161
|
+
if is_tool_installed('cd-hit'):
|
|
162
|
+
if options.verbose == True:
|
|
163
|
+
print("cd-hit is installed. Proceeding with clustering.")
|
|
164
|
+
else:
|
|
165
|
+
exit("cd-hit is not installed. Please install cd-hit to proceed.")
|
|
166
|
+
|
|
167
|
+
if options.write_families != None and options.original_fasta == False:
|
|
168
|
+
exit("-fasta must br provided if -w is used")
|
|
169
|
+
|
|
170
|
+
options.core_groups = options.core_groups + ',0'
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if options.cluster_file:
|
|
174
|
+
options.cluster_file = fix_path(options.cluster_file)
|
|
175
|
+
if options.reclustered:
|
|
176
|
+
options.reclustered = fix_path(options.reclustered)
|
|
177
|
+
if options.input_dir:
|
|
178
|
+
options.input_dir = fix_path(options.input_dir)
|
|
179
|
+
if options.output_dir:
|
|
180
|
+
options.output_dir = fix_path(options.output_dir)
|
|
181
|
+
|
|
182
|
+
output_path = os.path.abspath(options.output_dir)
|
|
183
|
+
combined_out_file = os.path.join(output_path, "combined_sequences.fasta")
|
|
184
|
+
clustering_output = os.path.join(output_path, 'clustering_' + options.clust_tool)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
if options.run_mode == 'Full':
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if options.input_type == 'separate':
|
|
192
|
+
read_separate_files(options.input_dir, options.name_split, combined_out_file)
|
|
193
|
+
else:
|
|
194
|
+
read_combined_files(options.input_dir, options.name_split, combined_out_file)
|
|
195
|
+
|
|
196
|
+
run_cd_hit(combined_out_file, clustering_output, options)
|
|
197
|
+
class clustering_options:
|
|
198
|
+
def __init__(self):
|
|
199
|
+
self.cluster_format = options.clust_tool
|
|
200
|
+
self.reclustered = options.reclustered
|
|
201
|
+
self.sequence_tag = options.sequence_tag
|
|
202
|
+
self.core_groups = '99,95,15,0'
|
|
203
|
+
self.clusters = clustering_output + clust_affix
|
|
204
|
+
self.gene_presence_absence_out = options.gene_presence_absence_out
|
|
205
|
+
self.write_families = options.write_families
|
|
206
|
+
self.con_core = options.con_core
|
|
207
|
+
self.fasta = combined_out_file
|
|
208
|
+
self.verbose = options.verbose
|
|
209
|
+
|
|
210
|
+
clustering_options = clustering_options()
|
|
211
|
+
|
|
212
|
+
elif options.run_mode == 'Partial':
|
|
213
|
+
class clustering_options:
|
|
214
|
+
def __init__(self):
|
|
215
|
+
self.cluster_format = options.clust_tool
|
|
216
|
+
self.reclustered = options.reclustered
|
|
217
|
+
self.sequence_tag = options.sequence_tag
|
|
218
|
+
self.core_groups = '99,95,15,0'
|
|
219
|
+
self.clusters = options.cluster_file
|
|
220
|
+
self.gene_presence_absence_out = options.gene_presence_absence_out
|
|
221
|
+
self.write_families = options.write_families
|
|
222
|
+
self.con_core = options.con_core
|
|
223
|
+
self.fasta = options.original_fasta
|
|
224
|
+
self.verbose = options.verbose
|
|
225
|
+
|
|
226
|
+
clustering_options = clustering_options()
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
cluster(clustering_options)
|
|
232
|
+
|
|
233
|
+
print("Thank you for using PyamilySeq -- A detailed user manual can be found at https://github.com/NickJD/PyamilySeq\n"
|
|
234
|
+
"Please report any issues to: https://github.com/NickJD/PyamilySeq/issues\n#####")
|
|
235
|
+
|
|
236
|
+
if __name__ == "__main__":
|
|
237
|
+
main()
|