SANBI-SA / studyGroup

Gather together a group to skill-share, co-work, and create community
http://mozillascience.github.io/studyGroup/
Other
0 stars 10 forks source link

From "Python for Biologist" #24

Open tralynca opened 6 years ago

tralynca commented 6 years ago

Binning DNA sequences Write a program which creates nine new folders – one for sequences between 100 and 199 bases long, one for sequences between 200 and 299 bases long, etc. Write out each DNA sequence in the input files to a separate file in the appropriate folder. They gave a few dna files, all file names with the file extension .dna, with each containing sequences of variable length.

I basically followed the example to the 't' and eventually even matched my variable names to theirs. The only part I initially got stuck on was line 37. I don't understand why it has to be repeated (it's a replica of line 13). I struggled for a long time to figure out why the code was just creating the folders and then printing out what it should to STDIN, but it wasn't moving the files to the created directories.

Anyway, I liked this exercise, because it's useful for sorting files, based on certain criteria and automatically creating the folders and their names, based on their content.

pvanheus commented 6 years ago

The code for this session is here. We did 3 different versions of the code - one in the session and two afterwards. @tralynca's original code is also in the repository. The data to test on is in the data/dna_files directory of the repository.