FormatFlow

No tool matches “”

Try a format (“webp”, “mp3”) or a verb (“merge”, “compress”).

Loading index

↵to open

how-to · 5 min read

How to calculate GC content from a sequence

GC content is the percentage of a nucleotide sequence made up of guanine and cytosine. It is one of the simplest sequence statistics to calculate and one of the easiest to get subtly wrong, because the clean percentage depends on which bases are counted in the denominator and how the input was formatted.

This guide gives the formula, explains how DNA and RNA change it, shows a worked example with an ambiguity code, and covers the normalization and cleaning steps that a GC content calculator should do for you.

The GC content formula

For a DNA sequence, GC content is (G + C) divided by (A + T + G + C), multiplied by 100. The denominator is every unambiguous base in the sequence, not the number of characters in the pasted text and not the sequence length including ambiguity codes. Stated as a formula, GC% = (G + C) / (A + T + G + C) × 100.

The result is a proportion expressed as a percentage, so a sequence with equal numbers of G and C bases and no other bases would give 100%, while a sequence of only A and T would give 0%. Most real sequences fall somewhere in between, and the number is only meaningful alongside the count of bases that produced it.

DNA and RNA: T and U change the denominator

RNA uses uracil in place of thymine, so the RNA version of the formula is (G + C) / (A + U + G + C) × 100. The numerator is unchanged, because guanine and cytosine are the same in both molecules. What changes is which fourth base contributes to the denominator.

If a sequence contains both T and U, it is not a normal single strand, so treat that as a warning rather than choosing one denominator silently. A calculator should report the molecule it detected and state the exact denominator it used, which is the only way to compare two GC values honestly.

Worked example: ATGCGCNN

Take the short sequence ATGCGCNN. It has eight letters, but two of them are N, an ambiguity code that does not identify a base. Removing the Ns leaves six unambiguous bases: one A, one T, two Gs and two Cs. The GC numerator is 2 + 2 = 4, and the denominator is 6, so GC content is 4/6 × 100 = 66.7%.

Compare that with counting all eight letters and treating the Ns as non-GC: 4/8 would give 50%. The difference is not a rounding detail, it is a different question. The first answer describes the known bases, the second treats unknown positions as if they were known not to be G or C. Reporting the denominator resolves the ambiguity.

Why ambiguity codes are handled separately

Ambiguity codes such as N, R, Y, S, W, K, M, B, D, H and V describe sets of possible bases. N means any base, R means a purine (A or G), Y means a pyrimidine (C or T), and the others encode partial information. A code like R might hide a G, which would raise the GC content, so counting it as GC would overstate the result and counting it as non-GC would understate it.

The most defensible approach is to exclude ambiguity codes from both the numerator and the denominator, then report how many there were and list the codes found. A sequence with many Ns can then be recognized as having a GC percentage based on very few known bases, which is a different level of confidence from a percentage over thousands of unambiguous bases.

Cleaning a FASTA record before counting

Sequence data rarely arrives as a bare string. A FASTA record has a header line beginning with >, the sequence may be wrapped across many lines, and pasted output often contains spaces or position numbers. None of those characters is a base, so counting the raw text would produce a wrong denominator.

A proper calculation strips header and comment lines, removes whitespace, digits and punctuation, uppercases the remaining letters, and then counts. If several records are pasted together, their sequences are usually concatenated by this kind of cleaning, so per-record GC content requires analyzing one record at a time or using software that keeps records separate.

What GC content tells you and what it does not

GC content is a compact summary of base composition. It is used to compare sequences and regions, to check that a primer or amplicon has the expected composition, and as one input when thinking about duplex stability, because G-C pairs have three hydrogen bonds and A-T or A-U pairs have two. That gives a qualitative trend, not a melting temperature: the actual stability also depends on length, salt, mismatches and sequence context.

GC content does not identify an organism, a gene or a function, and it does not tell you whether the molecule is DNA or RNA; the presence of T or U does that. Short sequences give noisy percentages, sequences with many ambiguity codes give low-confidence ones, and values from different samples are only comparable when they were counted the same way. Reporting the percentage, the denominator and the ambiguity count together keeps the number honest.

Frequently asked questions

What is the exact formula for GC content?
GC content is the number of guanine bases plus the number of cytosine bases, divided by the number of unambiguous bases in the sequence, multiplied by 100. For DNA the denominator is A + T + G + C; for RNA it is A + U + G + C. Ambiguity codes are excluded from both parts.
Should I count bases or base pairs when calculating GC content?
Count bases in the sequence you are analyzing. Because the two strands of DNA are complementary, the GC proportion of the paired molecule is the same as that of one strand, so a single-strand input is enough. Only mixed or double-counted data, such as pasting both strands, would need care.
How do ambiguity codes affect the GC percentage?
They are excluded from the numerator and the denominator and reported separately, because a code such as N does not identify a base and codes such as R or Y only narrow it down. Including them either as GC or as non-GC would bias the percentage, so the calculator shows how many were left out.
Why does my hand calculation differ from a sequence tool?
The usual causes are FASTA headers, line breaks, spaces and position numbers counted as if they were bases, or ambiguity codes included in the denominator. Tools strip those characters first and report the exact uncleaned characters they ignored, which explains a difference from a count done on the raw paste.
Does a high GC value mean the sequence is DNA?
No. GC content describes composition only, and both DNA and RNA can have high or low GC content. DNA versus RNA is identified by the fourth base: thymine indicates DNA, uracil indicates RNA, and a sequence with both is treated as a mixture rather than assigned to either molecule.

Tools for this job

All Biology Tools