Bioinformatics, 34(8), 1304-1312 (2018).
basepairs = []
opened_brackets = {}
// Iterate through input string and extract base pairs
for pos, symbol in enumerate(dot_bracket_notation):
if symbol in _OPENING_BRACKETS:
// Add opening residues to list (separate list for each
// bracket type)
index = _OPENING_BRACKETS.index(symbol)
if index not in opened_brackets:
opened_brackets[index] = []
opened_brackets[index].append(pos)
elif symbol in _CLOSING_BRACKETS:
// For each closing bracket, the the basepair consists out of
// the current index and the last index added to the list in
// `opened_brackets` corresponding to the same bracket type.
index = _CLOSING_BRACKETS.index(symbol)
basepairs.append((opened_brackets[index].pop(), pos))
else:
if symbol != ".":
raise ValueError(
f""{symbol}" is an invalid character for DBL-notation."
)
for _, not_closed in opened_brackets.items():
if not_closed != []:
raise ValueError(
"Invalid DBL-notation! Not all opening brackets have a "
After Change
Bioinformatics, 34(8), 1304-1312 (2018).
basepairs = []
opened_brackets = [[] for _ in range(len(_OPENING_BRACKETS))]
// Iterate through input string and extract base pairs
for pos, symbol in enumerate(dot_bracket_notation):