mrc-ide / SIMPLEGEN

Simulating Plasmodium Epidemiological and Genetic Data
https://mrc-ide.github.io/SIMPLEGEN/
MIT License
12 stars 0 forks source link

prune_transmission_record() returns an empty .txt file #34

Closed IzzyRou closed 2 years ago

IzzyRou commented 3 years ago

Problem: When using PC instead of unix/linux, prune_transmission_record() returns an empty .txt file. Code section: main.cpp, lines 43 to 275. Suspect problem is 221 - 275 but not sure. Notes: Thought it was to do with differences in reading ends of lines, but based on initial de-bugging the .txt file is being read and the appropriate IDs are being identified. Reproduction of bug : (when run on PC)

library(tidyverse)
library(devtools)
library(remotes)
#insert own working directory for GitHub repo
devtools:: load_all("/home/gimli/Documents/GitHub/SIMPLEGEN")
check_SIMPLEGEN_loaded()
set.seed(123)

n_demes <- 1
mig_mat<-diag(1, n_demes)
s <- simplegen_project() %>%
  define_epi_params(H = rep(1e3, n_demes),
                    M = rep(1e4, n_demes),
                    seed_infections = rep(40, n_demes),
                    mig_mat = mig_mat,
                    prob_infection = 0.6,
                    prob_acute = seq(1, 0, l = 25),
                    prob_AC = 1.0,
                    duration_acute = dgeom(1:250, 1/50),
                    duration_chronic = dgeom(1:250, 1/50),
                    detectability_microscopy_acute = 0.95,
                    detectability_microscopy_chronic = 0.4,
                    treatment_seeking_mean = 0,
                    infectivity_acute = 1.0,
                    infectivity_chronic = 1.0)

s<-define_genetic_params(
  s,
  r = 1e-06,
  alpha = 1,
  oocyst_distribution = dpois(1:10, lambda = 2),
  hepatocyte_distribution = dpois(1:10, lambda = 5),
  contig_lengths = c(643292, 947102, 1060087, 1204112, 1343552, 1418244, 1501717,
                    1419563, 1541723, 1687655, 2038337, 2271478, 2895605, 3291871)
)

# define sampling strategy
max_time <- 365*5
df_sample <- data.frame(time = max_time,
                        deme = 1,
                        case_detection = "active",
                        diagnosis = "microscopy",
                        n = 100)
s <- define_sampling_strategy(s, df_sample = df_sample)

# simulate from transmission model
s <- sim_epi(s, max_time = 5*365,
            save_transmission_record = TRUE,
            transmission_record_location = "ignore/trans_record.txt",
            overwrite_transmission_record = TRUE)
# prune transmission record
s <- prune_transmission_record(project = s,
                            transmission_record_location = "ignore/trans_record.txt",
                            pruned_record_location = "ignore/pruned_record.txt",
                            overwrite_pruned_record = TRUE)

R configuration: R version 4.0.3 SIMPLEGEN branch: master Computer used: Windows 10.0.18363