Skip to content

Instantly share code, notes, and snippets.

@CodePint
Created June 10, 2022 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodePint/bc4cfd8312359cf3fecd439ca5d43488 to your computer and use it in GitHub Desktop.
Save CodePint/bc4cfd8312359cf3fecd439ca5d43488 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# For a string containing only the letters A C G T, how would you count the occurrences
# of each triplet (overlapping three character substrings)? For example, in the input
# string "AACTGATGCTGACTGATAGTA" the characters "TGA" appear three times.
#
# AACTGATGCTGACTGATAGTA
# TGA: --- --- ---
#
# Produce a Python function (or class) that calculates these triplet counts, the FORMAT
# and STRUCTURE of the output is up to you.
#
# Return:| Triplet | Count |
# | AAC | 1 |
# | ACT | 2 |
# | CTG | 3 |
# | TGA | 3 |
# | GAT | 2 |
# | ATG | 1 |
# | TGC | 1 |
# | GCT | 1 |
# | GAC | 1 |
# | ATA | 1 |
# | TAG | 1 |
# | AGT | 1 |
# | GTA | 1 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment