annotate get_genelist.pl @ 50:7b5a48b972e9 draft

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