Exemple #1
0
    def process_mdlr(self, mdlrPath):
        '''
        main method. extracts species definition, creates bng-xml, creates mdl
        definitions
        '''
        try:
            nauty_dict = self.xml2hnauty_species_definitions(mdlrPath)
        except OSError:
            print(
                'Cannot open BNG2.pl. Please check BioNetGen is installed at:  %s'
                % (self.config['bionetgen']))
            sys.exit(0)

        # append extended bng-xml to the bng-xml definition (the one that
        # doesn't include seed information)
        bngxmlestr = writeBXe.merge_bxbxe(
            namespace.input + '_rules.xml',
            namespace.input + '_extended_bng.xml')
        with open(mdlrPath + '_rules.xml', 'w') as f:
            f.write(bngxmlestr)

        xmlspec = read_bngxml.parseFullXML(namespace.input + '.xml')
        # write out the equivalent plain mdl stuffs
        mdl_dict = write_mdl.construct_mcell(xmlspec, namespace.input,
                                             final_name.split(os.sep)[-1],
                                             nauty_dict)
        write_mdl.write_mdl(mdl_dict, final_name)
Exemple #2
0
    # temporaryly store bng-xml information in a separate file for display
    # purposes
    with open(namespace.input + '_extended.xml', 'wb') as f:
        f.write(result_dict['bngxmlestr'])

    # get cannonical label -bngl label dictionary

    if not namespace.nfsim:
        # bngl 2 sbml 2 json

        read_mdl.bngl2json(namespace.input + '.bngl')
        # json 2 plain mdl
        mdl_dict = write_mdl.constructMDL(namespace.input + '_sbml.xml.json',
                                          namespace.input, final_name)
        # create an mdl with nfsim-species and nfsim-reactions
        write_mdl.write_mdl(mdl_dict, final_name)
    else:
        try:
            mdlr2mdl = MDLR2MDL(os.path.join(get_script_path(), 'mcellr.yaml'))
            mdlr2mdl.process_mdlr(namespace.input)
        except IOError:
            print("Please create mcellr.yaml in the mcellRules directory. Use "
                  "mcellr.yaml.template as a reference.")
        # get the species definitions
    noext = os.path.splitext(namespace.input)[0]
    xml_name = "{0}.mdlr_total.xml".format(noext)
    mdl_name = "{0}.main.mdl".format(namespace.output)
    with open("mcellr.yaml", 'r') as f:
        config = yaml.load(f.read())
    try:
        mcell_path = config['mcell']