Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Miguel Román Sánchez
- #IMPORTANTE: ESTE PROGRAMA TOMA DATOS DE LA MATRIZ @ARGV, SUS ARGUMENTOS SON:
- # NOMBRE_DE_FICHERO LONGITUD_DE_VENTANA PASO_DE_VENTANA
- open (INPUT, $ARGV[0]);
- @input = <INPUT>; #recogida de datos del fichero
- chomp (@input);
- close INPUT;
- #---------------------------------------------------------------------------------------------------------|
- #FRAGMENTO NECESARIO PARA ARCHIVOS CON SECUENCIAS PARTIDAS EN LÍNEAS
- for (my $i = 0; $i < @input; $i++) {
- if ($input[$i] =~ /^>/) { #Si encontramos una cabecera:
- if (defined($line)) { #Si además teníamos previamente una secuencia:
- push (@format, $line); #Guardamos la secuencia
- undef $line; #Reiniciamos la variable temporal que recoge la secuencia
- }
- push (@format, $input[$i]);
- }else{
- $line .= $input[$i];
- }
- }
- push (@format, $line);
- #---------------------------------------------------------------------------------------------------------|
- #-------------------------------------------------------------|
- #ESTE BLOQUE SELECCIONA LA ID Y SECUENCIA CON MAYOR %GC
- for (my $i = 1; $i < @format; $i+=2) {
- if (gcratio($format[$i]) >= gcratio($winnerSeq)) {
- $winnerSeq = $format[$i];
- $winnerID = $format[$i-1];
- $winnerID =~ s/>//;
- }
- }
- #-------------------------------------------------------------|
- print $winnerID."\n"; # Ahora winnerID tiene la ID de la secuencia con mayor %GC
- print ((gcratio($winnerSeq)*100)."\n"."\n");
- #-----------------------------------------------------------------------------------------------------------------------------|
- #ESTE BLOQUE MUESTRA LOS PORCENTAJES TRAS PASAR VENTANAS
- if (defined($ARGV[1])) {
- $windowL = $ARGV[1];
- }else{
- $windowL = 100;
- } #Definición de la longitud de la ventana (default = 100)
- if (defined($ARGV[2])) {
- $offset = $ARGV[2];
- }else{
- $offset = 100;
- } #Definición del paso de las ventanas (default = 100)
- $LNG = length($winnerSeq);
- for (my $i = 0; $i < $LNG-$windowL; $i+=$offset) {
- print(gcratio(substr($winnerSeq, $i, $windowL))."\n"); #imprime los porcentajes de GC que va encontrando en cada ventana.
- }
- #-----------------------------------------------------------------------------------------------------------------------------|
- #DEFINICIÓN DE LA FUNCIÓN QUE DEVUELVE EL %GC DE UNA STRING
- sub gcratio () {
- my ($seq) = @_;
- my $gcCounter;
- $gcCounter = () = $seq =~ /[CG]/gi;
- if (length($seq) != 0) {
- return ($gcCounter/length($seq));
- }else{
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement