There may be a better way (my python is rudimentary),

explicitList = numpy.array([0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1,
1, 1, 1, 1, 0, 0])

onbits = numpy.where(explicitList==1)[0].tolist()

bv1 = DataStructs.SparseBitVect(20)

bv1.SetBitsFromList(onbits)

bv1

for i in range(20):
    print(bv1.GetBit(i))

False
True
True
True
False
True
False
True
False
True
True
True
False
True
True
True
True
True
False
False


Jason Biggs


On Thu, Jan 11, 2018 at 9:30 AM, Michał Nowotka <mmm...@gmail.com> wrote:

> Hi,
>
> Imagine I have two numpy arrays containing zeros and ones (or bools)
> effectively being fingerprints:
>
> np_1, np_2 = some_fingerprints_as_np_arrays()
>
> I want to convert them both to rdkit fingerprint objects so I can use
> DiceSimilarity:
>
> from rdkit import DataStructs
>
> # this won't work becuse of type incompatibility
> DataStructs.DiceSimilarity(np_1, np_2)
>
> In the http://www.rdkit.org/Python_Docs/rdkit.DataStructs.
> cDataStructs.ExplicitBitVect-class.html
> docs I can't find any constructor apart from FromBase64.
> Any hints?
>
> Cheers,
>
> Michał
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to