# Get the genome object from the workspace.
    wsClient = Workspace(url=args.wsURL, token=args.token)
    try:
        # The get() method returns an array of tuples where the first element is
        # the object's metadata (which is valid json) and the second element is
        # the object's data (which is not valid json).
        object = wsClient.get({ 'objects': [ args.genomeref ] })
        genome = json.loads(object[0][1])

    except WorkspaceServerError as e:
        sys.stderr.write('Failed to get genome using reference %s\n' %(args.genomeref))
        exit(1)

    # Create a worker for running the algorithm.
    worker = ProbAnnotationWorker(genome['id'])
        
    # Run the probabilistic annotation algorithm.
    try:
        # Convert the features in the genome object to a fasta file.
        fastaFile = worker.genomeToFasta(genome['features'])
        
        # Run blast using the fasta file.
        blastResultFile = worker.runBlast(fastaFile)
        
        # Calculate roleset probabilities.
        rolestringTuples = worker.rolesetProbabilitiesMarble(blastResultFile)
        
        # Calculate per-gene role probabilities.
        roleProbs = worker.rolesetProbabilitiesToRoleProbabilities(rolestringTuples)
        
                complexesToRoles[complexId].append(roleId)

    # Create a dictionary to map a reaction to a list of complexes as defined in the template.
    reactionsToComplexes = dict()
    for index in range(len(template['reactions'])):
        reactionId = template['reactions'][index]['id']
        if len(template['reactions'][index]['templatecomplex_refs']) > 0:
            reactionsToComplexes[reactionId] = list()
            for complexRef in template['reactions'][index][
                    'templatecomplex_refs']:
                # Complex ID is last element in reference.
                reactionsToComplexes[reactionId].append(
                    complexRef.split('/')[-1])

    # Create a worker for running the algorithm.
    worker = ProbAnnotationWorker(genome['id'])

    # Run the probabilistic annotation algorithm.
    try:
        # Convert the features in the genome object to a fasta file.
        fastaFile = worker.genomeToFasta(genome['features'])

        # Run blast using the fasta file.
        blastResultFile = worker.runBlast(fastaFile)

        # Calculate roleset probabilities.
        rolestringTuples = worker.rolesetProbabilitiesMarble(blastResultFile)

        # Calculate per-gene role probabilities.
        roleProbs = worker.rolesetProbabilitiesToRoleProbabilities(
            rolestringTuples)