File tree 1 file changed +66
-0
lines changed
1 file changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ # !/usr/bin/perl
2
+ # Script: parseByTax.pl
3
+ # Description: Trims an "out_table" file in accordance with a specific set of organisms
4
+ # Author: Steven Ahrendt
5
+
6
+ # Date: 04.02.2014
7
+ # #################################
8
+ use warnings;
9
+ use strict;
10
+ use Getopt::Long;
11
+ use Data::Dumper;
12
+
13
+ # ####-----Global Variables-----#####
14
+ my $input ;
15
+ my ($help ,$verb );
16
+ my %out_table ;
17
+ my @orgs = qw( Amac Bden Cang Clat Gpro Hpol OrpC PirE Rall Spun) ;
18
+
19
+ GetOptions (' i|input=s' => \$input ,
20
+ ' h|help' => \$help ,
21
+ ' v|verbose' => \$verb );
22
+ my $usage = " Usage: parseByTax.pl -i input\n " ;
23
+ die $usage if $help ;
24
+ die " No input.\n $usage " if (!$input );
25
+
26
+ # ####-----Main-----#####
27
+ open (my $fh ," <" ,$input ) or die " Can't open $input : $! \n " ;
28
+ my $lc = 0;
29
+ my @gene_names ;
30
+ while (my $line = <$fh >)
31
+ {
32
+ chomp $line ;
33
+ my @data = split (/ \t / ,$line );
34
+ if ($lc == 0)
35
+ {
36
+ @gene_names = @data ;
37
+ }
38
+ else
39
+ {
40
+ for (my $i =1;$i <scalar (@gene_names ); $i ++)
41
+ {
42
+ $out_table {$data [0]}{$gene_names [$i ]} = $data [$i ];
43
+ }
44
+ }
45
+ $lc ++;
46
+ }
47
+ close ($fh );
48
+
49
+ # print Dumper \%out_table;
50
+
51
+ print join (" \t " ,@gene_names )," \n " ;
52
+ shift @gene_names ;
53
+ foreach my $org (@orgs )
54
+ {
55
+ print $org ," \t " ;
56
+ foreach my $gene (@gene_names )
57
+ {
58
+ print $out_table {$org }{$gene }," \t " ;
59
+ }
60
+ print " \n " ;
61
+ }
62
+
63
+ warn " Done.\n " ;
64
+ exit (0);
65
+
66
+ # ####-----Subroutines-----#####
You can’t perform that action at this time.
0 commit comments