How to compute the amount in moles of XX grams of DNA using Python

You can easily compute the number of moles in a given mass of DNA using UliEngineering’s DNARNA module.

How to install

Install UliEngineering using:

pip install -U UliEngineering

Example: Calculating moles from DNA mass

Suppose you have a certain mass of single-stranded DNA (ssDNA) and want to know how many moles that corresponds to. You can use the dnarna_grams_to_moles function:

from UliEngineering.Chemistry.DNARNA import *
from UliEngineering.EngineerIO import format_value

length = 100  # Number of nucleotides

moles = dnarna_grams_to_moles("10mg", length, fractions=equal_dna_fractions)
print(f"{format_value(mass_g, 'g')} ssDNA ({length} nt, equal base composition) = {format_value(moles, 'mol')}")

Example output

0.01 g ssDNA (100 nt, equal base composition) = 3.227e-07 mol

Calculation Method

The function first calculates the molecular weight of the DNA strand and then divides the given mass by this molecular weight (in grams per mole) to obtain the number of moles.