root/galaxy-central/tools/human_genome_variation/linkToDavid.pl

リビジョン 2, 1.5 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

  • 属性 svn:executable の設定値 *
行番号 
1#!/usr/bin/env perl
2
3use strict;
4use warnings;
5
6###################################################
7# linkToDavid.pl
8# Generates a link to David for a list of gene IDs.
9###################################################
10 
11if (!@ARGV or scalar @ARGV != 4) {
12   print "usage: linkToDavid.pl infile.tab 1basedCol idType outfile\n";
13   exit 1;
14}
15
16my $in = shift @ARGV;
17my $col = shift @ARGV;
18my $type = shift @ARGV;
19my $out = shift @ARGV;
20
21if ($col < 1) {
22   print "ERROR the column number should be 1 based counting\n";
23   exit 1;
24}
25my @gene;
26open(FH, $in) or die "Couldn't open $in, $!\n";
27while (<FH>) {
28   chomp;
29   my @f = split(/\t/);
30   if (scalar @f < $col) {
31      print "ERROR there is no column $col in $in\n";
32      exit 1;
33   }
34   if ($f[$col-1]) { push(@gene, $f[$col-1]); }
35}
36close FH or die "Couldn't close $in, $!\n";
37
38if (scalar @gene > 400) {
39   print "ERROR David only allows 400 genes submitted via a link\n";
40   exit 1;
41}
42 
43my $link = 'http://david.abcc.ncifcrf.gov/api.jsp?type=TYPE&ids=GENELIST&tool=summary';
44
45my $g = join(",", @gene);
46$link =~ s/GENELIST/$g/;
47$link =~ s/TYPE/$type/;
48#print output
49if (length $link > 2048) {
50   print "ERROR too many genes to fit in URL, please select a smaller set\n";
51   exit;
52}
53open(FH, ">", $out) or die "Couldn't open $out, $!\n";
54print FH "<html><head><title>DAVID link</title></head><body>\n",
55      '<A TARGET=_BLANK HREF="', $link, '">click here to send of identifiers to DAVID</A>', "\n",
56      '</body></html>', "\n";
57close FH or die "Couldn't close $out, $!\n";
58
59exit;
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。