1 /* @source shuffleseq application
2 **
3 ** Randomises sequences maintaining composition
4 ** @author Copyright (C) Michael Schmitz (mschmitz@lbl.gov)
5 ** @@
6 **
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 ******************************************************************************/
21 
22 #include "emboss.h"
23 
24 
25 
26 
27 /* @prog shuffleseq ***********************************************************
28 **
29 ** Shuffles a set of sequences maintaining composition
30 **
31 ******************************************************************************/
32 
main(int argc,char ** argv)33 int main(int argc, char **argv)
34 {
35     ajint shuffles = 1;
36     ajint n;
37     AjPSeqall seqall;
38     AjPSeqout seqout;
39     AjPSeq seq;
40     AjPStr seq_str;
41 
42     embInit("shuffleseq", argc, argv);
43 
44     ajRandomSeed();
45 
46     seqout   = ajAcdGetSeqoutall("outseq");
47     seqall   = ajAcdGetSeqall("sequence");
48     shuffles = ajAcdGetInt("shuffle");
49 
50     while(ajSeqallNext(seqall, &seq))
51 	for(n=0;n<shuffles;++n)
52 	{
53 	    seq_str = ajSeqGetSeqCopyS(seq);
54 	    ajStrRandom(&seq_str);
55 	    ajSeqAssignSeqS(seq, seq_str);
56 	    ajSeqoutWriteSeq(seqout, seq);
57 	    ajStrDel(&seq_str);
58 	}
59 
60     ajSeqoutClose(seqout);
61     ajSeqallDel(&seqall);
62     ajSeqDel(&seq);
63     ajSeqoutDel(&seqout);
64     ajStrDel(&seq_str);
65 
66     embExit();
67 
68     return 0;
69 }
70