Skip to content

Commit

Permalink
[fix]
Browse files Browse the repository at this point in the history
Fixes nextstrain#591 in translate.py by perfoming the check for feature type source for vcf and alignment mode.

Fixes [1108] by moving the warnung about padding outside of translate_vcf_feature. Padding will happen in both cases - not only vcf - and the feature name is also available at this point
  • Loading branch information
andreott committed Dec 8, 2022
1 parent 029c5bd commit c4ab7e3
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions augur/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ def str_reverse_comp(str_seq):
prot['positions'] = []

refNuc = str(feature.extract( SeqRecord(seq=Seq(ref)) ).seq)
# Need to get ref translation to store. check if multiple of 3 for sanity.
# will be padded in safe_translate if not
if len(refNuc)%3:
print("Gene length of {} is not a multiple of 3. will pad with N".format(feature.qualifiers['Name'][0]), file=sys.stderr)

ref_aa_seq = safe_translate(refNuc)
prot['reference'] = ref_aa_seq

Expand Down Expand Up @@ -360,14 +355,18 @@ def run(args):
translations = {}
deleted = []
for fname, feat in features.items():
if is_vcf:
trans = translate_vcf_feature(sequences, ref, feat)
if trans:
translations[fname] = trans
if feat.type != 'source':
# Check if multiple of 3 for sanity.
# will be padded in safe_translate if not
if len(str(feat.extract( SeqRecord(seq=Seq(ref)) ).seq))%3:
print(f"Gene length of {fname} is not a multiple of 3. will pad with N", file=sys.stderr)
if is_vcf:
trans = translate_vcf_feature(sequences, ref, feat)
if trans:
translations[fname] = trans
else:
deleted.append(fname)
else:
deleted.append(fname)
else:
if feat.type != 'source':
translations[fname] = translate_feature(sequences, feat)

if len(deleted) != 0:
Expand Down

0 comments on commit c4ab7e3

Please sign in to comment.