<commit_before># -*- coding: utf-8 -*-

from __future__ import unicode_literals

import json
import logging
import os
import unittest

from pybel import from_cbn_jgif, to_jgif
from pybel.constants import *
from tests.constants import TestGraphMixin, bel_dir_path

test_path = os.path.join(bel_dir_path, 'Cytotoxic T-cell Signaling-2.0-Hs.json')

logging.getLogger('pybel.parser').setLevel(20)

calcium = (ABUNDANCE, 'SCHEM', 'Calcium')
calcineurin_complex = (COMPLEX, 'SCOMP', 'Calcineurin Complex')
foxo3 = (PROTEIN, 'HGNC', 'FOXO3')
tcell_proliferation = (BIOPROCESS, 'GOBP', 'CD8-positive, alpha-beta T cell proliferation')
il15 = (PROTEIN, 'HGNC', 'IL15')
il2rg = (PROTEIN, 'MGI', 'Il2rg')
jgif_expected_nodes = [
    calcium,
    calcineurin_complex,
    foxo3,
    tcell_proliferation,
    il15,
    il2rg,
    (PROTEIN, 'HGNC', 'CXCR6'),
    (PROTEIN, 'HGNC', 'IL15RA'),
    (BIOPROCESS, 'GOBP', 'lymphocyte chemotaxis'),
    (PROTEIN, 'HGNC', 'IL2RG'),
    (PROTEIN, 'HGNC', 'ZAP70'),
    (COMPLEX, 'SCOMP', 'T Cell Receptor Complex'),
    (BIOPROCESS, 'GOBP', 'T cell activation'),
    (PROTEIN, 'HGNC', 'CCL3'),
    (PROTEIN, 'HGNC', 'PLCG1'),
    (PROTEIN, 'HGNC', 'FASLG'),
    (PROTEIN, 'HGNC', 'IDO1'),
    (PROTEIN, 'HGNC', 'IL2'),
    (PROTEIN, 'HGNC', 'CD8A'),
    (PROTEIN, 'HGNC', 'CD8B'),
    (PROTEIN, 'HGNC', 'PLCG1'),
    (PROTEIN, 'HGNC', 'BCL2'),
    (PROTEIN, 'HGNC', 'CCR3'),
    (PROTEIN, 'HGNC', 'IL2RB'),
    (PROTEIN, 'HGNC', 'CD28'),
    (PATHOLOGY, 'SDIS', 'Cytotoxic T-cell activation'),
    (PROTEIN, 'HGNC', 'FYN'),
    (PROTEIN, 'HGNC', 'CXCL16'),
    (PROTEIN, 'HGNC', 'CCR5'),
    (PROTEIN, 'HGNC', 'LCK'),
    (PROTEIN, 'SFAM', 'Chemokine Receptor Family'),
    (PROTEIN, 'HGNC', 'CXCL9'),
    (PATHOLOGY, 'SDIS', 'T-cell migration'),
    (PROTEIN, 'HGNC', 'CXCR3'),
    (ABUNDANCE, 'CHEBI', 'acrolein'),
    (PROTEIN, 'HGNC', 'IDO2'),
    (PATHOLOGY, 'MESHD', 'Pulmonary Disease, Chronic Obstructive'),
    (PROTEIN, 'HGNC', 'IFNG'),
    (PROTEIN, 'HGNC', 'TNFRSF4'),
    (PROTEIN, 'HGNC', 'CTLA4'),
    (PROTEIN, 'HGNC', 'GZMA'),
    (PROTEIN, 'HGNC', 'PRF1'),
    (PROTEIN, 'HGNC', 'TNF'),
    (PROTEIN, 'SFAM', 'Chemokine Receptor Family'),
    (COMPLEX, (PROTEIN, 'HGNC', 'CD8A'), (PROTEIN, 'HGNC', 'CD8B')),
    (COMPLEX, (PROTEIN, 'HGNC', 'CD8A'), (PROTEIN, 'HGNC', 'CD8B')),
    (PROTEIN, 'HGNC', 'PLCG1', (PMOD, (BEL_DEFAULT_NAMESPACE, 'Ph'), 'Tyr')),
    (PROTEIN, 'EGID', '21577'),
]

