-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_gmt.pl
39 lines (31 loc) · 1005 Bytes
/
make_gmt.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
#!/usr/bin/env perl
use strict;
use warnings;
use IO::File;
my @files = ("Konrad_Raznahan_Sets", "Konrad_Raznahan_Modules", "Konrad_Raznahan_WGCNA_Modules", "DOSE_SENSITIVITY_GENES");
my $sets = {};
my $out = IO::File->new("> Konrad_Raznahan.gmt") || die "ERROR: Cannot create file:Konrad_Raznahan.gmt\n";
for my $index(0..2) {
print "Processing $files[$index]..\n";
my $fh = IO::File->new("$files[$index].txt") || die "ERROR: Cannot open file: $files[$index].txt\n";
while(my $line = $fh->getline) {
chomp($line);
print "Processing $line ..\n";
my ($set, $gene) = split(/\s+/, $line);
if(exists $sets->{$set}) {
$sets->{$set}->{genes} .= "\t".$gene;
next;
}
else {
$sets->{$set}->{genes} = $gene;
next;
}
}
$fh->close;
}
for my $index(sort keys %$sets) {
print $out $index."\t";
print $out $index."\t";
print $out $sets->{$index}->{genes}."\n";
}
$out->close;