mHiC icon indicating copy to clipboard operation
mHiC copied to clipboard

Step 4: Type Error

Open aakashsur opened this issue 4 years ago • 1 comments

When executing step 4 I get the following error:

Traceback (most recent call last):
  File "~/mhic/bin/KR_norm_mHiC.py", line 468, in <module>
    writeInteraction(norm_mtx, baseName, args.outdir, revFragsDic, args.chrNum, args.resolution)
  File "~/mhic/bin/KR_norm_mHiC.py", line 361, in writeInteraction
    matrixFile.write(("%s\t%d\t%s\t%d\t%.4f\n") % (chr1, mid1, chr2, mid2, values[i]))
TypeError: %d format: a number is required, not str

When I interrogate KR_norm_mHiC.py, it is trying to print the following:

LtaP_01 12500 LtaP_01 15500 3.3297406440638815

Where the type of each object is such:

<class 'str'> <class 'str'> <class 'str'> <class 'str'> <class 'numpy.float64'>

Clearly the bin coordinates are meant to be integers. I'm not sure why I would be running into this error, maybe a python version difference?

Also in regards to the string formatting, I think it is a bit more readable to use the Python 3 f-string formatting.

aakashsur avatar May 08 '20 19:05 aakashsur