annotate [APliBio]Nebula tools suite/Nebula/MakeTSSdist/createControlPeakSubSet.pl @ 1:0ec82f1785af draft

Uploaded
author alermine
date Wed, 14 Nov 2012 05:59:25 -0500
parents 2ec3ba0e9e70
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
1 #:t:::::::::::::::::g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
2 #:t::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
3 #:::::::::::::z;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
4 #::::::::::::i@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
5 #::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@$@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
6 #:::::::::::3@@@@@@@@@@@@@@@@@@@@@@@@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
7 #::::::::::3@@@@@@@@@@@@@@@@@@@@@BEEESSE5EEEEBBM@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
8 #::::::::::3@@@@@@@@@@@@@@@@@@@@BEEEEEE35EE55E2355E5SBMB@@@@@@@@@@@@@@@@@$
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
9 #::::::::::@@@@@@@@@@@@@@@@@@@EEEE55533t3tttt::::::!!!!7755E755SBBMMM@@@MM
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
10 #::::::::::3@@@@@@@@@@@@@@@@@@EEEE2t3ttttt:::::::::::::::::::::::!7?5225EE
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
11 #::::::::::3@@@@@@@@@@@@@@@@@@EEEEE31t::::::::::::::::::::::::::::::::3E5@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
12 #::::::::::3@@@@@@@@@@@@@@@@@@EEEEEEtt:::::::::::::::::::::::::::::::::353
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
13 #::::::::::3@@@@@@@@@@@@@@@@@@EEEEEE1ttz::::::::::::::::::::::::::::::::35
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
14 #:::::::::::@@@@@@@@@@@@@@@@@@EEEEEEEtz1::::::::::::::::::::::::::::::::t:
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
15 #:::::::::!3@@@@@@@@@@@@@@@@@@@EEEEEttt::::::::::::::::::::::::::::::::;zz
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
16 #::::::::::@@@@@@@@@@@@@@@@@@@@EEEEEttt:::::z;z:::::::::::::::::::::::::13
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
17 #::::::::::3B@@@@@@@@@@@@@@@@@@EEEEEEE3tt:czzztti;:::::::::::::::::::::::3
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
18 #::::ttt::::3@@@@@@@@@@@@@@@@EEEEE5EE25Ezt1EEEz5Etzzz;;;;:::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
19 #:::::::::::I9@@@@@@@@@@@@@@@@@@@@@@@@@@EEEEEE@@@@@@@@@@@@@@Ez;:::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
20 #:::::::::::::E@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Ez::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
21 #::::::::::::::E@@@@@@@@@@@@@@@@@@@@@@@@@@@@@BE5EBB@@@@@@@@@@@@@@@EEE:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
22 #:::::::::::::::@@@@@@@@@@@@@@@@@@@@@@@@@@@@E1::35@@@@@@@@@@ME3MMME2::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
23 #:::::::::::::::?@@@@@@@@@@@@@@@@@@M@@@@@@@EE:::::3SB@@BBESEEt::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
24 #::::::::::::::::J$@@@@@@@B@@@@@@@@@@@@@@@@EE:::::::!35E33t:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
25 #:::::::::::::::::3@E@@@EE5EESE5EESE@@@@@@@Et::::::::::::tz:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
26 #:::::::::::::::::J@E$@EEE5133555SE@@@@@@@@Et:::::::::::::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
27 #::::::::::::::::::E@E@EEEEtt3523EEE@@@@@@@E::::::::::::::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
28 #:t::::::::::::::::JEE3@@@EEEEEEEEEE@@@@@@@E:::::::::t;:::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
29 #:t:::::::::::::::::!5ES@EEEEEEEEES@@@@@@@@@E;:::;;;:3Ez::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
30 #:t::::::::::::::::::::JE@@EEEEEEE@@@@@@@@@@@@@@@@ME!:::;:::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
31 #:tz::::::::::::::::::::JE@@@EEEE@@@@@@@@@@@@@@EE!:::::::t::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
32 #:t::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@ESBE::::::::::::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
33 #:::::::::::::::::::::::::Q@@@@@@@@@@@@@@@@EE3EE;:::::zzzz::::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
34 #:::::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@@@@@NN@@@@@@Ez:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
35 #:zt:::::::::::::::::::::::3@@@@EE@@@@@@@@@@EEEEt::;z113E5t:::::::::::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
36 #::tt:::::::::::::::::::::::3@@@E@@@@@@@@@@@@@@@@BEt::::::::::::::::t:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
37 #:tt:t:::::::::::::::::::::::?S@@@@@@@@@@@BBEEE51!::::::::::::::zzzEt:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
38 #::::::::::::::::::::::::::::::3Q@@@@@@@BEEEEEt:::::::::::::;zz@@@EE::::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
39 #::::::::::::::::::::::::::::::::75B@@@@@EEEtt;:::::::::;zz@@@@BEEEtz:::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
40 #::::::::::::::::::::::::::::::::::::?9@@@@@@@@@@@E2Ezg@@@@@B@@@EEEE1t::::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
41 #:::::::::::::::::::::::::::::::::::::::3@@@@@@@@@@@@@@@@@@@E@EEEEEEEzzz::
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
42 #::::::::::::::::::::::::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@EEEEEEE5ttttt
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
43 #:::::::::::::::::::::::::::::::;g@@@@@@@@@@@@@@@@@@@@@@@@@@EEEEEEEEEEEtzt
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
44 #::::::::::::::::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@E@@EEEEEEEEEEEE@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
45 #::::::::::::::::::::::::::g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEE3EEEE@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
46 #:::::::::::::::::::::;;g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEt33@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
47 #:::::::::::::::::;g@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@E@@@@@@EEEtg@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
48 #::::::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@EEEE@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
49 #:::::::::::::@@@@@@@@@@@@@@@@@$@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
50 #::::::::::;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
51 #
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
52 # Copyleft ↄ⃝ 2012 Institut Curie
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
53 # Author(s): Valentina Boeva, Alban Lermine (Institut Curie) 2012
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
54 # Contact: valentina.boeva@curie.fr, alban.lermine@curie.fr
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
55 # This software is distributed under the terms of the GNU General
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
56 # Public License, either Version 2, June 1991 or Version 3, June 2007.
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
57
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
58 #!/usr/bin/perl
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
59
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
60 #create a control dataset with the same number of reads as in the SAMPLE (highest peaks)
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
61
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
62 use strict;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
63 use warnings;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
64 use diagnostics;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
65
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
66 my $usage = qq{
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
67 $0
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
68
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
69 -----------------------------
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
70 mandatory parameters:
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
71
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
72 -f CHiP_file
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
73 -c control_file
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
74 -o output file
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
75 -----------------------------
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
76 optional parameters:
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
77
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
78 -n number of files to create
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
79
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
80 none
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
81 };
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
82
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
83 if(scalar(@ARGV) == 0){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
84 print $usage;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
85 exit(0);
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
86 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
87
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
88 ## mandatory arguments
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
89
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
90 my $filename = "";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
91 my $output_fname = "";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
92
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
93 my $controlFilename = "";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
94
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
95 my $nBootstrap = 1;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
96
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
97
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
98 ## optional arguments
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
99
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
100 ## parse command line arguments
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
101
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
102 while(scalar(@ARGV) > 0){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
103 my $this_arg = shift @ARGV;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
104 if ( $this_arg eq '-h') {print "$usage\n"; exit; }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
105
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
106 elsif ( $this_arg eq '-f') {$filename = shift @ARGV;}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
107 elsif ( $this_arg eq '-c') {$controlFilename = shift @ARGV;}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
108 elsif ( $this_arg eq '-o') {$output_fname = shift @ARGV;}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
109 elsif ( $this_arg eq '-n') {$nBootstrap = shift @ARGV;}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
110
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
111 elsif ( $this_arg =~ m/^-/ ) { print "unknown flag: $this_arg\n";}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
112 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
113
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
114 if ( $filename eq ""){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
115 die "you should specify chip file\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
116 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
117 if( $controlFilename eq ""){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
118 die "you should specify control file\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
119 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
120
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
121 if( $output_fname eq ""){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
122 die "you should specify output filename\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
123 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
124
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
125
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
126 print "\n-----------------\n\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
127
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
128 my %hash;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
129 my $chipCount = 0;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
130 my @header;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
131 open FILE, "< $filename " || die "$filename : $!\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
132 while(<FILE>){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
133 $chipCount++;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
134 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
135 close FILE;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
136 #print "ChIP: $chipCount\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
137
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
138
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
139 my $controlCount = 0;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
140
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
141 open FILE, "< $controlFilename " || die "$controlFilename : $!\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
142 while(<FILE>){
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
143 next if (/track/);
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
144 my $entry = $_;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
145 my @fields = split(/\t/,$_);
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
146 $hash{$entry} = $fields[4];
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
147 $controlCount++;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
148 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
149 #print "controlCount : $controlCount\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
150
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
151 close FILE;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
152 open OUT, "> $output_fname" || die "$output_fname: $!\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
153 my $count = 0;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
154 if ($controlCount>$chipCount) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
155 for my $entry (sort {$hash{$b}<=>$hash{$a}} keys %hash) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
156 print OUT $entry;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
157 $count++;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
158 if ($count >=$chipCount) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
159 last;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
160 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
161 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
162
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
163 } else {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
164 for my $entry (keys %hash) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
165 print OUT $entry;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
166 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
167 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
168
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
169 close OUT;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
170
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
171
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
172 for my $try (2..$nBootstrap) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
173
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
174 open OUT, "> $output_fname$try" || die "$output_fname$try: $!\n";
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
175 my $count = 0;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
176 if ($controlCount>$chipCount) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
177 my $prob = $chipCount/$controlCount*1.1;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
178 for my $entry (sort {$hash{$b}<=>$hash{$a}} keys %hash) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
179 my $yes = rand();
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
180 if ($yes<=$prob) {$yes=1;}else {$yes=0;}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
181 if ($yes) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
182 print OUT $entry ;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
183 $count++;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
184 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
185
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
186 if ($count >=$chipCount ) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
187 last;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
188 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
189 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
190 if ($count <$chipCount) { #do it again!
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
191
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
192 for my $entry (sort {$hash{$b}<=>$hash{$a}} keys %hash) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
193 my $yes = rand();
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
194 if ($yes<=$prob) {$yes=1;}else {$yes=0;}
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
195 if ($yes) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
196 print OUT $entry ;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
197 $count++;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
198 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
199
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
200 if ($count >=$chipCount ) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
201 last;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
202 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
203 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
204
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
205 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
206
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
207 } else {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
208 for my $entry (keys %hash) {
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
209 print OUT $entry;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
210 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
211 }
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
212
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
213 close OUT;
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
214
2ec3ba0e9e70 Uploaded
alermine
parents:
diff changeset
215 }