phasegen 0.0.3b0__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.
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.1
2
+ Name: phasegen
3
+ Version: 0.0.3b0
4
+ Summary: Simulation and inference on exact solutions of coalescent distributions under diverse demographic scenarios.
5
+ License: MIT
6
+ Author: Sendrowski
7
+ Author-email: sendrowski.janek@gmail.com
8
+ Requires-Python: >=3.10,<3.13
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Dist: fastdfe (>=1.1.3)
15
+ Requires-Dist: jsonpickle (>=3.0.0,<4.0.0)
16
+ Requires-Dist: matplotlib (>=3.7.0,<4.0.0)
17
+ Requires-Dist: multiprocess (>=0.70.12,<0.71.0)
18
+ Requires-Dist: numpy (>=1.24.0,<2.0.0)
19
+ Requires-Dist: pandas (>=2.0.0,<3.0.0)
20
+ Requires-Dist: pyyaml (>=6.0,<7.0)
21
+ Requires-Dist: scipy (>=1.10.1,<2.0.0)
22
+ Requires-Dist: seaborn (>=0.13.0,<0.14.0)
23
+ Requires-Dist: tqdm (>=4.60.0,<5.0.0)
24
+ Requires-Dist: typing-extensions (>=4.5.0,<5.0.0)
25
+ Description-Content-Type: text/markdown
26
+
27
+ # PhaseGen <img align="right" width="100" src="https://raw.githubusercontent.com/Sendrowski/PhaseGen/master/docs/logo.png">
28
+
29
+ [![Documentation Status](https://readthedocs.org/projects/phasegen/badge/?version=latest)](https://phasegen.readthedocs.io/en/latest/?badge=latest)
30
+ [![PyPI version](https://badge.fury.io/py/phasegen.svg)](https://badge.fury.io/py/phasegen)
31
+
32
+
33
+ ``phasegen`` is a package for simulation and inference on exact solutions of coalescent distributions under diverse demographic scenarios. It used phase-type theory do so. ``phasegen`` supports a wide range of demographic models and coalescent tree statistics.
34
+
35
+ Please see the [documentation](https://phasegen.readthedocs.io/en/latest/) for all the details.
36
+
@@ -0,0 +1,9 @@
1
+ # PhaseGen <img align="right" width="100" src="https://raw.githubusercontent.com/Sendrowski/PhaseGen/master/docs/logo.png">
2
+
3
+ [![Documentation Status](https://readthedocs.org/projects/phasegen/badge/?version=latest)](https://phasegen.readthedocs.io/en/latest/?badge=latest)
4
+ [![PyPI version](https://badge.fury.io/py/phasegen.svg)](https://badge.fury.io/py/phasegen)
5
+
6
+
7
+ ``phasegen`` is a package for simulation and inference on exact solutions of coalescent distributions under diverse demographic scenarios. It used phase-type theory do so. ``phasegen`` supports a wide range of demographic models and coalescent tree statistics.
8
+
9
+ Please see the [documentation](https://phasegen.readthedocs.io/en/latest/) for all the details.
@@ -0,0 +1,225 @@
1
+ """
2
+ PhaseGen package.
3
+ """
4
+
5
+ __author__ = "Janek Sendrowski"
6
+ __contact__ = "sendrowski.janek@gmail.com"
7
+ __date__ = "2023-04-09"
8
+
9
+ __version__ = '0.0.3-beta'
10
+
11
+ import logging
12
+ import os
13
+ import sys
14
+
15
+ import jsonpickle.ext.numpy as jsonpickle_numpy
16
+ from tqdm import tqdm
17
+
18
+ # lower the verbosity of TensorFlow
19
+ if 'TF_CPP_MIN_LOG_LEVEL' not in os.environ:
20
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
21
+
22
+ # register handlers
23
+ jsonpickle_numpy.register_handlers()
24
+
25
+
26
+ class TqdmLoggingHandler(logging.Handler):
27
+ """
28
+ A logging handler that uses TQDM to display log messages.
29
+ """
30
+
31
+ def __init__(self, level=logging.NOTSET):
32
+ """
33
+ Initialize the handler.
34
+
35
+ :param level:
36
+ """
37
+ super().__init__(level)
38
+
39
+ def emit(self, record):
40
+ """
41
+ Emit a record.
42
+ """
43
+ try:
44
+ msg = self.format(record)
45
+
46
+ # we write to stderr to avoid as the progress bar
47
+ # to make the two work together
48
+ tqdm.write(msg, file=sys.stderr)
49
+ self.flush()
50
+ except Exception:
51
+ self.handleError(record)
52
+
53
+
54
+ class ColoredFormatter(logging.Formatter):
55
+ """
56
+ Colored formatter.
57
+ """
58
+
59
+ def __init__(self, *args, **kwargs):
60
+ """
61
+ Initialize the formatter.
62
+ """
63
+ super().__init__(*args, **kwargs)
64
+
65
+ self.colors = {
66
+ "DEBUG": "\033[36m", # Cyan
67
+ "INFO": "\033[32m", # Green
68
+ "WARNING": "\033[33m", # Yellow
69
+ "ERROR": "\033[31m", # Red
70
+ "CRITICAL": "\033[31m", # Red
71
+ }
72
+
73
+ self.reset = "\033[0m"
74
+
75
+ def format(self, record):
76
+ """
77
+ Format the record.
78
+ """
79
+ color = self.colors.get(record.levelname, self.reset)
80
+
81
+ formatted = super().format(record)
82
+
83
+ # remove package name
84
+ formatted = formatted.replace(record.name, record.name.split('.')[-1])
85
+
86
+ return f"{color}{formatted}{self.reset}"
87
+
88
+
89
+ # configure logger
90
+ logger = logging.getLogger('phasegen')
91
+
92
+ # don't propagate to the root logger
93
+ logger.propagate = False
94
+
95
+ # set to INFO by default
96
+ logger.setLevel(logging.INFO)
97
+
98
+ # let TQDM handle the logging
99
+ handler = TqdmLoggingHandler()
100
+
101
+ # define a Formatter with colors
102
+ formatter = ColoredFormatter('%(levelname)s:%(name)s: %(message)s')
103
+
104
+ handler.setFormatter(formatter)
105
+ logger.addHandler(handler)
106
+
107
+ from .distributions import PhaseTypeDistribution
108
+
109
+ from .distributions import Coalescent
110
+
111
+ from .demography import (
112
+ Demography,
113
+ Epoch,
114
+ DiscreteRateChanges,
115
+ PopSizeChanges,
116
+ PopSizeChange,
117
+ MigrationRateChanges,
118
+ MigrationRateChange,
119
+ SymmetricMigrationRateChanges,
120
+ PopulationSplit,
121
+ DiscretizedRateChanges,
122
+ DiscretizedRateChange,
123
+ ExponentialPopSizeChanges,
124
+ ExponentialRateChanges
125
+ )
126
+
127
+ from .coalescent_models import (
128
+ CoalescentModel,
129
+ StandardCoalescent,
130
+ BetaCoalescent,
131
+ DiracCoalescent
132
+ )
133
+
134
+ from .state_space import (
135
+ StateSpace,
136
+ DefaultStateSpace,
137
+ BlockCountingStateSpace
138
+ )
139
+
140
+ from .rewards import (
141
+ Reward,
142
+ DefaultReward,
143
+ NonDefaultReward,
144
+ TreeHeightReward,
145
+ TotalTreeHeightReward,
146
+ TotalBranchLengthReward,
147
+ UnfoldedSFSReward,
148
+ FoldedSFSReward,
149
+ CustomReward,
150
+ ProductReward,
151
+ SumReward,
152
+ CombinedReward,
153
+ DemeReward
154
+ )
155
+
156
+ from .spectrum import (
157
+ SFS,
158
+ Spectra,
159
+ SFS2
160
+ )
161
+
162
+ from .inference import Inference
163
+
164
+ from .lineage import LineageConfig
165
+
166
+ from .locus import LocusConfig
167
+
168
+ from .norms import (
169
+ LNorm,
170
+ L1Norm,
171
+ L2Norm,
172
+ LInfNorm,
173
+ PoissonLikelihood
174
+ )
175
+
176
+ from .state_space_old import StateSpace as OldStateSpace
177
+
178
+ __all__ = [
179
+ 'PhaseTypeDistribution',
180
+ 'Coalescent',
181
+ 'Demography',
182
+ 'Epoch',
183
+ 'PopSizeChanges',
184
+ 'PopSizeChange',
185
+ 'MigrationRateChanges',
186
+ 'MigrationRateChange',
187
+ 'SymmetricMigrationRateChanges',
188
+ 'PopulationSplit',
189
+ 'ExponentialPopSizeChanges',
190
+ 'ExponentialRateChanges',
191
+ 'DiscreteRateChanges',
192
+ 'DiscretizedRateChange',
193
+ 'DiscretizedRateChanges',
194
+ 'StandardCoalescent',
195
+ 'BetaCoalescent',
196
+ 'DiracCoalescent',
197
+ 'SFS2',
198
+ 'SFS',
199
+ 'Spectra',
200
+ 'Inference',
201
+ 'LNorm',
202
+ 'L1Norm',
203
+ 'L2Norm',
204
+ 'LInfNorm',
205
+ 'PoissonLikelihood',
206
+ 'Reward',
207
+ 'TreeHeightReward',
208
+ 'TotalTreeHeightReward',
209
+ 'TotalBranchLengthReward',
210
+ 'UnfoldedSFSReward',
211
+ 'FoldedSFSReward',
212
+ 'CustomReward',
213
+ 'ProductReward',
214
+ 'SumReward',
215
+ 'DemeReward',
216
+ 'DefaultReward',
217
+ 'NonDefaultReward',
218
+ 'CombinedReward',
219
+ 'StateSpace',
220
+ 'DefaultStateSpace',
221
+ 'BlockCountingStateSpace',
222
+ 'CoalescentModel',
223
+ 'LineageConfig',
224
+ 'LocusConfig',
225
+ ]