def pathwayGnab(dataD, pathways={}):

    print " "
    print " ************************************************************* "
    print " ************************************************************* "
    print " "
    print " in pathwayGnab ... "

    # check that the input feature matrix looks ok ...
    try:
        numRow = len(dataD['rowLabels'])
        numCol = len(dataD['colLabels'])
        rowLabels = dataD['rowLabels']
        print " %d rows x %d columns " % (numRow, numCol)
        # print rowLabels[:5]
        # print rowLabels[-5:]
    except:
        print " ERROR in pathwayGnab ??? bad data ??? "
        return (dataD)

    if (len(pathways) == 0):

        print " "
        print " WARNING: no pathway information found ... using a few hard-coded pathways for now "
        print " "

        pathways = {}

        pathways[
            "TP53_pathway"] = ["E2F1", "TP53", "RB1", "CDK4", "TIMP3", "CDK2", "ATM",
                               "CCNE1", "CCND1", "CDKN1A", "BCL2", "BAX", "PCNA", "MDM2",
                               "APAF1", "GADD45A"]

        pathways[
            "PI3K_AKT_pathway"] = ["FRAP1", "LST8", "PDPK1", "NGF", "NR4A1", "FOXO1", "CHUK",
                                   "THEM4", "PTEN", "CREB1", "BAD", "RHOA", "TRIB3", "PHLPP",
                                   "CASP9", "AKT1S1", "MDM2", "RPS6KB2"]

        pathways[
            "Wnt_pathway"] = ["PPP2R5B", "PPP2R5A", "PPP2R5D", "BTRC", "WNT3A",
                              "PPP2R5C", "MMP7", "PRKX", "CTNNB1", "WNT2", "CSNK2A2", "MAP3K7", "PRKACG",
                              "WNT1", "WNT4", "WNT3", "CSNK2A1", "PRKACA", "PRKACB", "WNT6", "CUL1",
                              "WNT10A", "WNT10B", "VANGL1", "ROCK1", "ROCK2", "VANGL2", "CHP2", "SKP1",
                              "EP300", "JUN", "MAPK9", "PPP2R5E", "MAPK8", "LOC728622", "WNT5A", "WNT5B",
                              "CXXC4", "DAAM1", "DAAM2", "RBX1", "RAC2", "RAC3", "RAC1", "CACYBP",
                              "AXIN2", "AXIN1", "DVL2", "DVL3", "TCF7", "CREBBP", "SMAD4", "SMAD3",
                              "SMAD2", "PORCN", "DVL1", "SFRP5", "SFRP1", "PRICKLE1", "SFRP2", "SFRP4",
                              "PRICKLE2", "WIF1", "PPARD", "PLCB3", "PLCB4", "FRAT1", "RHOA", "FRAT2",
                              "SOX17", "PLCB1", "FOSL1", "MYC", "PLCB2", "PPP2R1B", "PRKCA", "PPP2R1A",
                              "TBL1XR1", "CTBP1", "CTBP2", "TP53", "LEF1", "PRKCG", "PRKCB", "CTNNBIP1",
                              "SENP2", "CCND1", "PSEN1", "CCND3", "CCND2", "WNT9B", "WNT11", "SIAH1",
                              "RUVBL1", "WNT9A", "CER1", "NKD1", "WNT16", "NKD2", "APC2", "CAMK2G",
                              "PPP3R1", "PPP3R2", "TCF7L2", "TCF7L1", "CHD8", "PPP2CA", "PPP2CB",
                              "PPP3CB", "NFAT5", "CAMK2D", "PPP3CC", "NFATC4", "CAMK2B", "CHP",
                              "PPP3CA", "NFATC2", "NFATC3", "FBXW11", "CAMK2A", "WNT8A", "WNT8B",
                              "APC", "NFATC1", "CSNK1A1", "FZD9", "FZD8", "NLK", "FZD1", "CSNK2B",
                              "CSNK1A1L", "FZD3", "FZD2", "MAPK10", "FZD5", "FZD4", "FZD7", "DKK4",
                              "WNT2B", "FZD6", "DKK2", "FZD10", "WNT7B", "DKK1", "CSNK1E", "GSK3B",
                              "LRP6", "TBL1X", "WNT7A", "LRP5", "TBL1Y"]

    print " "
    print " total number of pathways : ", len(pathways)
    print " "

    mutationTypes = [":y_n_somatic", ":code_potential_somatic",
                     ":missense_somatic",
                     ":y_del_somatic", ":y_amp_somatic"]
    numTypes = len(mutationTypes)

    pathwayList = pathways.keys()
    pathwayList.sort()
    numPW = len(pathways)
    newNameVec = [0] * (numPW * numTypes)
    newDataMat = [0] * (numPW * numTypes)

    dMat = dataD['dataMatrix']

    min_numON = chooseCountThreshold(dataD)
    if (min_numON < (numCol / 100)):
        min_numON = int(numCol / 100)
    print " minimum count threshold : ", min_numON

    kFeat = 0
    max_numON = 0
    max_fracON = 0.

    ## outer loop is over pathways ...
    for aPathway in pathwayList:

        print " "
        print " outer loop over pathways ... ", aPathway

        ## next loop is over mutation types
        for aMutType in mutationTypes:

            numON = 0
            newFeatName = "B:GNAB:" + aPathway + "::::" + aMutType
            print "     new feature name : ", newFeatName

            # first make sure we don't already have a feature with this name
            stopNow = 0
            for iRow in range(numRow):
                if (newFeatName == rowLabels[iRow]): 
                    print "     STOPPING ... this feature already exists ??? ", newFeatName
                    stopNow = 1

            if (stopNow): continue

            print "     tentative new feature #%d ... <%s> " % (kFeat, newFeatName)
            newNameVec[kFeat] = newFeatName
            newDataMat[kFeat] = numpy.zeros(numCol)

            if (0):
                print " "
                print " "
                print aPathway, newFeatName
                print len(pathways[aPathway]), pathways[aPathway]

            ## and now we can loop over the genes in the pathway
            for gnabGene in pathways[aPathway]:

                print "         looking for pathway gene ", gnabGene

                ## and look for the desired feature
                iR = findFeature ( rowLabels, "B:GNAB:"+gnabGene+":", aMutType )

                ## if we don't find anything, and we are working on  y_del or y_amp
                ## then we can use y_n instead
                if ( iR < 0 ):
                    print " --> failed to find desired feature ", gnabGene, aMutType
                    if ( (aMutType==":y_del_somatic") or (aMutType==":y_amp_somatic") ):
                        iR = findFeature ( rowLabels, "B:GNAB:"+gnabGene+":", ":y_n_somatic" )
                        if ( iR >= 0 ):
                            print "     --> will use this feature instead ", iR, rowLabels[iR]
                        else:
                            print "     --> failed to find even a backup feature "
                else:
                    print " --> FOUND desired feature ", gnabGene, aMutType, iR, rowLabels[iR]