First I have some questions.
Why is ALIGNMENT not a hash ?  It seems perfect for what you are need.  If
you use ALIGNMENT as a hash, then you can do away with the ID array.

Also you are checking for existence in alignment not ALIGNMENT, this will
be causing problems.

Simplify like this:

mine:
[snip]
#my @ID;            # you don't really need this
my %ALIGNMENT;      #  a hash would work much better, look it up if you
need more info
read_alignment($FILE);

foreach my $key ( keys $ALIGNMENT )      #defines key for each key in your
hash
{
     printf "%-15s %s\n", $key, $ALIGNMENT{$key);
}
sub read_alignment {
     my ($file) = @_;
     my ($line);
     local (*TMP);


     open(TMP, "< $file") or die "can't open file '$file'\n";


     while ( $line = <TMP> )
     {
          my $key;  #something better perhaps
          next if $line =~ /^CLUSTAL/;

          ( $key, $sequence ) = $line =~ /[\w\-]+/;
          #This should grab the key and the sequence, basically you want to
match any word character and the dash
          # the first match is returned to key and the long sequence is
returned to sequence

          if ( !exists $ALIGNMENT{$key} )
          {
                $ALIGNMENT{$key} = "$sequence";
          }


     }

     close TMP
}

Any questions ?



-----------------------------------------
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]








Reply via email to