Hi all, I have an alignment file and I want to analyze it and output all of the positions that are not conserved. I was thinking of reading in the file as an array of arrays. Below is an example input file. And below that is my current code. Which currently produces the wrong output, and I feel is probably not the most correct way to go about this. Any help is appreciated.

5 15 1 ATCG--ATCG-ATCG 2 ATGC--ATCG-ATCG 3 ATGC-A-TCG-ATCG 4 ATGC--ATCG-ATCG 5 ATCG--ATCG-AACG
use strict; use warnings; my $align_file=$ARGV[0]; #.py (phylip file right now) open (F, $align_file) || die "Could not open $align_file: $!"; my @align_matrix; my %HoTaxids; my @columns; while (my $line = <F>) { chomp($line); <F>; # skip firts line of phylip next if $line =~ /^\s*$/; # skip blank lines my ($taxid,$align_line)=split(/\s/,$line); @columns = split(undef, $align_line);#splitting on undef split +s each character push (@align_matrix, \@columns); $HoTaxids{$taxid}=1; } close(F); my $num_rows=scalar(keys %HoTaxids); my $align_len=scalar(@columns); for (my $i=0;$i<$num_rows;$i++) { for (my $j=0;$j<$align_len;$j++){ if ($align_matrix[$i][$j] ne $align_matrix[$i][$j+1]) { print "position\t$j\t is not conserved\n"; } } }

In reply to manipulating alignment data by AWallBuilder

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.