예제 #1
0
def CycleMatchInDomainGraph(paramgraph, patterngraph, count):
    '''
    Search for cycle matches anywhere in the domain graph.
    :return: Integer count of parameters if count = True; if count = False return True if at least one match, False otherwise.
    '''
    # TODO: In order for cycle matches to work correctly, the last extremum on each time series with an odd number of extrema must be removed
    numparams = 0
    for paramind in range(paramgraph.size()):
        domaingraph = DSGRN.DomainGraph(paramgraph.parameter(paramind))
        searchgraph = DSGRN.SearchGraph(domaingraph)
        matchinggraph = DSGRN.MatchingGraph(searchgraph, patterngraph)
        if DSGRN.CycleMatch(matchinggraph):
            if count:
                numparams += 1
            else:
                return True
    return numparams if count else False
예제 #2
0
def CycleMatchInStableMorseSet(paramgraph, patterngraph, count):
    '''
    Search for cycle matches in stable Morse sets only.
    :return: Integer count of parameters if count = True; if count = False return True if at least one match, False otherwise.
    '''
    # TODO: In order for cycle matches to work correctly, the last extremum on each time series with an odd number of extrema must be removed
    numparams = 0
    for paramind in range(paramgraph.size()):
        domaingraph = DSGRN.DomainGraph(paramgraph.parameter(paramind))
        morsedecomposition = DSGRN.MorseDecomposition(domaingraph.digraph())
        morsegraph = DSGRN.MorseGraph(domaingraph, morsedecomposition)
        for i in range(0, morsedecomposition.poset().size()):
            if morsegraph.annotation(i)[0] in ["FC", "XC"] and len(
                    morsedecomposition.poset().children(i)) == 0:
                searchgraph = DSGRN.SearchGraph(domaingraph, i)
                matchinggraph = DSGRN.MatchingGraph(searchgraph, patterngraph)
                if DSGRN.CycleMatch(matchinggraph):
                    if count:
                        numparams += 1
                        break
                    else:
                        return True
    return numparams if count else False