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.

In reply to Help with randomly sampling with proportions from a fasta file by glorenzo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.