File: db.pl

package info (click to toggle)
snpeff 5.4.b%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 757,496 kB
  • sloc: java: 62,572; perl: 2,279; sh: 1,185; python: 744; xml: 507; makefile: 50
file content (29 lines) | stat: -rwxr-xr-x 750 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

#-------------------------------------------------------------------------------
#
# Converts one column to deciBel (Db)
# 		db = -10 * log(x) / log(10) 
#
#-------------------------------------------------------------------------------

# By default, change the first column
$colNum = 0;
if( $ARGV[0] ne '' )	{ $colNum = $ARGV[0] - 1; }		# Use argument as column number (transform to zero-based)

$k = -10 / log(10);

# Parse STDIN
while( $l = <STDIN> ) {
	chomp $l;
	@t = ();
	@t = split /\t/, $l;

	# Convert column to DB
	if( $t[$colNum] > 0 )	{ $t[$colNum] = $k * log( $t[$colNum] ); }
	else 					{ $t[$colNum] = "NA"; }

	# Show all fields in this line
	for( $i=0 ; $i < $#t ; $i++ ) {	print "$t[$i]\t"; }
	print "$t[$i]\n";
}