Compare commits
No commits in common. "83819b296beec0ceda99dc35d5fa39783faf47db" and "81ebd4fbbefda50a07fb9a11ce7a48ab55cc464c" have entirely different histories.
83819b296b
...
81ebd4fbbe
|
@ -11,13 +11,6 @@ parse_data <- function(file) {
|
||||||
return(list(sequences, vj_segments))
|
return(list(sequences, vj_segments))
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_metadata <- function(metadata) {
|
|
||||||
id_elements <- unlist(strsplit(metadata, split = " "))
|
|
||||||
v_identifier <- id_elements[2]
|
|
||||||
j_identifier <- id_elements[3]
|
|
||||||
return(list(v_id = v_identifier, j_id = j_identifier))
|
|
||||||
}
|
|
||||||
|
|
||||||
match_id_sequence <- function(names, vdj_segments, id) {
|
match_id_sequence <- function(names, vdj_segments, id) {
|
||||||
matches <- grep(names, pattern = id)
|
matches <- grep(names, pattern = id)
|
||||||
row <- matches[1]
|
row <- matches[1]
|
||||||
|
@ -25,20 +18,22 @@ match_id_sequence <- function(names, vdj_segments, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_vj_sequence <- function(metadata, names, vdj_segments) {
|
get_vj_sequence <- function(metadata, names, vdj_segments) {
|
||||||
identifiers <- parse_metadata(metadata)
|
id_elements <- unlist(strsplit(metadata, split = " "))
|
||||||
v_sequence <- match_id_sequence(names, vdj_segments, id = identifiers["v_id"])
|
v_identifier <- id_elements[2]
|
||||||
j_sequence <- match_id_sequence(names, vdj_segments, id = identifiers["j_id"])
|
j_identifier <- id_elements[3]
|
||||||
return(list(v_seq = v_sequence, j_seq = j_sequence))
|
v_sequence <- match_id_sequence(names, vdj_segments, id = v_identifier)
|
||||||
|
j_sequence <- match_id_sequence(names, vdj_segments, id = j_identifier)
|
||||||
|
return(c(v_sequence, j_sequence))
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_vj_sequences <- function(sequences, vdj_segments) {
|
fetch_vj_sequences <- function(sequences, vdj_segments) {
|
||||||
vj_sequences <- sapply(names(sequences),
|
vj_sequences <- mclapply(names(sequences),
|
||||||
names(vdj_segments),
|
names(vdj_segments),
|
||||||
vdj_segments,
|
vdj_segments,
|
||||||
FUN = get_vj_sequence
|
FUN = get_vj_sequence,
|
||||||
|
mc.cores = detectCores()
|
||||||
)
|
)
|
||||||
results <- data.frame(t(vj_sequences))
|
return(c(vj_sequences[1], vj_sequences[2]))
|
||||||
return(results)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align_sequence <- function(sequence, vdj_segment) {
|
align_sequence <- function(sequence, vdj_segment) {
|
||||||
|
@ -52,10 +47,15 @@ align_sequence <- function(sequence, vdj_segment) {
|
||||||
|
|
||||||
# TODO Extract CDR3
|
# TODO Extract CDR3
|
||||||
get_hvr_sequences <- function(sequences, vdj_segments) {
|
get_hvr_sequences <- function(sequences, vdj_segments) {
|
||||||
df <- fetch_vj_sequences(sequences, vdj_segments)
|
vj_sequences <- 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)
|
vj_sequences[1],
|
||||||
print(v_alignment)
|
FUN = align_sequence
|
||||||
|
)
|
||||||
|
j_alignment <- parallel::mcmapply(sequences,
|
||||||
|
vj_sequences[2],
|
||||||
|
FUN = align_sequence
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
data <- parse_data(file = "data/curesim_sequence.fastq")
|
data <- parse_data(file = "data/curesim_sequence.fastq")
|
||||||
|
|
Loading…
Reference in New Issue