Ejemplo n.º 1
0
def getContext(fileName, auxDirectory=None):
    if auxDirectory:
        auxFile = fileName.split('/')[-1]
        with open(os.path.join(auxDirectory, '{0}.dump'.format(auxFile))) as f:
            context = pickle.load(f)
            stateDict = pickle.load(f)
    else:
        context, stateDict = componentGroups.getContextRequirements(fileName)
    return [context, stateDict]
Ejemplo n.º 2
0
def getContext(fileName, auxDirectory=None):
    if auxDirectory:
        auxFile = fileName.split("/")[-1]
        with open(os.path.join(auxDirectory, "{0}.dump".format(auxFile))) as f:
            context = pickle.load(f)
            stateDict = pickle.load(f)
    else:
        context, stateDict = componentGroups.getContextRequirements(fileName)
    return [context, stateDict]
Ejemplo n.º 3
0
    def __init__(self, fileName,rawFileName=None):
        self.molecules, self.rules, _ = readBNGXML.parseXML(fileName)
        self.dependencies, self.patternXreactions = componentGroups.getContextRequirements(fileName, collapse=False)
        self.transposePatternsReactions()
        self.reverseDependencies = componentGroups.reverseContextDict(self.dependencies)
        self.moleculeMotifDict, self.motifMoleculeDict = self.classifyPairsByMotif(self.reverseDependencies)

        if rawFileName:
            self.processRawSBML(rawFileName)
        else:
            self.rawRules = {}
Ejemplo n.º 4
0
    def __init__(self, fileName, rawFileName=None):
        self.molecules, self.rules, _ = readBNGXML.parseXML(fileName)
        self.dependencies, self.patternXreactions = componentGroups.getContextRequirements(
            fileName, collapse=False)
        self.transposePatternsReactions()
        self.reverseDependencies = componentGroups.reverseContextDict(
            self.dependencies)
        self.moleculeMotifDict, self.motifMoleculeDict = self.classifyPairsByMotif(
            self.reverseDependencies)

        if rawFileName:
            self.processRawSBML(rawFileName)
        else:
            self.rawRules = {}
Ejemplo n.º 5
0
def createContextInformation(inputDirectory,outputDirectory):
    bngxml = getFiles(inputDirectory, 'xml')
    progress = progressbar.ProgressBar()
    fullContextDict = {}
    for idx in progress(range(len(bngxml))):
        fileName = bngxml[idx]
        #molecules,rules,_ = parseXML(fileName)
        extendedInformation, backup = componentGroups.getContextRequirements(fileName,False)
        fullContextDict[fileName] = extendedInformation
        with open(os.path.join(outputDirectory, '{0}.dump'.format(fileName.split('/')[-1])), 'w') as f:
            pickle.dump(default_to_regular(extendedInformation), f)
            pickle.dump(default_to_regular(backup), f)
        #collapsedContactMap.createCollapsedContact(rules,molecules,[1],fileName + '.gml',extendedInformation    )         
    with open(os.path.join(outputDirectory, '{0}.dump'.format(inputDirectory), 'w')) as f:
Ejemplo n.º 6
0
    molecules, rules, _ = parseXML(fileName)
    graph, graphDictionary = createCollapsedContact(rules, molecules, [1], outputfilename, extendedInformation,
                                                    contextOnlyFlag, nullContextFlag, separateGraphsFlag, motifFlag, bipartiteFlag)

    if separateGraphsFlag:
        for graphObject in graphDictionary:
            nx.write_gml(graphDictionary[graphObject], '{0}_{1}.gml'.format(fileName.split('.')[0], graphObject))
    else:
        nx.write_gml(graph, outputfilename)


if __name__ == "__main__":
    parser = defineConsole()
    namespace = parser.parse_args()
    inputFile = namespace.input
    if namespace.output is not None:
        outputFile = namespace.output
    else:
        outputFile = inputFile + '.gml'
    collapseFlag = False if namespace.expand else True
    if namespace.rulify:
        extendedInformation, _, exclusionCliques, processNodes = componentGroups.getContextRequirements(inputFile, collapse=collapseFlag,
                                                                                          motifFlag=namespace.motifs, excludeReverse=True)
    else:
        extendedInformation = {}
    extendedInformationDict = {'extendedInformation': extendedInformation,
                               'exclusionCliques': exclusionCliques, 'processNodes': processNodes}
    main(inputFile, outputFile, extendedInformationDict, namespace.context_only, namespace.null_context,
         namespace.separate_graphs, namespace.motifs, namespace.bipartite)
    #addAnnotations('fceri_ji')
Ejemplo n.º 7
0

def defineConsole():
    parser = argparse.ArgumentParser(description='SBML to BNGL translator')
    parser.add_argument('-i', '--input', type=str, help='settings file',required=True)
    parser.add_argument('-o', '--output', type=str, help='output directory')

    parser.add_argument('-r', '--rulify', action='store_true')
    return parser    


def main(fileName,outputfilename,extendedInformation):
    molecules,rules,_ = parseXML(fileName)
    createCollapsedContact(rules,molecules,[1],outputfilename,extendedInformation)         


if __name__ == "__main__":
    parser = defineConsole()
    namespace = parser.parse_args()
    inputFile = namespace.input
    if namespace.output != None:
        outputFile = namespace.output
    else:
        outputFile = inputFile + '.gml'
    if namespace.rulify:
        extendedInformation = componentGroups.getContextRequirements(inputFile)   
    else:
        extendedInformation = {}
    main(inputFile,outputFile,extendedInformation)
    
    #addAnnotations('fceri_ji')
Ejemplo n.º 8
0
    else:
        nx.write_gml(graph, outputfilename)


if __name__ == "__main__":
    parser = defineConsole()
    namespace = parser.parse_args()
    inputFile = namespace.input
    if namespace.output is not None:
        outputFile = namespace.output
    else:
        outputFile = inputFile + '.gml'
    collapseFlag = False if namespace.expand else True
    if namespace.rulify:
        extendedInformation, _, exclusionCliques, processNodes = componentGroups.getContextRequirements(
            inputFile,
            collapse=collapseFlag,
            motifFlag=namespace.motifs,
            excludeReverse=True)
    else:
        extendedInformation = {}
    extendedInformationDict = {
        'extendedInformation': extendedInformation,
        'exclusionCliques': exclusionCliques,
        'processNodes': processNodes
    }
    main(inputFile, outputFile, extendedInformationDict,
         namespace.context_only, namespace.null_context,
         namespace.separate_graphs, namespace.motifs, namespace.bipartite)
    #addAnnotations('fceri_ji')