-
Notifications
You must be signed in to change notification settings - Fork 2
/
nfr2ucsc.pl
executable file
·54 lines (44 loc) · 1.82 KB
/
nfr2ucsc.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl -w
use strict;
use warnings;
use Tie::IxHash;
use Getopt::Long;
use Statistics::Basic qw(:all);
use perlModule;
###############################################################################
## parse input options
use vars qw($nfrFile $help);
GetOptions ("i=s" => \$nfrFile,
"help" => \$help,
"h" => \$help);
usage() if($help || !$nfrFile);
###############################################################################
sub usage {
print STDERR "\nProgram: nfr2ucsc.pl (create UCSC track file for input NFR regions)\n";
print STDERR "Author: BRIC, University of Copenhagen, Denmark\n";
print STDERR "Version: 1.0\n";
print STDERR "Contact: pundhir\@binf.ku.dk\n";
print STDERR "Usage: nfr2ucsc.pl -i <file> [OPTIONS]\n";
print STDERR " -i <file> [input file having NFRs]\n";
print STDERR "[OPTIONS]\n";
print STDERR " -h [help]\n\n";
exit(-1);
}
###############################################################################
## create output file for writing UCSC tracks of NFR (all)
open(INFILE, $nfrFile) || die $!;
my @data=<INFILE>;
print "track name=\"Predicted NFR ($nfrFile)\" description=\"Predicted NFR ($nfrFile)\" itemRgb=\"On\"\n";
foreach my $l(@data) {
my @F=split(/\s+/,$l);
my @startBlock=split(/[\:\-]+/,$F[6]);
my @endBlock=split(/[\:\-]+/,$F[7]);
my $expr_up=sprintf("%0.4f", $F[8]/$F[9]);
my $expr_down=sprintf("%0.4f", $F[10]/$F[11]);
my $expr_nfr=sprintf("%0.4f", $F[12]/$F[13]);
print "$startBlock[0]\t$startBlock[1]\t$startBlock[2]\t$F[6]\t$expr_up\t.\t$startBlock[1]\t$startBlock[2]\t0,255,0\n";
print "$F[0]\t$F[1]\t$F[2]\t$F[3]\t$expr_nfr\t$F[5]\t$F[1]\t$F[2]\t255,0,0\n";
print "$endBlock[0]\t$endBlock[1]\t$endBlock[2]\t$F[7]\t$expr_down\t.\t$endBlock[1]\t$endBlock[2]\t0,255,0\n";
}
close INFILE;
exit(0);