Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code for the exercise #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions code.py

This file was deleted.

15 changes: 15 additions & 0 deletions print_proportions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import collections

def print_proportions(seq):
"""Print the proportions of each base in the string `seq`."""

counts = collections.Counter(seq)
total = counts.total()

# It's printing proportions here, not frequencies, but we'll keep this label for
# backwards compatibility.
print('freqs')
for base, n in counts.items():
print(f'{base}:{n/total}')

print_proportions('ATCTGACGCGCGCCGC')