--- title: Utils module keywords: fastai sidebar: home_sidebar summary: "the util functions" description: "the util functions" nb_path: "nbs/03_Utils.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
{% endraw %} {% raw %}

mkpath[source]

mkpath(directory)

Have to use system mkdir here because python2.7's mkpath is currently faulty!

{% endraw %} {% raw %}

class Environment[source]

Environment()

{% endraw %} {% raw %}

class StdoutCapturer[source]

StdoutCapturer(iterable=()) :: list

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

{% endraw %} {% raw %}

stdoutRedirect[source]

stdoutRedirect(to='/dev/null')

import os

with stdoutRedirect(to=filename): print("from Python") os.system("echo non-Python applications are also supported")

{% endraw %} {% raw %}

class cd[source]

cd(newPath)

Context manager for changing the current working directory

{% endraw %} {% raw %}

runCommand[source]

runCommand(cmd, instream=None, msg='', upon_succ=None, show_stderr=False, return_zero=True)

{% endraw %} {% raw %}

class CMDWorker[source]

CMDWorker(queue) :: Process

Process objects represent activity that is run in a separate process

The class is analogous to threading.Thread

{% endraw %} {% raw %}

runCommands[source]

runCommands(cmds, ncpu)

{% endraw %} {% raw %}

parmap[source]

parmap(f, X, nprocs=32)

{% endraw %} {% raw %}

downloadURL[source]

downloadURL(URL, dest_dir, quiet=True, mode=None, force=False)

{% endraw %} {% raw %}

calculateFileMD5[source]

calculateFileMD5(filename)

{% endraw %} {% raw %}

zipdir[source]

zipdir(path, zipfile, arcroot='/')

{% endraw %} {% raw %}

removeFiles[source]

removeFiles(dest, exclude=[], hidden=False)

{% endraw %} {% raw %}

removeEmptyDir[source]

removeEmptyDir(directory)

{% endraw %} {% raw %}

copyFiles[source]

copyFiles(pattern, dist, ignore_hidden=True)

{% endraw %} {% raw %}

downloadResources[source]

downloadResources(fromto)

{% endraw %} {% raw %}

getColumn[source]

getColumn(fn, num, delim=None, exclude=None)

{% endraw %} {% raw %}

wordCount[source]

wordCount(filename)

Returns a word/count dict for this filename.

{% endraw %} {% raw %}

fileLinesCount[source]

fileLinesCount(fname)

{% endraw %} {% raw %}

connected_components[source]

connected_components(lists)

{% endraw %} {% raw %}

listit[source]

listit(t)

{% endraw %} {% raw %}

parseVCFline[source]

parseVCFline(line, exclude=[])

{% endraw %} {% raw %}

indexVCF[source]

indexVCF(vcf, verbose=True)

{% endraw %} {% raw %}

extractSamplenames[source]

extractSamplenames(vcf)

{% endraw %} {% raw %}

checkVCFBundle[source]

checkVCFBundle(vcf)

VCF bundle should have a .gz file and a tabix file

{% endraw %} {% raw %}

rewriteFamfile[source]

rewriteFamfile(tfam, samples, keys)

{% endraw %} {% raw %}

checkSamples[source]

checkSamples(samp1, samp2)

check if two sample lists agree

  1. samples in FAM but not in VCF --> ERROR
  2. samples in VCF but not in FAM --> give a message
{% endraw %} {% raw %}

class NoCache[source]

NoCache()

{% endraw %} {% raw %}

class Cache[source]

Cache(cache_dir, cache_name, params)

{% endraw %} {% raw %}

class PseudoAutoRegion[source]

PseudoAutoRegion(chrom, build)

{% endraw %} {% raw %}

class TFAMParser[source]

TFAMParser(tfam=None)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

isnotebook[source]

isnotebook()

{% endraw %}