annotate fixedValueColumn.pl @ 4:023f0a3760b3 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/add_value commit 4066016ffafd7918ba9826db4f3c6fb41315e942
author devteam
date Fri, 29 Sep 2023 15:06:32 +0000
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;