code: def shuffle_genome(genome, cat, fraction = float(100), plot = True, \
          alpha = 0.1, beta = 100000, \
          min_length = 1000, max_length = 200000):
      header = '>randomized_%s' % (genome.name)
      sequence = list(''.join([i[1] for i in parse_fasta(genome)]))
      length = len(sequence)
      shuffled = []
      while sequence is not False:
          s = int(random.gammavariate(alpha, beta))
          if s <= min_length or s >= max_length:
              continue
          if len(sequence) < s:
              seq = sequence[0:]
          else:
              seq = sequence[0:s]
          sequence = sequence[s:]
          shuffled.append(''.join(seq))
          if sequence == []:
              break
      random.shuffle(shuffled)
      if fraction == float(100):
          subset = shuffled
      else:
          max_pieces = int(length * fraction/100)
          subset, total = [], 0
          for fragment in shuffled:
              length = len(fragment)
              if total + length <= max_pieces:
                  subset.append(fragment)
                  total += length
              else:
                  diff = max_pieces - total
                  subset.append(fragment[0:diff])
                  break
      if cat is True:
          yield [header, ''.join(subset)]
      else:
          for i, seq in enumerate(subset):
              yield ['%s fragment:%s' % (header, i), seq]