bscampp 1.0.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.
Files changed (35) hide show
  1. bscampp-1.0.1/CHANGELOG.md +13 -0
  2. bscampp-1.0.1/LICENSE +21 -0
  3. bscampp-1.0.1/MANIFEST.in +8 -0
  4. bscampp-1.0.1/PKG-INFO +234 -0
  5. bscampp-1.0.1/README.md +182 -0
  6. bscampp-1.0.1/bscampp/__init__.py +68 -0
  7. bscampp-1.0.1/bscampp/configs.py +169 -0
  8. bscampp-1.0.1/bscampp/default.config +5 -0
  9. bscampp-1.0.1/bscampp/functions.py +409 -0
  10. bscampp-1.0.1/bscampp/init_configs.py +93 -0
  11. bscampp-1.0.1/bscampp/jobs.py +198 -0
  12. bscampp-1.0.1/bscampp/pipeline.py +249 -0
  13. bscampp-1.0.1/bscampp/tools/epa-ng +0 -0
  14. bscampp-1.0.1/bscampp/tools/hamming_distance/CMakeLists.txt +13 -0
  15. bscampp-1.0.1/bscampp/tools/hamming_distance/fragment_hamming +0 -0
  16. bscampp-1.0.1/bscampp/tools/hamming_distance/hamming +0 -0
  17. bscampp-1.0.1/bscampp/tools/hamming_distance/homology +0 -0
  18. bscampp-1.0.1/bscampp/tools/hamming_distance/src/fragment_hamming.cpp +180 -0
  19. bscampp-1.0.1/bscampp/tools/hamming_distance/src/fragment_tree_hamming.cpp +183 -0
  20. bscampp-1.0.1/bscampp/tools/hamming_distance/src/fragment_tree_hamming_new.cpp +214 -0
  21. bscampp-1.0.1/bscampp/tools/hamming_distance/src/homology.cpp +179 -0
  22. bscampp-1.0.1/bscampp/tools/hamming_distance/src/new_hamming.cpp +161 -0
  23. bscampp-1.0.1/bscampp/tools/pplacer +0 -0
  24. bscampp-1.0.1/bscampp/utils.py +914 -0
  25. bscampp-1.0.1/bscampp.egg-info/PKG-INFO +234 -0
  26. bscampp-1.0.1/bscampp.egg-info/SOURCES.txt +33 -0
  27. bscampp-1.0.1/bscampp.egg-info/dependency_links.txt +1 -0
  28. bscampp-1.0.1/bscampp.egg-info/entry_points.txt +3 -0
  29. bscampp-1.0.1/bscampp.egg-info/requires.txt +4 -0
  30. bscampp-1.0.1/bscampp.egg-info/top_level.txt +1 -0
  31. bscampp-1.0.1/pyproject.toml +48 -0
  32. bscampp-1.0.1/requirements.txt +4 -0
  33. bscampp-1.0.1/run_bscampp.py +5 -0
  34. bscampp-1.0.1/setup.cfg +4 -0
  35. bscampp-1.0.1/tests/test_dry_run.py +11 -0
