Ejemplo n.º 1
0
 def upload_to_ndex(self):
     """Upload the assembled model as CX to NDEx"""
     assembled_stmts = self.run_assembly()
     cxa = CxAssembler(assembled_stmts, network_name=self.name)
     cxa.make_model()
     cx_str = cxa.print_cx()
     ndex_client.update_network(cx_str, self.ndex_network)
Ejemplo n.º 2
0
 def update_to_ndex(self):
     """Update assembled model as CX on NDEx, updates existing network."""
     if not self.assembled_stmts:
         self.run_assembly()
     cxa = CxAssembler(self.assembled_stmts, network_name=self.name)
     cxa.make_model()
     cx_str = cxa.print_cx()
     ndex_client.update_network(cx_str, self.ndex_network)
Ejemplo n.º 3
0
def upload_cx_to_ndex(cx_str, ndex_cred):
    network_id = ndex_cred['network']
    provenance = make_ndex_provenance(network_id)
    ndex_client.set_provenance(provenance, network_id, ndex_cred)
    try:
        ndex_client.update_network(cx_str, network_id, ndex_cred)
    except Exception as e:
        logger.error('NDEx network update failed')
        logger.exception(e)
Ejemplo n.º 4
0
def upload_cx_to_ndex(cx_str, ndex_cred):
    network_id = ndex_cred['network']
    provenance = make_ndex_provenance(network_id)
    ndex_client.set_provenance(provenance, network_id, ndex_cred)
    try:
        ndex_client.update_network(cx_str, network_id, ndex_cred)
    except Exception as e:
        logger.error('NDEx network update failed')
        logger.exception(e)
Ejemplo n.º 5
0
def create_upload_model(model_name, full_name, indra_stmts, ndex_id=None):
    """Make and upload an EMMAA model from a list of INDRA Statements.

    Parameters
    ----------
    short_name : str
        Short name of the model to use on S3.
    full_name : str
        Human-readable model name to use in EMMAA dashboard.
    indra_stmts : list of indra.statement
        INDRA Statements to be used to populate the EMMAA model.
    ndex_id : str
        UUID of the network corresponding to the model on NDex. If provided,
        the NDex network will be updated with the latest model content.
        If None (default), a new network will be created and the UUID stored
        in the model config files on S3.
    """
    emmaa_stmts = to_emmaa_stmts(indra_stmts, datetime.datetime.now(), [])
    # Get updated CX content for the INDRA Statements
    cxa = CxAssembler(indra_stmts)
    cx_str = cxa.make_model()
    # If we don't have an NDex ID, create network and upload to Ndex
    if ndex_id is None:
        ndex_id = cxa.upload_model(private=False)
        print(f'NDex ID for {model_name} is {ndex_id}.')
    # If the NDEx ID is provided, update the existing network
    else:
        ndex_client.update_network(cx_str, ndex_id)
    # Create the config dictionary
    config_dict = {'ndex': {'network': ndex_id}, 'search_terms': []}
    # Create EMMAA model
    emmaa_model = EmmaaModel(model_name, config_dict)
    emmaa_model.add_statements(emmaa_stmts)
    # Upload model to S3 with config as YAML and JSON
    emmaa_model.save_to_s3()
    s3_client = boto3.client('s3')
    config_json = json.dumps(config_dict)
    s3_client.put_object(Body=config_json.encode('utf8'),
                         Key='models/%s/config.json' % model_name,
                         Bucket='emmaa')
    config_json = json.dumps(config_dict)
    s3_client.put_object(Body=config_json.encode('utf8'),
                         Key='models/%s/config.json' % model_name,
                         Bucket='emmaa')
Ejemplo n.º 6
0
                                       username=ndex_cred['user'],
                                       password=ndex_cred['password'])
    gene_names = [
        hgnc_client.get_hgnc_name(ag.db_refs['HGNC'])
        for ag in ncp.get_agents()
    ]
    """
    # Get PMIDs for reading
    entrez_pmids = get_pmids(gene_names)
    network_pmids = ncp.get_pmids()
    pmids = list(set(entrez_pmids + network_pmids))
    save_pmids_for_reading(pmids, 'dna_damage_pmids.txt')
    """

    # Build the model
    prior_stmts = build_prior(gene_names, 'prior_stmts.pkl')
    reach_stmts = ac.load_statements('reach_stmts.pkl')
    stmts = ncp.statements + reach_stmts + prior_stmts
    stmts = run_assembly(stmts, 'unfiltered_assembled_stmts.pkl')

    # Filter the statements at different levels
    ids_cutoffs = (('4e26a4f0-9388-11e7-a10d-0ac135e8bacf',
                    0.90), ('527fecf7-9388-11e7-a10d-0ac135e8bacf', 0.95),
                   ('2f0e17bc-9387-11e7-a10d-0ac135e8bacf', 0.99))

    for net_id, cutoff in ids_cutoffs:
        stmts_filt = filter(stmts, cutoff, 'stmts_%.2f.pkl' % cutoff)
        cxa = assemble_cx(stmts_filt, 'dna_damage_%.2f.cx' % cutoff)
        cx_str = cxa.print_cx()
        ndex_client.update_network(cx_str, net_id, ndex_cred)