view DiffExpAnal/countNumber.pl @ 10:6e573fd3c41b draft

Uploaded
author yufei-luo
date Mon, 13 May 2013 10:06:30 -0400
parents 63799b789162
children
line wrap: on
line source

#!/usr/bin/perl -w
###
###Yufei LUO
###

use strict;

my $in_file = $ARGV[0];
my $out_file = $ARGV[1];
my $sort_type = $ARGV[2]; # n(umeric) or a(lphanumeric)
my ($line,$ID,$nbOverlaps,%hash);

open(IN, $in_file);
while ($line = <IN>){
	chomp($line);
	$line=~s/\t/|/g;
	my @part=split(/\|/,$line);
	my @split=split(";",$part[$#part]);
	$split[0] =~ m/^(\w+).+$/;
	
	foreach my $i (@split){
		if ($i=~m/nbOverlaps=(.+)/){
			$nbOverlaps=$1;
		}
		if ($i=~m/gene_id=(.+)/){
			$ID=$1;
			$hash{$ID}=$nbOverlaps;
		}
	}
}
close(IN);

open(OUT, ">$out_file");
foreach my $key ( sort keys %hash) {
	print OUT "$key\t$hash{$key}\n";
}
close(OUT);