Thanks, but I forgot to mention in the beginning that i need to make this modification only ONCE in my file- the ">" character comes up every few lines, but I only want the title "ALIGNMENTS" in the beginning..i.e, it shd not replace all the ">"s in my file.. ? sorry about that! -thanks, nandita
On Wed, 21 Aug 2002, Sudarshan Raghavan wrote: > On Tue, 20 Aug 2002, Nandita wrote: > > > Thanks for your message, this is how it looks: > > > > beginning of file : > > > > Reading High Probability Sequences producing High-scoring Segment Pairs: > > Frame Score P(N)N > > > > EMBL:B88446 CpG0200B CpIOWAgDNA1 Cryptosporidium parv... +3 75 0.391 > > EMBL:AQ935741 CpG2625B CpIOWAgDNA1 Cryptosporidium pa... +1 74 0.631 > > EMBL:AQ855708 CpG1711B CpIOWAgDNA1 Cryptosporidium pa... -1 71 0.891 > > EMBL:AQ935455 CpG2480A CpIOWAgDNA1 Cryptosporidium pa... +2 69 0.971 > > EMBL:AQ450103 500008A04.x1 CpIOWAM13mp18gDNA1 Cryptos... -1 69 0.981 > > EMBL:AQ254466 CpG0842A CpIOWAgDNA1 Cryptosporidium pa... +2 68 0.991 > > EMBL:AQ935528 CpG2517B CpIOWAgDNA1 Cryptosporidium pa... -2 67 0.9981 > > EMBL:AQ854869 CpG2093B CpIOWAgDNA1 Cryptosporidium pa... +2 67 0.9981 > > EMBL:AQ450236 500009E03.x1 CpIOWAM13mp18gDNA1 Cryptos... -1 65 0.99991 > > EMBL:AQ003639 CpG0296A CpIOWAgDNA1 Cryptosporidium pa... +2 5 0.999901 > > > > "ALIGNMENTS:" > > > > >EMBL:B88446 CpG0200B CpIOWAgDNA1 Cryptosporidium parvum genomic, genomic > > survey sequence. > > Length = 508 >EMBL AQ935528 Cp.... above is the word "ALIGNMENTS:" which is not present and which i'd like to > > add in each file. i figure i'd have to write out a reg exp- something like > > "newline followed by ">" ...but am not able to get a good start..-and dont > > know how to go abt the actual task- figured it had to do with "printing > > to" a variable in which i stored the file value... > > am chewing on it.. > > You don't have to check for the newline just a if (/^>/) would do > This assumes that the files to be modified are given in the command line > If you are getting it some place else, empty @ARGV and add these files to > @ARGV. > > #!/usr/local/bin/perl -w > use strict; > > $^I = '~'; # perldoc perlvar, inplace edit and creates a backup filename~ > while (<>) { > print "ALIGNMENT:\n" if (/^>/); > print; > } > > The same can also be done as an oneliner > perl -i~ -pe 'print "ALIGNMENTS:\n" if (/^>/);' *.txt > > Note: This will create a backup of all the files it processes, for e.g. > if the file names1.txt the original file will be backed up as names1.txt~, > the same as above. > > perldoc perlrun and read through the sections that explains these flags. > You can replace the *.txt with the list of files that you want modified. > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]