예제 #1
0
파일: auc.go 프로젝트: TuftsBCB/experiments
func rankMatrix(
	domains *inDomains,
	matrix *intern.Table,
	query intern.Atom,
) []intern.Atom {
	r := &rankedAtoms{
		atoms: make([]intern.Atom, len(domains.atoms)),
		dists: make([]float64, len(domains.atoms)),
	}
	for i, query2 := range domains.atoms {
		r.atoms[i] = query2
		r.dists[i] = matrix.Get(query, query2)
	}
	sort.Sort(r)
	return r.atoms
}
예제 #2
0
파일: auc.go 프로젝트: TuftsBCB/experiments
func tpsAndTns(
	domains *inDomains,
	boa *intern.Table,
	query intern.Atom,
	threshold float64,
) (tps []bool, tns []bool) {
	tps = make([]bool, domains.in.Len())
	tns = make([]bool, domains.in.Len())
	for _, query2 := range domains.atoms {
		if boa.Get(query, query2) <= threshold {
			tps[query2] = true
		} else {
			tns[query2] = true
		}
	}
	return
}
예제 #3
0
파일: main.go 프로젝트: ndaniels/tools
func treeClusters(
	threshold float64,
	dists *intern.Table,
	tree *newick.Tree,
) clusters {
	if len(tree.Children) == 0 {
		if len(tree.Label) > 0 {
			return clusters{[]string{tree.Label}}
		}
		return nil
	}

	// Compare all pairs in this tree. If all are within the threshold given,
	// then add this subtree as a cluster and move on. Otherwise, dig deeper.
	within := forNode(tree, func(node1 *newick.Tree) bool {
		if len(node1.Label) == 0 {
			return true
		}
		a1 := dists.Atom(node1.Label)
		return forNode(tree, func(node2 *newick.Tree) bool {
			if len(node2.Label) == 0 {
				return true
			}
			return dists.Get(a1, dists.Atom(node2.Label)) <= threshold
		})
	})
	if within {
		cluster := make([]string, 0, 10)
		forNode(tree, func(node *newick.Tree) bool {
			if len(node.Label) == 0 {
				return true
			}
			cluster = append(cluster, node.Label)
			return true
		})
		return clusters{cluster}
	}
	clusters := make(clusters, 0, len(tree.Children))
	for i := range tree.Children {
		clusters = append(
			clusters, treeClusters(threshold, dists, &tree.Children[i])...)
	}
	return clusters
}
예제 #4
0
func dist(matrix *intern.Table, d1, d2 string) float64 {
	return matrix.Get(matrix.Atom(d1), matrix.Atom(d2))
}