dmunoze has asked for the wisdom of the Perl Monks concerning the following question:
Hello! I hope my problem is more complicated than the title suggests. I need to compare a series of 100 sequences with the original and the program should give me one number of identities. For example:
Original sequence: ATCGGGACG Stream 0: TCGTCAGCG Sequence 1: ATGCGAAAA
Then the program should print:
The sequence 0 has 2 identities The sequence 1 has 4 identities
My code requires a file containing the original sequence (you will note this at the biginning, where it says: "original.FASTA") so I don't know if you can work without it. Thanks already.
#!/usr/bin/perl -w #Lectura de archivo de secuencias $secuencia = 'original.FASTA'; #Abrir el archivo open (SECUENCIA, $secuencia); #Leer la secuencia @secuencia = <SECUENCIA>; close SECUENCIA; #Eliminar la línea de título. $secuencia[0]=""; #print "Esta es la secuencia:\n\n"; #print @secuencia; #Convertir el arreglo a una variable, con el comando join. $DNA = join('',@secuencia); #Concatenar las líneas: chomp @secuencia; $DNA =~ s/\n//g; #Quita los saltos de línea. $DNA =~ s/\s//g; print "La secuencia original es: \n\n",$DNA,"\n\n"; #Secuencias aleatorias $test="ACGT"; @DNA=split("",$test); for ($j=0; $j < 100; ++$j){ $salida=""; for ($i=0; $i < 541; ++$i){ $random=rand(length($test)); $salida=$salida.$DNA[$random]; } print ">Secuencia_$j\n$salida\n"; } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compare two variables
by Cristoforo (Curate) on May 19, 2014 at 22:07 UTC | |
by dmunoze (Initiate) on May 20, 2014 at 00:17 UTC | |
by project129 (Beadle) on May 20, 2014 at 01:27 UTC | |
by AnomalousMonk (Archbishop) on May 20, 2014 at 14:18 UTC | |
by AnomalousMonk (Archbishop) on May 20, 2014 at 14:28 UTC | |
|
Re: Compare two variables
by GotToBTru (Prior) on May 19, 2014 at 21:41 UTC |