Hello,
i need your help in a small programme that i want to create. i have a file which contain the following
name1 1481.100 1436.550 1460.410 1444.460 1049.120 1076.890 1085.500 1 +053.100 name2 1978.700 1949.910 1734.030 1694.530 1930.000 2005.530 1696.960 1 +844.810 name3 ...
and i want to write it as it is in a new file by only replacing the values with log(value)
so i use this programme
my $Name = ""; my $Value1 = 0; my @files = glob ('*.txt'); sub log10 { my $n = shift; return log($n)/log(10); } open (MYFILE, '>data.txt'); foreach my $file (@files) { #print "$file\n"; $test = "$file"; open (TEST,"$test") || die "couldn't open the file YEASTFASTA:$!"; while (<TEST>) { my $line = $_; if ($_=~/^\d+[_]\w+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+.*/) { #$Name = $1; $Value1 = $2; $LogValue = log10($Value1); print MYFILE "$LogValue"; #print "d $LogValue \n"; } print MYFILE "$_"; } close TEST || die "can't close:$!"; close (MYFILE); }
and the output i take is
1.37852508154491 name1 23.907 15.022 25.234 22.573 21.541 13.972 25.07 +6 17.099 YLR331C 3.17058438193919 name2 1481.100 1436.550 1460.410 1444.460 1049.120 10 +76.890 1085.500 1053.100
so my point is how can i place the value 1.3785250815449 (which is the log(23.907)) not in the begging of the line but instead of the value 23.907, that means that i want this output
name1 1.3785250815449 log(value) log(value)...(log of all the values) name1 log(value) log(value)...(log of all the values)
Thanks in advance for your time.
In reply to Writing file by stavros
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |