Repository navigation
Expand file tree
/
Copy pathcornrows.pl
More file actions
107 lines (76 loc) · 2.63 KB
/
Copy pathcornrows.pl
File metadata and controls
107 lines (76 loc) · 2.63 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!usr/bin/perl
#Margaret Antonio
#Gets pathways from .tsv file that WebGestalt ouptus. Can put pathway lists into VennY
use strict;
use warnings;
use Getopt::Long;
sub print_usage(){
print "\nperl cornrows.pl <options> <inputfile.tsv> --db <database> --out <nameOutFile>";
print "\nRequired:\n";
print "In the command line (without a flag), input the name of the .diff file to be parsed\n";
print "--db \t Name of the database origin of the input file. Either reactome or webgestalt";
print "\nOptional:\n";
print "--out \t Name of output file. Database name and .txt. extensions will be automatically appended. Default: 'out'\n";
}
our ($db,$out);
GetOptions(
'db:s' => \$db,
'out:s' =>\$out,
);
#==========================================================================================
print print_usage(),"\n";
print "\n";
if (!$out){
$out="out";
}
if ($db eq "webgestalt"){
my @pathways=();
#my @pathway_ids=();
my $file = $ARGV[0] or die "Need to get input file on the command line\n";
open(INPUT, '<', $file) or die "Could not open '$file' $!\n";
while (my $line = <INPUT>) { #Open the input file and go through each line
my @fields = split("\t",$line);
my $fields=\@fields;
if ($fields[0] ne"KEGG pathway"){
next;
}
push (@pathways,$fields[1]);
#push (@pathway_ids,$fields[2]);
}
close INPUT;
print "\nCreating pathway name file\n";
my $outfile=$out."_wb_pathways.txt";
open (FH1,'>',$outfile);
foreach my $path(@pathways){
print FH1 $path, "\n";
}
close FH1;
#print "\nNow creating pathway id file\n";
# my $file=$out."_wb_pathways.txt";
#open (FH1,'>',$file);
#foreach my $id(@pathway_ids){
# print FH2 $id, "\n";
#}
#close FH2;
}
elsif ($db eq "reactome"){
my @pathways;
my $file = $ARGV[0] or die "Need to get input file on the command line\n";
open(INPUT, '<', $file) or die "Could not open '$file' $!\n";
while (my $line = <INPUT>) { #Open the input file and go through each line
my @fields = split("\t",$line);
my $fields=\@fields;
push (@pathways,$fields[1]);
}
close INPUT;
print "\nCreating pathway name file\n";
my $file1=$out."_reactome_pathways.txt";
open (FH1,'>',$file1);
foreach my $path(@pathways){
print FH1 $path, "\n";
}
close FH1;
}
else{
print "\nThat is not a supported database. Please enter -db reactome or -db webgestalt.\n" and die;
}