glorenzo has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
Question: How to randomly sample a percentage of sequences from a fasta file based on location identifier?
I have a task that I'm sure has been done before but I can't find a simple solution. Given a fasta file, with genomic sequences sampled from multiple locations, I want to randomly sample a subset of sequences several times (100 times without replacement) from the whole dataset based on a given percentage per location. Specifically, I'd like to generate 100 randomly sampled subsets, each having sequences from locations: Central-9%, Coast-7%, Eastern-9%, Nairobi-13%, Nyanza-35%, RiftValley-17%, Western-9%, whilst also retaining sequences from the earliest sampling time (1986-2000) to maximise the temporal evolutionary signal.
The headers for the 4000 sequences are labelled: year_location_patientID_riskGroup as follows:
2006_coast_970_FSW
2013_nairobi_Ri350_HET
2004_Rvalley_R0177_IDU
2004_nyanza_R0427_HET
2007_coast_R1442_MSM
2007_nairobi_R0760_HET e.t.c
Any solution in the form of a simple script or multiple scripts will be highly appreciated.
Much thanks,
George.
Comment on Help with randomly sampling with proportions from a fasta file
This sounds like homework, and that doesn't look like a fasta file format to me, at least not the way you present it here. This also isn't a code writing service. Show what you have so far, how it failed, proper data etc. How do I post a question effectively?.