import biokbase.narrative.common.service as service
from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.workspace.client import Workspace as workspaceService
from biokbase.InvocationService.Client import InvocationService
from biokbase.fbaModelServices.Client import fbaModelServices
from biokbase.GenomeComparison.Client import GenomeComparison
from biokbase.assembly.client import Client as ArastClient
from biokbase.KBaseTrees.Client import KBaseTrees

## Globals

VERSION = (0, 0, 1)
NAME = "Microbes Comparative Genomics"

# Initialize
init_service(name=NAME, desc="Demo workflow microbes service", version=VERSION)

@method(name="Compute Pangenome")
def _compute_pan_genome(meth, genome_set,pangenome_id):
    """ Rapidly compute gene families for a set of phylogenetically close genomes

    :param genome_set: a Genome Set to compute pangenome for
    :type genome_set: kbtypes.KBaseSearch.GenomeSet
    :ui_name genome_set: Genome Set ID
    
    :param pangenome_id: ID for output pangenome
    :type pangenome_id: kbtypes.KBaseGenomes.Pangenome
    :ui_name pangenome_id: Pangenome ID
    
    :return: Generated Pangenome Object
    :rtype: kbtypes.KBaseGenomes.Pangenome
Esempio n. 2
0
from biokbase.InvocationService.Client import InvocationService
from biokbase.shock import Client as shockService

## Globals
VERSION = (0, 0, 1)
NAME = "KBase Commands"


class URLS:
    shock = "http://shock.metagenomics.anl.gov"
    workspace = "https://kbase.us/services/ws"
    invocation = "https://kbase.us/services/invocation"


# Initialize
init_service(name=NAME, desc="Functions for executing KBase commands and manipulating the results", version=VERSION)


def _list_cmds():
    token = os.environ["KB_AUTH_TOKEN"]
    invo = InvocationService(url=URLS.invocation, token=token)
    return invo.valid_commands()


def _run_invo(cmd):
    token = os.environ["KB_AUTH_TOKEN"]
    invo = InvocationService(url=URLS.invocation, token=token)
    stdout, stderr = invo.run_pipeline("", cmd, [], 0, "/")
    return "".join(stdout), "".join(stderr)

Esempio n. 3
0
from biokbase.shock import Client as shockService

## Globals
VERSION = (0, 0, 1)
NAME = "KBase Commands"


class URLS:
    shock = "http://shock.metagenomics.anl.gov"
    workspace = "https://kbase.us/services/ws"
    invocation = "https://kbase.us/services/invocation"


# Initialize
init_service(
    name=NAME,
    desc="Functions for executing KBase commands and manipulating the results",
    version=VERSION)


def _list_cmds():
    token = os.environ['KB_AUTH_TOKEN']
    invo = InvocationService(url=URLS.invocation, token=token)
    return invo.valid_commands()


def _run_invo(cmd):
    token = os.environ['KB_AUTH_TOKEN']
    invo = InvocationService(url=URLS.invocation, token=token)
    stdout, stderr = invo.run_pipeline("", cmd, [], 0, '/')
    return "".join(stdout), "".join(stderr)
Esempio n. 4
0
import random
import numbers
import uuid
import hashlib
# Local
import biokbase.narrative.common.service as service
from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.userandjobstate.client import UserAndJobState

## Globals

VERSION = (0, 0, 1)
NAME = "Test Service"

# Initialize
init_service(name=NAME, desc="Testing Service!", version=VERSION)

@method(name="Register Fake Job")
def _reg_fake_job(meth):
    """Tries to register a fake job id. Will fail like SO HARD.

    :return: Test. And a job id.
    :rtype: kbtypes.Unicode
    """
    meth.stages = 2
    meth.advance("Testing.")

    job_id = "12345"
    meth.register_job(job_id)

    meth.advance("Done testing!")
Esempio n. 5
0
## Imports

from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.narrative.common import kbtypes

## Globals

VERSION = (0, 0, 1)  # We use Semantic Versioning
NAME = 'MyExampleService'  # Each service needs a name
DESC = 'This is an example service'

# Initialization
# This initializes a service to have the given attributes described above.
# Added service methods fall below.
init_service(name=NAME, desc=DESC, version=VERSION)

# Define one function


# Note that the user will see the text in this decorator, so consider that
# when writing the name.
@method(name='My Example Function')
def _my_service_function(meth, param1, param2):
    """This is an example function.

    :param param1: Input Genome
    :type param1: kbtypes.Genome
    :ui_name param1: Genome ID (what the user sees)
    :param param2: Some text
    :type param2: kbtypes.Unicode
Esempio n. 6
0
import json

# Local
import biokbase.narrative.common.service as service
from biokbase.narrative.common.service import init_service
from biokbase.narrative.common.service import finalize_service
from biokbase.narrative.common.service import method
from biokbase.Transform.Client import Transform

#  Global vars

VERSION = (0, 0, 1)
NAME = "Transform Service"

