Liad
Liad

Reputation: 339

How to generate IUPAC code from nucleotides?

I want to find the IUPAC equivalent to 2 different nucleotides.

Example: I have A and C and I want M. Or: I have R and T and I want D.

Is there a method for doing that in Biopython? (It sound easy but I only found method for doing that using alignment and that's not appropriate in my case.)

Thanks!

Upvotes: 1

Views: 659

Answers (1)

Chris_Rands
Chris_Rands

Reputation: 41168

I think you're looking for the dictionaries in Bio.Data.IUPACData, like:

>>> from Bio.Data import IUPACData
>>> d = {v:k for k,v in IUPACData.ambiguous_dna_values.items()}
>>> d['AC']
'M'

Note, reversing the dictionary mapping here means we lose a key since 'X' and 'N' both map to 'GATC'.

Upvotes: 5

Related Questions