Exemplo n.º 1
0
def _get_evidence(evidence):
    text = evidence.text if evidence.text else 'No evidence text.'

    # If there is a PMID, use it as the citation
    if evidence.pmid:
        citation = citation_dict(
            db=pc.CITATION_TYPE_PUBMED,
            db_id=evidence.pmid,
        )
    # If no PMID, include the interface and source_api for now--
    # in general this should probably be in the annotations for all evidence
    else:
        cit_source = evidence.source_api or 'Unknown'
        cit_id = evidence.source_id or 'Unknown'
        cit_ref_str = '%s:%s' % (cit_source, cit_id)
        citation = citation_dict(
            db=pc.CITATION_TYPE_OTHER,
            db_id=cit_ref_str,
        )

    annotations = {
        'source_hash': {evidence.get_source_hash(): True},
    }
    if evidence.source_api:
        annotations['source_api'] = {evidence.source_api: True}
    if evidence.source_id:
        annotations['source_id'] = {evidence.source_id: True}
    for key, value in evidence.epistemics.items():
        if key == 'direct' or value is None:
            continue
        if isinstance(value, (list, set, tuple)):
            annotations[key] = {v: True for v in value}
        else:
            annotations[key] = {value: True}
    return citation, text, annotations
    def test_build_pmid_inclusion_filter(self):
        """Test building a predicate for a single PubMed identifier."""
        pmid_inclusion_filter = build_pmid_inclusion_filter(pmid1)

        self.assertTrue(pmid_inclusion_filter({
            CITATION: citation_dict(namespace=CITATION_TYPE_PUBMED, identifier=pmid1),
        }))

        self.assertFalse(pmid_inclusion_filter({
            CITATION: citation_dict(namespace=CITATION_TYPE_PUBMED, identifier=pmid2),
        }))
    def test_build_author_inclusion_filter(self):
        """Test building a predicate for a single author."""
        author_inclusion_filter = build_author_inclusion_filter(author1)

        self.assertTrue(author_inclusion_filter({
            CITATION: citation_dict(namespace=CITATION_TYPE_PUBMED, identifier=pmid3, authors=[author1]),
        }))

        self.assertTrue(author_inclusion_filter({
            CITATION: citation_dict(namespace=CITATION_TYPE_PUBMED, identifier=pmid3, authors=[author1, author2]),
        }))

        self.assertFalse(author_inclusion_filter({
            CITATION: citation_dict(namespace=CITATION_TYPE_PUBMED, identifier=pmid3, authors=[author3]),
        }))
Exemplo n.º 4
0
    def test_citation(self):
        db_id = n()
        model = Citation(
            db=CITATION_TYPE_PUBMED,
            db_id=db_id,
        )

        expected = citation_dict(namespace=CITATION_TYPE_PUBMED, identifier=db_id)
        self.assertEqual(expected, model.to_json())

        expected[NAME] = model.title = n()
        self.assertEqual(expected, model.to_json())
Exemplo n.º 5
0
from pybel.language import citation_dict
from tests.constant_helper import (
    BEL_THOROUGH_EDGES,
    BEL_THOROUGH_NODES,
    citation_1,
    evidence_1,
    expected_test_simple_metadata,
    expected_test_thorough_metadata,
)

logger = logging.getLogger(__name__)

OPENBEL_DOMAIN = 'http://resources.openbel.org'
OPENBEL_ANNOTATION_RESOURCES = OPENBEL_DOMAIN + '/belframework/20150611/annotation/'

test_citation_dict = citation_dict(namespace=CITATION_TYPE_PUBMED,
                                   identifier='1235813')

SET_CITATION_TEST = f'SET Citation = {{"{test_citation_dict.namespace}", "{test_citation_dict.identifier}"}}'
test_evidence_text = 'I read it on Twitter'
test_set_evidence = f'SET Evidence = "{test_evidence_text}"'

HGNC_KEYWORD = 'HGNC'
MESH_DISEASES_KEYWORD = 'MeSHDisease'
MESH_DISEASES_URL = OPENBEL_ANNOTATION_RESOURCES + "mesh-diseases.belanno"

