Michael S. Robeson II wrote: > I have data (DNA sequence) in a file that looks like this: > > #### > # Infile > #### > >bob > AGTGATGCCGACG > >fred > ACGCATATCGCAT > >jon > CAGTACGATTTATC > > and I need it converted to: > > #### > # Outfile > #### > R 1 20 > > A G U G A T G C C G A C G - - - - - - - bob > A C G C A U A U C G C A U - - - - - - - fred > C A G U A C G A U U U A U C - - - - - - jon
there are many ways of doing that. here is one: #!/usr/bin/perl -w use strict; #-- #-- discard the first 3 header lines #-- <DATA> for 1..3; #-- #-- read each ' >' #-- $/ = ' >'; while(<DATA>){ next unless(my($n,$s) = /(.+)\n(.+)/); #-- #-- pad dna sequence to 20 bytes and translate T to U #-- here, you will prompt the user to enter a number instead #-- ($s .= '-'x(20-length($s))) =~ y/T/U/; #-- #-- put space after each character #-- $s =~ s/./$& /g; print "$s\t$n\n"; } __DATA__ #### # Infile #### >bob AGTGATGCCGACG >fred ACGCATATCGCAT >jon CAGTACGATTTATC __END__ prints: A G U G A U G C C G A C G - - - - - - - bob A C G C A U A U C G C A U - - - - - - - fred C A G U A C G A U U U A U C - - - - - - jon david -- sub'_{print"@_ ";* \ = * __ ,\ & \} sub'__{print"@_ ";* \ = * ___ ,\ & \} sub'___{print"@_ ";* \ = * ____ ,\ & \} sub'____{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>