#!/usr/bin/perl -w use strict; use warnings; use File::Path; use vars qw(@genes_number %count $AG_value $GC_bin @arr %gc_ag); ##################################################################################### # Open Input and Output Files # ##################################################################################### if( @ARGV < 2){ print "NSD analysis file needs the following arguments\n"; print "Name of merged Static and experimental file, Name of experiment (first col of first file, Output file name\n"; exit 0; } opendir (DIR, "/nsd/data") || die "Cannot open directroy data $!"; open(NSD, "firstfile.txt") || die "Cannot open file NSD file"; # NSD data open(INPUT1,$ARGV[0]) || die "Cannot open file \"$ARGV[0]\""; # Analysis file my $exp_name=$ARGV[1] || die "Enter the name of Experiment \"$ARGV[1]\""; open(RESULTS, ">/nsd/data/$ARGV[2]")|| die "Cannot open the results file"; #my $GC_bin=$ARGV[3] || die "Enter the GC content that you want to anlyze \"$ARGV[2]\""; #open(RESULTS,">result.txt")|| die "Cannot open the results file"; #my $AG_value=0; # read all AG 90 values for all gc bins into a hash # then for the keys of this hash use the values for making # comparisons my %gc_ag =(); while(){ chomp; my @current_line_nsd = split /\t/; if ($exp_name eq $current_line_nsd[0]){ $gc_ag{$current_line_nsd[2]} = $current_line_nsd[17]; } } foreach my $v (sort {$a<=>$b} keys %gc_ag) { print "$v\t$gc_ag{$v}\n"; } close (NSD); #reading the second file entered by user as an argument my %genes_number =(); while(){ chomp; my @current_line = split /\t/; foreach my $k (sort {$a<=>$b} keys %gc_ag) { if ($current_line[3] == $k && $current_line[8] > $gc_ag{$k} ) { # push(@genes_number, $current_line[1]); push(@{$genes_number{$k}}, $current_line[1]); } } } &count_unique (@genes_number); ###################################################### sub count_unique { @genes_number = @_; my %count; map { $count{$_}++ } @genes_number; #print them out: map {push our @arr, ${count{$_}}} sort keys(%count); for (my $j=1; $j<10; $j++){ my $counter =0; foreach my $element(@arr) { if ($element >=$j) { $counter++; } } print "$j\t$counter\n"; } #print "Number of genes with more than 5 probes is: $counter\n"; #print scalar(@arr)."\n" ; #map {print RESULTS "$_\n"} sort keys(%count); my $i =0; $i += keys %count; # print $i; return %count; } close (INPUT1); close (RESULTS); close (DIR);