I have a problem about converting a base64 encoded string into binary. I am collecting the Fingerprint2D in the following link,
url = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/108770/property/Fingerprint2D/xml"
Fingerprint2D=AAADccB6OAAAAAAAAAAAAAAAAAAAAAAAAAA8WIEAAAAAAACxAAAAHgAACAAADAzBmAQwzoMABgCI AiTSSACCCAAhIAAAiAEMTMgMJibMsZuGeijn4BnI+YeQ0OMOKAACAgAKAABQAAQEABQAAAAAAAAA AA==
The descriptiong in the Pubchem says that this is 115 byte string, and it should be 920 bits when converted into binary. I try to convert it to the binary with the following,
response = requests.get(url)
tree = ET.fromstring(response.text)
for el in tree[0]:
if "Fingerprint2D" in el.tag:
fpp = bin(int(el.text, 16))
print(len(fpp))
If I use the code above, I'm getting the following error, "Value error: invalid literal for int() with base16:
And if I use the code below, length of fpp (binary) is equal to 1278 which is not what I expected.
response = requests.get(url)
tree = ET.fromstring(response.text)
for el in tree[0]:
if "Fingerprint2D" in el.tag:
fpp = bin(int(hexlify(el.text), 16))
print(len(fpp))
Thanks a lot already!!