Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 4: Type Error #16

Open
aakashsur opened this issue May 8, 2020 · 1 comment
Open

Step 4: Type Error #16

aakashsur opened this issue May 8, 2020 · 1 comment

Comments

@aakashsur
Copy link

aakashsur commented May 8, 2020

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
Copy link
Author

At any rate, adding some type conversion lines seems to do the trick. After

chr2, mid2 = revFragsDic[col[i]].split("=")

If we add:

mid1 = int(mid1)
mid2 = int(mid2)

the error resolves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant