def _compare_proteomes(meth, genome1, genome2, out_proteome_cmp):
    """Start a job to run Blast between the proteomes of two genomes.
    The comparison information includes best-bidirectional hits. [17]
     
    :param genome1: Source genome1 ID [17.1]
    :type genome1: kbtypes.KBaseGenomes.Genome
    :ui_name genome1: Genome1 ID
    :param genome2: Source genome2 ID [17.2]
    :type genome2: kbtypes.KBaseGenomes.Genome
    :ui_name genome2: Genome2 ID
    :param out_proteome_cmp: Output proteome comparison ID. If empty, an ID will be chosen randomly. [17.3]
    :type out_proteome_cmp: kbtypes.GenomeComparison.ProteomeComparison
    :ui_name out_proteome_cmp: Output Proteome Comparison ID
    :return: Output Proteome Comparison ID
    :rtype: kbtypes.ProteomeComparison
    :output_widget: GenomeComparisonWidget
    """
    meth.stages = 1  # for reporting progress
    token = os.environ['KB_AUTH_TOKEN']
    workspace = os.environ['KB_WORKSPACE_ID']
    if not out_proteome_cmp:
        out_proteome_cmp = "proteome_cmp_" + ''.join([chr(random.randrange(0, 26) + ord('A')) for _ in xrange(8)])
    cmpClient = GenomeComparison(url = service.URLS.genomeCmp, token = token)
    blast_proteomes_params = {
        'genome1ws': workspace, 
        'genome1id': genome1, 
        'genome2ws': workspace, 
        'genome2id': genome2, 
        'output_ws': workspace, 
        'output_id': out_proteome_cmp, 
    }
    job_id = cmpClient.blast_proteomes(blast_proteomes_params)
    return json.dumps({'ws_name': workspace, 'ws_id': out_proteome_cmp, 'job_id': job_id})
Exemplo n.º 2
0
def _annotate_genome(meth, genome, out_genome):
    """Annotate a Genome object with structural and functional gene annotations.
    The annotation job may run for an hour or longer. When the annotation job finishes,
    the annotated Genome object will be stored in your workspace. [4]
    
    :param genome: Source genome ID [4.1]
    :type genome: kbtypes.KBaseGenomes.Genome
    :ui_name genome: Genome ID
    :param out_genome: Annotated output genome ID. If empty, annotation will be added into original genome object. [4.2]
    :type out_genome: kbtypes.KBaseGenomes.Genome
    :ui_name out_genome: Output Genome ID
    :return: Annotated output genome ID
    :rtype: kbtypes.KBaseGenomes.Genome
    :output_widget: GenomeAnnotation
    """
    meth.stages = 1  # for reporting progress
    token = os.environ['KB_AUTH_TOKEN']
    workspace = os.environ['KB_WORKSPACE_ID']
    if not out_genome:
        out_genome = genome
    cmpClient = GenomeComparison(url = service.URLS.genomeCmp, token = token)
    annotate_genome_params = {
        'in_genome_ws': workspace, 
        'in_genome_id': genome, 
        'out_genome_ws': workspace, 
        'out_genome_id': out_genome, 
    }
    job_id = cmpClient.annotate_genome(annotate_genome_params)
    return json.dumps({'ws_name': workspace, 'ws_id': out_genome, 'job_id': job_id})
Exemplo n.º 3
0
def _import_ncbi_genome(meth, ncbi_genome_name, genome_id):
    """Import a Genome and ContigSet from NCBI into your workspace. [26]

    :param ncbi_genome_name: Name of public genome accessible on NCBI FTP. [26.1]
    :type ncbi_genome_name: kbtypes.Unicode
    :ui_name ncbi_genome_name: NCBI Genome Name
    :param genome_id: Output Genome ID. If empty, an ID will be chosen automatically. [26.2]
    :type genome_id: kbtypes.KBaseGenomes.Genome
    :ui_name genome_id: Genome Object ID
    :return: Preparation message
    :rtype: kbtypes.Unicode
    :input_widget: NcbiGenomeImportInput
    :output_widget: GenomeAnnotation
    """
    if not genome_id:
        chars = ['\'',' ','-','=','.','/','(',')','_',':','+','*','#',',','[',']']
        genome_id_prefix = ncbi_genome_name
        for ch in chars:
            genome_id_prefix = genome_id_prefix.replace(ch, '_')
        genome_id = genome_id_prefix + '.ncbi'
    meth.stages = 1
    token, workspace = meth.token, meth.workspace_id
    cmpClient = GenomeComparison(url = service.URLS.genomeCmp, token = token)
    import_ncbi_genome_params = {
        'genome_name': ncbi_genome_name, 
        'out_genome_ws': workspace, 
        'out_genome_id': genome_id, 
    }
    cmpClient.import_ncbi_genome(import_ncbi_genome_params)
    return json.dumps({'ws_name': workspace, 'ws_id': genome_id})
Exemplo n.º 4
0
def _add_kbase_annotation(meth, genome, out_genome):
    """Add KBase annotations to a genome.  This function will start a job that might run for an hour or longer.
    When the job finishes, the Genome with KBase annotations will be stored in your workspace. [21]
    
    :param genome: Source genome ID [21.1]
    :type genome: kbtypes.KBaseGenomes.Genome
    :ui_name genome: Genome ID
    :param out_genome: Annotated output genome ID. If empty, annotation will be added into original genome object. [21.2]
    :type out_genome: kbtypes.KBaseGenomes.Genome
    :ui_name out_genome: Output Genome ID
    :return: Annotated output genome ID
    :rtype: kbtypes.Genome
    :output_widget: GenomeAnnotation
    """
    meth.stages = 1  # for reporting progress
    token = os.environ['KB_AUTH_TOKEN']
    workspace = os.environ['KB_WORKSPACE_ID']
    if not out_genome:
        out_genome = genome
    cmpClient = GenomeComparison(url = service.URLS.genomeCmp, token = token)
    annotate_genome_params = {
        'in_genome_ws': workspace, 
        'in_genome_id': genome, 
        'out_genome_ws': workspace, 
        'out_genome_id': out_genome,
        'seed_annotation_only' : 1,
    }
    job_id = cmpClient.annotate_genome(annotate_genome_params)
    return json.dumps({'ws_name': workspace, 'ws_id': out_genome, 'job_id': job_id})