コード例 #1
0
ファイル: owlsim.py プロジェクト: nicholsn/biolink-api
def get_owlsim_api():

    global owlsim_api

    if owlsim_api is None:
        owlsim_api = OwlSim2Api()

    return owlsim_api
コード例 #2
0
    def setup_class(self):
        patch('ontobio.sim.api.owlsim2.get_owlsim_stats',
              return_value=(None, None)).start()
        self.ic_store = OwlSim2Api()
        self.annot_scorer = AnnotationScorer(self.ic_store)

        self.ic_store.statistics = IcStatistic(mean_mean_ic=6.82480,
                                               mean_sum_ic=120.89767,
                                               mean_cls=15.47425,
                                               max_max_ic=16.16108,
                                               max_sum_ic=6746.96160,
                                               individual_count=65309,
                                               mean_max_ic=9.51535)
        self.ic_store.category_statistics = {
            'ear feature':
            IcStatistic(
                mean_mean_ic=7.55126,
                mean_sum_ic=26.60304,
                mean_cls=3.40207,
                max_max_ic=16.15508,
                max_sum_ic=613.22168,
                individual_count=6004,
                mean_max_ic=8.48152,
                descendants=['pointy ears', 'large ears', 'small ears']),
            'skin feature':
            IcStatistic(mean_mean_ic=7.55126,
                        mean_sum_ic=26.60304,
                        mean_cls=3.40207,
                        max_max_ic=16.15508,
                        max_sum_ic=613.22168,
                        individual_count=6004,
                        mean_max_ic=8.48152,
                        descendants=[
                            'blue skin', 'orange skin',
                            'increased pigmentation'
                        ]),
        }
        self.mock_ic_values = {
            'pointy ears': 12.0021,
            'large ears': 8.2345,
            'small ears': 8.1536,
            'blue skin': 10.12593,
            'orange skin': 15.1592,
            'increased pigmentation': 5.5926
        }
        self.negation_weight = .23
        self.category_weight = .33
コード例 #3
0
    def setup_class(self):

        self.resolve_mock = patch.object(PhenoSimEngine,
                                         '_resolve_nodes_to_phenotypes',
                                         side_effect=mock_resolve_nodes)
        self.mock_scigraph = patch(
            'ontobio.util.scigraph_util.get_scigraph_nodes',
            side_effect=mock_get_scigraph_nodes)

        self.owlsim2_api = OwlSim2Api()
        self.owlsim2_api.statistics = IcStatistic(mean_mean_ic=6.82480,
                                                  mean_sum_ic=120.89767,
                                                  mean_cls=15.47425,
                                                  max_max_ic=16.16108,
                                                  max_sum_ic=6746.96160,
                                                  individual_count=65309,
                                                  mean_max_ic=9.51535)
        self.pheno_sim = PhenoSimEngine(self.owlsim2_api)

        self.resolve_mock.start()
        self.mock_scigraph.start()
コード例 #4
0
from pathlib import Path
import json

import pytest
from dacite import from_dict, Config

from ontobio.sim.mme import clean_feature_ids, query_owlsim
from ontobio.model.mme.request import MmeRequest, Observed
from ontobio.sim.api.owlsim2 import OwlSim2Api
from ontobio.sim.phenosim_engine import PhenoSimEngine

patient_1 = Path(__file__).parent / 'resources' / 'mme' / 'patient1.json'
owlsim_api = PhenoSimEngine(OwlSim2Api())


@pytest.mark.parametrize("id, clean_id",
                         [("MIM:1234", "OMIM:1234"), ("SHH", "HGNC:10848"),
                          ("some-term-we-dont-have", "some-term-we-dont-have")]
                         )
def test_clean_feature_ids(id, clean_id):
    test_id = clean_feature_ids(id)
    assert clean_id == test_id


def test_mme_query():
    with open(patient_1, 'r') as patient_1_json:
        patient1 = json.load(patient_1_json)
    mme_request = from_dict(MmeRequest,
                            patient1,
                            config=Config(cast=[Observed]))
    response = query_owlsim(mme_request, owlsim_api, taxon='9606')
コード例 #5
0
from flask_restplus import Resource
from flask import request
from ontobio.sim.annotation_scorer import AnnotationScorer
from ontobio.sim.api.owlsim2 import OwlSim2Api
from biolink.api.restplus import api
from biolink.datamodel.sim_serializers import sufficiency_input, sufficiency_output

