The guanine-cytosine content, or GC-content, of a DNA sequence indicates the percentage of nucleotide base pairs where guanine is bonded to cytosine. DNA with a higher GC-content will be harder to break apart.

Method 2
Method 2 of 2:
Programmatically (Python 2)

  1. 1
    Create or accept an input file. This article assumes that the input is in FASTA format, with a single sequence per file.
  2. 2
    Read in the file. For FASTA format:
    • Discard the first line of the file.
    • Remove all remaining newlines and other trailing whitespace.
    def init(sequence):
        with open(argv[1]) as input:
            sequence = "".join([line.strip() for line in input.readlines()[1:]])
        return sequence
    
  3. 3
    Create a counter. Iterate through the data and increment your counter as you encounter any guanine or cytosine nucleotides.
  4. 4
    def GCcontent(sequence):
        GCcount = 0
        for letter in sequence:
            if letter == "G" or letter == "C":
                GCcount += 1
        return GCcount
    
  5. 5
    Divide the GC count by the total length of the sequence, and output the result in percentage format.
    Advertisement
  6. 6
    def main():
        script, input = argv
        sequence = ""
        sequence = init(sequence)
        print "%.2f" % (float(GCcontent(sequence)) / len(sequence))
    

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 9,242 times.
2 votes - 100%
Co-authors: 2
Updated: May 6, 2021
Views: 9,242
Categories: Genetics
Advertisement