jgif_expected_edges = [
    (calcium, calcineurin_complex, {
        RELATION: DIRECTLY_INCREASES,
        EVIDENCE: 'NMDA-mediated influx of calcium led to activated of the calcium-dependent phosphatase calcineurin and the subsequent dephosphorylation and activation of the protein-tyrosine phosphatase STEP',
        CITATION: {
            CITATION_TYPE: CITATION_TYPE_PUBMED,
            CITATION_NAME: 'Nat Neurosci 2003 Jan 6(1) 34-42',
            CITATION_REFERENCE: '12483215'
        },
        OBJECT: {MODIFIER: ACTIVITY, EFFECT: {NAMESPACE: BEL_DEFAULT_NAMESPACE, NAME: 'phos'}},
        ANNOTATIONS: {
            'Species': {'10116':True},
            'Cell': {'neuron':True}
        }
    }),
    (foxo3, tcell_proliferation, {
        RELATION: DECREASES,
        EVIDENCE: "\"These data suggested that FOXO3 downregulates the accumulation of CD8 T cells in tissue specific fashion during an acute LCMV [lymphocytic choriomeningitis virus] infection.\" (p. 3)",
        CITATION: {
            CITATION_TYPE: CITATION_TYPE_OTHER,
            CITATION_NAME: "<NAME>, <NAME>, <NAME>, \"FOXO3 regulates CD8 T cell memory by T cell-intrinsic mechanisms,\" PLoS Pathog, 2012, 8:1002533.",
            CITATION_REFERENCE: "22359505"
        },
        ANNOTATIONS: {
            'Species': {'10090':True},
            'Disease': {'Viral infection':True}
        }
    }),
    (il15, il2rg, {
        RELATION: DIRECTLY_INCREASES,
        EVIDENCE: "IL-15 utilizes ... the common cytokine receptor γ-chain (CD132) for signal transduction in lymphocytes",
        CITATION: {
            CITATION_TYPE: CITATION_TYPE_OTHER,
            CITATION_REFERENCE: "20335267"
        },
        OBJECT: {MODIFIER: ACTIVITY, EFFECT: {NAMESPACE: BEL_DEFAULT_NAMESPACE, NAME: 'cat'}},
        ANNOTATIONS: {
            'Tissue': {'lung':True}
        }
    })
]


class TestJgif(TestGraphMixin):
    """Tests data interchange of """

    def test_jgif_interchange(self):
        """Tests data from CBN"""<commit_msg>Remove checking for citation names<commit_after># -*- coding: utf-8 -*-

from __future__ import unicode_literals

import json
import logging
import os
import unittest

from pybel import from_cbn_jgif, to_jgif
from pybel.constants import *
from tests.constants import TestGraphMixin, bel_dir_path

test_path = os.path.join(bel_dir_path, 'Cytotoxic T-cell Signaling-2.0-Hs.json')

logging.getLogger('pybel.parser').setLevel(20)

