Quite a unique case.
If your data is no very huge I would suggest, you just first keep on
reading all data into a huge has ( key as the animal value as the data)
and then just print out the hash into files
like  ( writing pseudo code is easier if written in perl :-) )

my @files = qw(file1 file2 file3);
$/="\n" . '>';        #this way you could read one record at a time
my %alldata=();
foreach $f(@files) {
  open(IN,$f) || die " Couldnt open file";
  while(<IN>){
        my ($animal) = /^(.*?)\n/;   
        $alldata{$animal} .="$_\n\n";
    }
   close IN;
}

###### %alldata has all the data

  




On Mon, 2004-05-17 at 05:20, Michael S. Robeson II wrote:
> Hi all,
> 
> I am having trouble with combining data from several files, and I can't  
> even figure out how to get started. So, I am NOT asking for any code  
> (though pseudo-code is ok) as I would like to try figuring this problem  
> out myself. So, if anyone can give me any references or hints that  
> would be great.
> 
> So, here is what I am trying to do:
> 
> I have say 2 files (I'd like to do this to as many files as the user  
> needs):
> 
> ***FILE 1***
>  >cat
> atacta--gat--acgt-
> ac-ac-ggttta-ca--
> 
>  >dog
> atgcgtatgc-atcgat-ac--ac-a-ac-a-cac
> 
>  >mouse
> acagctagc-atgca--
> ----acgtatgctacg--atg-
> ***end file 1***
> 
> 
> ***FILE 2***
> 
>  >mouse
> aatctgatcgc-atgca--
> ----acgtaaggctagg-
> 
>  >cat
> atacta--gat--acgt-
> ac-acacagcta--ca--
> 
>  >dog
> atgcgtatgc-atcgat
> -ac--ac-a-ac-a-cac
> ***end file 2***
> 
> Basically, I would like to concatenate the sequence of each  
> corresponding animal so that the various input files would  be out put  
> to a file like so:
> 
> ***output***
>  >cat
> atacta--gat--acgt-ac-ac-ggttta-ca--atacta--gat--acgt-ac-acacagcta--ca--
> 
>  >dog
> atgcgtatgc-atcgat-ac--ac-a-ac-a-cacatgcgtatgc-atcgat-ac--ac-a-ac-a-cac
> 
>  >mouse
> acagctagc-atgca------acgtatgctacg--atg-aatctgatcgc-atgca------ 
> acgtaaggctagg-
> ***output end***
> 
> Notice that in the two files the data are not in the same order. So, I  
> am trying to figure out how to have the script figure out what the  
> first organism is in FILE 1( say "cat" in this case) and find the  
> corresponding "cat" in the other input files. Then take the sequence  
> data (all the cat data) from FILE 2 and concatenate it to the cat  
> sequence data in FILE 1 to an output file. Then it should go on to the  
> next organism in FILE 1 and search for that next organism in the other  
> files (in this case FILE 2). I do not care about the order of the data,  
> only that the "like" data is concatenated together.
> 
> Again, I do NOT want this solved for me (unless I am totally lost).  
> Otherwise, I'll never learn. I would just like either hints /  
> suggestions / pseudo code / even links to books or sites that discuss  
> this particular topic. Meanwhile, I am eagerly awaiting my "PERL  
> Cookbook" and I'll keep searching the web.
> 
> -Thanks!
> -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