annotate tools/human_genome_variation/linkToGProfile.pl @ 1:cdcb0ce84a1b

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:45:15 -0500
parents 9071e359b9a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #!/usr/bin/env perl
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 use strict;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 use warnings;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 ###################################################
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 # linkToGProfile.pl
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 # Generates a link to gprofile for a list of gene IDs.
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 # g:Profiler a web-based toolset for functional profiling of gene lists from large-scale experiments (2007) NAR 35 W193-W200
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 ###################################################
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 if (!@ARGV or scalar @ARGV != 4) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 print "usage: linkToGProfile.pl infile.tab 1basedCol idType outfile\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 exit 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 my $in = shift @ARGV;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 my $col = shift @ARGV;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 my $type = shift @ARGV;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 my $out = shift @ARGV;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 if ($col < 1) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 print "ERROR the column number should be 1 based counting\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24 exit 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 my @gene;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 open(FH, $in) or die "Couldn't open $in, $!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28 while (<FH>) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 chomp;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 my @f = split(/\t/);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 if (scalar @f < $col) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 print "ERROR there is no column $col in $in\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 exit 1;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 if ($f[$col-1]) { push(@gene, $f[$col-1]); }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 close FH or die "Couldn't close $in, $!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 my $link = 'http://biit.cs.ut.ee/gprofiler/index.cgi?organism=hsapiens&query=GENELIST&r_chr=1&r_start=start&r_end=end&analytical=1&domain_size_type=annotated&term=&significant=1&sort_by_structure=1&user_thr=1.00&output=png&prefix=TYPE';
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40 $link =~ s/TYPE/$type/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 my $g = join("+", @gene);
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
42 $link =~ s/GENELIST/$g/;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
43 #print output
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
44 if (length $link > 2048) {
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
45 print "ERROR too many genes to fit in URL, please select a smaller set\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
46 exit;
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
47 }
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
48 open(FH, ">", $out) or die "Couldn't open $out, $!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
49 print FH "<html><head><title>g:Profiler link</title></head><body>\n",
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
50 '<A TARGET=_BLANK HREF="', $link, '">click here to send list of identifiers to g:Profiler</A>', "\n",
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
51 '</body></html>', "\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
52 close FH or die "Couldn't close $out, $!\n";
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
53
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
54 #also do link that prints text that could be pulled back into Galaxy?
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
55 exit;