Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_one_week_4_biologists_solutions
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub-courses
python_one_week_4_biologists_solutions
Commits
a61cb0b0
Commit
a61cb0b0
authored
10 years ago
by
Bertrand NÉRON
Browse files
Options
Downloads
Patches
Plain Diff
add alt solution for exercise on kmer
add solution using a defaultdict
parent
de19a22e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Collection_Data_Types.rst
+10
-0
10 additions, 0 deletions
source/Collection_Data_Types.rst
with
10 additions
and
0 deletions
source/Collection_Data_Types.rst
+
10
−
0
View file @
a61cb0b0
...
...
@@ -275,6 +275,16 @@ solution ::
for kmer, occurence in kmers.items():
print kmer, " = ", occurence
we can use also a defaultdict: ::
import collections
s = s.replace('\n', '')
kmers = collection.defaultdict(int)
for i in range(len(s) - 3):
kmer = s[i:i+3]
kmers[kmer] += 1
solution bonus ::
list_of_kmers = kmers.items()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment