Just a comment that Python supports sets which make this more efficient
and easier to read:
a = set(list1)b = set(list2)intersection = a & bunion = a | b
len(intersection) / float(union)
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), Research Unit in Bioinformatics (RUBi)
> Mail: diallobaka...@gmail.com |  Skype: diallobakary4
> Tel:  +27798233845 | +223 74 56 57 22 | +223 97 39 77 14
> 
> 
> 
> 
> _______________________________________________OpenBabel-discuss
> mailing listopenbabel-disc...@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