deps/kb_meme/meme-5.0.1/src/seq.c
/****************************************************************************
 * Shuffle the letters of a sequence.
 ****************************************************************************/
Shuffle the letters of a sequence.
Shuffle the letters of a sequence .
SEQ_T *shuffle_seq (
  SEQ_T *seq,		
  int kmer,		
  int i_copy		
) {
  assert(i_copy >= 1);
  SEQ_T *new_seq = copy_sequence(seq);
  ushuffle(seq->sequence, new_seq->sequence, seq->length, kmer);
  int pad = log(i_copy)/log(10) + 1;	
  char name[MAX_SEQ_NAME+1];
  int len = strlen(seq->name);
  strncpy(name, seq->name, MAX_SEQ_NAME);
  if (len > MAX_SEQ_NAME - pad) {
    len = MAX_SEQ_NAME - pad;
    name[len] = '\0';
  }
  sprintf(new_seq->name, "%s_shuf_%-3i", seq->name, i_copy);
  return(new_seq);
}
SEQ_T * shuffle_seq ( SEQ_T * seq , int kmer , int i_copy ) { assert ( i_copy >= 1 ) ; SEQ_T * new_seq = copy_sequence ( seq ) ; ushuffle ( seq -> sequence , new_seq -> sequence , seq -> length , kmer ) ; int pad = log ( i_copy ) / log ( 10 ) + 1 ; char name [ MAX_SEQ_NAME + 1 ] ; int len = strlen ( seq -> name ) ; strncpy ( name , seq -> name , MAX_SEQ_NAME ) ; if ( len > MAX_SEQ_NAME - pad ) { len = MAX_SEQ_NAME - pad ; name [ len ] = ' \0 ' ; } sprintf ( new_seq -> name , " " , seq -> name , i_copy ) ; return ( new_seq ) ; }
Shuffle the letters of a sequence.
Shuffle the letters of a sequence .
// a sequence // preserve the frequencies of words of size kmer // a number to add to the new sequence name // Create the new sequence. // Shuffle the  sequence. // Create the new name, shortening if necessary. // number of digits in the copy number