<commit_before>#!/usr/bin/env python


"""Script runs cactus to compare a bunch of assemblies against a set of two haplotypes and 
a set of contamination sequences.
"""

import os
import xml.etree.ElementTree as ET
import xml
import sys
from optparse import OptionParser

from jobTree.scriptTree.target import Target 
from jobTree.scriptTree.stack import Stack

from jobTree.src.bioio import logger
from jobTree.src.bioio import setLoggingFromOptions

from cactus.shared.config import CactusWorkflowExperiment
from cactus.shared.common import runCactusWorkflow

from sonLib.bioio import getTempFile, getTempDirectory
from sonLib.bioio import fastaRead, fastaWrite
from sonLib.bioio import system

from jobTree.test.jobTree.jobTreeTest import runJobTreeStatusAndFailIfNotComplete

def getRootPathString():
    """
    function for finding external location
    """
    import os
    import assemblathon.bin.pipeline
    i = os.path.abspath(assemblathon.bin.pipeline.__file__)
    return os.path.split(os.path.split(i)[0])[0] #os.path.split(os.path.split(os.path.split(i)[0])[0])[0]

def getCactusDiskString(alignmentFile):
    return "<st_kv_database_conf type=\"tokyo_cabinet\"><tokyo_cabinet database_dir=\"%s\"/></st_kv_database_conf>" % alignmentFile

class MakeAlignment(Target):
    """Target runs the alignment.
    """
    def __init__(self, newickTree, haplotypeSequences, 
                 assemblyFile, outputDir, configFile, options):
        Target.__init__(self, cpu=1, memory=8000000000)
        self.newickTree = newickTree
        self.haplotypeSequences = haplotypeSequences
        self.assemblyFile = assemblyFile
        self.outputDir = outputDir
        self.configFile = configFile
        self.options = options
    
    def run(self):
        cactusAlignmentName = "cactusAlignment"
        cactusAlignment = os.path.join(self.outputDir, cactusAlignmentName)
        if not os.path.exists(cactusAlignment):
            #Prepare the assembly
            #First copy it.
            if self.assemblyFile[-3:] == '.gz':
               tempAssemblyFile = getTempFile(rootDir=self.getLocalTempDir(), suffix=".gz")<commit_msg>Fixed import<commit_after>#!/usr/bin/env python


"""Script runs cactus to compare a bunch of assemblies against a set of two haplotypes and 
a set of contamination sequences.
"""

import os
import xml.etree.ElementTree as ET
import xml
import sys
from optparse import OptionParser

from jobTree.scriptTree.target import Target 
from jobTree.scriptTree.stack import Stack

from jobTree.src.bioio import logger
from jobTree.src.bioio import setLoggingFromOptions

from cactus.shared.config import CactusWorkflowExperiment
from cactus.shared.common import runCactusWorkflow

from sonLib.bioio import getTempFile, getTempDirectory
from sonLib.bioio import fastaRead, fastaWrite
from sonLib.bioio import system

from jobTree.test.jobTree.jobTreeTest import runJobTreeStatusAndFailIfNotComplete

def getRootPathString():
    """
    function for finding external location
    """
    import os
    import assemblaScripts.bin.pipeline
    i = os.path.abspath(assemblaScripts.bin.pipeline.__file__)
    return os.path.split(os.path.split(i)[0])[0] #os.path.split(os.path.split(os.path.split(i)[0])[0])[0]

def getCactusDiskString(alignmentFile):
    return "<st_kv_database_conf type=\"tokyo_cabinet\"><tokyo_cabinet database_dir=\"%s\"/></st_kv_database_conf>" % alignmentFile

class MakeAlignment(Target):
    """Target runs the alignment.
    """
    def __init__(self, newickTree, haplotypeSequences, 
                 assemblyFile, outputDir, configFile, options):
        Target.__init__(self, cpu=1, memory=8000000000)
        self.newickTree = newickTree
        self.haplotypeSequences = haplotypeSequences
        self.assemblyFile = assemblyFile
        self.outputDir = outputDir
        self.configFile = configFile
        self.options = options
    
    def run(self):
        cactusAlignmentName = "cactusAlignment"
        cactusAlignment = os.path.join(self.outputDir, cactusAlignmentName)
        if not os.path.exists(cactusAlignment):
            #Prepare the assembly
            #First copy it.
            if self.assemblyFile[-3:] == '.gz':
               tempAssemblyFile = getTempFile(rootDir=self.getLocalTempDir(), suffix=".gz")
{'fraction_non_alphanumeric': 0.09033760186263097, 'fraction_numerical': 0.007916181606519208, 'mean_word_length': 3.7733333333333334, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 2, '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': '7508073', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1267, 'n_words': 306}