comparison get_genelist.pl @ 16:7d12d9b130bc draft

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