comparison fixedValueColumn.pl @ 0:181dd378275c

Uploaded add_value tarball.
author devteam
date Tue, 04 Dec 2012 10:37:05 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:181dd378275c
1 #! /usr/bin/perl -w
2
3 use strict;
4 use warnings;
5
6 # fixedValueColumn.pl $input $out_file1 "expression" "iterate [yes|no]"
7
8 my ($input, $out_file1, $expression, $iterate) = @ARGV;
9 my $i = 0;
10 my $numeric = 0;
11
12 die "Check arguments\n" unless @ARGV == 4;
13
14 open (DATA, "<$input") or die "Cannot open $input:$!\n";
15 open (OUT, ">$out_file1") or die "Cannot create $out_file1:$!\n";
16
17 if ($expression =~ m/^\d+$/) {
18 $numeric = 1;
19 $i = $expression;
20 }
21
22 while (<DATA>) {
23 chop;
24 if ($iterate eq "no") {
25 print OUT "$_\t$expression\n";
26 } else {
27 print OUT "$_\t$i\n" if $numeric == 1;
28 print OUT "$_\t$expression-$i\n" if $numeric == 0;
29 ++$i;
30 }
31 }
32
33 close DATA;
34 close OUT;