Mercurial > repos > mcharles > rapsodyn
comparison rapsodyn/listfiltering.pl @ 9:ad321ff1b67d draft
Uploaded
author | mcharles |
---|---|
date | Thu, 14 Aug 2014 08:12:06 -0400 |
parents | |
children | 7b8646f46010 |
comparison
equal
deleted
inserted
replaced
8:1d37c16ab674 | 9:ad321ff1b67d |
---|---|
1 #!/usr/bin/perl | |
2 use strict; | |
3 use Getopt::Long; | |
4 | |
5 my $inputfile; | |
6 my $headerfile; | |
7 my $nb_col=1; | |
8 my %header; | |
9 | |
10 if ($#ARGV<0){ | |
11 print "\n"; | |
12 print "perl 021_ListFiltering.pl -input_file <file> -header_file <file> -nb_col <integer>[1]\n"; | |
13 exit(0); | |
14 } | |
15 | |
16 GetOptions ( | |
17 "input_file=s" => \$inputfile, | |
18 "header_file=s" => \$headerfile, | |
19 "nb_col=i" => \$nb_col | |
20 ) or die("Error in command line arguments\n"); | |
21 | |
22 open(HF, $headerfile) or die("Can't open $headerfile\n"); | |
23 while (my $line=<HF>){ | |
24 chomp($line); | |
25 my @fields = split(/\s+/,$line); | |
26 my $ref=""; | |
27 my $compt=0; | |
28 while ($compt<$nb_col){ | |
29 if ($ref){$ref.="\t";} | |
30 $ref.=$fields[$compt]; | |
31 $compt++; | |
32 } | |
33 # my $ref = "$fields[0]\t$fields[1]"; | |
34 $header{$ref}=$line; | |
35 } | |
36 close (HF); | |
37 | |
38 | |
39 open(IF, $inputfile) or die("Can't open $inputfile\n"); | |
40 while (my $line=<IF>){ | |
41 my @fields = split(/\s+/,$line); | |
42 my $ref=""; | |
43 my $compt=0; | |
44 while ($compt<$nb_col){ | |
45 if ($ref){$ref.="\t";} | |
46 $ref.=$fields[$compt]; | |
47 $compt++; | |
48 } | |
49 # my $ref = "$fields[0]\t$fields[1]"; | |
50 | |
51 if ($header{$ref}){ | |
52 # print $line; | |
53 # print $header{$ref},"\n"; | |
54 } | |
55 else { | |
56 print $line; | |
57 } | |
58 | |
59 } | |
60 close(IF); | |
61 |