calcium = (ABUNDANCE, 'SCHEM', 'Calcium')
calcineurin_complex = (COMPLEX, 'SCOMP', 'Calcineurin Complex')
foxo3 = (PROTEIN, 'HGNC', 'FOXO3')
tcell_proliferation = (BIOPROCESS, 'GOBP', 'CD8-positive, alpha-beta T cell proliferation')
il15 = (PROTEIN, 'HGNC', 'IL15')
il2rg = (PROTEIN, 'MGI', 'Il2rg')
jgif_expected_nodes = [
    calcium,
    calcineurin_complex,
    foxo3,
    tcell_proliferation,
    il15,
    il2rg,
    (PROTEIN, 'HGNC', 'CXCR6'),
    (PROTEIN, 'HGNC', 'IL15RA'),
    (BIOPROCESS, 'GOBP', 'lymphocyte chemotaxis'),
    (PROTEIN, 'HGNC', 'IL2RG'),
    (PROTEIN, 'HGNC', 'ZAP70'),
    (COMPLEX, 'SCOMP', 'T Cell Receptor Complex'),
    (BIOPROCESS, 'GOBP', 'T cell activation'),
    (PROTEIN, 'HGNC', 'CCL3'),
    (PROTEIN, 'HGNC', 'PLCG1'),
    (PROTEIN, 'HGNC', 'FASLG'),
    (PROTEIN, 'HGNC', 'IDO1'),
    (PROTEIN, 'HGNC', 'IL2'),
    (PROTEIN, 'HGNC', 'CD8A'),
    (PROTEIN, 'HGNC', 'CD8B'),
    (PROTEIN, 'HGNC', 'PLCG1'),
    (PROTEIN, 'HGNC', 'BCL2'),
    (PROTEIN, 'HGNC', 'CCR3'),
    (PROTEIN, 'HGNC', 'IL2RB'),
    (PROTEIN, 'HGNC', 'CD28'),
    (PATHOLOGY, 'SDIS', 'Cytotoxic T-cell activation'),
    (PROTEIN, 'HGNC', 'FYN'),
    (PROTEIN, 'HGNC', 'CXCL16'),
    (PROTEIN, 'HGNC', 'CCR5'),
    (PROTEIN, 'HGNC', 'LCK'),
    (PROTEIN, 'SFAM', 'Chemokine Receptor Family'),
    (PROTEIN, 'HGNC', 'CXCL9'),
    (PATHOLOGY, 'SDIS', 'T-cell migration'),
    (PROTEIN, 'HGNC', 'CXCR3'),
    (ABUNDANCE, 'CHEBI', 'acrolein'),
    (PROTEIN, 'HGNC', 'IDO2'),
    (PATHOLOGY, 'MESHD', 'Pulmonary Disease, Chronic Obstructive'),
    (PROTEIN, 'HGNC', 'IFNG'),
    (PROTEIN, 'HGNC', 'TNFRSF4'),
    (PROTEIN, 'HGNC', 'CTLA4'),
    (PROTEIN, 'HGNC', 'GZMA'),
    (PROTEIN, 'HGNC', 'PRF1'),
    (PROTEIN, 'HGNC', 'TNF'),
    (PROTEIN, 'SFAM', 'Chemokine Receptor Family'),
    (COMPLEX, (PROTEIN, 'HGNC', 'CD8A'), (PROTEIN, 'HGNC', 'CD8B')),
    (COMPLEX, (PROTEIN, 'HGNC', 'CD8A'), (PROTEIN, 'HGNC', 'CD8B')),
    (PROTEIN, 'HGNC', 'PLCG1', (PMOD, (BEL_DEFAULT_NAMESPACE, 'Ph'), 'Tyr')),
    (PROTEIN, 'EGID', '21577'),
]

jgif_expected_edges = [
    (calcium, calcineurin_complex, {
        RELATION: DIRECTLY_INCREASES,
        EVIDENCE: 'NMDA-mediated influx of calcium led to activated of the calcium-dependent phosphatase calcineurin and the subsequent dephosphorylation and activation of the protein-tyrosine phosphatase STEP',
        CITATION: {
            CITATION_TYPE: CITATION_TYPE_PUBMED,
            CITATION_REFERENCE: '12483215'
        },
        OBJECT: {MODIFIER: ACTIVITY, EFFECT: {NAMESPACE: BEL_DEFAULT_NAMESPACE, NAME: 'phos'}},
        ANNOTATIONS: {
            'Species': {'10116':True},
            'Cell': {'neuron':True}
        }
    }),
    (foxo3, tcell_proliferation, {
        RELATION: DECREASES,
        EVIDENCE: "\"These data suggested that FOXO3 downregulates the accumulation of CD8 T cells in tissue specific fashion during an acute LCMV [lymphocytic choriomeningitis virus] infection.\" (p. 3)",
        CITATION: {
            CITATION_TYPE: CITATION_TYPE_OTHER,
            CITATION_REFERENCE: "22359505"
        },
        ANNOTATIONS: {
            'Species': {'10090':True},
            'Disease': {'Viral infection':True}
        }
    }),
    (il15, il2rg, {
        RELATION: DIRECTLY_INCREASES,
        EVIDENCE: "IL-15 utilizes ... the common cytokine receptor γ-chain (CD132) for signal transduction in lymphocytes",
        CITATION: {
            CITATION_TYPE: CITATION_TYPE_OTHER,
            CITATION_REFERENCE: "20335267"
        },
        OBJECT: {MODIFIER: ACTIVITY, EFFECT: {NAMESPACE: BEL_DEFAULT_NAMESPACE, NAME: 'cat'}},
        ANNOTATIONS: {
            'Tissue': {'lung':True}
        }
    })
]


class TestJgif(TestGraphMixin):
    """Tests data interchange of """

    def test_jgif_interchange(self):
        """Tests data from CBN"""
{'fraction_non_alphanumeric': 0.16590073529411764, 'fraction_numerical': 0.025965073529411766, 'mean_word_length': 3.3942453306410902, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5678928', 'n_tokens_mistral': 3664, 'n_tokens_neox': 3292, 'n_words': 746}