# Initialize
init_service(name=NAME, desc="KBase Transform Service Calls", version=VERSION)


@method(name="Assy to ContigSet")
def _assy_to_cs(meth, input_assyfile, output_contigset):
    """Makes a call to the app service

    :param input_assyfile: the KBaseFile.AssemblyFile to convert
    :type input_assyfile: kbtypes.Unicode
    :ui_name input_assyfile: assembly file
    :param output_contigset: the name for the output ContigSet
    :type output_contigset: kbtypes.Unicode
    :ui_name output_contigset: output ContigSet name
    :rtype: kbtypes.Unicode
    :return: running job info
    """
Esempio n. 7
0
import json
# Local
import biokbase.narrative.common.service as service
from biokbase.narrative.common.service import init_service
from biokbase.narrative.common.service import finalize_service
from biokbase.narrative.common.service import method
from biokbase.Transform.Client import Transform

#  Global vars

VERSION = (0, 0, 1)
NAME = "Transform Service"

# Initialize
init_service(name=NAME, desc="KBase Transform Service Calls", version=VERSION)


@method(name="Assy to ContigSet")
def _assy_to_cs(meth, input_assyfile, output_contigset):
    """Makes a call to the app service

    :param input_assyfile: the KBaseFile.AssemblyFile to convert
    :type input_assyfile: kbtypes.Unicode
    :ui_name input_assyfile: assembly file
    :param output_contigset: the name for the output ContigSet
    :type output_contigset: kbtypes.Unicode
    :ui_name output_contigset: output ContigSet name
    :rtype: kbtypes.Unicode
    :return: running job info
    """
Esempio n. 8
0
__date__ = 'MM/DD/YYYY'

## Imports

from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.narrative.common import kbtypes
import json

## Globals

VERSION = (0, 0, 1)
NAME = "MyExampleService"

# Initialization

init_service(name=NAME, desc="This is an example", version=VERSION)

# Define one service


@method(name="MyExampleFunction")
def _my_service_function(meth, param1, param2):
    """This is an example function.

    :param param1: Input Genome
    :type param1: kbtypes.Genome
    :ui_name param1: Genome ID (what the user sees)
    :param param2: Some text
    :type param2: kbtypes.Unicode
    :ui_name param2: Text
    :return: Workspace object ID
Esempio n. 9
0
## Imports

from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.narrative.common import kbtypes

## Globals

VERSION = (0, 0, 1)         # We use Semantic Versioning
NAME = 'MyExampleService'   # Each service needs a name
DESC = 'This is an example service'

# Initialization
# This initializes a service to have the given attributes described above.
# Added service methods fall below.
init_service(name=NAME, desc=DESC, version=VERSION)

# Define one function

# Note that the user will see the text in this decorator, so consider that
# when writing the name.
@method(name='My Example Function')
def _my_service_function(meth, param1, param2):
    """This is an example function.

    :param param1: Input Genome
    :type param1: kbtypes.Genome
    :ui_name param1: Genome ID (what the user sees)
    :param param2: Some text
    :type param2: kbtypes.Unicode
    :ui_name param2: Text
Esempio n. 10
0
    cdmi = "http://kbase.us/services/cdmi_api"
    #cdmi = "http://140.221.85.181:7032"
    ontology = "http://kbase.us/services/ontology_service"
    #gwas = "http://140.221.85.182:7086"
    gwas = "https://kbase.us/services/GWAS"
    ujs = "https://kbase.us/services/userandjobstate"
    networks = "http://kbase.us/services/networks"
    #networks = "http://140.221.85.172:7064/KBaseNetworksRPC/networks"
    idmap = "http://kbase.us/services/id_map"
    #idmap = "http://140.221.85.181:7111"


AweJob.URL = URLS.awe

# Initialize
init_service(name=NAME, desc="Plants GWAS service", version=VERSION)


def _output_object(name):
    """Format an object ID as JSON output, for returning from a narr. function.
    """
    return json.dumps({'output': name})


def _workspace_output(wsid):
    return json.dumps({'values': [["Workspace object", wsid]]})


class Node:
    nodes = []
    edges = []
