Beispiel #1
0
def _custom_pb_assembly(stmts_list=None):
    if stmts_list is None:
        logger.info('No statements provided, downloading latest pa stmt dump')
        stmts_list = get_latest_pa_stmt_dump()

    # Filter bad statements
    logger.info('Filtering out statements with bad position attribute')
    filtered_stmts = []
    for st in stmts_list:
        try:
            pos = getattr(st, 'position')
            try:
                if pos is not None and str(int(float(pos))) != pos:
                    continue
                else:
                    filtered_stmts.append(st)
            # Pos is not convertible to float
            except ValueError:
                continue
        # Not a statement with a position attribute
        except AttributeError:
            filtered_stmts.append(st)

    # Assemble Pybel model
    logger.info('Assembling PyBEL model')
    pb = PybelAssembler(stmts=filtered_stmts)
    pb_model = pb.make_model()
    return pb_model
Beispiel #2
0
 def assemble_pybel(self):
     """Assemble the model into PyBEL and return the assembled model."""
     if not self.assembled_stmts:
         self.run_assembly()
     pba = PybelAssembler(self.assembled_stmts)
     pybel_model = pba.make_model()
     return pybel_model
def stmts_to_pybel_graph(stmts):
    pba = PybelAssembler(stmts,
                         name='INDRA/REACH Fallahi Eval Model',
                         description='Automatically assembled model.',
                         version='0.0.1')
    pba.make_model()
    return pba.to_signed_graph()
def get_graph_from_statement(statement: Statement) -> BELGraph:
    """Convert an INDRA statement to a BEL graph."""
    pba = PybelAssembler([statement])

    try:
        graph = pba.make_model()
    except AttributeError:  # something funny happening
        logger.exception('problem making BEL graph from INDRA statements')
        return BELGraph()
    else:
        return graph
Beispiel #5
0
 def assemble_pybel(self, mode='local', bucket=EMMAA_BUCKET_NAME):
     """Assemble the model into PyBEL and return the assembled model."""
     if not self.assembled_stmts:
         self.run_assembly()
     pba = PybelAssembler(self.assembled_stmts)
     pybel_model = pba.make_model()
     if mode == 's3' and 'pybel' in self.export_formats:
         fname = f'pybel_{self.date_str}.bel.nodelink.json.gz'
         pybel.dump(pybel_model, fname)
         logger.info(f'Uploading {fname}')
         client = get_s3_client(unsigned=False)
         client.upload_file(fname, bucket, f'exports/{self.name}/{fname}')
     return pybel_model
Beispiel #6
0
def assemble_pybel(stmts, out_file_prefix):
    """Return a PyBEL Assembler"""
    stmts = ac.filter_belief(stmts, 0.95)
    stmts = ac.filter_top_level(stmts)

    pba = PybelAssembler(stmts,
                         name='INDRA/REACH Korkut Model',
                         description='Automatically assembled model of '
                         'cancer signaling.',
                         version='0.0.10')
    pba.make_model()
    pybel.to_bel_path(pba.model, out_file_prefix + '.bel')
    with open(out_file_prefix, 'wt') as f:
        pybel.to_json_file(pba.model, f)
    url = 'https://pybel.scai.fraunhofer.de/api/receive'
    headers = {'content-type': 'application/json'}
    requests.post(url, json=pybel.to_json(pba.model), headers=headers)
Beispiel #7
0
def from_indra_statements(
    stmts,
    name: Optional[str] = None,
    version: Optional[str] = None,
    description: Optional[str] = None,
    authors: Optional[str] = None,
    contact: Optional[str] = None,
    license: Optional[str] = None,
    copyright: Optional[str] = None,
    disclaimer: Optional[str] = None,
):
    """Import a model from :mod:`indra`.

    :param List[indra.statements.Statement] stmts: A list of statements
    :param name: The graph's name
    :param version: The graph's version. Recommended to use `semantic versioning <http://semver.org/>`_ or
                        ``YYYYMMDD`` format.
    :param description: The description of the graph
    :param authors: The authors of this graph
    :param contact: The contact email for this graph
    :param license: The license for this graph
    :param copyright: The copyright for this graph
    :param disclaimer: The disclaimer for this graph
    :rtype: pybel.BELGraph
    """
    from indra.assemblers.pybel import PybelAssembler

    if authors is None:
        authors = 'INDRA'

    pba = PybelAssembler(
        stmts=stmts,
        name=name,
        version=version,
        description=description,
        authors=authors,
        contact=contact,
        license=license,
        copyright=copyright,
        disclaimer=disclaimer,
    )

    graph = pba.make_model()
    return graph
Beispiel #8
0
    ActiveForm(elk1_p, 'transcription', True),
    IncreaseAmount(elk1_tscript, fos),
    Conversion(hk1, [glu], [g6p]),
    Complex([egfr, grb2, sos1]),
    Autophosphorylation(p38_tab1, 'Y', '100'),
    Transphosphorylation(egfr_dimer, 'Y', '1173'),
]

ev = Evidence('assertion', 'assertion', 'assertion', 'assertion')
for stmt in stmts:
    stmt.evidence = [ev]

model_description = 'Test of INDRA Statement assembly into PyBEL.'
print("Assembling to PyBEL...")

pba = PybelAssembler(stmts,
                     name='INDRA_PyBEL_test',
                     description=model_description,
                     version='0.0.22')
belgraph = pba.make_model()

# Write to BEL file
pybel.to_bel_path(belgraph, 'simple_pybel.bel')

# Upload to PyBEL web
with open('pybel_model.json', 'wt') as f:
    pybel.to_json_file(pba.model, f)
url = 'https://pybel.scai.fraunhofer.de/api/receive'
headers = {'content-type': 'application/json'}
requests.post(url, json=pybel.to_json(pba.model), headers=headers)