annotate Dotplot_Release/SaintConvert.pl @ 3:bc752a05f16d draft

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