From 83819b296beec0ceda99dc35d5fa39783faf47db Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 22 Apr 2021 01:18:25 +0200 Subject: [PATCH] Save vj_sequences in a dataframe --- src/alignment.r | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/alignment.r b/src/alignment.r index 3b0aab9..2067f92 100644 --- a/src/alignment.r +++ b/src/alignment.r @@ -32,13 +32,13 @@ get_vj_sequence <- function(metadata, names, vdj_segments) { } fetch_vj_sequences <- function(sequences, vdj_segments) { - vj_sequences <- mclapply(names(sequences), + vj_sequences <- sapply(names(sequences), names(vdj_segments), vdj_segments, - FUN = get_vj_sequence, - mc.cores = detectCores() + FUN = get_vj_sequence ) - return(c(vj_sequences[1], vj_sequences[2])) + results <- data.frame(t(vj_sequences)) + return(results) } align_sequence <- function(sequence, vdj_segment) { @@ -52,15 +52,10 @@ align_sequence <- function(sequence, vdj_segment) { # TODO Extract CDR3 get_hvr_sequences <- function(sequences, vdj_segments) { - vj_sequences <- fetch_vj_sequences(sequences, vdj_segments) - v_alignment <- parallel::mcmapply(sequences, - vj_sequences[1], - FUN = align_sequence - ) - j_alignment <- parallel::mcmapply(sequences, - vj_sequences[2], - FUN = align_sequence - ) + df <- fetch_vj_sequences(sequences, vdj_segments) + v_alignment <- parallel::mcmapply(sequences, df$v_seq, FUN = align_sequence) + j_alignment <- parallel::mcmapply(sequences, df$j_seq, FUN = align_sequence) + print(v_alignment) } data <- parse_data(file = "data/curesim_sequence.fastq")