@@ -0,0 +1,13 @@
1
+ # BSCAMPP v1.0.1
2
+ 1. Bumped version to full release.
3
+ 2. Completed examples for display in `bscampp --help`.
4
+
5
+ # BSCAMPP v1.0.1b
6
+ 1. Removed redundant codes and fixed missing variables.
7
+ 2. Added badges for PyPI installation and current Python Build, etc.
8
+ 3. Added a single Pytest for dry-running BSCAMPP under `tests/`.
9
+ 4. For 3, added the `dry_run` parameter to function `pipeline.py:bscampp_pipeline`.
10
+
11
+ # BSCAMPP v1.0.1a
12
+ 1. Completed features with both `epa-ng` and `pplacer` support.
13
+ 2. Refactorized all codes and worked out the PyPI installation for release.
bscampp-1.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 ewedell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ include README.md
2
+ include CHANGELOG.md
3
+ include run_bscampp.py
4
+ include bscampp/default.config
5
+ include requirements.txt
6
+ graft bscampp/tools
7
+ prune */__pycache__
8
+ global-exclude *.py[cod]
bscampp-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.2
2
+ Name: bscampp
3
+ Version: 1.0.1
4
+ Summary: BSCAMPP - A Scalable Phylogenetic Placement Tool
5
+ Author-email: Eleanor Wedell <ewedell2@illinois.edu>, Chengze Shen <chengze5@illinois.edu>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2022 ewedell
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/ewedell/BSCAMPP
29
+ Project-URL: Changelog, https://github.com/ewedell/BSCAMPP/CHANGELOG.md
30
+ Classifier: Development Status :: 4 - Beta
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
35
+ Classifier: Topic :: Software Development
36
+ Classifier: License :: OSI Approved :: GNU General Public License (GPL)
37
+ Classifier: Programming Language :: Python
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.7
40
+ Classifier: Programming Language :: Python :: 3.8
41
+ Classifier: Programming Language :: Python :: 3.9
42
+ Classifier: Programming Language :: Python :: 3.10
43
+ Classifier: Programming Language :: Python :: 3.11
44
+ Classifier: Programming Language :: Python :: 3.12
45
+ Requires-Python: >=3.7
46
+ Description-Content-Type: text/markdown
47
+ License-File: LICENSE
48
+ Requires-Dist: ConfigParser>=5.0.0
49
+ Requires-Dist: numpy>=1.21.6
50
+ Requires-Dist: treeswift>=1.1.45
51
+ Requires-Dist: taxtastic>=0.9.3
52
+
53
+ # BSCAMPP - A Scalable Phylogenetic Placement Method and Framework
54
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bscampp)](https://pypi.org/project/bscampp/)
55
+ [![PyPI - Version](https://img.shields.io/pypi/v/bscampp?color=blue)](https://pypi.org/project/bscampp/#history)
56
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/ewedell/BSCAMPP/python-package.yml?branch=main&label=build)](https://github.com/ewedell/BSCAMPP/)
57
+ [![PyPI - License](https://img.shields.io/pypi/l/bscampp?color=blue)](https://github.com/ewedell/BSCAMPP/blob/main/LICENSE)
58
+ [![Changelog](https://img.shields.io/badge/CHANGELOG-grey)](https://github.com/ewedell/BSCAMPP/blob/main/CHANGELOG.md)
59
+
60
+ **Table of Contents**
61
+ 1. [Overview](#overview)
62
+ 2. [Installation](#installation)
63
+ 3. [Usage](#usage)
64
+ 4. [Example Code and Data](#example-code-and-data)
65
+
66
+ # Overview
67
+ * **Inputs**
68
+ 1. Reference tree to place sequences into.
69
+ 2. Alignment of reference sequences.
70
+ 3. Alignment of query sequences (can be combined with ii.).
71
+ 4. Tree info file.
72
+ - (EPA-ng as base method), RAxML-ng info file, typically with suffix `.bestModel`.
73
+ - (pplacer as base method), RAxML-ng or FastTree log file.
74
+ * **Output**
75
+ 1. Placement results of query sequences in the reference tree in `.jplace` format.
76
+
77
+
78
+ BSCAMPP is an extension and scalable solution to its previous method [SCAMPP](https://github.com/chry04/PLUSplacer) for phylogenetic placement.
79
+ BSCAMPP achieves some magnitudes of speedup compared to the SCAMPP framework.
80
+ The core algorithm is described in detail at <https://doi.org/10.1101/2022.10.26.513936>.
81
+ In short, BSCAMPP in default uses EPA-ng as the base placement method, allowing it to scale to placement trees of up to ~200,000 leaves.
82
+ BSCAMPP achieves this by extracting appropriate subtrees and assigning each query to its most fitting subtree.
83
+
84
+ BSCAMPP essentially is a divide-and-conquer framework and can be used with any base placement methods (e.g., `pplacer` as well).
85
+ Currently, BSCAMPP is implemented with `epa-ng` and `pplacer`.
86
+
87
+ It is recommended that BSCAMPP be used with subtrees of size 2000 and with 5 votes based on current best results, especially if sequences
88
+ are fragmentary. Defaults for the subtree size and number of votes are set to 2,000 and 5 respectively (see [Usage](#usage) for more details
89
+ on customizing BSCAMPP).
90
+
91
+ # Installation
92
+ BSCAMPP was tested on **Python 3.7 to 3.12**. There are two ways to install and use BSCAMPP: (1) with PyPI, or
93
+ (2) from this GitHub repository. If you have any difficulties installing or running BSCAMPP, please contact Eleanor Wedell
94
+ (ewedell@illinois.edu).
95
+
96
+ ### External requirements
97
+ EPA-ng and/or pplacer are requirements to run BSCAMPP since BSCAMPP will use them as the base phylogenetic placement methods.
98
+ By default, BSCAMPP will search for binary executables of `pplacer` and `epa-ng` in the user's environment when running for the first time.
99
+ We also included a compiled version of `pplacer` for the Linux system under `bscampp/tools`.
100
+
101
+ ### (1) Install with `pip` (Coming soon)
102
+ The easiest way to install BSCAMPP is to use `pip install`. This will also install all required Python packages.
103
+
104
+ ```bash
105
+ # 1. install with pip (--user if no root access)
106
+ pip install bscampp [--user]
107
+
108
+ # 2. Two binary executables will be installed. The first time
109
+ # running any will create a config file at
110
+ # ~/.bscampp/main.config that resolves the links to all
111
+ # external software (e.g., epa-ng, pplacer)
112
+ bscampp [-h] # or
113
+ run_bscampp.py [-h]
114
+ ```
115
+
116
+ ### (2) Install from GitHub
117
+ Alternatively, the user can clone this GitHub repository and install the required packages manually.
118
+
119
+ #### Requirements
120
+ ```bash
121
+ python>=3.7
122
+ ConfigParser>=5.0.0
123
+ numpy>=1.21.6
124
+ treeswift>=1.1.45
125
+ taxtastic>=0.9.3
126
+ ```
127
+
128
+ ```bash
129
+ # 1. Close the GitHub repo
130
+ git clone https://github.com/ewedell/BSCAMPP.git
131
+
132
+ # 2. Install all requirements
133
+ pip install -r requirements.txt
134
+
135
+ # 3. Execute BSCAMPP executable `run_bscampp.py`
136
+ python run_bscampp.py [-h]
137
+ ```
138
+
139
+ # Usage
140
+ All parameter settings can be found by running
141
+ ```bash
142
+ run_bscampp.py -h
143
+ ```
144
+
145
+ ### (1) Default case (`epa-ng`)
146
+ ```bash
147
+ run_bscampp.py -i [raxml best model] -t [reference tree] -a [alignment file]
148
+ ```
149
+ To run BSCAMPP in its default mode with EPA-ng. `[alignment file]` should contain both sequences from the placement tree and
150
+ the query sequences to be placed. This will create an output directory `bscampp_output` and write the placement results to
151
+ `bscampp_output/bscampp_result.jplace`.
152
+
153
+ ### (2) Separately giving query alignment and finer control of outputs
154
+ ```bash
155
+ run_bscampp.py -i [raxml best model] -t [reference tree] -a [reference alignment] \
156
+ -q [query sequence alignment] -d [output directory] -o [output name] \
157
+ --threads [num cpus]
158
+ ```
159
+
160
+ ### (3) Using `pplacer` as the base placement method
161
+ ```bash
162
+ run_bscampp.py -i [logfile from either RAxML/FastTree] -t [reference tree] \
163
+ -a [reference alignment] -q [query sequence alignment]
164
+ ```
165
+
166
+ ### More comprehensive usage
167
+ ```bash
168
+ > usage: run_bscampp.py [-h] [-v] [--placement-method {epa-ng,pplacer}] -i
169
+ > INFO_PATH -t TREE_PATH -a ALN_PATH [-q QALN_PATH]
170
+ > [-d OUTDIR] [-o OUTNAME] [--threads NUM_CPUS] [-m MODEL]
171
+ > [-b SUBTREESIZE] [-V VOTES]
172
+ > [--similarityflag SIMILARITYFLAG] [-n TMPFILENBR]
173
+ > [--fragmentflag FRAGMENTFLAG] [--keeptemp KEEPTEMP]
174
+ >
175
+ > This program runs BSCAMPP, a scalable phylogenetic placement framework that scales EPA-ng/pplacer to very large tree placement.
176
+ >
177
+ > options:
178
+ > -h, --help show this help message and exit
179
+ > -v, --version show program's version number and exit
180
+ >
181
+ > BASIC PARAMETERS:
182
+ > These are the basic parameters for BSCAMPP.
183
+ >
184
+ > --placement-method {epa-ng,pplacer}
185
+ > The base placement method to use. Default: epa-ng
186
+ > -i INFO_PATH, --info INFO_PATH, --info-path INFO_PATH
187
+ > Path to model parameters. E.g., .bestModel from
188
+ > RAxML/RAxML-ng
189
+ > -t TREE_PATH, --tree TREE_PATH, --tree-path TREE_PATH
190
+ > Path to reference tree with estimated branch lengths
191
+ > -a ALN_PATH, --alignment ALN_PATH, --aln-path ALN_PATH
192
+ > Path for reference sequence alignment in FASTA format.
193
+ > Optionally with query sequences. Query alignment can
194
+ > be specified with --qaln-path
195
+ > -q QALN_PATH, --qalignment QALN_PATH, --qaln-path QALN_PATH
196
+ > Optionally provide path to query sequence alignment in
197
+ > FASTA format. Default: None
198
+ > -d OUTDIR, --outdir OUTDIR
199
+ > Directory path for output. Default: bscampp_output/
200
+ > -o OUTNAME, --output OUTNAME
201
+ > Output file name. Default: bscampp_result.jplace
202
+ > --threads NUM_CPUS, --num-cpus NUM_CPUS
203
+ > Number of cores for parallelization, default: -1 (all)
204
+ >
205
+ > ADVANCE PARAMETERS:
206
+ > These parameters control how BSCAMPP is run. The default values are set based on experiments.
207
+ >
208
+ > -m MODEL, --model MODEL
209
+ > Model used for edge distances. Default: GTR
210
+ > -b SUBTREESIZE, --subtreesize SUBTREESIZE
211
+ > Integer size of the subtree. Default: 2000
212
+ > -V VOTES, --votes VOTES
213
+ > Number of votes per query sequence. Default: 5
214
+ > --similarityflag SIMILARITYFLAG
215
+ > Boolean, True if maximizing sequence similarity
216
+ > instead of simple Hamming distance (ignoring gap sites
217
+ > in the query). Default: True
218
+ >
219
+ > MISCELLANEOUS PARAMETERS:
220
+ > -n TMPFILENBR, --tmpfilenbr TMPFILENBR
221
+ > Temporary file indexing. Default: 0
222
+ > --fragmentflag FRAGMENTFLAG
223
+ > If queries contains fragments. Default: True
224
+ > --keeptemp KEEPTEMP Boolean, True to keep all temporary files. Default:
225
+ False
226
+ ```
227
+
228
+
229
+ # Example Code and Data
230
+ Example script and data are provided in this GitHub repository in `examples/`. The data is originally from the [RNAsim-VS datasets](https://doi.org/10.1093/sysbio/syz063).
231
+ * `examples/run.sh`: contains a simple script to test BSCAMPP with `epa-ng` or `pplacer`, placing 200 query sequences to a 10000-leaf placement tree.
232
+ The info file is from RAxML-ng when running `epa-ng`, and from FastTree-2 when running `pplacer`.
233
+ - `run.sh` will invoke BSCAMPP with `epa-ng`.
234
+ - `run.sh pplacer` will invoke BSCAMPP with `pplacer`.
@@ -0,0 +1,182 @@
1
+ # BSCAMPP - A Scalable Phylogenetic Placement Method and Framework
2
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/bscampp)](https://pypi.org/project/bscampp/)
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/bscampp?color=blue)](https://pypi.org/project/bscampp/#history)
4
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/ewedell/BSCAMPP/python-package.yml?branch=main&label=build)](https://github.com/ewedell/BSCAMPP/)
5
+ [![PyPI - License](https://img.shields.io/pypi/l/bscampp?color=blue)](https://github.com/ewedell/BSCAMPP/blob/main/LICENSE)
6
+ [![Changelog](https://img.shields.io/badge/CHANGELOG-grey)](https://github.com/ewedell/BSCAMPP/blob/main/CHANGELOG.md)
7
+
8
+ **Table of Contents**
9
+ 1. [Overview](#overview)
10
+ 2. [Installation](#installation)
11
+ 3. [Usage](#usage)
12
+ 4. [Example Code and Data](#example-code-and-data)
13
+
14
+ # Overview
15
+ * **Inputs**
16
+ 1. Reference tree to place sequences into.
17
+ 2. Alignment of reference sequences.
18
+ 3. Alignment of query sequences (can be combined with ii.).
19
+ 4. Tree info file.
20
+ - (EPA-ng as base method), RAxML-ng info file, typically with suffix `.bestModel`.
21
+ - (pplacer as base method), RAxML-ng or FastTree log file.
22
+ * **Output**
23
+ 1. Placement results of query sequences in the reference tree in `.jplace` format.
24
+
25
+
26
+ BSCAMPP is an extension and scalable solution to its previous method [SCAMPP](https://github.com/chry04/PLUSplacer) for phylogenetic placement.
27
+ BSCAMPP achieves some magnitudes of speedup compared to the SCAMPP framework.
28
+ The core algorithm is described in detail at <https://doi.org/10.1101/2022.10.26.513936>.
29
+ In short, BSCAMPP in default uses EPA-ng as the base placement method, allowing it to scale to placement trees of up to ~200,000 leaves.
30
+ BSCAMPP achieves this by extracting appropriate subtrees and assigning each query to its most fitting subtree.
31
+
32
+ BSCAMPP essentially is a divide-and-conquer framework and can be used with any base placement methods (e.g., `pplacer` as well).
33
+ Currently, BSCAMPP is implemented with `epa-ng` and `pplacer`.
34
+
35
+ It is recommended that BSCAMPP be used with subtrees of size 2000 and with 5 votes based on current best results, especially if sequences
36
+ are fragmentary. Defaults for the subtree size and number of votes are set to 2,000 and 5 respectively (see [Usage](#usage) for more details
37
+ on customizing BSCAMPP).
38
+
39
+ # Installation
40
+ BSCAMPP was tested on **Python 3.7 to 3.12**. There are two ways to install and use BSCAMPP: (1) with PyPI, or
41
+ (2) from this GitHub repository. If you have any difficulties installing or running BSCAMPP, please contact Eleanor Wedell
42
+ (ewedell@illinois.edu).
43
+
44
+ ### External requirements
45
+ EPA-ng and/or pplacer are requirements to run BSCAMPP since BSCAMPP will use them as the base phylogenetic placement methods.
46
+ By default, BSCAMPP will search for binary executables of `pplacer` and `epa-ng` in the user's environment when running for the first time.
47
+ We also included a compiled version of `pplacer` for the Linux system under `bscampp/tools`.
48
+
49
+ ### (1) Install with `pip` (Coming soon)
50
+ The easiest way to install BSCAMPP is to use `pip install`. This will also install all required Python packages.
51
+
52
+ ```bash
53
+ # 1. install with pip (--user if no root access)
54
+ pip install bscampp [--user]
55
+
56
+ # 2. Two binary executables will be installed. The first time
57
+ # running any will create a config file at
58
+ # ~/.bscampp/main.config that resolves the links to all
59
+ # external software (e.g., epa-ng, pplacer)
60
+ bscampp [-h] # or
61
+ run_bscampp.py [-h]
62
+ ```
63
+
64
+ ### (2) Install from GitHub
65
+ Alternatively, the user can clone this GitHub repository and install the required packages manually.
66
+
67
+ #### Requirements
68
+ ```bash
69
+ python>=3.7
70
+ ConfigParser>=5.0.0
71
+ numpy>=1.21.6
72
+ treeswift>=1.1.45
73
+ taxtastic>=0.9.3
74
+ ```
75
+
76
+ ```bash
77
+ # 1. Close the GitHub repo
78
+ git clone https://github.com/ewedell/BSCAMPP.git
79
+
80
+ # 2. Install all requirements
81
+ pip install -r requirements.txt
82
+
83
+ # 3. Execute BSCAMPP executable `run_bscampp.py`
84
+ python run_bscampp.py [-h]
85
+ ```
86
+
87
+ # Usage
88
+ All parameter settings can be found by running
89
+ ```bash
90
+ run_bscampp.py -h
91
+ ```
92
+
93
+ ### (1) Default case (`epa-ng`)
94
+ ```bash
95
+ run_bscampp.py -i [raxml best model] -t [reference tree] -a [alignment file]
96
+ ```
97
+ To run BSCAMPP in its default mode with EPA-ng. `[alignment file]` should contain both sequences from the placement tree and
98
+ the query sequences to be placed. This will create an output directory `bscampp_output` and write the placement results to
99
+ `bscampp_output/bscampp_result.jplace`.
100
+
101
+ ### (2) Separately giving query alignment and finer control of outputs
102
+ ```bash
103
+ run_bscampp.py -i [raxml best model] -t [reference tree] -a [reference alignment] \
104
+ -q [query sequence alignment] -d [output directory] -o [output name] \
105
+ --threads [num cpus]
106
+ ```
107
+
108
+ ### (3) Using `pplacer` as the base placement method
109
+ ```bash
110
+ run_bscampp.py -i [logfile from either RAxML/FastTree] -t [reference tree] \
111
+ -a [reference alignment] -q [query sequence alignment]
112
+ ```
113
+
114
+ ### More comprehensive usage
115
+ ```bash
116
+ > usage: run_bscampp.py [-h] [-v] [--placement-method {epa-ng,pplacer}] -i
117
+ > INFO_PATH -t TREE_PATH -a ALN_PATH [-q QALN_PATH]
118
+ > [-d OUTDIR] [-o OUTNAME] [--threads NUM_CPUS] [-m MODEL]
119
+ > [-b SUBTREESIZE] [-V VOTES]
120
+ > [--similarityflag SIMILARITYFLAG] [-n TMPFILENBR]
121
+ > [--fragmentflag FRAGMENTFLAG] [--keeptemp KEEPTEMP]
122
+ >
123
+ > This program runs BSCAMPP, a scalable phylogenetic placement framework that scales EPA-ng/pplacer to very large tree placement.
124
+ >
125
+ > options:
126
+ > -h, --help show this help message and exit
127
+ > -v, --version show program's version number and exit
128
+ >
129
+ > BASIC PARAMETERS:
130
+ > These are the basic parameters for BSCAMPP.
131
+ >
132
+ > --placement-method {epa-ng,pplacer}
133
+ > The base placement method to use. Default: epa-ng
134
+ > -i INFO_PATH, --info INFO_PATH, --info-path INFO_PATH
135
+ > Path to model parameters. E.g., .bestModel from
136
+ > RAxML/RAxML-ng
137
+ > -t TREE_PATH, --tree TREE_PATH, --tree-path TREE_PATH
138
+ > Path to reference tree with estimated branch lengths
139
+ > -a ALN_PATH, --alignment ALN_PATH, --aln-path ALN_PATH
140
+ > Path for reference sequence alignment in FASTA format.
141
+ > Optionally with query sequences. Query alignment can
142
+ > be specified with --qaln-path
143
+ > -q QALN_PATH, --qalignment QALN_PATH, --qaln-path QALN_PATH
144
+ > Optionally provide path to query sequence alignment in
145
+ > FASTA format. Default: None
146
+ > -d OUTDIR, --outdir OUTDIR
147
+ > Directory path for output. Default: bscampp_output/
148
+ > -o OUTNAME, --output OUTNAME
149
+ > Output file name. Default: bscampp_result.jplace
150
+ > --threads NUM_CPUS, --num-cpus NUM_CPUS
151
+ > Number of cores for parallelization, default: -1 (all)
152
+ >
153
+ > ADVANCE PARAMETERS:
154
+ > These parameters control how BSCAMPP is run. The default values are set based on experiments.
155
+ >
156
+ > -m MODEL, --model MODEL
157
+ > Model used for edge distances. Default: GTR
158
+ > -b SUBTREESIZE, --subtreesize SUBTREESIZE
159
+ > Integer size of the subtree. Default: 2000
160
+ > -V VOTES, --votes VOTES
161
+ > Number of votes per query sequence. Default: 5
162
+ > --similarityflag SIMILARITYFLAG
163
+ > Boolean, True if maximizing sequence similarity
164
+ > instead of simple Hamming distance (ignoring gap sites
165
+ > in the query). Default: True
166
+ >
167
+ > MISCELLANEOUS PARAMETERS:
168
+ > -n TMPFILENBR, --tmpfilenbr TMPFILENBR
169
+ > Temporary file indexing. Default: 0
170
+ > --fragmentflag FRAGMENTFLAG
171
+ > If queries contains fragments. Default: True
172
+ > --keeptemp KEEPTEMP Boolean, True to keep all temporary files. Default:
173
+ False
174
+ ```
175
+
176
+
177
+ # Example Code and Data
178
+ Example script and data are provided in this GitHub repository in `examples/`. The data is originally from the [RNAsim-VS datasets](https://doi.org/10.1093/sysbio/syz063).
179
+ * `examples/run.sh`: contains a simple script to test BSCAMPP with `epa-ng` or `pplacer`, placing 200 query sequences to a 10000-leaf placement tree.
180
+ The info file is from RAxML-ng when running `epa-ng`, and from FastTree-2 when running `pplacer`.
181
+ - `run.sh` will invoke BSCAMPP with `epa-ng`.
182
+ - `run.sh pplacer` will invoke BSCAMPP with `pplacer`.
@@ -0,0 +1,68 @@
1
+ ############################################################
2
+ #
3
+ # Init file for BSCAMPP, using the __init__.py from
4
+ # SEPP as the original template. Current adaption comes
5
+ # from https://github.com/c5shen/TIPP3.git
6
+ #
7
+ ############################################################
8
+ from operator import itemgetter
9
+ import logging, os
10
+
11
+ # update system recursion limit to avoid issues
12
+ # not really needed for BSCAMPP but safe to update here
13
+ os.sys.setrecursionlimit(1000000)
14
+
15
+ __version__ = "1.0.1"
16
+ _INSTALL_PATH = __path__[0]
17
+
18
+ # global variables to store all loggers
19
+ __set_loggers = set()
20
+
21
+ # obtain the current logging level, default to INFO
22
+ def get_logging_level(logging_level='info'):
23
+ logging_level_map = {
24
+ 'DEBUG': logging.DEBUG, 'INFO': logging.INFO,
25
+ 'WARNING': logging.WARNING, 'ERROR': logging.ERROR,
26
+ 'CRITICAL': logging.CRITICAL,
27
+ }
28
+ # obtain from environment variable to determine logging level, if
29
+ # set by the user
30
+ env_level = os.getenv('BSCAMPP_LOGGING_LEVEL')
31
+ if env_level is not None:
32
+ ll = env_level.upper()
33
+ else:
34
+ ll = logging_level.upper()
35
+ # default to INFO if ll is not defined
36
+ return logging_level_map.get(ll, logging.INFO)
37
+
38
+ # obtain a logger for a given file
39
+ def get_logger(name='bscampp', log_path=None, logging_level='info'):
40
+ logger = logging.getLogger(name)
41
+ if name not in __set_loggers:
42
+ # set up a new logger for a name not in __set_loggers yet
43
+ level = get_logging_level(logging_level)
44
+ logging_formatter = logging.Formatter(
45
+ ("[%(asctime)s] %(filename)s (line %(lineno)d):"
46
+ " %(levelname) 8s: %(message)s"))
47
+ logging_formatter.datefmt = "%H:%M:%S"
48
+ logger.setLevel(level)
49
+
50
+ # logging to stdout
51
+ if log_path is None:
52
+ ch = logging.StreamHandler()
53
+ else:
54
+ # use FileHandler for logging
55
+ ch = logging.FileHandler(log_path, mode='a')
56
+ ch.setLevel(level)
57
+ ch.setFormatter(logging_formatter)
58
+ logger.addHandler(ch)
59
+ __set_loggers.add(name)
60
+ return logger
61
+
62
+ # logging exception
63
+ def log_exception(logger):
64
+ import traceback, io
65
+ s = io.StringIO()
66
+ traceback.print_exc(None, s)
67
+ logger.error(s.getvalue())
68
+ exit(1)