Commit 127bb74d authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

germline/generate-recombinations.py: add locus code + ' ' at the end of the should_pattern

parent eed68279
...@@ -68,7 +68,7 @@ def id_line_to_tap(l, tap_id): ...@@ -68,7 +68,7 @@ def id_line_to_tap(l, tap_id):
l = l.strip() l = l.strip()
pos = l.find(' ') pos = l.find(' ')
should = l[1:pos] should = l[1:pos]
result = l[pos+1:] result = l[pos+1:] + ' '
# We could have something that allows some regexp (still allowing * and + without escaping) # We could have something that allows some regexp (still allowing * and + without escaping)
should_pattern = should.replace('_', ' ') should_pattern = should.replace('_', ' ')
......
...@@ -7,8 +7,8 @@ import random ...@@ -7,8 +7,8 @@ import random
random.seed(33328778554) random.seed(33328778554)
def recombine_VJ(seq5, remove5, N, remove3, seq3): def recombine_VJ(seq5, remove5, N, remove3, seq3, code):
name = "%s %d/%s/%d %s" % (seq5.name, remove5, N, remove3, seq3.name) name = "%s %d/%s/%d %s %s " % (seq5.name, remove5, N, remove3, seq3.name, code)
seq = seq5.seq[:len(seq5)-remove5] + '\n' + N + '\n' + seq3.seq[remove3:] seq = seq5.seq[:len(seq5)-remove5] + '\n' + N + '\n' + seq3.seq[remove3:]
return fasta.Fasta(name, seq) return fasta.Fasta(name, seq)
...@@ -17,7 +17,7 @@ def recombine_VJ(seq5, remove5, N, remove3, seq3): ...@@ -17,7 +17,7 @@ def recombine_VJ(seq5, remove5, N, remove3, seq3):
def random_sequence(characters, length): def random_sequence(characters, length):
return ''.join([random.choice(characters) for x in range(length)]) return ''.join([random.choice(characters) for x in range(length)])
def recombine_VJ_with_removes(seq5, remove5, Nlength, remove3, seq3): def recombine_VJ_with_removes(seq5, remove5, Nlength, remove3, seq3, code):
'''Recombine V and J with a random N, ensuring that the bases in N are not the same that what was ultimately removed from V or J''' '''Recombine V and J with a random N, ensuring that the bases in N are not the same that what was ultimately removed from V or J'''
assert(Nlength >= 1) assert(Nlength >= 1)
...@@ -29,7 +29,7 @@ def recombine_VJ_with_removes(seq5, remove5, Nlength, remove3, seq3): ...@@ -29,7 +29,7 @@ def recombine_VJ_with_removes(seq5, remove5, Nlength, remove3, seq3):
if c in available: if c in available:
available.remove(c) available.remove(c)
return recombine_VJ(seq5, remove5, random_sequence(available, Nlength), remove3, seq3) return recombine_VJ(seq5, remove5, random_sequence(available, Nlength), remove3, seq3, code)
def select_genes(rep5, rep3, at_least=0): def select_genes(rep5, rep3, at_least=0):
...@@ -89,9 +89,9 @@ for code in germlines: ...@@ -89,9 +89,9 @@ for code in germlines:
# Generate recombinations # Generate recombinations
generate_to_file(rep5, rep3, '../data/gen/0-removes-%s.should-vdj.fa' % code, generate_to_file(rep5, rep3, '../data/gen/0-removes-%s.should-vdj.fa' % code,
(lambda seq5, seq3: recombine_VJ(seq5, 0, 'ATCG', 0, seq3))) (lambda seq5, seq3: recombine_VJ(seq5, 0, 'ATCG', 0, seq3, code)))
generate_to_file(rep5, rep3, '../data/gen/5-removes-%s.should-vdj.fa' % code, generate_to_file(rep5, rep3, '../data/gen/5-removes-%s.should-vdj.fa' % code,
(lambda seq5, seq3: recombine_VJ_with_removes(seq5, 5, 4, 5, seq3))) (lambda seq5, seq3: recombine_VJ_with_removes(seq5, 5, 4, 5, seq3, code)))
print() print()
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