Hi folks,
The code shown bellow is supposed to de-reference a hash-reference of 
array-references and print everything out nicely. But the array 
references do not get de-referenced.  I really appreciate the help.
Thanks,
Hans


#!usr/bin/perl  -w
use strict;
use warnings;
use diagnostics;
my $alignment_hash;

$alignment_hash = &read_alignment ("Aligned_friz.txt", "%");
foreach my $key (keys (%$alignment_hash)) {
        print "{$key}\t=>\t[$$alignment_hash{$key}]\n";
}


sub read_alignment {

        my (
        $align_file,    # The path to the aligned sequence file
        $esc                    # The escape character indicating 
anotation lines in the alignement file
        ) = @_;
        my ($seq, $seq_key, $amino_acids, %alignments);
        open (ALIGNMENT, "<$align_file") or die "Could not open 
\"$align_file\". $!\n";
        while (<ALIGNMENT>) {
                chomp;
                next unless ($_ =~ /\S/); 
        # Skip any lines with only white space
                if ($_ =~ /$esc/o) { 
        # "%" indicates an anotation line
                        if (not $seq) {                         # No 
seq yet, must be the first pass ...
                                $seq_key = $_;                  # so 
just get the anottation and goto next
                                next;
                        } else {
                                                                #turn 
the seq into a list of amino acids
                                $amino_acids = [split (//, $seq)];
                                                                # 
Place the anotation and the seq in a hash
                                $alignments{$seq_key} = $amino_acids;
                                $seq = ""; 
        # Reset the $seq variable for the next seq
                                $seq_key = $_;                  # 
Store the new key

                        }
                } else { 
        # Not anotation:
                        next unless $seq_key;                   # 
Skip any junk at the beginning of the file
                        $seq .= $_;                             # Get 
more of the seq.
                }
        }                                                       # 
Done reding file
        close (ALIGNMENT);
        $amino_acids = [split (//, $seq)];
        $alignments{$seq_key} = $amino_acids; 
        # Place the anotation with last seq in hash

        return (\%alignments);
}
-- 



________________________________________________

Hans E. E. Holtan
Graduate Student
UC Berkeley-Department of Plant and Microbial Biology
Plant Gene Expression Center
800 Buchanan Street
Albany, California 94710
U. S. A.
Phone: (510) 559-5922
FAX: (510) 559-6089
[EMAIL PROTECTED]
_________________________________________________

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to