<commit_before>"""Wrapper functions for assisting in running the various programs of the cactus package.
"""

import os
import random

from sonLib.bioio import logger
from sonLib.bioio import getTempFile
from sonLib.bioio import getTempDirectory
from sonLib.bioio import system
from sonLib.bioio import nameValue

from workflow.jobTree.test.jobTree.jobTreeTest import runJobTreeStatusAndFailIfNotComplete

#############################################
#############################################
#All the following provide command line wrappers
#for core programs in the cactus pipeline.
#############################################
#############################################  

def runCactusSetup(cactusDiskDatabaseString, sequences, 
                   newickTreeString, logLevel="DEBUG", debug=False):
    debugString = nameValue("debug", debug, bool)
    system("cactus_setup %s --speciesTree '%s' --cactusDisk '%s' \
--logLevel %s %s" \
           % (" ".join(sequences), newickTreeString,
              cactusDiskDatabaseString, logLevel, debugString))
    logger.info("Ran cactus setup okay")
    
def runCactusAligner(cactusDiskDatabaseString, alignmentFile, tempDir, useDummy=True, flowerName="0", logLevel="DEBUG"):        
    """Runs job tree and fails if not complete.
    """
    tempDir = getTempDirectory(tempDir)
    jobTreeDir = os.path.join(tempDir, "jobTree")
    useDummy = nameValue("useDummy", useDummy, bool)
    command = "cactus_aligner.py --cactusDisk '%s' --flowerName %s \
--resultsFile %s %s --jobTree %s --logLevel %s" % (cactusDiskDatabaseString, flowerName, alignmentFile, useDummy, jobTreeDir, logLevel)
    system(command)
    runJobTreeStatusAndFailIfNotComplete(jobTreeDir)
    system("rm -rf %s" % tempDir)
    logger.info("Ran the cactus aligner okay")
            
def runCactusCore(cactusDiskDatabaseString, alignmentFile, 
                  flowerName=0,
                  logLevel="DEBUG", 
                  writeDebugFiles=False,
                  annealingRounds=False,
                  alignRepeatsAtRound=False,
                  trim=None,
                  trimChange=None,
                  minimumTreeCoverage=None,
                  minimumBlockLength=None,
                  minimumBlockLengthChange=None,
                  minimumChainLength=None,
                  minimumChainLengthChange=None,
                  deannealingRounds=None,
                  adjacencyComponentOverlap=None):
    writeDebugFiles = nameValue("writeDebugFiles", writeDebugFiles, bool)
    annealingRounds = nameValue("annealingRounds", annealingRounds, int)
    alignRepeatsAtRound = nameValue("alignRepeatsAtRound", alignRepeatsAtRound, int)
    trim = nameValue("trim", trim, int)
    trimChange = nameValue("trimChange", trimChange, float)
    minimumTreeCoverage = nameValue("minimumTreeCoverage", minimumTreeCoverage, float)
    minimumBlockLength = nameValue("minimumBlockLength", minimumBlockLength, int)
    minimumBlockLengthChange = nameValue("minimumBlockLengthChange", minimumBlockLengthChange, float)
    minimumChainLength = nameValue("minimumChainLength", minimumChainLength, int)
    minimumChainLengthChange = nameValue("minimumChainLengthChange", minimumChainLengthChange, float)
    deannealingRounds = nameValue("deannealingRounds", deannealingRounds, int)
    adjacencyComponentOverlap = nameValue("adjacencyComponentOverlap", adjacencyComponentOverlap, int)
    
    command = "cactus_core --cactusDisk '%s' --flowerName %s --alignments %s --logLevel %s %s %s %s %s %s %s %s %s %s %s %s %s" % \
    (cactusDiskDatabaseString, flowerName, alignmentFile, logLevel, writeDebugFiles, annealingRounds, alignRepeatsAtRound,
     trim, trimChange, minimumTreeCoverage, minimumBlockLength,
     minimumBlockLengthChange, minimumChainLength, minimumChainLengthChange, deannealingRounds, adjacencyComponentOverlap)
    
    print "going to run", command
    assert 0
    system(command)
    logger.info("Ran cactus_core okay")
    
def runCactusPhylogeny(cactusDiskDatabaseString,
                  flowerNames=("0",),
                  logLevel="DEBUG"):<commit_msg>Incomplete - task : speed everything up <commit_after>"""Wrapper functions for assisting in running the various programs of the cactus package.
"""

