Skip to content

Commit

Permalink
Merge pull request #75 from lauraluebbert/patch-1
Browse files Browse the repository at this point in the history
Update biotables.py to allow standard ambigious amino acid annotations (X, B, J, Z)
  • Loading branch information
veghp authored Jun 6, 2023
2 parents 68f993d + 6188a97 commit 7f7c17c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dnachisel/biotools/biotables.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def dict_from_csv(filepath, sep=";"):
iupac_file = os.path.join(data_dir, "iupac_notation.csv")
IUPAC_NOTATION = {k: set(v) for k, v in dict_from_csv(iupac_file).items()}

def flatten(l):
return [item for sublist in l for item in sublist]

def get_backtranslation_table(table_name="Standard"):
table = CodonTable.unambiguous_dna_by_name[table_name]
Expand All @@ -59,4 +61,8 @@ def get_backtranslation_table(table_name="Standard"):
back_translation_table[amino_acid].append(codon)
back_translation_table["*"] = table.stop_codons
back_translation_table["START"] = table.start_codons
back_translation_table["X"] = list(set(flatten(back_translation_table.values())) - set(back_translation_table["*"]))
back_translation_table["B"] = back_translation_table["N"] + back_translation_table["D"]
back_translation_table["J"] = back_translation_table["L"] + back_translation_table["I"]
back_translation_table["Z"] = back_translation_table["E"] + back_translation_table["Q"]
return back_translation_table

0 comments on commit 7f7c17c

Please sign in to comment.