annotate get_genelist.pl @ 0:87fe81de0931 draft default tip

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