Skip to content

Commit

Permalink
remove (now-)unused glfo seq argument
Browse files Browse the repository at this point in the history
  • Loading branch information
psathyrella committed Feb 1, 2017
1 parent f59e743 commit 6b50d46
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion bin/example-output-processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
for line in reader:
utils.process_input_line(line)
utils.add_implicit_info(glfo, line)
utils.print_reco_event(glfo['seqs'], line)
utils.print_reco_event(line)
cdr3_bounds = (line['codon_positions']['v'], line['codon_positions']['j'] + 3)
print ''
print ' should match the above:'
Expand Down
2 changes: 1 addition & 1 deletion python/alleleremover.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def finalize(self, pcounter, swfo, debug=False):
# unpadded_line['seqs'][0] = unpadded_line['seqs'][0][unpadded_line['padlefts'][0] : ]
# if unpadded_line['padrights'][0] > 0:
# unpadded_line['seqs'][0] = unpadded_line['seqs'][0][ : -unpadded_line['padrights'][0]]
# utils.print_reco_event(self.glfo['seqs'], unpadded_line)
# utils.print_reco_event(unpadded_line)

print ' keeping %d %s genes' % (len(self.genes_to_keep), self.region)
print ' removing %d %s genes: %d with no matches, %d with unconvincing matches (%d / %d queries had their best match removed)' % (len(self.genes_to_remove), self.region, len(set(self.glfo['seqs'][self.region]) - set(easycounts)), len(set(easycounts) - self.genes_to_keep), n_queries_with_removed_genes, len(swfo['queries']))
Expand Down
2 changes: 1 addition & 1 deletion python/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def print_event(self):
line['cdr3_length'] = self.cdr3_length
line['codon_positions'] = copy.deepcopy(self.final_codon_positions)
utils.add_implicit_info(self.glfo, line)
utils.print_reco_event(self.glfo['seqs'], line, extra_str=' ')
utils.print_reco_event(line, extra_str=' ')

# ----------------------------------------------------------------------------------------
def print_gene_choice(self):
Expand Down
10 changes: 5 additions & 5 deletions python/partitiondriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def view_existing_annotations(self):
print ' %s' % ':'.join(line['unique_ids'])
else:
print ''
utils.print_reco_event(self.glfo['seqs'], line)
utils.print_reco_event(line)
if len(failed_queries) > 0:
print '%d failed queries' % len(failed_queries)

Expand Down Expand Up @@ -1311,7 +1311,7 @@ def process_dummy_d_hack(self, line, debug=False):
if debug:
print ''
print ' dummy d hack for %s' % ' '.join(line['unique_ids'])
utils.print_reco_event(self.glfo['seqs'], tmpline, extra_str=' ', label='before')
utils.print_reco_event(tmpline, extra_str=' ', label='before')

gl_v_base = None
if tmpline['v_3p_del'] > 0:
Expand Down Expand Up @@ -1361,7 +1361,7 @@ def process_dummy_d_hack(self, line, debug=False):
after_line = copy.deepcopy(line)
utils.add_implicit_info(self.glfo, after_line)
if debug:
utils.print_reco_event(self.glfo['seqs'], after_line, extra_str=' ', label='after')
utils.print_reco_event(after_line, extra_str=' ', label='after')

