Lib Filter¶
Contain functions to filter information from the DB.
- idpconfgen.libs.libfilter.make_any_overlap_regex(range_)¶
Make an overlap regex.
- idpconfgen.libs.libfilter.make_helix_overlap_regex(range_)¶
Make an overlap regex.
- idpconfgen.libs.libfilter.make_loop_overlap_regex(range_)¶
Make an overlap regex.
- idpconfgen.libs.libfilter.make_ranges(regex_string, rang_rex=re.compile('(\\{\\d+\\,\\d+\\}|\\{\\d+\\}|\\{\\d+\\,\\}|\\{\\,\\d+\\})'), char_rex=re.compile('((\\w)\\{|\\[([\\w ]+)\\]\\{)'), max_range=30)[source]¶
Define a set of ranges and characters from regex_string.
Examples
>>> make_range('L{1}H{1,2}') [range(1, 2), range(1, 3)], ['L', 'H']
>>> make_range('L{1,}H{,2}') [range(1, None), range(1, 3)], ['L', 'H']
- idpconfgen.libs.libfilter.make_regex_combinations(ranges, chars, pre=None, suf=None)[source]¶
Make combinations of regexes from ranges and chars.
This function is not a general abstraction. Is instead a partial abstraction within the problem of IDPConfGen.
- Parameters:
ranges (list of range objects) – Ranges where to start and stop searching in the regex. Ranges should follow regex conventions, usually 1-indexed and stop inclusive.
chars (list of 1 letter chars) – The chars that will be searched in ranges.
pre, suf (str) – Strings to add as prefix and suffix of the generates ranges.
- idpconfgen.libs.libfilter.make_strand_overlap_regex(range_)¶
Make an overlap regex.
- idpconfgen.libs.libfilter.regex_forward_no_overlap(sequence, regex)[source]¶
Search for regex forward without overlap.
Examples
r’L’ r’L{2}’ r’L{1,3}’
- In the first example, returns all indexes of single char L without
overlap.
- On the second example, returns all indexes of entire ‘LL’ sequences
without overlap. So, ‘LLL’ returns only slice(0, 2).
- returns all sequences with ‘LLL’ without overlap, if a terminal ‘LL’
is found, returns that. Same for ‘L’ if found at the end.
Using expressions such as r’(?=(L))’ give not correct results. Use regex_forward_with_overlap instead.
- idpconfgen.libs.libfilter.regex_forward_with_overlap(sequence, regex)[source]¶
Find matches for regex in sequence of chars.
Considers regex defines overlap.
Accepts only regex expressions with overlap, for example:
r’(?=(L{3}))’
- Returns:
list of slices – Where slice.start and slice.stop follow Python conventions.
- idpconfgen.libs.libfilter.regex_has_overlap(regex_string, overlap_rex=re.compile('\\(\\?\\=\\(.+\\)'))[source]¶
Find if a regex_string defines overlap.
- Parameters:
regex_string (str) – The regex string.
overlap_fmt (str) – The regex to find overlap in regex_string.
- Returns:
bool
- idpconfgen.libs.libfilter.regex_range(sequence, regex_string, ncores=1)[source]¶
Find slices of sequence where regex_string applies.
Searches forward and backwards by means of exploring ranges as individual regexes.
- idpconfgen.libs.libfilter.regex_search(sequence, regex_string, rex_range=re.compile('(\\{\\d+\\,\\d+\\}|\\{\\d+\\}|\\{\\d+\\,\\}|\\{\\,\\d+\\})'), **kwargs)[source]¶
Search for regex in sequence.
- Parameters:
sequence (str) – The sequence where to apply the regex.
regex_string (str) – The regex to search for.
regex_range (compiled regex) – A regex to apply in regex_string to identify if regex_string refers to a range.
- Returns:
list of slices