Skip to content
Snippets Groups Projects
Commit 05edfb17 authored by Blaise Li's avatar Blaise Li
Browse files

Moving small types definition in libsmallrna.

parent 27f617cc
No related branches found
No related tags found
No related merge requests found
...@@ -3,4 +3,10 @@ from .libsmallrna import ( ...@@ -3,4 +3,10 @@ from .libsmallrna import (
count_small, count_small,
count_annots, count_pimis, count_sis, count_all_sis, count_nucl, count_first_bases, count_annots, count_pimis, count_sis, count_all_sis, count_nucl, count_first_bases,
add_compositions, add_results, Composition, get_read_info, add_compositions, add_results, Composition, get_read_info,
PI_MIN, PI_MAX, SI_MIN, SI_MAX) PI_MIN, PI_MAX, SI_MIN, SI_MAX
SI_PREFIXES, SMALL_TYPES_TREE,
types_under,
SMALL_TYPES,
SI_TYPES,
SIU_TYPES,
RMSK_SISIU_TYPES)
...@@ -40,11 +40,50 @@ from operator import add ...@@ -40,11 +40,50 @@ from operator import add
from functools import reduce from functools import reduce
#from pysam import AlignedSegment #from pysam import AlignedSegment
#############################################
# Declaring small types and their hierarchy #
#############################################
RMSK_PREFIXES = ["te", "satel", "simrep"]
SI_PREFIXES = ["prot", "pseu"] + RMSK_PREFIXES
# Should we have only non-overlapping sets ?
SMALL_TYPES_TREE = {
"si": {
"rmsk": [prefix + "_si" for prefix in RMSK_PREFIXES],
"prot": ["prot_si"], "pseu": ["pseu_si"]},
"siu": {
"rmsk": [prefix + "_siu" for prefix in RMSK_PREFIXES],
"prot": ["prot_siu"], "pseu": ["pseu_siu"]},
"pi": ["pi"],
"mi": ["mi"]
}
def types_under(typekeys, tree=SMALL_TYPES_TREE):
"""
Generate type names corresponding to the branching according to the
succession of keys *typekeys* in the *tree* dictionary of (ultimately)
lists.
"""
if typekeys:
yield from types_under(typekeys[1:], tree[typekeys[0]])
else:
if isinstance(tree, dict):
for subtree in tree.values():
yield from types_under([], subtree)
else:
yield from tree
SMALL_TYPES = list(types_under([]))
SI_TYPES = list(types_under(["si"]))
SIU_TYPES = list(types_under(["siu"]))
RMSK_SISIU_TYPES = set(chain(types_under(["si", "rmsk"]), types_under(["siu", "rmsk"])))
FQ_TEMPLATE = b"@%s\n%s\n+\n%s\n" FQ_TEMPLATE = b"@%s\n%s\n+\n%s\n"
DNA_COMPL_TABLE = str.maketrans("ACGTRYSWKMBDHVN", "TGCAYRWSMKVHDBN") DNA_COMPL_TABLE = str.maketrans("ACGTRYSWKMBDHVN", "TGCAYRWSMKVHDBN")
cdef str creverse_complement(str seq): cdef str creverse_complement(str seq):
return seq.translate(DNA_COMPL_TABLE)[::-1] return seq.translate(DNA_COMPL_TABLE)[::-1]
......
...@@ -3,7 +3,7 @@ from Cython.Build import cythonize ...@@ -3,7 +3,7 @@ from Cython.Build import cythonize
setup( setup(
name="libsmallrna", name="libsmallrna",
version="0.1", version="0.2",
description="Miscellaneous things to deal with small RNA", description="Miscellaneous things to deal with small RNA",
author="Blaise Li", author="Blaise Li",
author_email="blaise.li@normalesup.org", author_email="blaise.li@normalesup.org",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment