title: DNA sequence random sampling
body: <p>I would like to create say a 1000 random groups using 100 DNA sequences. I have text file (sequence.txt) containing 100 fasta sequences, and i want subgroups containing 10 fasta sequence chosen at random for further analysis. here is the code that i tried and i have been getting some errors.</p>
  
  <pre><code>import random
  import re
  f = open("sequence.txt", "r")
  lf = f.split("&gt;")
  lf.pop(0)
  f.close()
  for i in range(10):
      sublist = "subset_%s.fas" % i
      random_group = random.randrange(len("sequence.txt"), 10)
      output = open(sublist, "w")
      for m in random_group:
          sequence = "&gt;" + lf[m]
          output.write(sequence)
      output.close()
  </code></pre>