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;

In reply to Compare two variables by dmunoze

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.