Pedro,
On Tue, 21 Aug 2001, Pedro A Reche Gallardo wrote:
> Hi All, I have a file (see below) that I would like to split in three
> files: One file for the information under "Alignment (DIALIGN
> format)", another for the information under the line "Alignment (FASTA
> format)" and a third one for the information under sequence tree.
> Any help to do this will be appreciated.
Well, if all of your files are going to be this small, perhaps you
should just do it by hand?
Otherwise, we just want to read lines of text until we find the breaks
between the sections. So, the logic is more or less:
----------
open (PROTEINFILE, "<protein_file") or die;
open (DIALIGNOUTPUT, ">DIALIGN_info") or die;
open (FASTAOUTPUT, ">FASTA_info") or die;
open (TREEOUTPUT, ">TREE_info") or die;
select DIALIGNOUTPUT; # start printing to DIALIGN_info file
while(<PROTEINFILE>) { # grab input protein info line by line
if (/FASTA/) { # once we see FASTA, go to next output file
close (DIALIGNOUTPUT);
select FASTAOUTPUT;
} elsif (/Sequence tree/) { # once we see 'Sequence tree',
# switch to final output file
close (FASTAOUTPUT);
select TREEOUTPUT;
}
print; # in all cases, print contents of $_, the current
# input line
}
close (TREEOUTPUT); # close the last output file
close (PROTEINFILE); # and the input file
----------
HTH,
Dan
> Alignment (DIALIGN format):
> ===========================
>
> gi|38145|e 1 MALPVTALLL PLALLLHAAR ---PSQFRVS PLDRTWNLGE TVELKCQVLL
>
> gi|7438693 1 MALPVTALLL PLALLLHAAR ---PSQFRVS PLDRTWNLGE TVELKCQVLL
>
> ********** ********** ******* ********** **********
>
> ********** ********* ******* ********** **********
>
> Alignment (FASTA format):
> =========================
>
> >gi|38145|emb|CAA4278
> MALPVTALLLPLALLLHAAR---PSQFRVSPLDRTWNLGETVELKCQVLL
> SNPTSGCSWLFQPRGAAASPTFLLYLSQNKPKAAEGLDTQRFSGKRLGDT
> >gi|7438693|pir||S256
> MALPVTALLLPLALLLHAAR---PSQFRVSPLDRTWNLGETVELKCQVLL
>
> Sequence tree:
> ==============
>
> ((gi|38145|emb|CAA4278:0.003018,
> gi|7438693|pir||S256:0.003018):0.002338,
> gi|1168854|sp|P41688:0.005357);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]