annotate DiffExpAnal/countNumber.pl @ 0:63799b789162 draft

Uploaded
author yufei-luo
date Tue, 22 Jan 2013 10:07:03 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
1 #!/usr/bin/perl -w
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
2 ###
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
3 ###Yufei LUO
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
4 ###
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
5
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
6 use strict;
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
7
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
8 my $in_file = $ARGV[0];
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
9 my $out_file = $ARGV[1];
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
10 my $sort_type = $ARGV[2]; # n(umeric) or a(lphanumeric)
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
11 my ($line,$ID,$nbOverlaps,%hash);
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
12
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
13 open(IN, $in_file);
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
14 while ($line = <IN>){
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
15 chomp($line);
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
16 $line=~s/\t/|/g;
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
17 my @part=split(/\|/,$line);
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
18 my @split=split(";",$part[$#part]);
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
19 $split[0] =~ m/^(\w+).+$/;
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
20
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
21 foreach my $i (@split){
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
22 if ($i=~m/nbOverlaps=(.+)/){
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
23 $nbOverlaps=$1;
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
24 }
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
25 if ($i=~m/gene_id=(.+)/){
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
26 $ID=$1;
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
27 $hash{$ID}=$nbOverlaps;
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
28 }
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
29 }
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
30 }
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
31 close(IN);
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
32
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
33 open(OUT, ">$out_file");
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
34 foreach my $key ( sort keys %hash) {
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
35 print OUT "$key\t$hash{$key}\n";
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
36 }
63799b789162 Uploaded
yufei-luo
parents:
diff changeset
37 close(OUT);