Hi Thomas, You could also use SetBitsFromList() method:
> bv.SetBitsFromList(np.where(ar)[0].tolist()) > ---- Pozdrawiam, | Best regards, Maciek Wójcikowski mac...@wojcikowski.pl czw., 14 lis 2019 o 16:28 Greg Landrum <greg.land...@gmail.com> napisał(a): > Hi Thomas, > > There may be more efficient ways to do this, but here's something that > works (and isn't the slowest thing I came up with): > def np_to_bv(fv): > bv = DataStructs.ExplicitBitVect(len(fv)) > for i,v in enumerate(fv): > if v: > bv.SetBit(i) > return bv > > -greg > > > > On Thu, Nov 14, 2019 at 3:47 PM Thomas Evangelidis <teva...@gmail.com> > wrote: > >> Greetings, >> >> I am opening this old thread again for someone to answer my initial >> question this time, which was "How do I convert numpy.ndarray objects to >> rdkit.DataStructs.ExplicitBitVect objects?". At the time I asked >> the question I circumvented the problem by calculating Tanimoto >> similarities with Scipy, but now I want to utilize all similarity functions >> offered by rdkit.DataStructs. I am struggling with that for quite some time >> although I feel that the answer is simple. >> >> So basically, I have these arrays and want to calculate their >> DataStructs.McConnaugheySimilarity similarity. How do I do it? >> >> fv1 = numpy.array([1,1,0,0,1,0,1]) >> >> >> fv2 = numpy.array([0,1,1,0,1,0,0]) >> >> Thanks in advance. >> Thomas >> >> >> -- >> >> ====================================================================== >> >> Dr. Thomas Evangelidis >> >> Research Scientist >> >> IOCB - Institute of Organic Chemistry and Biochemistry of the Czech >> Academy of Sciences <https://www.uochb.cz/web/structure/31.html?lang=en> >> , Prague, Czech Republic >> & >> CEITEC - Central European Institute of Technology >> <https://www.ceitec.eu/>, Brno, Czech Republic >> >> email: teva...@gmail.com, Twitter: tevangelidis >> <https://twitter.com/tevangelidis>, LinkedIn: Thomas Evangelidis >> <https://www.linkedin.com/in/thomas-evangelidis-495b45125/> >> >> website: https://sites.google.com/site/thomasevangelidishomepage/ >> >> >> >> _______________________________________________ >> Rdkit-discuss mailing list >> Rdkit-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> > _______________________________________________ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss