def _computeSimilarityMatrix(self, symbols):
        if symbols is None:
            raise TypeError("Symbols cannot be None")
        for symbol in symbols:
            if not isinstance(symbol, Symbol):
                raise TypeError(
                    "At least one specified symbol is not a valid symbol")

        # Execute the Clustering part in C
        debug = False
        wrapper = WrapperArgsFactory(
            "_libScoreComputation.computeSimilarityMatrix")
        wrapper.typeList[wrapper.function](symbols)
        self._logger.debug("wrapper = {0}".format(wrapper))

        (listScores) = _libScoreComputation.computeSimilarityMatrix(
            self.internalSlick, self._cb_executionStatus, self._isFinish,
            debug, wrapper)
        # Retrieve the scores for each association of symbols
        scores = OrderedDict()
        for (iuid, juid, score) in listScores:
            if iuid not in list(scores.keys()):
                scores[iuid] = OrderedDict()
            if juid not in list(scores.keys()):
                scores[juid] = OrderedDict()
            scores[iuid][juid] = score
            if iuid not in list(scores[juid].keys()):
                scores[juid][iuid] = score
        return scores
Exemple #2
0
    def _computeSimilarityMatrix(self, symbols):
        if symbols is None:
            raise TypeError("Symbols cannot be None")
        for symbol in symbols:
            if not isinstance(symbol, Symbol):
                raise TypeError(
                    "At least one specified symbol is not a valid symbol")

        # Execute the Clustering part in C
        debug = False
        wrapper = WrapperArgsFactory(
            "_libScoreComputation.computeSimilarityMatrix")
        wrapper.typeList[wrapper.function](symbols)
        self._logger.debug("wrapper = {0}".format(wrapper))

        (listScores) = _libScoreComputation.computeSimilarityMatrix(
            self.internalSlick, self._cb_executionStatus, self._isFinish,
            debug, wrapper)
        # Retrieve the scores for each association of symbols
        scores = OrderedDict()
        for (iuid, juid, score) in listScores:
            if iuid not in list(scores.keys()):
                scores[iuid] = OrderedDict()
            if juid not in list(scores.keys()):
                scores[juid] = OrderedDict()
            scores[iuid][juid] = score
            if iuid not in list(scores[juid].keys()):
                scores[juid][iuid] = score
        return scores
Exemple #3
0
    def processUPGMA(self):
        """Computes the matrix of equivalences (in C) and reduce it
        iteratively."""
        self.log.debug("Computing the associated matrix")

        # Execute the Clustering part in C
        debug = False
        wrapper = WrapperArgsFactory("_libScoreComputation.computeSimilarityMatrix")
        wrapper.typeList[wrapper.function](self.symbols)
        (listScores) = _libScoreComputation.computeSimilarityMatrix(self.doInternalSlick, self.cb_executionStatus, self.isFinish, debug, wrapper)
        # Retrieve the scores for each association of symbols
        self.scores = {}
        for (iuid, juid, score) in listScores:
            if self.isFinish():
                return (None, None, None)

            if iuid not in self.scores.keys():
                self.scores[iuid] = {}
            if juid not in self.scores.keys():
                self.scores[juid] = {}
            self.scores[iuid][juid] = score
            if iuid not in self.scores[juid].keys():
                self.scores[juid][iuid] = score

        # Reduce the UPGMA matrix (merge symbols by similarity)
        self.computePhylogenicTree()