On 23/05/2019 22:07, Moritz Beber wrote:
Just a comment that Python supports sets which make this more
efficient and easier to read:

a = set(list1)

b = set(list2)

intersection = a & b

union = a | b

len(intersection) / float(union)

Inspired by your contribution, this is probably faster (because you
don't need to compute the set union):

---
s1 = set(list1)
s2 = set(list2)
intersection = s1 & s2
a = len(s1)
b = len(s2)
c = len(intersection)
return (c / float(a + b - c))
---

Note that a and b can be computed once and for all for each molecule, if required
by performance constraints.

Regards,
F.

On Tue, 2019-05-21 at 15:15 +0200, Bakary N'tji Diallo wrote:

Hello there,
Hope you are doing very well.

I would like to compute tanimoto similarity using obspectrophore
fingerprint. I have found a formula on the net for the tanimoto
similarity:
def tanimoto(list1, list2):

#list1 and list2 #spectrophore fingerprint
intersection = [common_item for common_item in list1 if
common_item in list2]
return float(len(intersection))/(len(list1) + len(list2) -
len(intersection))

For now, I tested this using the same compound as input and the
result is 1.
Just wanted to confirm this is the right formula for Tanimoto
coefficient for spectrophore.

Thanks
Best regards--

Bakary N’tji DIALLO

PhD Student (Bioinformatics) [1], Research Unit in Bioinformatics
(RUBi) [2]

Mail: diallobaka...@gmail.com |  Skype: diallobakary4

Tel:  +27798233845 | +223 74 56 57 22 | +223 97 39 77 14

_______________________________________________

OpenBabel-discuss mailing list

OpenBabel-discuss@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


Links:
------
[1] http://linkedin.com/in/bakarydiallo
[2] https://rubi.ru.ac.za/
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to