library(immuneSIM) library(Biostrings) generate_repertoire <- function(number_of_sequences) { return(immuneSIM( number_of_seqs = number_of_sequences, species = "hs", receptor = "tr", chain = "b" )) } process_data <- function(repertoire, reads) { columns <- c("sequence", "v_call", "j_call") data <- repertoire[, columns] dna_sequence <- Biostrings::DNAStringSet(data$sequence) data$sequence <- Biostrings::reverseComplement(dna_sequence) names(data$sequence) <- paste(rownames(data), data$v_call, data$j_call) Biostrings::writeXStringSet(data$sequence, "data/sequence.fasta") } parse_cli_arguments <- function() { args <- commandArgs(trailingOnly = TRUE) if (length(args) != 2) { stop("usage: repertoire.r ") } return(c(args[1], args[2])) } args <- parse_cli_arguments() repertoire <- generate_repertoire(number_of_sequences = as.integer(args[1])) process_data(repertoire = repertoire, reads = as.integer(args[2]))