Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# AIGO.Similarity.GO_Similarity

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
```Calculates pairwise semantic similarity scores in a list of annotation sets
```

```        def GO_Similarity(G, allGO, metric="GS2", **kargs):
"""
Calculates pairwise semantic similarity scores in a list of annotation sets
"""

if len(allGO)<2:
sim=1.0
l=[1.0]
else:
if metric=="GS2":
sim,l=G.GS2( [G.GOtoInt(GO)  for GO in allGO ])
elif metric=="CzekanowskiDice":
allGO=[G.GOtoInt(GO)  for GO in allGO ]

allD=dict()
l=list()
for i,GO1 in enumerate(allGO):
foo=[allD.setdefault(sort([i,j])[0],dict()).setdefault(sort([i,j])[1], G.CzekanowskiDice(GO1, GO2)) for j,GO2 in enumerate(allGO) if not j==i]
l.append(mean(foo))

sim=mean(l)

elif metric=="Resnik":
allGO=[G.GOtoInt(GO)  for GO in allGO ]

allD=dict()
l=list()
for i,GO1 in enumerate(allGO):
foo=[allD.setdefault(sort([i,j])[0],dict()).setdefault(sort([i,j])[1], G.Resnik(GO1, GO2, kargs.get('IC', dict()))) for j,GO2 in enumerate(allGO) if not j==i]
l.append(mean(foo))

sim=mean(l)

else:
logger.handleWarning ("Sorry, unknown semnatic similarity %s " % metric)
sim,l=None,None

return sim,l
```

```from AIGO import logger, logFun

from AIGO.Similarity import GOSet_Similarity, GO_Similarity

class AnalyseFA(dict):
```
```            allCompactness=dict()
for a in FA.G.aspect:
sim, l = GO_Similarity(FA.G, FA.GPtoGO[a].values())
allCompactness[a]=l

```