annotation_scorer = AnnotationScorer(OwlSim2Api())

score_get = api.parser()
score_get.add_argument('id',
                       action='append',
                       help='Phenotype identifier (eg HP:0004935)')
score_get.add_argument('absent_id',
                       default=[],
                       action='append',
                       help='absent phenotype (eg HP:0002828)')


class AnnotationScore(Resource):
    @api.expect(sufficiency_input)
    @api.marshal_with(sufficiency_output)
    def post(self):
        """
        Get annotation score
        """
        data = request.json
        phenotypes = [
            feature['id'] for feature in data['features']
            if feature['isPresent'] is True
        ]
コード例 #6
0
from flask_restplus import Resource
from flask import request
from ontobio.sim.api.owlsim2 import OwlSim2Api
from ontobio.sim.phenosim_engine import PhenoSimEngine
from biolink.api.restplus import api
from biolink.datamodel.sim_serializers import sim_result, compare_input

sim_engine = PhenoSimEngine(OwlSim2Api())


def get_compare_parser():

    help_msg = 'A phenotype or identifier that is composed of phenotypes (eg disease, gene)'

    sim_get_parser = api.parser()
    sim_get_parser.add_argument('ref_id',
                                action='append',
                                help=help_msg,
                                default=[])
    sim_get_parser.add_argument('query_id',
                                action='append',
                                help=help_msg,
                                default=[])
    return sim_get_parser


def get_search_parser():
    sim_search_parser = api.parser()

    sim_search_parser.add_argument(
        'id',
コード例 #7
0
ファイル: semanticsim.py プロジェクト: nicholsn/biolink-api
from flask_restplus import Resource, inputs
from flask import request
from ontobio.sim.api.owlsim2 import OwlSim2Api
from ontobio.sim.phenosim_engine import PhenoSimEngine
from ontobio.vocabulary.similarity import SimAlgorithm
from biolink.api.restplus import api
from biolink.api.sim.endpoints.owlsim import get_owlsim_api
from biolink.datamodel.sim_serializers import sim_result, compare_input

metrics = [matcher.value for matcher in OwlSim2Api.matchers()]

# Common args
sim_parser = api.parser()
sim_parser.add_argument(
        'is_feature_set',
        type=inputs.boolean,
        help='set to true if *all* input ids are phenotypic features, else set to false',
        default=True
    )

sim_parser.add_argument(
    'metric', type=str, choices=metrics,
    default='phenodigm', help='Metric for computing similarity')


def get_compare_parser():

    help_msg = 'A phenotype or identifier that is composed of phenotypes (eg disease, gene)'

    sim_get_parser = sim_parser.copy()
    sim_get_parser.add_argument(
コード例 #8
0
 def setup_class(self):
     patch('ontobio.sim.api.owlsim2.get_owlsim_stats',
           return_value=(None, None)).start()
     self.sim_api = OwlSim2Api()
コード例 #9
0
 def setup_class(self):
     self.sim_api = OwlSim2Api()
コード例 #10
0
ファイル: test_owlsim2_int.py プロジェクト: valearna/ontobio
 def setup_class(self):
     self.owlsim2_api = OwlSim2Api()
     self.annot_scorer = AnnotationScorer(self.owlsim2_api)
     self.pheno_sim = PhenoSimEngine(self.owlsim2_api)
コード例 #11
0
from flask_restplus import Resource, inputs
from flask import request
from ontobio.sim.api.owlsim2 import OwlSim2Api
from ontobio.sim.phenosim_engine import PhenoSimEngine
from ontobio.vocabulary.similarity import SimAlgorithm
from biolink.api.restplus import api
from biolink.datamodel.sim_serializers import sim_result, compare_input

sim_engine = PhenoSimEngine(OwlSim2Api())
metrics = [matcher.value for matcher in OwlSim2Api.matchers()]

# Common args
sim_parser = api.parser()
sim_parser.add_argument(
    'is_feature_set',
    type=inputs.boolean,
    help=
    'set to true if *all* input ids are phenotypic features, else set to false',
    default=True)

sim_parser.add_argument('metric',
                        type=str,
                        choices=metrics,
                        default='phenodigm',
                        help='Metric for computing similarity')


def get_compare_parser():

    help_msg = 'A phenotype or identifier that is composed of phenotypes (eg disease, gene)'