msasim 24.9.0__tar.gz → 24.9.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of msasim might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msasim
3
- Version: 24.9.0
3
+ Version: 24.9.2
4
4
  Summary: A fast MSA simulator
5
5
  Home-page: https://github.com/elyawy/Sailfish-backend
6
6
  Author: Elya Wygoda
@@ -467,7 +467,8 @@ class Simulator:
467
467
  model: _Sailfish.modelCode,
468
468
  model_parameters: List = None,
469
469
  gamma_parameters_alpha : float = 1.0,
470
- gamma_parameters_catergories: int = 1
470
+ gamma_parameters_catergories: int = 1,
471
+ invariant_sites_proportion: float = 0.0
471
472
  ) -> None:
472
473
  if not model:
473
474
  raise ValueError(f"please provide a substitution model from the the following list: {_Sailfish.modelCode}")
@@ -490,8 +491,9 @@ class Simulator:
490
491
  raise ValueError(f"please provide a model parameters")
491
492
  else:
492
493
  self._model_factory.set_model_parameters(model_parameters)
493
-
494
+
494
495
  self._model_factory.set_gamma_parameters(gamma_parameters_alpha, gamma_parameters_catergories)
496
+ self._model_factory.set_invariant_sites_proportion(invariant_sites_proportion)
495
497
  self._simulator.init_substitution_sim(self._model_factory)
496
498
 
497
499
  self._is_sub_model_init = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msasim
3
- Version: 24.9.0
3
+ Version: 24.9.2
4
4
  Summary: A fast MSA simulator
5
5
  Home-page: https://github.com/elyawy/Sailfish-backend
6
6
  Author: Elya Wygoda
@@ -9,7 +9,7 @@ from datetime import datetime
9
9
  now = datetime.now()
10
10
 
11
11
 
12
- __version__ = f"{now.year % 100}.{now.month+1}.0"
12
+ __version__ = f"{now.year % 100}.{now.month+1}.2"
13
13
 
14
14
  # The main interface is through Pybind11Extension.
15
15
  # * You can add cxx_std=11/14/17, and then build_ext can be removed.
@@ -123,6 +123,7 @@ PYBIND11_MODULE(_Sailfish, m) {
123
123
  .def("set_replacement_model" , &modelFactory::setReplacementModel)
124
124
  .def("set_model_parameters" , &modelFactory::setModelParameters)
125
125
  .def("set_gamma_parameters" , &modelFactory::setGammaParameters)
126
+ .def("set_invariant_sites_proportion", &modelFactory::setInvariantSitesProportion)
126
127
  .def("reset", &modelFactory::resetFactory);
127
128
 
128
129
 
@@ -75,6 +75,7 @@ void modelFactory::setGammaParameters(MDOUBLE alpha, size_t numCategories) {
75
75
 
76
76
  void modelFactory::resetFactory() {
77
77
  _state = factoryState::ALPHABET;
78
+ _invariantProportion = 0.0;
78
79
  }
79
80
 
80
81
 
@@ -19,7 +19,8 @@
19
19
  // };
20
20
 
21
21
  rateMatrixSim::rateMatrixSim(modelFactory& mFac, std::shared_ptr<std::vector<bool>> nodesToSave) :
22
- _et(mFac.getTree()), _sp(mFac.getStochasticProcess()), _alph(mFac.getAlphabet()),
22
+ _et(mFac.getTree()), _sp(mFac.getStochasticProcess()), _alph(mFac.getAlphabet()),
23
+ _invariantSitesProportion(mFac.getInvariantSitesProportion()),
23
24
  _cpijGam(), _rootSequence(mFac.getAlphabet()), _subManager(mFac.getTree()->getNodesNum()),
24
25
  _nodesToSave(nodesToSave), _saveRates(false), _biased_coin(0,1) {
25
26
  // _et = mFac.getTree();
@@ -34,8 +35,12 @@ rateMatrixSim::rateMatrixSim(modelFactory& mFac, std::shared_ptr<std::vector<boo
34
35
 
35
36
  std::vector<MDOUBLE> rateProbs;
36
37
  for (int j = 0 ; j < _sp->categories(); ++j) {
37
- rateProbs.push_back(_sp->ratesProb(j));
38
+ MDOUBLE currentRateProb = _sp->ratesProb(j);
39
+ currentRateProb = currentRateProb * (1.0 - _invariantSitesProportion);
40
+ rateProbs.push_back(currentRateProb);
38
41
  }
42
+ if (_invariantSitesProportion > 0.0) rateProbs.push_back(_invariantSitesProportion);
43
+
39
44
  _rateSampler = std::make_unique<DiscreteDistribution>(rateProbs);
40
45
 
41
46
  std::vector<MDOUBLE> frequencies;
@@ -103,6 +108,10 @@ void rateMatrixSim::generate_substitution_log(int seqLength) {
103
108
  for (int h = 0; h < seqLength; h++) {
104
109
  int selectedRandomCategory = _rateSampler->drawSample() - 1;
105
110
  _rateCategories[h] = selectedRandomCategory;
111
+ if (selectedRandomCategory == _sp->categories()) {
112
+ ratesVec[h] = 0.0;
113
+ continue;
114
+ }
106
115
  ratesVec[h] = _sp->rates(selectedRandomCategory);
107
116
  sumOfRatesAcrossSites += ratesVec[h];
108
117
  }
@@ -149,6 +158,7 @@ void rateMatrixSim::mutateEntireSeq(tree::nodeP currentNode, int seqLength) {
149
158
 
150
159
  for (size_t site = 0; site < seqLength; ++site) {
151
160
  ALPHACHAR parentChar = _rootSequence[site];//_subManager.getCharacter(parentId, site, _rootSequence);
161
+ if (_rateCategories[site] == _sp->categories()) continue;
152
162
  ALPHACHAR nextChar = _cpijGam.getRandomChar(_rateCategories[site], nodeId, parentChar);
153
163
  if (nextChar != parentChar){
154
164
  _subManager.handleEvent(nodeId, site, nextChar, _rateCategories, _sp.get(), _rootSequence);
File without changes
File without changes
File without changes
File without changes
File without changes