akt1 = hgnc(name='AKT1')
egfr = hgnc(name='EGFR')
fadd = hgnc(name='FADD')
casp8 = hgnc(name='CASP8')

Exemplo n.º 6
0
                                       annotations={
                                           'Confidence': 'Low',
                                           'Number': '50'
                                       })
"""
SET Evidence = "% Entrez Gene summary: Rat: SUMMARY: precursor protein of kinin which is found in plasma; cysteine protease inhibitor and a major acute phase reactant [RGD] OMIM summary: (summary is not available from this source) kininogens; Endogenous peptides present in most body fluids. Certain enzymes convert them to active kinins which are involved in inflammation, blood clotting, complement reactions, etc. Kininogens belong to the cystatin superfamily. They are cysteine proteinase inhibitors. High-molecular-weight kininogen (hmwk) is split by plasma kallikrein to produce bradykinin. Low-molecular-weight kininogen (lmwk) is split by tissue kallikrein to produce kallidin. kinins; Inflammatory mediators that cause dilation of blood vessels and altered vascular permeability.  Kinins are small peptides produced from kininogen by kallikrein and are broken down by kininases. Act on phospholipase and increase arachidonic acid release and thus prostaglandin (PGE2) production. bradykinin; Vasoactive nonapeptide (RPPGFSPFR) formed by action of proteases on kininogens. Very similar to kallidin (which has the same sequence but with an additional N terminal lysine). Bradykinin is a very potent vasodilator and increases permeability of post capillary venules, it acts on endothelial cells to activate phospholipase A2. It is also spasmogenic for some smooth muscle and will cause pain. kallidin; Decapeptide (lysyl bradykinin, amino acid sequence KRPPGFSPFR) produced in kidney. Like bradykinin, an inflammatory mediator (a kinin), causes dilation of renal blood vessels and increased water excretion."
SET Species = 9606
SET Citation = {"Other","Genstruct Kininogen Overview","Genstruct Kininogen Overview","","",""}

bp(GOBP:"inflammatory response") increases rxn(reactants(p(HGNC:KNG1)),products(a(SCHEM:Kallidin)))
path(SDIS:"tissue damage") increases rxn(reactants(p(HGNC:KNG1)),products(a(SCHEM:Kallidin)))
a(SCHEM:Kallidin) increases cat(p(HGNC:BDKRB1))
cat(p(HGNC:BDKRB1)) increases cat(p(SFAM:"PLA2 Family"))
"""

c4 = citation_dict(namespace=CITATION_TYPE_OTHER,
                   identifier='Genstruct Reference')
e4 = '% Entrez Gene summary: Rat: SUMMARY: precursor protein of kinin which is found in plasma; cysteine protease inhibitor and a major acute phase reactant [RGD] OMIM summary: (summary is not available from this source) kininogens; Endogenous peptides present in most body fluids. Certain enzymes convert them to active kinins which are involved in inflammation, blood clotting, complement reactions, etc. Kininogens belong to the cystatin superfamily. They are cysteine proteinase inhibitors. High-molecular-weight kininogen (hmwk) is split by plasma kallikrein to produce bradykinin. Low-molecular-weight kininogen (lmwk) is split by tissue kallikrein to produce kallidin. kinins; Inflammatory mediators that cause dilation of blood vessels and altered vascular permeability.  Kinins are small peptides produced from kininogen by kallikrein and are broken down by kininases. Act on phospholipase and increase arachidonic acid release and thus prostaglandin (PGE2) production. bradykinin; Vasoactive nonapeptide (RPPGFSPFR) formed by action of proteases on kininogens. Very similar to kallidin (which has the same sequence but with an additional N terminal lysine). Bradykinin is a very potent vasodilator and increases permeability of post capillary venules, it acts on endothelial cells to activate phospholipase A2. It is also spasmogenic for some smooth muscle and will cause pain. kallidin; Decapeptide (lysyl bradykinin, amino acid sequence KRPPGFSPFR) produced in kidney. Like bradykinin, an inflammatory mediator (a kinin), causes dilation of renal blood vessels and increased water excretion.'
e4 = str(hash(e4))

