Well this is the best I could do thinking through what you said. This is actually my first time working with hashes. Also, I am still a PERL newbie. So, I guess a little helpful code would go a long way. I just can't figure out how to link the regular expressions to the hash when searching through the multiple files. to do as you say:

***Philipp wrote:***

- open the first file
- search for the beginning of an "organism" (say: ">cat"), read everything
after this point
- search in your hash if you already stored data of this organism
- if yes, append your new sequence to the already existing data
- if no, create a new key in the hash
- repeat this until you run out of "organisms"
- repeat the whole procedure until you run out of files


***end***

#!/usr/bin/perl
# This script will take separate FASTA files and combine the "like"
# data into one FASTA file.
#

use warnings;
use strict;

my %organisms (
        "$orgID" => "$orgSeq",
     );

print "Enter in a list of files to be processed:\n";

# For example:
# CytB.fasta
# NADH1.fasta
# ....

chomp (my @infiles = <STDIN>);

foreach $infile (@infiles) {
        open  (FASTA, $infile)
                or die "Can't open INFILE: $!";

        $/='>'; #Set input operator

        while (FASTA) {
                chomp;

                # Some regular expression match here?
                # something that will set, say... ">cat"
                # as the key "$orgID", something similar
                # to below?
                # and then set the sequence as the value
                # "$orgSeq" like below?

                # Do not know if or where to put the following,
                # but something like:

                if (exists $organisms{$orgID}) {
                        # somehow concatenate "like" data
                        # from the different files
                }

        # print the final Hash to an outfile?

}

.... yeah, I'm lost.  :-)

-Mike


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to