/tools/human_genome_variation/linkToGProfile.pl

https://bitbucket.org/cistrome/cistrome-harvard/ · Perl · 55 lines · 40 code · 7 blank · 8 comment · 7 complexity · ac44394bc1c449d1e413adb287473faa MD5 · raw file

  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. ###################################################
  5. # linkToGProfile.pl
  6. # Generates a link to gprofile for a list of gene IDs.
  7. # g:Profiler a web-based toolset for functional profiling of gene lists from large-scale experiments (2007) NAR 35 W193-W200
  8. ###################################################
  9. if (!@ARGV or scalar @ARGV != 4) {
  10. print "usage: linkToGProfile.pl infile.tab 1basedCol idType outfile\n";
  11. exit 1;
  12. }
  13. my $in = shift @ARGV;
  14. my $col = shift @ARGV;
  15. my $type = shift @ARGV;
  16. my $out = shift @ARGV;
  17. if ($col < 1) {
  18. print "ERROR the column number should be 1 based counting\n";
  19. exit 1;
  20. }
  21. my @gene;
  22. open(FH, $in) or die "Couldn't open $in, $!\n";
  23. while (<FH>) {
  24. chomp;
  25. my @f = split(/\t/);
  26. if (scalar @f < $col) {
  27. print "ERROR there is no column $col in $in\n";
  28. exit 1;
  29. }
  30. if ($f[$col-1]) { push(@gene, $f[$col-1]); }
  31. }
  32. close FH or die "Couldn't close $in, $!\n";
  33. 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';
  34. $link =~ s/TYPE/$type/;
  35. my $g = join("+", @gene);
  36. $link =~ s/GENELIST/$g/;
  37. #print output
  38. if (length $link > 2048) {
  39. print "ERROR too many genes to fit in URL, please select a smaller set\n";
  40. exit;
  41. }
  42. open(FH, ">", $out) or die "Couldn't open $out, $!\n";
  43. print FH "<html><head><title>g:Profiler link</title></head><body>\n",
  44. '<A TARGET=_BLANK HREF="', $link, '">click here to send list of identifiers to g:Profiler</A>', "\n",
  45. '</body></html>', "\n";
  46. close FH or die "Couldn't close $out, $!\n";
  47. #also do link that prints text that could be pulled back into Galaxy?
  48. exit;