Пример #1
0
                'compartmentId']
            reagent['coefficient'] = cpd['stoich']
            reagent[
                'isCofactor'] = 0  # @todo Is this set separately from value in compound?
            rxn['reagents'].append(reagent)
        del rxn['equation']  # Remove after converting to reagent format
        biochem['reactions'].append(rxn)

    # Create the compartment list from the dictionary assembled above.
    biochem['compartments'] = list()
    for id in compartments:
        biochem['compartments'].append(compartments[id])

    # Add the aliases from all of the aliases files.
    print(('Reading aliases from %s ...' % (args.aliasdir)))
    compoundAliases, reactionAliases = helper.readAliasFiles(args.aliasdir)
    biochem['compound_aliases'] = compoundAliases
    biochem['reaction_aliases'] = reactionAliases

    # Save the Biochemistry typed object to the specified workspace path. An existing typed object
    # is overwritten with the updated data.
    print(('Saving typed object to %s ...' % (args.ref)))
    wsClient = Workspace(args.wsurl)
    output = wsClient.create({
        'objects': [[args.ref, 'biochemistry', {}, biochem]],
        'overwrite':
        1
    })

    #    json.dump(biochem, open('master.json', 'w'), indent=4)
    exit(0)
Пример #2
0
    parser.usage = argparse.SUPPRESS
    args = parser.parse_args()

    # Get the token from the config file if one is not provided.
    if args.token is None:
        authdata = _read_inifile()
        args.token = authdata['token']

    # Workaround for extraneous delimiter tacked on the end of references.
    if args.genomeref[-2:] == '||':
        args.genomeref = args.genomeref[:-2]
    if args.templateref[-2:] == '||':
        args.templateref = args.templateref[:-2]

    # Get the genome object from the workspace (for the features).
    wsClient = Workspace(url=args.wsURL, token=args.token)
    genome = getObject(wsClient, args.genomeref, args.token)

    # Get the template object from the workspace (for the complexes and roles).
    template = getObject(wsClient, args.templateref, args.token)

    # Build a dictionary to look up roles in the template by ID.
    roles = dict()
    for index in range(len(template['roles'])):
        roles[template['roles'][index]['id']] = index

    # Create a dictionary to map a complex to a list of roles as defined in the template.
    complexesToRoles = dict()
    for index in range(len(template['complexes'])):
        complexId = template['complexes'][index]['id']
        if len(template['complexes'][index]['complexroles']) > 0: