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

#Copyright (C) 2013 by <NAME>
#
#Released under the MIT license, see LICENSE.txt
#!/usr/bin/env python

"""Generate a series of HAL files at progressively coarse levels of detail
from an input file by calling halLodExtract
"""
import argparse
import os
import sys
import copy
import subprocess
import time
import inspect
import math
import random
import string
from collections import defaultdict
from multiprocessing import Pool

from hal.stats.halStats import runParallelShellCommands
from hal.stats.halStats import getHalGenomes
from hal.stats.halStats import getHalNumSegments
from hal.stats.halStats import getHalStats
from hal.stats.halStats import getHalSequenceStats
from hal.stats.halStats import getHalGenomeLength
from hal.stats.halStats import getHalRootName


# Wrapper for hal2maf
def getHal2MafCmd(options):
    cmd = "hal2maf %s %s --unique" % (options.halFile, makeOutMafPath(options))
    for opt,val in options.__dict__.items():
        if (val is not None and
            (type(val) != bool or val == True) and
            (opt == 'refGenome' or
             opt == 'refSequence' or
             opt == 'refTargets' or
             opt == 'start' or
             opt == 'length' or
             opt == 'rootGenome' or
             opt == 'targetGenomes' or
             opt == 'maxRefGap' or
             opt == 'noDupes' or
             opt == 'noAncestors' or
             opt == 'ucscNames')):
            if val is not True:
                cmd += ' --%s %s' % (opt, str(val))
            else:
                cmd += ' --%s' % opt
    if options.smallFile and not options.firstSmallFile:
        cmd += ' --append'
    return cmd

# Generate a MAF file name from an input HAL file and some options
# the MAF file will be in the specified directory
def makeOutMafPath(options):
    mafFile = os.path.basename(options.mafFile)
    mafName = os.path.splitext(mafFile)[0]
    mafDir = os.path.dirname(options.mafFile)
    if options.smallFile:
        mafName += '_small'
    else:
        if options.refSequence is not None and options.splitBySequence is True:
            mafName += '_%s' % options.refSequence
        if options.sliceNumber is not None:
            mafName += '_%s_%d' % (options.tempID, options.sliceNumber)
    mafPath = os.path.join(mafDir, mafName + '.maf')
    return mafPath

# slice an interval
# return (start, length, sliceIndex)
def computeSlices(options, seqLen):
    inStart = options.start
    if inStart is None:<commit_msg>pass inmemory option throught hal2maf<commit_after>#!/usr/bin/env python

#Copyright (C) 2013 by <NAME>
#
#Released under the MIT license, see LICENSE.txt
#!/usr/bin/env python

"""Generate a series of HAL files at progressively coarse levels of detail
from an input file by calling halLodExtract
"""
import argparse
import os
import sys
import copy
import subprocess
import time
import inspect
import math
import random
import string
from collections import defaultdict
from multiprocessing import Pool

from hal.stats.halStats import runParallelShellCommands
from hal.stats.halStats import getHalGenomes
from hal.stats.halStats import getHalNumSegments
from hal.stats.halStats import getHalStats
from hal.stats.halStats import getHalSequenceStats
from hal.stats.halStats import getHalGenomeLength
from hal.stats.halStats import getHalRootName


# Wrapper for hal2maf
def getHal2MafCmd(options):
    cmd = "hal2maf %s %s --unique" % (options.halFile, makeOutMafPath(options))
    for opt,val in options.__dict__.items():
        if (val is not None and
            (type(val) != bool or val == True) and
            (opt == 'refGenome' or
             opt == 'refSequence' or
             opt == 'refTargets' or
             opt == 'start' or
             opt == 'length' or
             opt == 'rootGenome' or
             opt == 'targetGenomes' or
             opt == 'maxRefGap' or
             opt == 'noDupes' or
             opt == 'noAncestors' or
             opt == 'ucscNames' or
             opt == 'inMemory')):
            if val is not True:
                cmd += ' --%s %s' % (opt, str(val))
            else:
                cmd += ' --%s' % opt
    if options.smallFile and not options.firstSmallFile:
        cmd += ' --append'
    return cmd

# Generate a MAF file name from an input HAL file and some options
# the MAF file will be in the specified directory
def makeOutMafPath(options):
    mafFile = os.path.basename(options.mafFile)
    mafName = os.path.splitext(mafFile)[0]
    mafDir = os.path.dirname(options.mafFile)
    if options.smallFile:
        mafName += '_small'
    else:
        if options.refSequence is not None and options.splitBySequence is True:
            mafName += '_%s' % options.refSequence
        if options.sliceNumber is not None:
            mafName += '_%s_%d' % (options.tempID, options.sliceNumber)
    mafPath = os.path.join(mafDir, mafName + '.maf')
    return mafPath

# slice an interval
# return (start, length, sliceIndex)
def computeSlices(options, seqLen):
    inStart = options.start
    if inStart is None:
{'fraction_non_alphanumeric': 0.09269442262372349, 'fraction_numerical': 0.0033385703063629223, 'mean_word_length': 2.6959361393323658, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '60920', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1522, 'n_words': 510}