annotate get_genelist.pl @ 16:7d12d9b130bc draft

Uploaded
author big-tiandm
date Wed, 29 Oct 2014 05:03:28 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
2 #Filename:
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
3 #Author: chentt
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
4 #Email:
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
5 #Date: 2012-4-6
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
6 #Modified:
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
7 #Description:
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
8 my $version=1.00;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
9
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
10 use strict;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
11 use Getopt::Long;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
12
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
13 my %opts;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
14 GetOptions(\%opts,"i=s","o=s","h");
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
15 if (!(defined $opts{i} and defined $opts{o}) || defined $opts{h}) { #necessary arguments
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
16 &usage;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
17 }
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
18 open IN,"<$opts{i}";
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
19 open OUT ,">$opts{o}";
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
20 print OUT "#ID\tchr\tstart\tend\tstrand\n";
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
21 my $n=1;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
22 my %gene1;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
23 while (my $aline=<IN>) {
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
24 chomp $aline;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
25 next if($aline=~/^\#/);
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
26 my @tmp=split/\t/,$aline;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
27 my $ID;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
28 if ($tmp[2] eq "gene") {
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
29 $tmp[0]=~s/Chr\./Chr/;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
30 #$tmp[0]=~s/Chr/chr/;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
31 my @infor=split/;/,$tmp[8];
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
32 for (my $i=0;$i<@infor ;$i++) {
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
33 if ($infor[$i]=~/Alias\=(\S+)$/) {
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
34 $ID=$1;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
35 last;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
36 }
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
37 else {
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
38 $ID="unknown$n";
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
39 $n++;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
40 }
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
41 }
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
42 #$gene{$tmp[0]}{$ID}=[$tmp[3],$tmp[4],$tmp[6]];#$gene{chr}{geneID}=[start,end,strand]
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
43 push @{$gene1{$ID}},[$tmp[3],$tmp[4],$tmp[0]];
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
44 print OUT "$ID\t$tmp[0]\t$tmp[3]\t$tmp[4]\t$tmp[6]\n";
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
45 }
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
46 }
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
47 close IN;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
48 close OUT;
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
49
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
50
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
51 sub usage{
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
52 print <<"USAGE";
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
53 Version $version
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
54 Usage:
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
55 $0 -i -o -h
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
56 options:
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
57 -i input cluster file
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
58 -o output file
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
59 -h help
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
60 USAGE
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
61 exit(1);
7d12d9b130bc Uploaded
big-tiandm
parents:
diff changeset
62 }