annotate Dotplot_Release/SaintConvert.pl @ 6:b4bb92033d59 draft default tip

Uploaded
author bornea
date Fri, 29 Jan 2016 10:39:00 -0500
parents dfa3436beb67
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
1 #!/usr/bin/perl
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
2
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
3 # 17/12/2013
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
4
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
5 if($#ARGV==0){
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
6 print "This program takes non-SaintExpress formatted data and converts it to look like it.\n";
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
7 print "\nusage:\n $0\n-i [csv saint output file]\n\n";
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
8 die;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
9 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
10 else{
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
11 $i=0;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
12 while($i<=$#ARGV){
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
13 if($ARGV[$i] eq '-i'){
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
14 $i++;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
15 $ifile=$ARGV[$i];
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
16 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
17 else{
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
18 die "\Incorrect program usage\n\n";
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
19 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
20 $i++;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
21 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
22 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
23
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
24 $i=0;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
25 $file='';
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
26 open(IFILE,"<$ifile") || die "$ifile can't be opened: $!";
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
27 { local $/=undef; $file=<IFILE>; }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
28 @lines=split /[\r\n]+/, $file;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
29 foreach $line (@lines) {
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
30 if($line =~ /^Bait/){
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
31 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
32 elsif($line =~ /^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)/){
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
33 $bait[$i]=$1;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
34 $prey[$i]=$2;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
35 $spec[$i]=$3;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
36 $fdr[$i]=$4;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
37 $i++;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
38 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
39 else{
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
40 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
41 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
42 close(IFILE);
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
43 $line_count=$i;
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
44
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
45 open(OFILE, ">mockSaintExpress.txt");
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
46 print OFILE "Bait\tPrey\tPreyGene\tSpec\tSpecSum\tAvgSpec\tNumReplicates\tctrlCounts\tAvgP\tMaxP\tTopoAvgP\tTopoMaxP\tSaintScore\tFoldChange\tBFDR\tboosted_by\n";
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
47
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
48 for($i=0; $i<$line_count; $i++){
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
49 print OFILE "$bait[$i]\t111\t$prey[$i]\t111\t111\t$spec[$i]\t111\t111\t111\t111\t111\t111\t111\t111\t$fdr[$i]\t111\n";
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
50 }
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
51 close(OFILE);
dfa3436beb67 Uploaded
bornea
parents:
diff changeset
52