-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function DiploidPopulation.add_mutation. (#764)
Add ability to drop mutations onto populations with existing ancestry.
- Loading branch information
Showing
14 changed files
with
872 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,6 +325,9 @@ print(fwdpy11.NOGROWTH) | |
.. autoattribute:: __init__ | ||
.. autoclass:: fwdpy11.NewMutationData | ||
:members: | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import typing | ||
|
||
import attr | ||
|
||
from .._fwdpy11 import ll_NewMutationData | ||
|
||
|
||
@attr.s(auto_attribs=True, frozen=True, repr_ns="fwdpy11", kw_only=True) | ||
class NewMutationData(ll_NewMutationData): | ||
""" | ||
Data object for :func:`fwdpy11.DiploidPopulation.add_mutation` | ||
.. versionadded:: 0.16.0 | ||
This class has the following attributes, whose names | ||
are also `kwargs` for intitialization. The attribute names | ||
also determine the order of positional arguments: | ||
:param effect_size: The fixed/univariate effect size. | ||
Will fill in :attr:`fwdpy11.Mutation.s` | ||
:type effect_size: float | ||
:param dominance: Heterozygous effect of the mutation. | ||
Will fill in :attr:`fwdpy11.Mutation.h` | ||
:type dominance: float | ||
:param esizes: Data to fill :attr:`fwdpy11.Mutation.esizes`. | ||
Default is `None`. | ||
:type esizes: list[float] | ||
:param heffects: Data to fill :attr:`fwdpy11.Mutation.heffects`. | ||
Default is `None`. | ||
:type heffects: list[float] | ||
:param label: Data for :attr:`fwdpy11.Mutation.label`. | ||
Default is 0. | ||
:type label: int | ||
""" | ||
|
||
effect_size: float | ||
dominance: float | ||
esizes: typing.Optional[typing.List[float]] = None | ||
heffects: typing.Optional[typing.List[float]] = None | ||
label: int = 0 | ||
|
||
def __attrs_post_init__(self): | ||
if self.esizes is None and self.heffects is None: | ||
super(NewMutationData, self).__init__( | ||
self.effect_size, self.dominance, [], [], self.label | ||
) | ||
else: | ||
super(NewMutationData, self).__init__( | ||
self.effect_size, self.dominance, self.esizes, self.heffects, self.label | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Copyright (C) 2021 Kevin Thornton <krthornt@uci.edu> | ||
// | ||
// This file is part of fwdpy11. | ||
// | ||
// fwdpy11 is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// fwdpy11 is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with fwdpy11. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include "add_mutation.hpp" | ||
|
||
namespace py = pybind11; | ||
|
||
void | ||
init_add_mutation(py::module& m) | ||
{ | ||
m.def("_add_mutation", &add_mutation); | ||
|
||
py::class_<new_mutation_data>(m, "ll_NewMutationData") | ||
.def(py::init<double, double, std::vector<double>, std::vector<double>, | ||
decltype(fwdpy11::Mutation::xtra)>()); | ||
} | ||
|
Oops, something went wrong.