bdkrb1 = Protein(namespace='hgnc', name='BDKRB1')
inflammatory_process = bioprocess('GO', 'inflammatory process')
kng1 = Protein(namespace='hgnc', name='KNG1')
kallidin = abundance('CHEBI', 'Kallidin')
pla2_family = Protein('SFAM', 'PLA2 Family')
kng1_to_kallidin = reaction(reactants=[kng1], products=[kallidin])

example_graph.add_increases(inflammatory_process,
                            kng1_to_kallidin,
                            citation=c4,
                            evidence=e4)
example_graph.add_increases(kallidin,
Exemplo n.º 7
0
    def bel_simple_reconstituted(self, graph: BELGraph, check_metadata: bool = True):
        """Check that test_bel.bel was loaded properly."""
        self.assertIsNotNone(graph)
        self.assertIsInstance(graph, BELGraph)

        if check_metadata:
            self.assertIsNotNone(graph.document)
            self.assertEqual(expected_test_simple_metadata[METADATA_NAME], graph.name)
            self.assertEqual(expected_test_simple_metadata[METADATA_VERSION], graph.version)

        self.assertEqual(4, graph.number_of_nodes())

        # FIXME this should work, but is getting 8 for the upgrade function
        # self.assertEqual(6, graph.number_of_edges(),
        #                  msg='Edges:\n{}'.format('\n'.join(map(str, graph.edges(keys=True, data=True)))))

        for node in graph:
            self.assertIsInstance(node, BaseEntity)

        self.assertIn(akt1, graph)
        self.assertIn(egfr, graph)
        self.assertIn(fadd, graph)
        self.assertIn(casp8, graph)

        bel_simple_citation_1 = citation_dict(namespace=CITATION_TYPE_PUBMED, identifier="123455")
        bel_simple_citation_2 = citation_dict(namespace=CITATION_TYPE_PUBMED, identifier="123456")

        evidence_1_extra = "Evidence 1 w extra notes"
        evidence_2 = 'Evidence 2'
        evidence_3 = 'Evidence 3'

        assert_has_edge(self, akt1, egfr, graph, only=True, **{
            RELATION: INCREASES,
            CITATION: bel_simple_citation_1,
            EVIDENCE: evidence_1_extra,
            ANNOTATIONS: {
                'Species': [Entity(namespace='Species', identifier='9606')],
            }
        })
        assert_has_edge(self, egfr, fadd, graph, only=True, **{
            RELATION: DECREASES,
            ANNOTATIONS: {
                'Species': [Entity(namespace='Species', identifier='9606')],
                'CellLine': [Entity(namespace='CellLine', identifier='10B9 cell')],
            },
            CITATION: bel_simple_citation_1,
            EVIDENCE: evidence_2
        })
        assert_has_edge(self, egfr, casp8, graph, only=True, **{
            RELATION: DIRECTLY_DECREASES,
            ANNOTATIONS: {
                'Species': [Entity(namespace='Species', identifier='9606')],
                'CellLine': [Entity(namespace='CellLine', identifier='10B9 cell')],
            },
            CITATION: bel_simple_citation_1,
            EVIDENCE: evidence_2,
        })
        assert_has_edge(self, fadd, casp8, graph, only=True, **{
            RELATION: INCREASES,
            ANNOTATIONS: {
                'Species': [Entity(namespace='Species', identifier='10116')],
            },
            CITATION: bel_simple_citation_2,
            EVIDENCE: evidence_3,
        })
        assert_has_edge(self, akt1, casp8, graph, only=True, **{
            RELATION: ASSOCIATION,
            ANNOTATIONS: {
                'Species': [Entity(namespace='Species', identifier='10116')],
            },
            CITATION: bel_simple_citation_2,
            EVIDENCE: evidence_3,
        })
        assert_has_edge(self, casp8, akt1, graph, only=True, **{
            RELATION: ASSOCIATION,
            ANNOTATIONS: {
                'Species': [Entity(namespace='Species', identifier='10116')],
            },
            CITATION: bel_simple_citation_2,
            EVIDENCE: evidence_3,
        })