# ----------------------------------------------------------------------------------------
def read_annotation_output(self, annotation_fname, outfname=None, count_parameters=False, parameter_out_dir=None, print_annotations=False):
Expand Down Expand Up @@ -1402,7 +1402,7 @@ def read_annotation_output(self, annotation_fname, outfname=None, count_paramete
n_invalid_events += 1
if self.args.debug:
print ' %s padded line invalid' % uidstr
utils.print_reco_event(self.glfo['seqs'], padded_line, extra_str=' ', label='invalid:')
utils.print_reco_event(padded_line, extra_str=' ', label='invalid:')
continue

assert uidstr not in padded_annotations
Expand Down Expand Up @@ -1520,7 +1520,7 @@ def print_hmm_output(self, line, print_true=False):
label = 'inferred:'
if self.args.seed_unique_id is not None and self.args.seed_unique_id in line['unique_ids']:
label += ' (found %d sequences clonal to seed %s)' % (len(line['unique_ids']), self.args.seed_unique_id)
utils.print_reco_event(self.glfo['seqs'], line, extra_str=' ', label=label, seed_uid=self.args.seed_unique_id)
utils.print_reco_event(line, extra_str=' ', label=label, seed_uid=self.args.seed_unique_id)

# ----------------------------------------------------------------------------------------
def write_annotations(self, annotations, outfname):
Expand Down
15 changes: 9 additions & 6 deletions python/prutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def ismuted(ch1, ch2):
return outstrs

# ----------------------------------------------------------------------------------------
def print_seq_in_reco_event(germlines, original_line, iseq, extra_str='', label='', one_line=False, seed_uid=None, check_line_integrity=False):
def print_seq_in_reco_event(original_line, iseq, extra_str='', label='', one_line=False, seed_uid=None, check_line_integrity=False):
"""
Print ascii summary of recombination event and mutation.
If <one_line>, then skip the germline lines, and only print the final_seq line.
Expand Down Expand Up @@ -135,7 +135,7 @@ def print_seq_in_reco_event(germlines, original_line, iseq, extra_str='', label=
+ line['vd_insertion'] + ' ' * line['lengths']['d'] + line['dj_insertion'] \
+ ' ' * (line['lengths']['j'] + line['j_3p_del'] + len(line['jf_insertion']))
germline_d_start = len(line['fv_insertion']) + line['lengths']['v'] + len(line['vd_insertion']) - line['d_5p_del']
germline_d_end = germline_d_start + len(germlines['d'][line['d_gene']])
germline_d_end = germline_d_start + line['d_5p_del'] + line['lengths']['d'] + line['d_3p_del']
d_line = ' ' * (germline_d_start + len(delstrs['v_5p'])) \
+ eroded_seqs_dots['d'] \
+ ' ' * (len(line['j_gl_seq']) + len(line['dj_insertion']) - line['d_3p_del'] + line['j_3p_del'] + len(line['jf_insertion']))
Expand All @@ -146,16 +146,19 @@ def print_seq_in_reco_event(germlines, original_line, iseq, extra_str='', label=
# and the query line
qrseq_line = ' ' * len(delstrs['v_5p']) + line['seqs'][iseq] + ' ' * line['j_3p_del']

outstrs = [insert_line, d_line, vj_line, qrseq_line]

if gap_insert_point is not None: # <gap_insert_point> point is only right here as long as there's no colors in these lines... but there usually almost probably always aren't
qrseq_line = qrseq_line[:gap_insert_point] + gapstr + qrseq_line[gap_insert_point:]
insert_line = insert_line[:gap_insert_point] + gapstr + insert_line[gap_insert_point:]
d_line = d_line[:gap_insert_point] + gapstr + d_line[gap_insert_point:]
for istr in [0, 1, 3]: # everybody except the vj line, which already has the modified interior delstrs above
outstrs[istr] = outstrs[istr][:gap_insert_point] + gapstr + outstrs[istr][gap_insert_point:]

if len(set([len(ostr) for ostr in outstrs])) > 1: # could put this in a bunch of different places, but things're probably most likely to get screwed up either when initally building the four lines, or dealing with the stupid gaps
raise Exception('outstrs not all the same length %s' % [len(ostr) for ostr in outstrs])

chain = utils.get_chain(line['v_gene'])
if chain != 'h':
assert line['lengths']['d'] == 0 and len(line['vd_insertion']) == 0

outstrs = [insert_line, d_line, vj_line, qrseq_line]
colors = [[[] for _ in range(len(ostr))] for ostr in outstrs]
outstrs, colors = indel_shenanigans(outstrs, colors, line['indelfos'][iseq], iseq)
outstrs = add_colors(outstrs, colors, line)
Expand Down
8 changes: 4 additions & 4 deletions python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def convert_from_adaptive_headers(glfo, line, uid=None, only_dj_rearrangements=F

if print_it:
add_implicit_info(glfo, newline)
print_reco_event(glfo['seqs'], newline, label=uid)
print_reco_event(newline, label=uid)

# still need to convert to integers/lists/whatnot (?)

Expand Down Expand Up @@ -996,7 +996,7 @@ def print_true_events(glfo, reco_info, line, print_naive_seqs=False, extra_str='
true_naive_seqs = []
for uids in get_true_partition(reco_info, ids=line['unique_ids']): # make a multi-seq line that has all the seqs from this clonal family
multiline = synthesize_multi_seq_line(uids, reco_info)
print_reco_event(glfo['seqs'], multiline, extra_str=extra_str, label=color('green', 'true:'))
print_reco_event(multiline, extra_str=extra_str, label=color('green', 'true:'))
true_naive_seqs.append(multiline['naive_seq'])

if print_naive_seqs:
Expand All @@ -1005,9 +1005,9 @@ def print_true_events(glfo, reco_info, line, print_naive_seqs=False, extra_str='
color_mutants(tseq, line['naive_seq'], print_result=True, print_hfrac=True, ref_label='true ', extra_str=' ')

# ----------------------------------------------------------------------------------------
def print_reco_event(germlines, line, one_line=False, extra_str='', label='', seed_uid=None):
def print_reco_event(line, one_line=False, extra_str='', label='', seed_uid=None):
for iseq in range(len(line['unique_ids'])):
prutils.print_seq_in_reco_event(germlines, line, iseq, extra_str=extra_str, label=(label if iseq==0 else ''), one_line=(iseq>0), seed_uid=seed_uid)
prutils.print_seq_in_reco_event(line, iseq, extra_str=extra_str, label=(label if iseq==0 else ''), one_line=(iseq>0), seed_uid=seed_uid)

#----------------------------------------------------------------------------------------
def sanitize_name(name):
Expand Down
10 changes: 5 additions & 5 deletions python/waterer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def finalize(self, cachefname=None, just_read_cachefile=False):
if self.debug and not self.args.is_data and len(self.remaining_queries) > 0:
print 'true annotations for remaining events:'
for qry in self.remaining_queries:
utils.print_reco_event(self.glfo['seqs'], self.reco_info[qry], extra_str=' ', label='true:')
utils.print_reco_event(self.reco_info[qry], extra_str=' ', label='true:')

self.info['remaining_queries'] = self.remaining_queries

Expand Down Expand Up @@ -772,8 +772,8 @@ def add_to_info(self, infoline):
inf_label = ' ' + utils.kbound_str({r : infoline['k_' + r] for r in ['v', 'd']})
if not self.args.is_data:
inf_label = 'inferred: ' + inf_label
utils.print_reco_event(self.glfo['seqs'], self.reco_info[qname], extra_str=' ', label=utils.color('green', 'true:'))
utils.print_reco_event(self.glfo['seqs'], self.info[qname], extra_str=' ', label=inf_label)
utils.print_reco_event(self.reco_info[qname], extra_str=' ', label=utils.color('green', 'true:'))
utils.print_reco_event(self.info[qname], extra_str=' ', label=inf_label)

if self.pcounter is not None:
self.pcounter.increment(self.info[qname])
Expand Down Expand Up @@ -1093,7 +1093,7 @@ def remove_framework_insertions(self, debug=False):
if swfo['indelfos'][0]['reversed_seq'] != swfo['seqs'][0]:
print '%s reversed seq not same as seq:\n%s\n%s' % (utils.color('red', 'warning'), swfo['indelfos'][0]['reversed_seq'], swfo['seqs'][0])

# utils.print_reco_event(self.glfo['seqs'], swfo)
# utils.print_reco_event(swfo)
utils.remove_all_implicit_info(swfo)
fv_len = len(swfo['fv_insertion'])
jf_len = len(swfo['jf_insertion'])
Expand All @@ -1109,7 +1109,7 @@ def remove_framework_insertions(self, debug=False):
swfo['jf_insertion'] = ''

utils.add_implicit_info(self.glfo, swfo)
# utils.print_reco_event(self.glfo['seqs'], swfo)
# utils.print_reco_event(swfo)

# *sigh* not super happy about it, but I think the best way to handle this is to also remove these bases from the simulation info
if self.reco_info is not None:
Expand Down

0 comments on commit 6b50d46

Please sign in to comment.