Compare commits

...

2 Commits

Author SHA1 Message Date
coolneng 36eb73b458
Add alignment to generation script 2021-05-03 21:51:48 +02:00
coolneng 81a57657fe
Fix HVR end position computation 2021-05-03 21:51:32 +02:00
2 changed files with 19 additions and 17 deletions

View File

@ -18,4 +18,5 @@ prefix="curesim_"
Rscript src/repertoire.r "$sequences" "$number_of_reads" && Rscript src/repertoire.r "$sequences" "$number_of_reads" &&
java -jar tools/CuReSim.jar -f "$data_directory$filename$fastq" -o "$data_directory$prefix$filename$fastq" java -jar tools/CuReSim.jar -f "$data_directory$filename$fastq" -o "$data_directory$prefix$filename$fastq"
Rscript src/alignment.r
rm "$data_directory/log.txt" rm "$data_directory/log.txt"

View File

@ -70,31 +70,32 @@ get_cys_coordinates <- function(alignment) {
return(list("start" = cys_start, "end" = cys_end)) return(list("start" = cys_start, "end" = cys_end))
} }
# TODO Refactor this mess get_hvr_sequences <- function(sequences, vdj_segments, cores = detectCores()) {
get_hvr_sequences <- function(sequences, vdj_segments) {
df <- fetch_vj_sequences(sequences, vdj_segments) df <- fetch_vj_sequences(sequences, vdj_segments)
v_alignment <- parallel::mcmapply(sequences, df$v_seq, FUN = align_sequence) v_alignment <- parallel::mcmapply(sequences,
j_alignment <- parallel::mcmapply(sequences, df$j_seq, FUN = align_sequence) df$v_seq,
FUN = align_sequence,
mc.cores = cores
)
cys_coordinates <- parallel::mclapply(v_alignment, FUN = get_cys_coordinates) cys_coordinates <- parallel::mclapply(v_alignment, FUN = get_cys_coordinates)
cys_df <- as.data.frame(do.call(rbind, cys_coordinates)) cys_df <- as.data.frame(do.call(rbind, cys_coordinates))
remaining <- Biostrings::subseq(sequences, start = unlist(cys_df$end))
j_alignment <- parallel::mcmapply(remaining,
df$j_seq,
FUN = align_sequence,
mc.cores = cores
)
j_start <- parallel::mclapply( j_start <- parallel::mclapply(
j_alignment, j_alignment,
function(x) start(Biostrings::Views(x)) function(x) start(Biostrings::Views(x)),
) mc.cores = cores
hvr <- Biostrings::subseq(sequences,
start = unlist(cys_df$start),
end = unlist(j_start) + 2
) )
hvr_start <- unlist(cys_df$start)
hvr_end <- unlist(cys_df$start) + unlist(j_start) + 2
hvr <- Biostrings::subseq(sequences, start = hvr_start, end = hvr_end)
return(hvr) return(hvr)
} }
save_data <- function(data) {
Biostrings::writeXStringSet(data, "data/CuReSim-HVR.fastq", format = "fastq")
}
data <- parse_data(file = "data/curesim_sequence.fastq") data <- parse_data(file = "data/curesim_sequence.fastq")
hvr <- get_hvr_sequences( hvr <- get_hvr_sequences(sequences = data[[1]], vdj_segments = data[[2]])
sequences = data[[1]],
vdj_segments = data[[2]]
)
Biostrings::writeXStringSet(hvr, "data/CuReSim-HVR.fastq", format = "fastq") Biostrings::writeXStringSet(hvr, "data/CuReSim-HVR.fastq", format = "fastq")