Commit 7cfeaca8 authored by Mikaël Salson's avatar Mikaël Salson

should-vdj: Allow more complex ambiguous designations

parent a7aaee81
......@@ -109,12 +109,10 @@ def should_pattern_to_regex(p):
return []
# Ambiguous/alternate pattern
if term.startswith('('):
if term.startswith(','):
choices = []
term_without_par = term[1:-1]
for t in term_without_par.split(','):
choices += process_term(t)
return ['(%s)' % '|'.join(choices)]
term_without_comma = term[1:]
return ['|' + ''.join(process_term(term_without_comma))]
# (such as CDR3 / junction)
if term.startswith('{'):
......@@ -159,12 +157,21 @@ def should_pattern_to_regex(p):
r = []
p = p.replace(', ', ',')
p = re.sub('\s*,\s*', ' ,', p)
m = re.search('^(.*)\s*\((.+)\)\s*(.*)$', p)
if m:
# We have parentheses
re1 = should_pattern_to_regex(m.group(1)).pattern
re2 = '('+should_pattern_to_regex(m.group(2)).pattern+')'
re3 = should_pattern_to_regex(m.group(3)).pattern
regex_pattern = '\s*'.join(x for x in [re1, re2, re3])
else:
# We have a parenthesis free expression
for term in p.split():
r += process_term(term)
for term in p.split():
r += process_term(term)
regex_pattern = ' .*'.join(r)
regex_pattern = ' .*'.join(r)
try:
regex = re.compile(regex_pattern)
......
......@@ -128,9 +128,14 @@ TGGGGCCAGGGAACCCTGGTCACCGTCTCCTCAGTT
# TRGJ1*01 or TRGJ1*02
>TRGV5*01 (TRGJ1*01, TRGJ1*02) [TRG]
...
# TRGJ1*01 or TRGJ1*02 but with different deletions
>TRGV4*02 (4/4/4 TRGJ1*01, 4/4/1 TRGJ1*02) [TRG]
#+END_EXAMPLE
* Program-specific information
** Vidjil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment