Skip to content

Commit 5406710

Browse files
committed
Make epistasis configurable
1 parent 62fea82 commit 5406710

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

src/core/fitness/epistasis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ pub struct EpistasisTable {
2525
impl EpistasisTable {
2626
pub fn from_model(model: &FitnessModel) -> Result<Self, VirolutionError> {
2727
let table = match &model.distribution {
28-
FitnessDistribution::Epistatic(_, epi_params) => {
29-
let entries = epi_params.load_table();
28+
FitnessDistribution::Epistatic(epi_params) => {
29+
let entries = epi_params.load_epistasis();
3030
Self::from_vec(entries)
3131
}
3232
_ => {

src/core/fitness/init.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum FitnessDistribution {
2929
Exponential(ExponentialParameters),
3030
File(FileParameters),
3131
Lognormal(LognormalParameters),
32-
Epistatic(FileParameters, EpiFileParameters),
32+
Epistatic(EpiFileParameters),
3333
// Spikes,
3434
// Beta,
3535
// Empirical,
@@ -73,6 +73,7 @@ pub struct FileParameters {
7373
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
7474
pub struct EpiFileParameters {
7575
pub path: String,
76+
pub epi_path: String,
7677
}
7778

7879
impl MutationCategoryWeights {
@@ -170,7 +171,16 @@ impl FileParameters {
170171
}
171172

172173
impl EpiFileParameters {
173-
pub fn load_table(&self) -> Vec<EpiEntry> {
174+
pub fn load_table(&self) -> Vec<f64> {
175+
let reader = NpyFile::new(std::fs::File::open(&self.path).unwrap()).unwrap();
176+
reader
177+
.data::<f64>()
178+
.unwrap()
179+
.map(|entry| entry.unwrap())
180+
.collect()
181+
}
182+
183+
pub fn load_epistasis(&self) -> Vec<EpiEntry> {
174184
let reader = NpyFile::new(std::fs::File::open(&self.path).unwrap()).unwrap();
175185
reader
176186
.data::<EpiEntry>()

src/core/fitness/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl FitnessProvider {
4848
let table = FitnessTable::from_model(sequence, n_symbols, model)?;
4949
FitnessFunction::NonEpistatic(table)
5050
}
51-
FitnessDistribution::Epistatic(_, _) => {
51+
FitnessDistribution::Epistatic(_) => {
5252
let table = FitnessTable::from_model(sequence, n_symbols, model)?;
5353
let epistasis = EpistasisTable::from_model(model)?;
5454
FitnessFunction::SimpleEpistatic(table, epistasis)

src/core/fitness/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl FitnessTable {
3535
}
3636
FitnessDistribution::Lognormal(ref params) => params.create_table(n_symbols, sequence),
3737
FitnessDistribution::File(ref params) => params.load_table(),
38-
FitnessDistribution::Epistatic(ref params, _) => params.load_table(),
38+
FitnessDistribution::Epistatic(ref params) => params.load_table(),
3939
};
4040

4141
if table.len() != n_sites * n_symbols {

0 commit comments

Comments
 (0)