1
# Generate a parameter file.
2
create_par_file <- function(files, data, params) {
3 1
  geno <- data$geno
4 1
  snp <- data$snp
5 1
  ind <- ifelse(is.null(data$group), data$ind, data$group)
6 1
  exclude <- data$exclude
7

8 1
  sprintf("genotypename: %s\nsnpname: %s\nindivname: %s\n", geno, snp, ind) %>%
9 1
    writeLines(con = files$par_file)
10

11 1
  if (!is.null(files[["pop_file"]])) {
12 1
    write(sprintf("popfilename: %s\n", files$pop_file), file = files$par_file, append = TRUE)
13 1
  } else if (!is.null(files$popleft) & !is.null(files$popright)) {
14 1
    write(sprintf("popleft: %s", files$popleft), file = files$par_file, append = TRUE)
15 1
    write(sprintf("popright: %s", files$popright), file = files$par_file, append = TRUE)
16
  }
17

18 1
  if (!is.null(exclude)) {
19 1
    write(sprintf("badsnpname: %s", exclude), file = files$par_file, append = TRUE)
20
  }
21

22
  # write user-specified parameters
23 1
  for (par in names(params)) {
24 1
    write(sprintf("%s: %s\n", par, params[[par]]), file = files$par_file, append = TRUE)
25
  }
26
}
27

28

29
# Generate a file with populations for a qpF4ratio run.
30
create_qpF4ratio_pop_file <- function(X, A, B, C, O, file) {
31 1
  lines <- sprintf("%s %s : %s %s :: %s %s : %s %s", A, O, X, C, A, O, B, C)
32 1
  writeLines(lines, file)
33
}
34

35

36
# Generate a file with populations for a qpDstat run.
37
create_qpDstat_pop_file <- function(W = NULL, X = NULL, Y = NULL, Z = NULL, file) {
38 1
  lines <- c()
39 1
  for (w in W) for (x in X) for (y in Y) for (z in Z) {
40 1
    lines <- c(lines, sprintf("%s %s %s %s", w, x, y, z))
41
  }
42 1
  writeLines(lines, file)
43
}
44

45

46
# Generate a file with populations for a qpDstat run based on given
47
# list of quartets.
48
create_qpDstat_pop_file_quartets <- function(quartets, file) {
49 0
  lines <- c()
50 0
  for (q in quartets) {
51 0
    lines <- c(lines, sprintf("%s %s %s %s", q[1], q[2], q[3], q[4]))
52
  }
53 0
  writeLines(lines, file)
54
}
55

56

57
# Generate a file with populations for a qp3Pop run.
58
create_qp3Pop_pop_file <- function(A, B, C, file) {
59 1
  lines <- c()
60 1
  for (a in A) for (b in B) for (c in C) {
61 1
    lines <- c(lines, sprintf("%s %s %s", a, b, c))
62
  }
63 1
  writeLines(lines, file)
64
}
65

66
# Generate a file with populations for a qpDstat run.
67
create_leftright_pop_files <- function(left, right, files) {
68 1
  writeLines(left, files$popleft)
69 1
  writeLines(right, files$popright)
70
}
71

Read our documentation on viewing source code .

Loading