<commit_before>// vim: ts=4:expandtab:sw=4:cindent
//////////////////////////////////////////////////////////////////
// 
// Pipeline stage to run CODEX on exome data
//
//////////////////////////////////////////////////////////////////
codex_call_cnvs = {

    var batch_name : false

    def outputFile = batch_name ? batch_name + '.codex.cnvs.tsv' : input.bam + '.codex.cnvs.tsv'
    
    
    def chr = branch.name

    produce(outputFile) {
        
        def bamDir = file(input.bam).parentFile.absoluteFile.absolutePath
        
        R({"""

            source("$TOOLS/r-utils/cnv_utils.R")

            library(CODEX)

            bam.files = c('${inputs.bam.join("','")}')

            bam.samples = as.matrix(data.frame(sample=sapply(bam.files, function(file.name) {
                # Scan the bam header and parse out the sample name from the first read group
                read.group.info = strsplit(scanBamHeader(file.name)[[1]]$text[["@RG"]],":")
                names(read.group.info) = sapply(read.group.info, function(field) field[[1]]) 
                return(read.group.info$SM[[2]])
            })))

            for(bam_sample in bam.samples) {
                bedFile <- "$input.bed"
                chr <- "$chr"
    
                bambedObj <- getbambed(bamdir = "$bamDir", bedFile = bedFile,
                                         sampname = bam_sample, projectname = "sureselect_sim", chr)
                
                bamdir <- bambedObj$bamdir; sampname <- bambedObj$sampname
                
                
                ref <- bambedObj$ref; 
                projectname <- bambedObj$projectname; 
                chr <- bambedObj$chr
                
                
                coverageObj <- getcoverage(bambedObj, mapqthres = 20)<commit_msg>fix bad chr reference in CODEX support<commit_after>// vim: ts=4:expandtab:sw=4:cindent
//////////////////////////////////////////////////////////////////
// 
// Pipeline stage to run CODEX on exome data
//
//////////////////////////////////////////////////////////////////
codex_call_cnvs = {

    var batch_name : false

    def outputFile = batch_name ? batch_name + '.codex.cnvs.tsv' : input.bam + '.codex.cnvs.tsv'
    
    
    def chr = branch.name

    produce(outputFile) {
        
        def bamDir = file(input.bam).parentFile.absoluteFile.absolutePath
        
        R({"""

            source("$TOOLS/r-utils/cnv_utils.R")

            library(CODEX)

            bam.files = c('${inputs.bam.join("','")}')

            bam.samples = as.matrix(data.frame(sample=sapply(bam.files, function(file.name) {
                # Scan the bam header and parse out the sample name from the first read group
                read.group.info = strsplit(scanBamHeader(file.name)[[1]]$text[["@RG"]],":")
                names(read.group.info) = sapply(read.group.info, function(field) field[[1]]) 
                return(read.group.info$SM[[2]])
            })))

            for(bam_sample in bam.samples) {
                bedFile <- "$input.bed"
                chr <- "$chr"
    
                bambedObj <- getbambed(bamdir = "$bamDir", bedFile = bedFile,
                                         sampname = bam_sample, projectname = "sureselect_sim", chr)
                
                bamdir <- bambedObj$bamdir; sampname <- bambedObj$sampname
                
                
                ref <- bambedObj$ref; 
                projectname <- bambedObj$projectname; 
                chr <- bambedObj\$chr
                
                
                coverageObj <- getcoverage(bambedObj, mapqthres = 20)
{'fraction_non_alphanumeric': 0.18681015452538632, 'fraction_numerical': 0.003863134657836645, 'mean_word_length': 1.317774936061381, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1175987', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1030, 'n_words': 185}