Esempio n. 11
0
            "taskid": "1",
            "skip": 0,
            "totalwork": 1
        }
    ]
}
"""
def gnid(s):
    return s if s.startswith('kb|g.') else 'kb|g.' + s

def nbconsole(x):
    sys.stderr.write('@ ' + x + '\n')
    sys.stderr.flush()

# Initialize
init_service(name=NAME, desc="Plants Coexpression service", version=VERSION)


def join_stripped(iterable):
    return ''.join((s.strip() for s in iterable))



def upload_file(uri, filename, att_content):
    file_contents = open(filename).read()
    data = {'upload': (filename, file_contents),
            'attributes': ('', att_content)}
    r = requests.post("%s/node" % uri, files=data)
    response = json.loads(r.text)
    if response['data'] is None:
        raise UploadException("Response from upload has no data: {}".format(response))
Esempio n. 12
0
    datatabletype = 'MAK.FloatDataTable'

class IDServerids:
    ### variation
    var_vcf = 'kb|variant'
    ###RNASeq
    rnaseq_expsample = 'kb|sample'
    rnaseq_series = 'kb|series'
    rnaseq_alignment = 'kb|alignment'
    rnaseq_difexp = 'kb|differentialExpression'
    dt_type = 'kb|dataTable'

# Init logging.
g_log = logging.getLogger(__name__)

init_service(name = NAME, desc="Variation and Expression service", version = VERSION)

clients = {}


##
##Decorators for control logic
##

def _get_wsname(meth, ws):
    '''gets the workspace name
    '''
    if ws:
        return ws
    elif meth.workspace_id and (meth.workspace_id != 'null'):
        return meth.workspace_id
Esempio n. 13
0
    ids = "http://kbase.us/services/idserver"
    cdmi = "http://kbase.us/services/cdmi_api"
    #cdmi = "http://140.221.85.181:7032"
    ontology = "http://kbase.us/services/ontology_service"
    #gwas = "http://140.221.85.182:7086"
    gwas = "https://kbase.us/services/GWAS"
    ujs = "https://kbase.us/services/userandjobstate"
    networks = "http://kbase.us/services/networks"
    #networks = "http://140.221.85.172:7064/KBaseNetworksRPC/networks"
    idmap = "http://kbase.us/services/id_map"
    #idmap = "http://140.221.85.181:7111"

AweJob.URL = URLS.awe

# Initialize
init_service(name=NAME, desc="Plants GWAS service", version=VERSION)


def _output_object(name):
    """Format an object ID as JSON output, for returning from a narr. function.
    """
    return json.dumps({'output': name})


def _workspace_output(wsid):
    return json.dumps({'values': [["Workspace object", wsid]]})

class Node:
    nodes = []
    edges = []
    ugids = {}
Esempio n. 14
0
__author__ = 'Bill Riehl <*****@*****.**>'
__date__ = '9/30/14'

## Imports
# Stdlib
import json
# Local
import biokbase.narrative.common.service as service
from biokbase.narrative.common.service import init_service, method, finalize_service

## Globals
VERSION = (0, 0, 1)
NAME = "Bill Test"

# Initialize
init_service(name=NAME, desc="Bill Demo!", version=VERSION)


@method(name="Try some Perl")
def _try_perl(meth):
    """Run a Perl command. Maybe. 
    
    :return: A string
    :rtype: kbtypes.Unicode
    """
    meth.stages = 2  # for reporting progress
    meth.advance("Starting...")

    from IPython import get_ipython
    ipy = get_ipython()
Esempio n. 15
0
    ]
}
"""


def gnid(s):
    return s if s.startswith('kb|g.') else 'kb|g.' + s


def nbconsole(x):
    sys.stderr.write('@ ' + x + '\n')
    sys.stderr.flush()


# Initialize
init_service(name=NAME, desc="Plants Coexpression service", version=VERSION)


def join_stripped(iterable):
    return ''.join((s.strip() for s in iterable))


def upload_file(uri, filename, att_content):
    file_contents = open(filename).read()
    data = {
        'upload': (filename, file_contents),
        'attributes': ('', att_content)
    }
    r = requests.post("%s/node" % uri, files=data)
    response = json.loads(r.text)
    if response['data'] is None:
Esempio n. 16
0
import random
import numbers
import uuid
import hashlib
# Local
import biokbase.narrative.common.service as service
from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.userandjobstate.client import UserAndJobState

## Globals

VERSION = (0, 0, 1)
NAME = "Test Service"

# Initialize
init_service(name=NAME, desc="Testing Service!", version=VERSION)


@method(name="Register Fake Job")
def _reg_fake_job(meth):
    """Tries to register a fake job id. Will fail like SO HARD.

    :return: Test. And a job id.
    :rtype: kbtypes.Unicode
    """
    meth.stages = 2
    meth.advance("Testing.")

    job_id = "12345"
    meth.register_job(job_id)
Esempio n. 17
0
__date__ = 'MM/DD/YYYY'

## Imports

from biokbase.narrative.common.service import init_service, method, finalize_service
from biokbase.narrative.common import kbtypes
import json

## Globals

VERSION = (0, 0, 1)
NAME = "MyExampleService"

# Initialization

init_service(name=NAME, desc="This is an example", version=VERSION)

# Define one service

@method(name="MyExampleFunction")
def _my_service_function(meth, param1, param2):
    """This is an example function.

    :param param1: Input Genome
    :type param1: kbtypes.Genome
    :ui_name param1: Genome ID (what the user sees)
    :param param2: Some text
    :type param2: kbtypes.Unicode
    :ui_name param2: Text
    :return: Workspace object ID
    :rtype: kbtypes.Unicode