#!/usr/bin/perl -w use strict; if (scalar (@ARGV) != 1) { print STDERR "UTILITZA: progama_dades_estadístiques.pl fitxer_resultats.txt\n"; }; my ($resultat) = @ARGV; ############################################################################################### ############################## FUNCIO OBRIR FITXER DELS RESULTATS ######################## ############################################################################################### my $total_suma; $total_suma = &sumar_valors_resultatsSNPs($resultat); &proporcions(); ################################################################################################ ################################# FUNCIONS ################################################## ################################################################################################ sub sumar_valors_resultatsSNPs () { my $fitxer_SNPs = $_[0]; my $valors = ""; # A la variable valors li assignem la paraula buida my @valors_v; my $i = 0; my $total_suma = 0; open(FITXER1, "<$fitxer_SNPs"); while () { $valors = $valors.$_; # Amb aixo anem afegint a la $valors, els valors que pren $_ } # while close(FITXER1); # A CONTINUACIO COPIEM LA $VALORS EN UN VECTOR @valors_v = split (/\n/,$valors); while ($i < scalar(@valors_v)) { $total_suma = $total_suma + $valors_v[$i]; $i = $i + 1; } # while # print "dentro de la funcion: $total_suma\n"; return $total_suma; } # funcio sumar_valors_resultatsSNPs sub proporcions () { my $proporcio; my $total_SNPs = 100823; $proporcio = $total_suma / $total_SNPs; print "La proporcio d'aquest tipus de SNPs es : $proporcio\n"; } #funcio proporicions