Converts between chromosome names.
lcdblib.utils.chrom_convert.fasta_convert(input, output, mapper)[source]¶Uses Biopython.SeqIO to convert FASTA headers.
lcdblib.utils.chrom_convert.import_conversion(f, t)[source]¶Import NCBI conversion table.
| Parameters: |
|
|---|---|
| Returns: | dict |
| Return type: | Mapping {f: t} |
lcdblib.utils.chrom_convert.pybedtools_convert(input, output, mapper)[source]¶Use pybedtools to convert chromosomes in BED, GTF, or GFF.
lcdblib.utils.chrom_convert.pysam_convert(input, output, kind, mapper)[source]¶Use pysam to convert chromosomes in BAM and SAM files.
pysam uses a header to define chromosomes, then each read is just mapped back to this header. Only the header needs to be modified, and reads need to be written to the new output file which uses this header.
lcdblib.utils.utils.boolean_labels(names, idx, mapping={False: 'NOT', True: 'AND'}, strip='AND_')[source]¶Creates labels for boolean lists.
For example:
>>> names = ['exp1', 'exp2', 'exp3']
>>> idx = [True, True, False]
>>> boolean_labels(names, idx)
'exp1_AND_exp2_NOT_exp3'
| Parameters: |
|
|---|
lcdblib.utils.utils.flatten(iter, unlist=False)[source]¶Flatten an arbitrarily nested iterable whose innermost items are strings into a flat list of strings.
| Parameters: |
|
|---|
lcdblib.utils.utils.make_relative_symlink(target, linkname)[source]¶Helper function to create a relative symlink.
Changes to the dirname of the linkname and figures out the relative path to the target before creating the symlink.
lcdblib.utils.utils.update_recursive(orig, update_with)[source]¶Recursively update one dict with another.
From https://stackoverflow.com/a/3233356
>>> orig = {'a': {'b': 1, 'c': 2, 'd': [7, 8, 9]}}
>>> update_with = {'a': {'b': 5}}
>>> expected = {'a': {'b': 5, 'c': 2, 'd': [7, 8, 9]}}
>>> result = update_recursive(orig, update_with)
>>> assert result == expected, result
>>> update_with = {'a': {'d': 1}}
>>> result = update_recursive(orig, update_with)
>>> expected = {'a': {'b': 5, 'c': 2, 'd': 1}}
>>> result = update_recursive(orig, update_with)
>>> assert result == expected, result
lcdblib.utils.utils.updatecopy(orig, update_with, keys=None, override=False)[source]¶Update a copy of a dictionary, with a bit more control than the built-in dict.update.
| Parameters: |
|
|---|