-
Notifications
You must be signed in to change notification settings - Fork 4
Madc2vcf strawberry fix #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -75,7 +75,7 @@ | |||||
| "out_vcf= ", out_vcf, ', ', | ||||||
| "verbose= ", verbose,')">') | ||||||
|
|
||||||
| if(!is.null(madc)) report <- read.csv(madc) else stop("Please provide a MADC file") | ||||||
| if(!is.null(madc)) report <- read.csv(madc, check.names = FALSE) else stop("Please provide a MADC file") | ||||||
| if(!is.null(botloci_file)) botloci <- read.csv(botloci_file, header = F) else stop("Please provide a botloci file") | ||||||
| if(!is.null(hap_seq_file)) hap_seq <- read.table(hap_seq_file, header = F) else hap_seq <- NULL | ||||||
|
|
||||||
|
|
@@ -142,12 +142,12 @@ | |||||
| new.file <- data.frame("AlleleID" = report[,1], | ||||||
| "Chromosome" = NA, "SNP_position_in_Genome" = NA, | ||||||
| "Ref" = NA, "Alt" =NA, | ||||||
| "CloneID" = report[,2], report[,3:ncol(report)]) | ||||||
| "CloneID" = report[,2], report[,3:ncol(report)], check.names = FALSE) | ||||||
|
|
||||||
| by_cloneID <- split.data.frame(new.file, new.file$CloneID) | ||||||
|
|
||||||
| clust <- makeCluster(n.cores) | ||||||
| #clusterExport(clust, c("hap_seq","add_ref_alt")) | ||||||
| #clusterExport(clust, c("hap_seq","add_ref_alt", "nsamples")) | ||||||
| add_ref_alt_results <- parLapply(clust, by_cloneID, function(x) add_ref_alt(x, hap_seq, nsamples, verbose = verbose)) | ||||||
| stopCluster(clust) | ||||||
|
|
||||||
|
|
@@ -169,7 +169,6 @@ | |||||
|
|
||||||
| clust <- makeCluster(n.cores) | ||||||
| #clusterExport(clust, c("botloci", "compare", "nucleotideSubstitutionMatrix", "pairwiseAlignment", "DNAString", "reverseComplement")) | ||||||
| #clusterExport(clust, c("botloci")) | ||||||
| compare_results <- parLapply(clust, updated_by_cloneID, function(x) compare(x, botloci, alignment_score_thr)) | ||||||
| stopCluster(clust) | ||||||
|
|
||||||
|
|
@@ -209,7 +208,6 @@ | |||||
| #' | ||||||
| #' @noRd | ||||||
| add_ref_alt <- function(one_tag, hap_seq, nsamples, verbose = TRUE) { | ||||||
|
|
||||||
| # Add ref and alt | ||||||
| cloneID <- one_tag$CloneID[1] | ||||||
| ref <- paste0(cloneID, "|Ref_0001") | ||||||
|
|
@@ -281,13 +279,14 @@ | |||||
| #' | ||||||
| #' @noRd | ||||||
| compare <- function(one_tag, botloci, alignment_score_thr = 40){ | ||||||
| #one_tag <- updated_by_cloneID[[2]] | ||||||
| cloneID <- one_tag$CloneID[1] | ||||||
| isBotLoci <- cloneID %in% botloci[,1] | ||||||
| # If marker is present in the botloc list, get the reverse complement sequence | ||||||
| if(isBotLoci) one_tag$AlleleSequence <- sapply(one_tag$AlleleSequence, function(x) as.character(reverseComplement(DNAString(x)))) | ||||||
|
|
||||||
| chr <- sapply(strsplit(cloneID, "_"), function(x) x[-length(x)]) | ||||||
| if(length(chr > 1)) chr <- paste(chr, collapse = "_") | ||||||
|
||||||
| if(length(chr > 1)) chr <- paste(chr, collapse = "_") | |
| if(length(chr) > 1) chr <- paste(chr, collapse = "_") |
Copilot
AI
May 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use && instead of & for scalar logical operations in if conditions to avoid unintended vectorized behavior.
| if(all(alt_base %in% c("A", "T", "C", "G")) & length(align@pattern@mismatch@unlistData) == 1) { | |
| if(all(alt_base %in% c("A", "T", "C", "G")) && length(align@pattern@mismatch@unlistData) == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
clusterExportcall is commented out, sohap_seq,nsamples, andadd_ref_altwon't be available on the workers. Uncomment or add the export call beforeparLapplyto ensure these objects are passed to the cluster.