annotate SMART/DiffExpAnal/countNumber.pl @ 18:94ab73e8a190

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