I have a problem converting a base64 encoded string to binary. I compile Fingerprint2D at the following link,
url = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/108770/property/Fingerprint2D/xml"
Fingerprint2D=AAADccB6OAAAAAAAAAAAAAAAAAAAAAAAAAA8WIEAAAAAAACxAAAAHgAACAAADAzBmAQwzoMABgCI AiTSSACCCAAhIAAAiAEMTMgMJibMsZuGeijn4BnI+YeQ0OMOKAACAgAKAABQAAQEABQAAAAAAAAA AA==
Pubchem's g description says it is a 115-byte string, and it should be 920 bits when converting to binary. I am trying to convert it to a 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 get the following error: "Error value: invalid literal for int () with base 16:
And if I use the code below, the length of fpp (binary) is 1278, which I did not expect.
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!
source
share