annotate fixedValueColumn.pl @ 1:4676e145a44e

Updated command line format per dev team standards.
author InitHello <inithello@gmail.com>
date Mon, 01 Apr 2013 13:48:07 -0400
parents 181dd378275c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
1 #! /usr/bin/perl -w
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
2
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
3 use strict;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
4 use warnings;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
5
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
6 # fixedValueColumn.pl $input $out_file1 "expression" "iterate [yes|no]"
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
7
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
8 my ($input, $out_file1, $expression, $iterate) = @ARGV;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
9 my $i = 0;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
10 my $numeric = 0;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
11
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
12 die "Check arguments\n" unless @ARGV == 4;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
13
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
14 open (DATA, "<$input") or die "Cannot open $input:$!\n";
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
15 open (OUT, ">$out_file1") or die "Cannot create $out_file1:$!\n";
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
16
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
17 if ($expression =~ m/^\d+$/) {
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
18 $numeric = 1;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
19 $i = $expression;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
20 }
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
21
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
22 while (<DATA>) {
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
23 chop;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
24 if ($iterate eq "no") {
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
25 print OUT "$_\t$expression\n";
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
26 } else {
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
27 print OUT "$_\t$i\n" if $numeric == 1;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
28 print OUT "$_\t$expression-$i\n" if $numeric == 0;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
29 ++$i;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
30 }
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
31 }
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
32
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
33 close DATA;
181dd378275c Uploaded add_value tarball.
devteam
parents:
diff changeset
34 close OUT;