import os
import random

from sonLib.bioio import logger
from sonLib.bioio import getTempFile
from sonLib.bioio import getTempDirectory
from sonLib.bioio import system
from sonLib.bioio import nameValue

from workflow.jobTree.test.jobTree.jobTreeTest import runJobTreeStatusAndFailIfNotComplete

#############################################
#############################################
#All the following provide command line wrappers
#for core programs in the cactus pipeline.
#############################################
#############################################  

def runCactusSetup(cactusDiskDatabaseString, sequences, 
                   newickTreeString, logLevel="DEBUG", debug=False):
    debugString = nameValue("debug", debug, bool)
    system("cactus_setup %s --speciesTree '%s' --cactusDisk '%s' \
--logLevel %s %s" \
           % (" ".join(sequences), newickTreeString,
              cactusDiskDatabaseString, logLevel, debugString))
    logger.info("Ran cactus setup okay")
    
def runCactusAligner(cactusDiskDatabaseString, alignmentFile, tempDir, useDummy=True, flowerName="0", logLevel="DEBUG"):        
    """Runs job tree and fails if not complete.
    """
    tempDir = getTempDirectory(tempDir)
    jobTreeDir = os.path.join(tempDir, "jobTree")
    useDummy = nameValue("useDummy", useDummy, bool)
    command = "cactus_aligner.py --cactusDisk '%s' --flowerName %s \
--resultsFile %s %s --jobTree %s --logLevel %s" % (cactusDiskDatabaseString, flowerName, alignmentFile, useDummy, jobTreeDir, logLevel)
    system(command)
    runJobTreeStatusAndFailIfNotComplete(jobTreeDir)
    system("rm -rf %s" % tempDir)
    logger.info("Ran the cactus aligner okay")
            
def runCactusCore(cactusDiskDatabaseString, alignmentFile, 
                  flowerName=0,
                  logLevel="DEBUG", 
                  writeDebugFiles=False,
                  annealingRounds=False,
                  alignRepeatsAtRound=False,
                  trim=None,
                  trimChange=None,
                  minimumTreeCoverage=None,
                  minimumBlockLength=None,
                  minimumBlockLengthChange=None,
                  minimumChainLength=None,
                  minimumChainLengthChange=None,
                  deannealingRounds=None,
                  adjacencyComponentOverlap=None):
    writeDebugFiles = nameValue("writeDebugFiles", writeDebugFiles, bool)
    annealingRounds = nameValue("annealingRounds", annealingRounds, int)
    alignRepeatsAtRound = nameValue("alignRepeatsAtRound", alignRepeatsAtRound, int)
    trim = nameValue("trim", trim, int)
    trimChange = nameValue("trimChange", trimChange, float)
    minimumTreeCoverage = nameValue("minimumTreeCoverage", minimumTreeCoverage, float)
    minimumBlockLength = nameValue("minimumBlockLength", minimumBlockLength, int)
    minimumBlockLengthChange = nameValue("minimumBlockLengthChange", minimumBlockLengthChange, float)
    minimumChainLength = nameValue("minimumChainLength", minimumChainLength, int)
    minimumChainLengthChange = nameValue("minimumChainLengthChange", minimumChainLengthChange, float)
    deannealingRounds = nameValue("deannealingRounds", deannealingRounds, int)
    adjacencyComponentOverlap = nameValue("adjacencyComponentOverlap", adjacencyComponentOverlap, int)
    
    command = "cactus_core --cactusDisk '%s' --flowerName %s --alignments %s --logLevel %s %s %s %s %s %s %s %s %s %s %s %s %s" % \
    (cactusDiskDatabaseString, flowerName, alignmentFile, logLevel, writeDebugFiles, annealingRounds, alignRepeatsAtRound,
     trim, trimChange, minimumTreeCoverage, minimumBlockLength,
     minimumBlockLengthChange, minimumChainLength, minimumChainLengthChange, deannealingRounds, adjacencyComponentOverlap)
    system(command)
    logger.info("Ran cactus_core okay")
    
def runCactusPhylogeny(cactusDiskDatabaseString,
                  flowerNames=("0",),
                  logLevel="DEBUG"):
{'fraction_non_alphanumeric': 0.13012781497261108, 'fraction_numerical': 0.000852099817407182, 'mean_word_length': 3.8529238038984053, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7272913', 'n_tokens_mistral': 2324, 'n_tokens_neox': 2216, 'n_words': 507}