Entering edit mode
3.9 years ago
Fadhalsh441
•
0
I was hoping to randomly select 500 fasta files of sequences from a directory which is a folder containing all the split fasta files and then make put the randomly selected fasta files in a separate folder. I want to mention that I want random sampling without replacement! Please help. Maybe include what the first thin to write down when opening python as I have minimum coding experience.
Lay out your logic first, then look for ways to implement that logic. For example, you need a list of file names and a way to pick a 500-size sample without replacement from them. Google "python random sample without replacement" and see where that takes you. Plug in your array of file names and you'll have the solution.
First thing to write down: the core of the problem in plain English.
I'll give you a hint:
You'll want the
os
module to get a list of files in the directory (alternatively you can use theglob
module if needed).Then you'll want the
random
ornumpy
modules for implementing a random choice. If you're using python3.6
or higher,random.choices
has with replacement by default. Easily google-able so I suggest you start there.