Wednesday, October 15, 2008
Working with a 64 bit machine
I thought I will write this in my note book, but instead I ended up putting it on my blog site! This problem has taken a lot of my working time to solve. Recently I have been moving our entire web portal from a 32 bit machine to a 64 bit machine. The data transfer was quite smooth except for some small troubles here and there - like with PHP versions. In older PHP versions, I did not need to write 'php' near the opening tag(
I have written a C program to calculate the Fickett score as well as the coding potential of a given sequence. Then plot the values on fly using perl GD graphics module. To my surprise, the same GD code plotted like Fig-1 in 32 bit machine where as in 64 bit machine the output was a straight line(Fig-2). I tried to compare the computed text output in 2 machines. Although they were not identical but they had quite good similarity. What the heck. Even I got the numerical output and plotted on 32 bit machine still got figures like the first one. Then on a quick look I found that the newer bioperl module(perl -MGD -e 'print $GD::VERSION'; 2.41) is unable to plot anything when there is a number like '-inf'. This is handled very well with older(2.35) GD packages. Apart from this I was also wondering how 'atof' function works in C. Earlier, the codon usage table was written where there was no '0' preceeding the decimal point (like 0.02344). The array that reads this value is just an array of size 5 and I used fscanf function to read this.My syntax was:
(fscanf(fp,"%s",store[i])!=EOF) . The file was something like this :
GCA .0200 GCC .019 GCG .0238 GCT .0255
TGC .0104 TGT .008 GAC .0356 GAT .022
GAA .0234 GAG .0427 TTC .017 TTT .0213
GGA .014 GGC .022 GGG .009 GGT .0178
No matter whatever I did, fscanf always mis-behaved when it is reading a float as a string (with syntax %s).So, instead of reading .0200 and GCC as 2 different variables it sometimes read .0200GCC as one variable and GCC as another. It practically did not ignore the space in between. So, when I converted the string .0200GCC to a float using atof, it produced a different result than just .0200. As a result of which I would get values like -inf when the log likelihood values are calculated, where it should have been some negative integer. Now having learn t this lesson, I would suggest anyone reading a mixed file of characters and float or any other data types to read them any other way then to read it as string. For this particular case something like
(fscanf(fp,"%s%f",tmp,&val) !=EOF) would be more than appropriate..
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment