-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcbind.pl
executable file
·61 lines (54 loc) · 1.3 KB
/
cbind.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/perl
# Script: cbind.pl
# Description: Like cbind() in R
# Author: Steven Ahrendt
# email: [email protected]
# Date: 11.21.2014
##################################
# argument is comma-separated list of files
###########################
use warnings;
use strict;
use Getopt::Long;
use Data::Dumper;
#####-----Global Variables-----#####
my $files;
my ($help,$verb);
my %final;
GetOptions ('--input=s' => \$files,
'h|help' => \$help,
'v|verbose' => \$verb);
my $usage = "Usage: cbind.pl --input file1,file2[,file3,file4,...]\n";
die $usage if $help;
die "No input.\n$usage" if (!$files);
#####-----Main-----#####
chomp $files;
my @file_list = split(/,/,$files);
for (my $i=0; $i < scalar (@file_list); $i++)
{
open(FH,"<",$file_list[$i]) or die "Can't open $file_list[$i]: $!\n";
my @file_headers;
while(my $line = <FH>)
{
chomp $line;
my ($key,@vals) = split(/\t/,$line);
if ($line =~ /^Org/)
{
@file_headers = @vals;
}
else
{
# print Dumper \@file_headers;
$final{$key}{$i}{"Headers"} = join(",",@file_headers);
$final{$key}{$i}{"Data"} = join(",",@vals);
}
}
close(FH);
}
#print Dumper \%final;
my $test = "Wseb";
print $test,"\n";
print Dumper $final{$test};
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####