├── .dockerignore ├── .github └── workflows │ └── docker.yml ├── .gitignore ├── .project ├── LICENSE ├── README.md ├── docker-compose.yml ├── idorg.xml ├── job_wait.sh ├── k8chart ├── oxo-indexer │ ├── Chart.yaml │ ├── templates │ │ ├── _helpers.tpl │ │ └── oxo-indexer-job.yaml │ └── values.yaml ├── oxo-loader │ ├── Chart.yaml │ ├── templates │ │ ├── _helpers.tpl │ │ ├── oxo-loader-configmap.yaml │ │ └── oxo-loader-job.yaml │ └── values.yaml ├── oxo │ ├── .helmignore │ ├── Chart.yaml │ ├── templates │ │ ├── _helpers.tpl │ │ ├── oxo-configmap.yaml │ │ ├── oxo-ingress.yaml │ │ ├── oxo-neo4j-deployment.yaml │ │ ├── oxo-neo4j-service.yaml │ │ ├── oxo-proxy-configmap.yaml │ │ ├── oxo-solr-deployment.yaml │ │ ├── oxo-solr-service.yaml │ │ ├── oxo-web-deployment.yaml │ │ └── oxo-web-service.yaml │ └── values.yaml └── pvcs │ ├── Chart.yaml │ ├── templates │ ├── _helpers.tpl │ ├── oxo-neo4j-data-pvc.yaml │ ├── oxo-neo4jimport-pvc.yaml │ └── oxo-solr-data-pvc.yaml │ └── values.yaml ├── lib ├── javax.annotation.jar ├── sping-security-orcid-stateless-0.0.8.jar ├── spring-data-jpa-1.10.8.RELEASE.jar ├── spring-security-core-4.1.4.RELEASE.jar └── spring-security-oauth2-2.0.13.RELEASE.jar ├── mvnw ├── mvnw.cmd ├── oxo-indexer ├── .classpath ├── .factorypath ├── .project ├── Dockerfile ├── pom.xml └── src │ └── main │ ├── java │ └── uk │ │ └── ac │ │ └── ebi │ │ └── spot │ │ └── indexer │ │ └── SolrIndexer.java │ └── resources │ └── application.properties ├── oxo-loader ├── Dockerfile ├── LoincMappingExtractor.py ├── OlsDatasetExtractor.py ├── OlsDatasetExtractor.py.bak ├── OlsMappingExtractor.py ├── OxoClient.py ├── OxoCsvBuilder.py ├── OxoNeo4jLoader.py ├── README.md ├── UmlsMappingExtractor.py ├── config.ini ├── config.sample.ini ├── idorg.csv ├── idorg.xml ├── load_all.sh ├── loader.png ├── requirements.txt └── runLoader.sh ├── oxo-model ├── .classpath ├── .factorypath ├── .project ├── pom.xml └── src │ └── main │ ├── java │ └── uk │ │ └── ac │ │ └── ebi │ │ └── spot │ │ ├── config │ │ ├── IndexCreator.java │ │ └── OxoNeo4jConfiguration.java │ │ ├── exception │ │ ├── InvalidCurieException.java │ │ ├── MappingException.java │ │ ├── TermCreationException.java │ │ ├── UnknownDatasourceException.java │ │ └── UnknownTermException.java │ │ ├── index │ │ ├── Document.java │ │ └── DocumentRepository.java │ │ ├── loader │ │ └── Loader.java │ │ ├── model │ │ ├── Curie.java │ │ ├── Datasource.java │ │ ├── IndexableTermInfo.java │ │ ├── Mapping.java │ │ ├── MappingRequest.java │ │ ├── MappingSource.java │ │ ├── Scope.java │ │ ├── SourceType.java │ │ └── Term.java │ │ ├── repository │ │ ├── DatasourceRepository.java │ │ ├── MappingRepository.java │ │ └── TermGraphRepository.java │ │ ├── service │ │ ├── CypherQueryService.java │ │ ├── DatasourceService.java │ │ ├── DocumentBuilder.java │ │ ├── MappingBuilder.java │ │ ├── MappingQueryService.java │ │ ├── MappingResponse.java │ │ ├── MappingService.java │ │ ├── SearchResult.java │ │ ├── SearchResultsCsvBuilder.java │ │ ├── SimpleCache.java │ │ └── TermService.java │ │ └── util │ │ ├── CurieUtils.java │ │ ├── DatasourceConverter.java │ │ └── MappingDistance.java │ └── resources │ ├── application.properties │ └── ogm-2.properties ├── oxo-web ├── .classpath ├── .factorypath ├── .project ├── Dockerfile ├── pom.xml └── src │ ├── main │ ├── asciidoc │ │ ├── api.adoc │ │ ├── developer.adoc │ │ ├── index.adoc │ │ └── website.adoc │ ├── java │ │ └── uk │ │ │ └── ac │ │ │ └── ebi │ │ │ └── spot │ │ │ ├── OxoWebApp.java │ │ │ ├── config │ │ │ ├── CustomBackendIdConverter.java │ │ │ ├── FormatFilter.java │ │ │ ├── OxOWebMvcConfig.java │ │ │ ├── RESTConfig.java │ │ │ └── ReadOnlyMVHandlerInterceptor.java │ │ │ ├── controller │ │ │ ├── api │ │ │ │ ├── DatasourceAssembler.java │ │ │ │ ├── DatasourceController.java │ │ │ │ ├── MappingAssembler.java │ │ │ │ ├── MappingController.java │ │ │ │ ├── SearchController.java │ │ │ │ ├── SearchResultAssembler.java │ │ │ │ ├── TermAssembler.java │ │ │ │ └── TermController.java │ │ │ └── ui │ │ │ │ ├── CustomisationProperties.java │ │ │ │ ├── DatasourceControllerUI.java │ │ │ │ ├── IndexController.java │ │ │ │ ├── MappingControllerUI.java │ │ │ │ ├── SearchControllerUI.java │ │ │ │ └── TermControllerUI.java │ │ │ └── model │ │ │ ├── MappingQuery.java │ │ │ └── MappingSearchRequest.java │ └── resources │ │ ├── application.properties │ │ ├── static │ │ ├── css │ │ │ ├── oxo-d3.css │ │ │ ├── oxo.css │ │ │ └── vis.css │ │ ├── img │ │ │ ├── OXO_logo_2017_colour_background.png │ │ │ └── infinity.gif │ │ └── js │ │ │ ├── docs.js │ │ │ ├── oxo-flare.js │ │ │ ├── oxo-graph.js │ │ │ ├── oxo-hchart.js │ │ │ ├── oxo-search-result.js │ │ │ ├── oxo.js │ │ │ └── vis.js │ │ └── templates │ │ ├── about.html │ │ ├── contact.html │ │ ├── datasource.html │ │ ├── docs-template.html │ │ ├── fragments │ │ ├── footer.html │ │ ├── head.html │ │ ├── header.html │ │ └── slider.html │ │ ├── index.html │ │ ├── login.html │ │ ├── mapping.html │ │ ├── mappings.html │ │ ├── myaccount.html │ │ ├── search.html │ │ └── terms.html │ └── test │ └── java │ └── ApiDocumentation.java ├── paxo-loader ├── config │ ├── listprocessing_dummy_config.ini │ └── paxo_dummy_config.ini ├── listprocessing.py ├── listprocessing_config.ini ├── neoExporter.py ├── paxo.py ├── paxo_config.ini ├── paxo_internals.py ├── readme.md ├── requirements.txt ├── standard │ └── dummy-standard.csv └── validation.py ├── pom.xml ├── queries.txt └── solr-config ├── mapping ├── conf │ ├── _rest_managed.json │ ├── lang │ │ └── stopwords_en.txt │ ├── protwords.txt │ ├── schema.xml │ ├── solrconfig.xml │ ├── stopwords.txt │ └── synonyms.txt └── core.properties └── solr.xml /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .idea 3 | dataloading 4 | neo4jimport/*.csv 5 | neo4jdata 6 | db 7 | solr-config/data 8 | *.rtf 9 | *.iml 10 | *.md 11 | !oxo-web/target/oxo-web.war 12 | __pycache__ 13 | *.pyc 14 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Build & publish OXO images 2 | 3 | on: 4 | push: 5 | branches: [ "dev", "stable" ] 6 | 7 | env: 8 | REGISTRY: ghcr.io 9 | IMAGE_NAME: ${{ github.repository }} 10 | 11 | jobs: 12 | build-and-push-image: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v2 20 | 21 | - name: Log in to the Container registry 22 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 23 | with: 24 | registry: ${{ env.REGISTRY }} 25 | username: ${{ github.actor }} 26 | password: ${{ secrets.GITHUB_TOKEN }} 27 | 28 | - name: Build and push OXO Docker image 29 | run: | 30 | docker build -t ghcr.io/ebispot/oxo-loader:${{ github.sha }} -f ./oxo-loader/Dockerfile . 31 | docker build -t ghcr.io/ebispot/oxo-indexer:${{ github.sha }} -f ./oxo-indexer/Dockerfile . 32 | docker build -t ghcr.io/ebispot/oxo-web:${{ github.sha }} -f ./oxo-web/Dockerfile . 33 | docker tag ghcr.io/ebispot/oxo-loader:${{ github.sha }} ghcr.io/ebispot/oxo-loader:${{ github.ref_name }} 34 | docker tag ghcr.io/ebispot/oxo-indexer:${{ github.sha }} ghcr.io/ebispot/oxo-indexer:${{ github.ref_name }} 35 | docker tag ghcr.io/ebispot/oxo-web:${{ github.sha }} ghcr.io/ebispot/oxo-web:${{ github.ref_name }} 36 | docker push --all-tags ghcr.io/ebispot/oxo-loader 37 | docker push --all-tags ghcr.io/ebispot/oxo-indexer 38 | docker push --all-tags ghcr.io/ebispot/oxo-web 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *.iml 3 | *.DS_store 4 | .idea 5 | *~ 6 | properties 7 | application.properties 8 | *.pyc 9 | .mvn 10 | oxo-web/src/main/resources/templates/search-orig.html 11 | oxo-web/src/main/asciidoc/generated-snippets 12 | oxo-web/src/main/resources/static 13 | .settings 14 | data/solr/data/* 15 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | oxo 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.m2e.core.maven2Builder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.m2e.core.maven2Nature 16 | 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OxO is a service for finding mappings (or cross-references) between terms from 2 | ontologies, vocabularies and coding standards. OxO imports mappings from a 3 | variety of sources including the [Ontology Lookup Service](https://www.ebi.ac.uk/ols/index) and a subset of 4 | mappings provided by the [UMLS](https://www.nlm.nih.gov/research/umls/index.html). 5 | 6 | # OxO with Docker 7 | 8 | OxO is comprised of three components: 9 | 10 | * The loader scripts (oxo-loader/), which pull data about terms and mappings from the OLS, OBO xrefs, and UMLS and upload them to neo4j 11 | * The indexer (oxo-indexer/), which indexes terms and mappings found in neo4j in solr 12 | * The Web application (oxo-web/), which provides the user interface 13 | 14 | The preferred method of deployment for OxO is using Docker. If you would like to deploy **the entire OntoTools stack** (OLS, OxO, and ZOOMA), check out the [OntoTools Docker Config](https://github.com/EBISPOT/ontotools-docker-config) repository. If you would like to deploy **OxO only**, read on. 15 | 16 | First, create the necessary volumes: 17 | 18 | docker volume create --name=oxo-neo4j-data 19 | docker volume create --name=oxo-neo4j-import 20 | docker volume create --name=oxo-mongo-data 21 | docker volume create --name=oxo-solr-data 22 | docker volume create --name=oxo-hsqldb 23 | 24 | Then, start OxO: 25 | 26 | docker-compose up 27 | 28 | The OxO instance will be empty until the loader and indexer have been executed. 29 | 30 | ## Running the loader 31 | 32 | The loader scripts are documented in the README of the oxo-loader/ directory. 33 | 34 | ## Running the indexer 35 | 36 | After using the loader to load data into neo4j, the indexer can be executed 37 | using Docker: 38 | 39 | docker run --net=host ebispot/oxo-indexer:dev 40 | 41 | 42 | # OxO without Docker 43 | 44 | Sometimes it is impractical to use Docker (e.g. for local development). To get 45 | OxO up and running without Docker, first install: 46 | 47 | * neo4j community edition 3.1.1 48 | * solr 5.3.0 49 | * Java 1.8 50 | * Maven 51 | 52 | The instructions for the loader are not Docker-specific, and can be found in the 53 | oxo-loader/ directory. For the indexer and Web application, first compile the 54 | project using Maven: 55 | 56 | mvn clean package 57 | 58 | Then run the indexer: 59 | 60 | java -Xmx10g -jar oxo-indexer.jar 61 | 62 | The Web application is a standard WAR and can be deployed using e.g. Tomcat. 63 | 64 | ## Customisation 65 | 66 | It is possible to customise several branding options in `oxo-web/src/main/resources/application.properties`: 67 | 68 | * `oxo.customisation.debrand` — If set to true, removes the EBI header and footer, documentation, and about page 69 | * `oxo.customisation.title` — A custom title for your instance, e.g. "My OxO Instance" 70 | * `oxo.customisation.short-title` — A shorter version of the custom title, e.g. "MYOxO" 71 | * `oxo.customisation.description` — A description of the instance 72 | * `oxo.customisation.org` — The organisation hosting your instance 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | solr: 4 | image: ebispot/ols-solr:latest 5 | environment: 6 | - SOLR_HOME=/mnt/solr-config 7 | ports: 8 | - 8983:8983 9 | volumes: 10 | - oxo-solr-data:/var/solr 11 | - ./solr-config:/mnt/solr-config 12 | command: ["-Dsolr.solr.home=/mnt/solr-config", "-Dsolr.data.dir=/var/solr", "-Dsolr.log=/var/solr/logs", "-f"] 13 | neo4j: 14 | image: neo4j:3.1.1 15 | environment: 16 | # - NEO4J_HEAP_MEMORY=10g # configure the heap memory 17 | # - NEO4J_dbms_memory_heap_maxSize=8g 18 | - NEO4J_AUTH=neo4j/dba 19 | cap_add: 20 | - SYS_RESOURCE 21 | ports: 22 | - 7474:7474 23 | - 7687:7687 24 | volumes: 25 | - oxo-neo4j-import:/var/lib/neo4j/import 26 | - oxo-neo4j-data:/data 27 | oxo-web: 28 | build: 29 | context: . 30 | dockerfile: oxo-web/Dockerfile 31 | depends_on: 32 | - neo4j 33 | - solr 34 | links: 35 | - neo4j 36 | - solr 37 | environment: 38 | - spring.datasource.url=jdbc:hsqldb:file:/mnt/hsqldb 39 | - oxo.neo.driver=org.neo4j.ogm.drivers.http.driver.HttpDriver 40 | - oxo.neo.uri=http://neo4j:dba@neo4j:7474 41 | - spring.data.solr.host=http://solr:8983/solr 42 | volumes: 43 | - oxo-hsqldb:/mnt/hsqldb 44 | ports: 45 | - 8080:8080 46 | volumes: 47 | oxo-neo4j-import: 48 | external: true 49 | oxo-neo4j-data: 50 | external: true 51 | oxo-mongo-data: 52 | external: true 53 | oxo-solr-data: 54 | external: true 55 | oxo-hsqldb: 56 | external: true 57 | -------------------------------------------------------------------------------- /job_wait.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | # https://stackoverflow.com/questions/55073453/wait-for-kubernetes-job-to-complete-on-either-failure-success-using-command-line 5 | 6 | 7 | # wait for completion as background process - capture PID 8 | kubectl wait --timeout=2h --for=condition=complete -n $1 $2 & 9 | completion_pid=$! 10 | 11 | # wait for failure as background process - capture PID 12 | kubectl wait --timeout=2h --for=condition=failed -n $1 $2 && exit 1 & 13 | failure_pid=$! 14 | 15 | # capture exit code of the first subprocess to exit 16 | wait -n $completion_pid $failure_pid 17 | 18 | # store exit code in variable 19 | exit_code=$? 20 | 21 | if (( $exit_code == 0 )); then 22 | echo "Job completed" 23 | else 24 | echo "Job failed with exit code ${exit_code}, exiting..." 25 | fi 26 | 27 | kubectl logs -n $1 $2 28 | 29 | exit $exit_code 30 | -------------------------------------------------------------------------------- /k8chart/oxo-indexer/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: oxo indexer 4 | name: oxo 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /k8chart/oxo-indexer/templates/_helpers.tpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/k8chart/oxo-indexer/templates/_helpers.tpl -------------------------------------------------------------------------------- /k8chart/oxo-indexer/templates/oxo-indexer-job.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: {{ .Release.Name }}-job 5 | spec: 6 | backoffLimit: 0 7 | restartPolicy: Never 8 | template: 9 | metadata: 10 | name: {{ .Release.Name }}-job 11 | spec: 12 | restartPolicy: Never 13 | containers: 14 | - name: oxo-indexer 15 | image: {{.Values.image.name}}:{{.Values.image.tag}} 16 | command: [ 'java', '-Xmx10g', '-jar', 'oxo-indexer.jar' ] 17 | resources: 18 | limits: 19 | memory: "15Gi" 20 | requests: 21 | memory: "15Gi" 22 | env: 23 | - name: OXO_NEO_DRIVER 24 | value: "org.neo4j.ogm.drivers.http.driver.HttpDriver" 25 | - name: OXO_NEO_URI 26 | value: "http://neo4j:dba@oxo-{{.Values.oxoRelease}}-neo4j:7474" 27 | - name: SPRING_DATA_SOLR_HOST 28 | value: "http://oxo-{{.Values.oxoRelease}}-solr:8983/solr" 29 | - name: OXO_INDEXER_CHUNKS 30 | value: "5000" 31 | -------------------------------------------------------------------------------- /k8chart/oxo-indexer/values.yaml: -------------------------------------------------------------------------------- 1 | 2 | image: 3 | name: ebispot/oxo-indexer 4 | tag: stable 5 | 6 | 7 | oxoRelease: dev 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /k8chart/oxo-loader/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: oxo loader 4 | name: oxo 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /k8chart/oxo-loader/templates/_helpers.tpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/k8chart/oxo-loader/templates/_helpers.tpl -------------------------------------------------------------------------------- /k8chart/oxo-loader/templates/oxo-loader-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ .Release.Name }}-configmap 5 | data: 6 | config.ini: |- 7 | [Basics] 8 | oxoUrl=http://oxo-{{ .Values.oxoRelease }}-web.oxo.svc.cluster.local:8080 9 | oxoAPIkey=key 10 | olsSolrBaseUrl=http://ves-hx-7e.ebi.ac.uk:8993/solr 11 | solrChunks=5000 12 | neoURL=bolt://oxo-{{ .Values.oxoRelease }}-neo4j.oxo.svc.cluster.local:7687 13 | neoUser=neo4j 14 | neoPass=dba 15 | olsurl=https://www.ebi.ac.uk/ols/api 16 | oboDbxrefUrl=https://raw.githubusercontent.com/geneontology/go-site/master/metadata/db-xrefs.yaml 17 | 18 | [Paths] 19 | exportFileDatasources=datasources.csv 20 | exportFileTerms=/path/terms.csv 21 | exportFileMappings=/path/mappings.csv 22 | idorgDataLocation = /path/idorg.xml 23 | 24 | [SQLumls] 25 | user=username 26 | password=password 27 | host=mysql-name 28 | db=dbName 29 | port=4570 30 | 31 | [LOINC] 32 | Part=/path/Part.csv 33 | PartRelatedCodeMapping=/path/PartRelatedCodeMapping.csv 34 | -------------------------------------------------------------------------------- /k8chart/oxo-loader/templates/oxo-loader-job.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: {{ .Release.Name }}-job 5 | backoffLimit: 0 6 | concurrencyPolicy: Forbid 7 | failedJobsHistoryLimit: 1 8 | restartPolicy: Never 9 | spec: 10 | restartPolicy: Never 11 | template: 12 | metadata: 13 | name: {{ .Release.Name }}-job 14 | spec: 15 | restartPolicy: Never 16 | containers: 17 | - name: oxo-loader 18 | image: {{.Values.image.name}}:{{.Values.image.tag}} 19 | imagePullPolicy: Always 20 | command: ['bash', '/opt/oxo-loader/load_all.sh'] 21 | volumeMounts: 22 | - name: oxoloader-config 23 | mountPath: "/opt/oxo-config" 24 | readOnly: true 25 | - name: oxo-{{.Values.oxoRelease}}-neo4jimport 26 | mountPath: "/mnt/neo4jimport" 27 | env: 28 | - name: NEO4JIMPORT 29 | value: '/mnt/neo4jimport' 30 | - name: CONFIG_INI 31 | value: '/opt/oxo-config/config.ini' 32 | - name: IDORG_XML 33 | value: '/opt/oxo-loader/idorg.xml' 34 | envFrom: 35 | - configMapRef: 36 | name: oxo-{{ .Values.oxoRelease }}-proxy-configmap 37 | volumes: 38 | - name: oxoloader-config 39 | configMap: 40 | name: {{ .Release.Name }}-configmap 41 | - name: oxo-{{.Values.oxoRelease}}-neo4jimport 42 | persistentVolumeClaim: 43 | claimName: oxo-{{.Values.oxoRelease}}-neo4jimport 44 | -------------------------------------------------------------------------------- /k8chart/oxo-loader/values.yaml: -------------------------------------------------------------------------------- 1 | 2 | image: 3 | name: ebispot/oxo-loader 4 | tag: stable 5 | 6 | 7 | oxoRelease: dev 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /k8chart/oxo/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /k8chart/oxo/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: oxo deployment 4 | name: oxo 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /k8chart/oxo/templates/_helpers.tpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/k8chart/oxo/templates/_helpers.tpl -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ .Release.Name }}-configmap 5 | data: 6 | myvalue: "Hello World" -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: {{ .Release.Name }}-ingress 5 | annotations: 6 | nginx.ingress.kubernetes.io/rewrite-target: / 7 | spec: 8 | rules: 9 | - http: 10 | paths: 11 | - path: / 12 | backend: 13 | serviceName: {{ .Release.Name }}-web 14 | servicePort: 8080 15 | -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-neo4j-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ .Release.Name }}-neo4j 5 | labels: 6 | app: {{ .Release.Name }}-neo4j 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app: {{ .Release.Name }}-neo4j 12 | template: 13 | metadata: 14 | labels: 15 | app: {{ .Release.Name }}-neo4j 16 | spec: 17 | containers: 18 | - name: neo4j 19 | image: neo4j:3.1.1 20 | imagePullPolicy: Always 21 | env: 22 | # - name: NEO4J_HEAP_MEMORY 23 | # value: 10g 24 | # - name: NEO4J_dbms_memory_heap_maxSize 25 | # value: 8g 26 | - name: NEO4J_AUTH 27 | value: neo4j/dba 28 | ports: 29 | - containerPort: 7474 30 | - containerPort: 7687 31 | volumeMounts: 32 | - name: {{.Release.Name}}-neo4jimport 33 | mountPath: "/var/lib/neo4j/import" 34 | - name: {{.Release.Name}}-neo4j-data 35 | mountPath: "/data" 36 | volumes: 37 | - name: {{.Release.Name}}-neo4jimport 38 | persistentVolumeClaim: 39 | claimName: {{.Release.Name}}-neo4jimport 40 | - name: {{.Release.Name}}-neo4j-data 41 | persistentVolumeClaim: 42 | claimName: {{.Release.Name}}-neo4j-data 43 | -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-neo4j-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Release.Name }}-neo4j 5 | labels: 6 | app: {{ .Release.Name }}-neo4j 7 | spec: 8 | ports: 9 | - port: 7474 10 | targetPort: 7474 11 | name: http 12 | protocol: TCP 13 | - port: 7687 14 | targetPort: 7687 15 | name: bolt 16 | protocol: TCP 17 | selector: 18 | app: {{ .Release.Name }}-neo4j -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-proxy-configmap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ .Release.Name }}-proxy-configmap 5 | data: 6 | HTTP_PROXY: http://hx-wwwcache.ebi.ac.uk:3128 7 | HTTPS_PROXY: http://hx-wwwcache.ebi.ac.uk:3128 8 | http_proxy: http://hx-wwwcache.ebi.ac.uk:3128 9 | https_proxy: http://hx-wwwcache.ebi.ac.uk:3128 10 | no_proxy: localhost,.cluster.local 11 | -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-solr-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ .Release.Name }}-solr 5 | labels: 6 | app: {{ .Release.Name }}-solr 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app: {{ .Release.Name }}-solr 12 | template: 13 | metadata: 14 | labels: 15 | app: {{ .Release.Name }}-solr 16 | spec: 17 | # initContainers: 18 | # - name: init-solr 19 | # image: solr:5.5.3-alpine 20 | # command: ['solr', 'create_core', '-c', 'mapping'] 21 | # volumeMounts: 22 | # - name: {{.Release.Name}}-solr-data 23 | # mountPath: "/var/solr" 24 | containers: 25 | - name: solr 26 | image: solr:5.5.3-alpine 27 | imagePullPolicy: Always 28 | command: ['solr-precreate', 'mapping'] 29 | ports: 30 | - containerPort: 8983 31 | volumeMounts: 32 | - name: {{.Release.Name}}-solr-data 33 | mountPath: "/var/solr" 34 | volumes: 35 | - name: {{.Release.Name}}-solr-data 36 | persistentVolumeClaim: 37 | claimName: {{.Release.Name}}-solr-data 38 | 39 | -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-solr-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Release.Name }}-solr 5 | labels: 6 | app: {{ .Release.Name }}-solr 7 | spec: 8 | ports: 9 | - port: 8983 10 | targetPort: 8983 11 | name: http 12 | protocol: TCP 13 | selector: 14 | app: {{ .Release.Name }}-solr -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-web-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ .Release.Name }}-web 5 | labels: 6 | app: {{ .Release.Name }}-web 7 | spec: 8 | replicas: 1 9 | selector: 10 | matchLabels: 11 | app: {{ .Release.Name }}-web 12 | template: 13 | metadata: 14 | labels: 15 | app: {{ .Release.Name }}-web 16 | spec: 17 | containers: 18 | - name: web 19 | image: {{.Values.image.name}}:{{.Values.image.tag}} 20 | imagePullPolicy: Always 21 | ports: 22 | - containerPort: 8080 23 | env: 24 | - name: spring.datasource.url 25 | value: jdbc:hsqldb:file:/mnt/hsqldb 26 | - name: oxo.neo.driver 27 | value: org.neo4j.ogm.drivers.http.driver.HttpDriver 28 | - name: oxo.neo.uri 29 | value: http://neo4j:dba@{{ .Release.Name }}-neo4j:7474 30 | - name: spring.data.solr.host 31 | value: http://{{ .Release.Name }}-solr:8983/solr -------------------------------------------------------------------------------- /k8chart/oxo/templates/oxo-web-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Release.Name }}-web 5 | labels: 6 | app: {{ .Release.Name }}-web 7 | spec: 8 | ports: 9 | - port: 8080 10 | targetPort: 8080 11 | name: http 12 | protocol: TCP 13 | selector: 14 | app: {{ .Release.Name }}-web -------------------------------------------------------------------------------- /k8chart/oxo/values.yaml: -------------------------------------------------------------------------------- 1 | 2 | image: 3 | name: ebispot/oxo-web 4 | tag: stable 5 | 6 | 7 | -------------------------------------------------------------------------------- /k8chart/pvcs/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.0" 3 | description: oxo PVCs 4 | name: oxo 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /k8chart/pvcs/templates/_helpers.tpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/k8chart/pvcs/templates/_helpers.tpl -------------------------------------------------------------------------------- /k8chart/pvcs/templates/oxo-neo4j-data-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | creationTimestamp: null 5 | name: oxo-{{ .Values.oxoRelease }}-neo4j-data 6 | spec: 7 | accessModes: 8 | - ReadWriteOnce 9 | resources: 10 | requests: 11 | storage: 10Gi 12 | -------------------------------------------------------------------------------- /k8chart/pvcs/templates/oxo-neo4jimport-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | creationTimestamp: null 5 | name: oxo-{{ .Values.oxoRelease }}-neo4jimport 6 | spec: 7 | accessModes: 8 | - ReadWriteMany 9 | resources: 10 | requests: 11 | storage: 10Gi 12 | -------------------------------------------------------------------------------- /k8chart/pvcs/templates/oxo-solr-data-pvc.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | creationTimestamp: null 5 | name: oxo-{{ .Values.oxoRelease }}-solr-data 6 | spec: 7 | accessModes: 8 | - ReadWriteOnce 9 | resources: 10 | requests: 11 | storage: 10Gi 12 | -------------------------------------------------------------------------------- /k8chart/pvcs/values.yaml: -------------------------------------------------------------------------------- 1 | 2 | oxoRelease: dev 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/javax.annotation.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/lib/javax.annotation.jar -------------------------------------------------------------------------------- /lib/sping-security-orcid-stateless-0.0.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/lib/sping-security-orcid-stateless-0.0.8.jar -------------------------------------------------------------------------------- /lib/spring-data-jpa-1.10.8.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/lib/spring-data-jpa-1.10.8.RELEASE.jar -------------------------------------------------------------------------------- /lib/spring-security-core-4.1.4.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/lib/spring-security-core-4.1.4.RELEASE.jar -------------------------------------------------------------------------------- /lib/spring-security-oauth2-2.0.13.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/lib/spring-security-oauth2-2.0.13.RELEASE.jar -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% 125 | if ERRORLEVEL 1 goto error 126 | goto end 127 | 128 | :error 129 | set ERROR_CODE=1 130 | 131 | :end 132 | @endlocal & set ERROR_CODE=%ERROR_CODE% 133 | 134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 138 | :skipRcPost 139 | 140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 142 | 143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 144 | 145 | exit /B %ERROR_CODE% -------------------------------------------------------------------------------- /oxo-indexer/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /oxo-indexer/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | oxo-indexer 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /oxo-indexer/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM maven:3.6-jdk-8 AS build 3 | RUN mkdir /opt/oxo 4 | COPY pom.xml /opt/oxo/pom.xml 5 | COPY oxo-web /opt/oxo/oxo-web 6 | COPY oxo-model /opt/oxo/oxo-model 7 | COPY oxo-indexer /opt/oxo/oxo-indexer 8 | COPY lib /opt/oxo/lib 9 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/sping-security-orcid-stateless-0.0.8.jar -DgroupId=uk.ac.ebi.spot -DartifactId=sping-security-orcid-stateless -Dversion=0.0.8 10 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/spring-security-core-4.1.4.RELEASE.jar -DgroupId=org.springframework.security -DartifactId=spring-security-core -Dversion=4.1.4.RELEASE 11 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/spring-security-oauth2-2.0.13.RELEASE.jar -DgroupId=org.springframework.security.oauth -DartifactId=spring-security-oauth2 -Dversion=2.0.13.RELEASE 12 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/spring-data-jpa-1.10.8.RELEASE.jar -DgroupId=org.springframework.data -DartifactId=spring-data-jpa -Dversion=1.10.8.RELEASE 13 | RUN cd /opt/oxo && mvn clean package -DskipTests 14 | 15 | FROM openjdk:8-jre-alpine 16 | RUN apk add bash 17 | COPY --from=build /opt/oxo/oxo-indexer/target/oxo-indexer.jar /opt/oxo-indexer.jar 18 | COPY --from=build /opt/oxo/oxo-indexer/application.properties /opt/application.properties 19 | WORKDIR /opt 20 | ENTRYPOINT ["java", "-Xmx10g", "-jar", "oxo-indexer.jar"] 21 | 22 | -------------------------------------------------------------------------------- /oxo-indexer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | oxo 7 | uk.ac.ebi.spot 8 | 0.0.17-SNAPSHOT 9 | ../ 10 | 11 | 4.0.0 12 | 13 | uk.ac.ebi.spot.oxo 14 | oxo-indexer 15 | 16 | 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-autoconfigure 21 | 22 | 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter 27 | 28 | 29 | 30 | uk.ac.ebi.spot 31 | oxo-model 32 | 0.0.17-SNAPSHOT 33 | 34 | 35 | 36 | uk.ac.ebi.spot 37 | sping-security-orcid-stateless 38 | 0.0.8 39 | 40 | 41 | 42 | org.springframework.security 43 | spring-security-core 44 | 4.1.4.RELEASE 45 | 46 | 47 | 48 | org.springframework.security.oauth 49 | spring-security-oauth2 50 | 2.0.13.RELEASE 51 | 52 | 53 | 54 | org.springframework.data 55 | spring-data-jpa 56 | 1.10.8.RELEASE 57 | 58 | 59 | 60 | jar 61 | 62 | 63 | 64 | oxo-indexer 65 | 66 | 67 | 68 | org.springframework.boot 69 | spring-boot-maven-plugin 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /oxo-indexer/src/main/java/uk/ac/ebi/spot/indexer/SolrIndexer.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.indexer; 2 | 3 | import org.apache.solr.client.solrj.SolrClient; 4 | import org.apache.solr.client.solrj.impl.HttpSolrClient; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.ComponentScan; 12 | import org.springframework.core.env.Environment; 13 | import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; 14 | import org.springframework.data.solr.core.SolrTemplate; 15 | import org.springframework.data.solr.repository.config.EnableSolrRepositories; 16 | import uk.ac.ebi.spot.index.Document; 17 | import uk.ac.ebi.spot.service.TermService; 18 | 19 | import javax.annotation.Resource; 20 | 21 | /** 22 | * @author Simon Jupp 23 | * @date 04/03/2018 24 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 25 | */ 26 | 27 | @SpringBootApplication 28 | @EnableNeo4jRepositories(basePackages = "uk.ac.ebi.spot.repository") 29 | @EnableSolrRepositories(basePackages = "uk.ac.ebi.spot.index", basePackageClasses = {Document.class}) 30 | @EnableConfigurationProperties 31 | @ComponentScan({"uk.ac.ebi"}) 32 | public class SolrIndexer implements CommandLineRunner { 33 | 34 | @Autowired 35 | TermService termService; 36 | 37 | @Resource 38 | private Environment environment; 39 | 40 | @Bean 41 | SolrClient solrClient() { 42 | return new HttpSolrClient(environment.getProperty("spring.data.solr.host")); 43 | } 44 | 45 | @Bean 46 | public SolrTemplate solrTemplate() { 47 | return new SolrTemplate(solrClient(), "mapping"); 48 | } 49 | 50 | @Override 51 | public void run(String... strings) throws Exception { 52 | termService.rebuildIndexes(); 53 | } 54 | 55 | public static void main(String[] args) throws Exception { 56 | SpringApplication.run(SolrIndexer.class, args); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /oxo-indexer/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.springframework=ERROR 2 | logging.level.org.neo4j.ogm=ERROR 3 | logging.level.uk.ac.ebi.spot=INFO 4 | 5 | oxo.neo.driver=org.neo4j.ogm.drivers.http.driver.HttpDriver 6 | #oxo.neo.driver=org.neo4j.ogm.drivers.bolt.driver.BoltDriver 7 | oxo.neo.uri=http://localhost:7474 8 | #bolt://neo4j:dba@localhost:7688 9 | 10 | spring.data.solr.host=http://localhost:8983/solr 11 | spring.main.web-environment=false 12 | 13 | oxo.indexer.chunks=100000 14 | 15 | -------------------------------------------------------------------------------- /oxo-loader/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3-alpine 2 | 3 | ADD oxo-loader /opt/oxo-loader 4 | 5 | RUN apk add --no-cache bash mariadb-dev build-base 6 | #RUN apk --update add mysql mysql-client 7 | RUN cd /opt/oxo-loader && pip install -r requirements.txt 8 | RUN chmod +x /opt/oxo-loader/load_all.sh 9 | 10 | CMD bash 11 | -------------------------------------------------------------------------------- /oxo-loader/LoincMappingExtractor.py: -------------------------------------------------------------------------------- 1 | 2 | import csv 3 | from configparser import ConfigParser 4 | from optparse import OptionParser 5 | import OxoCsvBuilder 6 | import OxoClient 7 | import datetime 8 | 9 | parser = OptionParser() 10 | parser.add_option("-t", "--terms", help="terms csv export file") 11 | parser.add_option("-m", "--mappings", help="mappings csv export file") 12 | parser.add_option("-c", "--config", help="config file", default="config.ini") 13 | 14 | (options, args) = parser.parse_args() 15 | 16 | config = ConfigParser() 17 | config.read(options.config) 18 | 19 | exportFileTerms=config.get("Paths","exportFileTerms") 20 | if options.terms: 21 | exportFileTerms = options.terms 22 | 23 | exportFileMappings=config.get("Paths","exportFileMappings") 24 | if options.mappings: 25 | exportFileMappings = options.mappings 26 | 27 | loinc_mapping_file = open(config.get("LOINC", "PartRelatedCodeMapping")) 28 | loinc_mapping_reader = csv.reader(loinc_mapping_file, delimiter=',', quotechar='"') 29 | 30 | loinc_part_file = open(config.get("LOINC", "Part")) 31 | loinc_part_reader = csv.reader(loinc_part_file, delimiter=',', quotechar='"') 32 | 33 | OXO = OxoClient.OXO() 34 | OXO.oxoUrl = config.get("Basics","oxoUrl") 35 | datasets = OXO.getOxODatasets() 36 | 37 | loincDatasource = None 38 | 39 | for dataset in datasets: 40 | print(dataset) 41 | if dataset['prefix'] == "LNC": 42 | loincDatasource = dataset 43 | 44 | mappings = [] 45 | terms = {} 46 | 47 | 48 | next(loinc_part_reader) 49 | 50 | for row in loinc_part_reader: 51 | part_number=row[0] 52 | part_type_name=row[1] 53 | part_name=row[2] 54 | part_display_name=row[3] 55 | status=row[4] 56 | 57 | terms['LNC:' + part_number] = { 58 | "prefix": 'LNC', 59 | "id": part_number, 60 | "curie": 'LNC:' + part_number, 61 | "uri": 'http://loinc.org/#' + part_number, 62 | "label": part_name 63 | } 64 | 65 | 66 | 67 | 68 | 69 | next(loinc_mapping_reader) 70 | 71 | for row in loinc_mapping_reader: 72 | part_number=row[0] 73 | part_name=row[1] 74 | rpart_type_name=row[2] 75 | ext_code_id=row[3] 76 | ext_code_display_name=row[4] 77 | ext_code_system=row[5] 78 | equivalence=row[6] 79 | content_origin=row[7] 80 | ext_code_system_version=row[8] 81 | ext_code_system_copyright_notice=row[9] 82 | 83 | from_curie="LNC:" + part_number 84 | to_curie=ext_code_id 85 | 86 | if ext_code_system == "http://pubchem.ncbi.nlm.nih.gov": 87 | # 5997 88 | continue 89 | elif ext_code_system == "http://www.nlm.nih.gov/research/umls/rxnorm": 90 | # 260101 91 | continue 92 | elif ext_code_system == "http://www.radlex.org": 93 | # RID88 94 | continue 95 | elif ext_code_system == "http://snomed.info/sct": 96 | to_curie = "SNOMEDCT:" + ext_code_id 97 | elif ext_code_system == "https://www.ebi.ac.uk/chebi": 98 | to_curie = ext_code_id 99 | elif ext_code_system == "https://www.ncbi.nlm.nih.gov/taxonomy": 100 | to_curie = "NCIT:" + ext_code_id 101 | elif ext_code_system == "https://www.ncbi.nlm.nih.gov/gene": 102 | # 6329 103 | continue 104 | elif ext_code_system == "https://www.ncbi.nlm.nih.gov/clinvar": 105 | # 7111 106 | continue 107 | 108 | mapping = { 109 | 'fromId': from_curie, 110 | 'toId': to_curie, 111 | 'datasourcePrefix': "LNC", 112 | 'sourceType': "ONTOLOGY", 113 | 'scope': "RELATED" 114 | } 115 | 116 | mappings.append(mapping) 117 | 118 | print("Generating CSV files for neo loading...") 119 | 120 | builder = OxoCsvBuilder.Builder() 121 | 122 | builder.exportTermsToCsv(exportFileTerms, terms) 123 | builder.exportMappingsToCsv(exportFileMappings, mappings, { 'LNC': loincDatasource }) 124 | 125 | print("Finished process!") 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /oxo-loader/OxoCsvBuilder.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Generates a CSV file from sets of OxO datasrouces, terms or mappings 4 | """ 5 | __author__ = "jupp" 6 | __license__ = "Apache 2.0" 7 | __date__ = "04/03/2018" 8 | 9 | 10 | import csv 11 | import datetime 12 | import json 13 | 14 | class Builder: 15 | 16 | def generateAllAltPrefixes(self, alternatePrefixes): 17 | terms = {} 18 | for ap in alternatePrefixes: 19 | terms[ap] = 1 20 | terms[ap.lower()] = 1 21 | terms[ap.upper()] = 1 22 | 23 | return list(terms.keys()) 24 | 25 | def exportDatasourceToCsv(self, file, datasources): 26 | with open(file, 'w') as csvfile: 27 | spamwriter = csv.writer(csvfile, delimiter=',', 28 | quoting=csv.QUOTE_ALL, escapechar='\\', doublequote=False) 29 | spamwriter.writerow( 30 | ['prefix', "idorgNamespace", "title", "description", "sourceType", "baseUri", "alternatePrefixes", 31 | "licence", "versionInfo"]) 32 | for key, value in datasources.items(): 33 | value.alternatePrefixes.append(key) 34 | alternatePrefixes = self.generateAllAltPrefixes(value.alternatePrefixes) 35 | 36 | spamwriter.writerow([value.prefPrefix, value.idorgNamespace, str(value.title), 37 | str(value.description), value.sourceType, value.baseUri, 38 | ",".join(alternatePrefixes), str(value.licence), 39 | str(value.versionInfo)]) 40 | 41 | def exportTermsToCsv(self, file, terms): 42 | with open(file, 'w') as csvfile: 43 | spamwriter = csv.writer(csvfile, delimiter=',', 44 | quoting=csv.QUOTE_ALL, escapechar='\\', doublequote=False) 45 | spamwriter.writerow(['identifier', "curie", "label", "uri", "prefix"]) 46 | for key, term in terms.items(): 47 | label = None 48 | uri = None 49 | 50 | try: 51 | if term["label"] is not None: 52 | label = term["label"].encode('utf-8', errors="ignore") 53 | except: 54 | pass 55 | 56 | if term["uri"] is not None: 57 | uri = term["uri"] 58 | 59 | spamwriter.writerow([term["id"], term["curie"], label, uri, term["prefix"]]) 60 | 61 | def exportMappingsToCsv(self, file, postMappings, prefixToDatasource): 62 | 63 | with open(file, 'w') as csvfile: 64 | spamwriter = csv.writer(csvfile, delimiter=',', 65 | quoting=csv.QUOTE_ALL, escapechar='\\', doublequote=False) 66 | spamwriter.writerow( 67 | ['fromCurie', "toCurie", "datasourcePrefix", "datasource", "sourceType", "scope", "date"]) 68 | for mapping in postMappings: 69 | datasource = prefixToDatasource[mapping["datasourcePrefix"]] 70 | spamwriter.writerow( 71 | [mapping["fromId"], mapping["toId"], mapping["datasourcePrefix"], json.dumps(datasource), 72 | mapping["sourceType"], mapping["scope"], datetime.datetime.now().strftime("%y-%m-%d")]) 73 | -------------------------------------------------------------------------------- /oxo-loader/config.ini: -------------------------------------------------------------------------------- 1 | [Basics] 2 | oxoUrl=http://host.docker.internal:8080 3 | oxoAPIkey=key 4 | olsSolrBaseUrl=http://host.docker.internal:8993/solr 5 | solrChunks=5000 6 | neoURL=bolt://host.docker.internal:7687 7 | neoUser=neo4j 8 | neoPass=dba 9 | olsurl=http://www.ebi.ac.uk/ols/api 10 | oboDbxrefUrl=https://raw.githubusercontent.com/geneontology/go-site/master/metadata/db-xrefs.yaml 11 | 12 | [Paths] 13 | exportFileDatasources=datasources.csv 14 | exportFileTerms=/path/terms.csv 15 | exportFileMappings=/path/mappings.csv 16 | idorgDataLocation = /path/idorg.xml 17 | 18 | [SQLumls] 19 | user=username 20 | password=password 21 | host=mysql-name 22 | db=dbName 23 | port=4570 24 | 25 | [LOINC] 26 | Part=/path/Part.csv 27 | PartRelatedCodeMapping=/path/PartRelatedCodeMapping.csv 28 | -------------------------------------------------------------------------------- /oxo-loader/config.sample.ini: -------------------------------------------------------------------------------- 1 | [Basics] 2 | oxoUrl=http://localhost:8080 3 | oxoAPIkey=key 4 | olsSolrBaseUrl=http://localhost:8983/solr 5 | solrChunks=5000 6 | neoURL=bolt://localhost:7687 7 | neoUser=neo4j 8 | neoPass=neo4j 9 | olsurl=http://www.ebi.ac.uk/ols/api 10 | oboDbxrefUrl=https://raw.githubusercontent.com/geneontology/go-site/master/metadata/db-xrefs.yaml 11 | 12 | [Paths] 13 | exportFileDatasources=datasources.csv 14 | exportFileTerms=/path/terms.csv 15 | exportFileMappings=/path/mappings.csv 16 | idorgDataLocation = /path/idorg.xml 17 | 18 | [SQLumls] 19 | user=username 20 | password=password 21 | host=mysql-name 22 | db=dbName 23 | port=4570 24 | 25 | [LOINC] 26 | Part=/path/Part.csv 27 | PartRelatedCodeMapping=/path/PartRelatedCodeMapping.csv 28 | -------------------------------------------------------------------------------- /oxo-loader/load_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python /opt/oxo-loader/OlsDatasetExtractor.py -c $CONFIG_INI -i $IDORG_XML -d $NEO4JIMPORT/datasources.csv 4 | python /opt/oxo-loader/OxoNeo4jLoader.py -W -d datasources.csv -c $CONFIG_INI 5 | 6 | python /opt/oxo-loader/OlsMappingExtractor.py -c $CONFIG_INI -t $NEO4JIMPORT/ols_terms.csv -m $NEO4JIMPORT/ols_mappings.csv 7 | python /opt/oxo-loader/OxoNeo4jLoader.py -c $CONFIG_INI -t ols_terms.csv -m ols_mappings.csv 8 | 9 | #python /app/UmlsMappingExtractor.py -c /app/config/config.ini -t $NEO4JIMPORT/umls_terms.csv -m $NEO4JIMPORT/umls_mappings.csv 10 | #python /app/OxoNeo4jLoader.py -c $CONFIG_INI -t umls_terms.csv -m umls_mappings.csv 11 | -------------------------------------------------------------------------------- /oxo-loader/loader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/oxo-loader/loader.png -------------------------------------------------------------------------------- /oxo-loader/requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2018.1.18 2 | chardet==3.0.4 3 | configparser==3.5.0 4 | idna==2.6 5 | pymysql==0.9.3 6 | neo4j-driver==1.7.6 7 | PyYAML==5.3.1 8 | requests==2.18.4 9 | urllib3==1.22 10 | -------------------------------------------------------------------------------- /oxo-loader/runLoader.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | #module load python-3.10.2-gcc-9.3.0-gswnsij 5 | pip3 install -r requirements.txt 6 | 7 | echo 1 get datasources from OLS 8 | 9 | python3 OlsDatasetExtractor.py -c config.ini -i idorg.xml -d datasources.csv 10 | 11 | echo 2 Load datasources into neo4j 12 | 13 | scp datasources.csv $NEO4J_HOME/import/ 14 | python3 OxoNeo4jLoader.py -W -d datasources.csv -c config.ini 15 | 16 | echo 3 get the OLS mappings 17 | 18 | python3 OlsMappingExtractor.py -c config.ini -t ols_terms.csv -m ols_mappings.csv 19 | 20 | echo 4 load the OLS data into Neo4j 21 | 22 | scp ols_terms.csv $NEO4J_HOME/import 23 | scp ols_mappings.csv $NEO4J_HOME/import 24 | python3 OxoNeo4jLoader.py -c config.ini -t ols_terms.csv -m ols_mappings.csv 25 | 26 | 27 | # get the umls mappings 28 | echo 5 get the umls mappings 29 | 30 | #bsub -Is -M 30000 -R "rusage[mem=30000]" "singularity exec -B /nfs/production/parkinso/spot/oxo/dev/loader:/opt/config -B /nfs/production/parkinso/spot/oxo/dev/import:/opt/oxo-loader/data docker://ebispot/oxo-loader:$OXO_LOADER_VERSION python /opt/oxo-loader/UmlsMappingExtractor.py -c /opt/config/config.ini -t /opt/oxo-loader/data/umls_terms.csv -m /opt/oxo-loader/data/umls_mappings.csv" 31 | 32 | # load the UMLS data into neo4j 33 | echo 6 load the UMLS data into neo4j 34 | 35 | #bsub -Is -M 30000 -R "rusage[mem=30000]" "singularity exec -B /nfs/production/parkinso/spot/oxo/dev/loader:/opt/config docker://ebispot/oxo-loader:$OXO_LOADER_VERSION python /opt/oxo-loader/OxoNeo4jLoader.py -c /opt/config/config.ini -t umls_terms.csv -m umls_mappings.csv" 36 | 37 | # get the LOINC mappings 38 | echo 7 get the LOINC mappings 39 | 40 | #bsub -Is -M 30000 -R "rusage[mem=30000]" "singularity exec -B /nfs/production/parkinso/spot/oxo/dev/loader:/opt/config -B /nfs/production/parkinso/spot/oxo/dev/import:/opt/oxo-loader/data docker://ebispot/oxo-loader:$OXO_LOADER_VERSION python /opt/oxo-loader/LoincMappingExtractor.py -c /opt/config/config.ini -t /opt/oxo-loader/data/loinc_terms.csv -m /opt/oxo-loader/data/loinc_mappings.csv" 41 | 42 | # load the LOINC data into neo4j 43 | echo 8 load the LOINC data into neo4j 44 | 45 | #bsub -Is -M 30000 -R "rusage[mem=30000]" "singularity exec -B /nfs/production/parkinso/spot/oxo/dev/loader:/opt/config docker://ebispot/oxo-loader:$OXO_LOADER_VERSION python /opt/oxo-loader/OxoNeo4jLoader.py -c /opt/config/config.ini -t loinc_terms.csv -m loinc_mappings.csv" -------------------------------------------------------------------------------- /oxo-model/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /oxo-model/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | oxo-model 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /oxo-model/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | oxo 5 | uk.ac.ebi.spot 6 | 0.0.17-SNAPSHOT 7 | ../ 8 | 9 | 4.0.0 10 | 11 | oxo-model 12 | 13 | 14 | 15 | org.springframework.data 16 | spring-data-neo4j 17 | 18 | 19 | 20 | org.neo4j 21 | neo4j-ogm-embedded-driver 22 | 2.0.6 23 | 24 | 25 | 26 | org.springframework.data 27 | spring-data-solr 28 | 29 | 30 | 31 | org.springframework.data 32 | spring-data-rest-core 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-autoconfigure 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/config/IndexCreator.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.neo4j.ogm.model.Result; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.context.event.ApplicationReadyEvent; 6 | import org.springframework.context.ApplicationListener; 7 | import org.springframework.data.neo4j.template.Neo4jOperations; 8 | import org.springframework.data.neo4j.template.Neo4jTemplate; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.HashMap; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 11/05/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | @Component 19 | public class IndexCreator implements ApplicationListener { 20 | 21 | @Autowired 22 | Neo4jOperations neo4jTemplate; 23 | 24 | /** 25 | * This event is executed as late as conceivably possible to indicate that 26 | * the application is ready to service requests. 27 | */ 28 | @Override 29 | public void onApplicationEvent(final ApplicationReadyEvent event) { 30 | 31 | // try { 32 | // Result result = neo4jTemplate.query("CREATE INDEX ON :Term(curie)", new HashMap()); 33 | // result.queryStatistics().toString(); 34 | // 35 | // } catch (Exception ex) { 36 | // ex.printStackTrace(); 37 | // // index already exists? 38 | // } 39 | // 40 | // try { 41 | // neo4jTemplate.query("CREATE INDEX ON :Datasource(prefix)", new HashMap()); 42 | // } catch (Exception ex) { 43 | // ex.printStackTrace(); 44 | // // index already exists? 45 | // } 46 | 47 | try { 48 | neo4jTemplate.query("CREATE CONSTRAINT ON (i:Term) ASSERT i.curie IS UNIQUE", new HashMap()); 49 | } catch (Exception ex) { 50 | ex.printStackTrace(); 51 | // index already exists? 52 | } 53 | 54 | try { 55 | neo4jTemplate.query("CREATE CONSTRAINT ON (i:Datasource) ASSERT i.prefix IS UNIQUE", new HashMap()); 56 | } catch (Exception ex) { 57 | ex.printStackTrace(); 58 | // index already exists? 59 | } 60 | 61 | 62 | return; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/config/OxoNeo4jConfiguration.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.apache.solr.client.solrj.SolrClient; 4 | import org.apache.solr.client.solrj.SolrServer; 5 | import org.apache.solr.client.solrj.impl.HttpSolrClient; 6 | import org.apache.solr.client.solrj.impl.HttpSolrServer; 7 | import org.neo4j.ogm.session.Session; 8 | import org.neo4j.ogm.session.SessionFactory; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.context.annotation.Scope; 14 | import org.springframework.context.annotation.ScopedProxyMode; 15 | import org.springframework.core.env.Environment; 16 | import org.springframework.data.neo4j.config.Neo4jConfiguration; 17 | import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; 18 | import org.springframework.data.solr.core.SolrTemplate; 19 | import org.springframework.data.solr.repository.config.EnableSolrRepositories; 20 | import org.springframework.scheduling.annotation.EnableAsync; 21 | import org.springframework.transaction.PlatformTransactionManager; 22 | import org.springframework.transaction.annotation.EnableTransactionManagement; 23 | import uk.ac.ebi.spot.model.Datasource; 24 | import uk.ac.ebi.spot.model.Mapping; 25 | import uk.ac.ebi.spot.model.Term; 26 | 27 | import java.net.MalformedURLException; 28 | 29 | /** 30 | * @author Simon Jupp 31 | * @since 11/05/2016 32 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 33 | */ 34 | @Configuration 35 | @EnableAsync 36 | @EnableAutoConfiguration 37 | @EnableNeo4jRepositories(basePackages = "uk.ac.ebi.spot.repository", basePackageClasses = {Datasource.class, Term.class, Mapping.class}) 38 | //@EnableSolrRepositories(basePackages = "uk.ac.ebi.spot.index") 39 | @EnableTransactionManagement 40 | public class OxoNeo4jConfiguration extends Neo4jConfiguration { 41 | 42 | @Value("${oxo.neo.driver:org.neo4j.ogm.drivers.http.driver.HttpDriver}") 43 | String driver; 44 | @Value("${oxo.neo.uri:http://localhost:7474}") 45 | String uri; 46 | @Bean 47 | public SessionFactory getSessionFactory() { 48 | // with domain entity base package(s) 49 | return new SessionFactory(getConfiguration(), "uk.ac.ebi.spot.model"); 50 | } 51 | 52 | 53 | public org.neo4j.ogm.config.Configuration getConfiguration() { 54 | org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration(); 55 | config 56 | .driverConfiguration() 57 | .setDriverClassName(driver) 58 | .setURI(uri); 59 | return config; 60 | } 61 | 62 | @Override 63 | public PlatformTransactionManager transactionManager() throws Exception { 64 | return super.transactionManager(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/exception/InvalidCurieException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.exception; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 04/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class InvalidCurieException extends Exception{ 9 | 10 | public InvalidCurieException () { 11 | super(); 12 | } 13 | 14 | public InvalidCurieException (String msg) { 15 | super(msg); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/exception/MappingException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.exception; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 19/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class MappingException extends RuntimeException { 9 | 10 | public MappingException(String s) { 11 | super(s); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/exception/TermCreationException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.exception; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 04/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class TermCreationException extends RuntimeException { 9 | public TermCreationException(String s) { 10 | super(s); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/exception/UnknownDatasourceException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.exception; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 04/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class UnknownDatasourceException extends RuntimeException { 9 | 10 | public UnknownDatasourceException (String msg) { 11 | super(msg); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/exception/UnknownTermException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.exception; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 09/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class UnknownTermException extends RuntimeException { 9 | 10 | public UnknownTermException(String msg) { 11 | super(msg); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/index/Document.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.index; 2 | 3 | import org.apache.solr.client.solrj.beans.Field; 4 | import org.springframework.data.annotation.Id; 5 | import org.springframework.data.solr.core.mapping.SolrDocument; 6 | 7 | import java.util.Collection; 8 | 9 | /** 10 | * @author Simon Jupp 11 | * @since 04/08/2016 12 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 13 | */ 14 | @SolrDocument(solrCoreName = "mapping") 15 | public class Document { 16 | 17 | @Id 18 | private String id; 19 | 20 | @Field("identifier") 21 | private Collection identifier; 22 | 23 | public Collection getKnownIdentifiers() { 24 | return identifier; 25 | } 26 | 27 | public void setKnownIdentifiers(Collection knownIdentifiers) { 28 | this.identifier = knownIdentifiers; 29 | } 30 | 31 | public Document(String curie, Collection knownIdentifiers) { 32 | this.id = curie; 33 | this.identifier = knownIdentifiers; 34 | } 35 | 36 | public String getId() { 37 | return id; 38 | } 39 | 40 | public void setId(String id) { 41 | this.id = id; 42 | } 43 | 44 | public String getCurie() { 45 | return id; 46 | } 47 | 48 | public void setCurie(String curie) { 49 | this.id = curie; 50 | } 51 | 52 | public Document() { 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/index/DocumentRepository.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.index; 2 | 3 | import org.springframework.beans.factory.annotation.Qualifier; 4 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 5 | import org.springframework.data.solr.repository.SolrCrudRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | /** 9 | * @author Simon Jupp 10 | * @since 04/08/2016 11 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 12 | */ 13 | @RepositoryRestResource(exported = false) 14 | public interface DocumentRepository extends SolrCrudRepository { 15 | 16 | Document findOneByIdentifier(String id); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/loader/Loader.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.loader; 2 | 3 | import org.springframework.stereotype.Component; 4 | import uk.ac.ebi.spot.model.MappingSource; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * @author Simon Jupp 10 | * @since 11/05/2016 11 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 12 | */ 13 | @Component 14 | public interface Loader { 15 | 16 | Collection load(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/Curie.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 04/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class Curie { 9 | 10 | private String prefix; 11 | private String local; 12 | 13 | public String toString () { 14 | return prefix+":"+local; 15 | } 16 | public String getPrefix() { 17 | return prefix; 18 | } 19 | 20 | public void setPrefix(String prefix) { 21 | this.prefix = prefix; 22 | } 23 | 24 | public String getLocal() { 25 | return local; 26 | } 27 | 28 | public void setLocal(String local) { 29 | this.local = local; 30 | } 31 | 32 | public Curie(String prefix, String local) { 33 | 34 | this.prefix = prefix; 35 | this.local = local; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/Datasource.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.neo4j.ogm.annotation.GraphId; 5 | import org.neo4j.ogm.annotation.NodeEntity; 6 | import org.neo4j.ogm.annotation.Property; 7 | import org.springframework.beans.factory.annotation.Required; 8 | 9 | import java.io.Serializable; 10 | import java.util.HashSet; 11 | import java.util.Set; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 11/05/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | @NodeEntity (label = "Datasource") 19 | public class Datasource implements Serializable { 20 | 21 | @GraphId 22 | @JsonIgnore 23 | private Long id; 24 | 25 | // always LC 26 | @Property(name="prefix") 27 | private String prefix; 28 | 29 | @Property(name="preferredPrefix") 30 | private String preferredPrefix; 31 | 32 | @Property(name="idorgNamespace") 33 | private String idorgNamespace; 34 | 35 | @Property(name="alternatePrefix") 36 | private Set alternatePrefix = new HashSet<>(); 37 | 38 | @Property(name="alternateIris") 39 | private Set alternateIris = new HashSet<>(); 40 | 41 | @Property(name="name") 42 | private String name; 43 | 44 | @Property(name="orcid") 45 | private String orcid; 46 | 47 | @Property(name="description") 48 | private String description; 49 | 50 | @Property(name = "sourceType") 51 | private SourceType source; 52 | 53 | @Property(name="licence") 54 | private String licence; 55 | 56 | @Property(name="versionInfo") 57 | private String versionInfo; 58 | 59 | public Datasource(String prefix, String preferredPrefix, String idorgNamespace, Set alternatePrefix, String name, String description, SourceType source) { 60 | this.prefix = prefix; 61 | this.preferredPrefix = preferredPrefix; 62 | this.idorgNamespace = idorgNamespace; 63 | this.alternatePrefix = alternatePrefix; 64 | this.name = name; 65 | this.description = description; 66 | this.source = source; 67 | } 68 | 69 | public Datasource() { 70 | 71 | } 72 | 73 | public String getPreferredPrefix() { 74 | if (preferredPrefix == null) { 75 | return getPrefix(); 76 | } 77 | return preferredPrefix; 78 | } 79 | 80 | public void setPreferredPrefix(String preferredPrefix) { 81 | this.preferredPrefix = preferredPrefix; 82 | } 83 | 84 | public Set getAlternateIris() { 85 | return alternateIris; 86 | } 87 | 88 | public void setAlternateIris(Set alternateIris) { 89 | this.alternateIris = alternateIris; 90 | } 91 | 92 | public String getIdorgNamespace() { 93 | return idorgNamespace; 94 | } 95 | 96 | public void setIdorgNamespace(String idorgNamespace) { 97 | this.idorgNamespace = idorgNamespace; 98 | } 99 | 100 | public Set getAlternatePrefix() { 101 | return alternatePrefix; 102 | } 103 | 104 | public void setAlternatePrefix(Set alternatePrefix) { 105 | this.alternatePrefix = alternatePrefix; 106 | } 107 | 108 | public String getPrefix() { 109 | return prefix; 110 | } 111 | 112 | public String getOrcid() { 113 | return orcid; 114 | } 115 | 116 | public String getVersionInfo() { 117 | return versionInfo; 118 | } 119 | 120 | public void setVersionInfo(String versionInfo) { 121 | this.versionInfo = versionInfo; 122 | } 123 | 124 | public String getLicence() { 125 | return licence; 126 | } 127 | 128 | public void setLicence(String licence) { 129 | this.licence = licence; 130 | } 131 | 132 | public void setOrcid(String orcid) { 133 | this.orcid = orcid; 134 | } 135 | 136 | public void setPrefix(String prefix) { 137 | this.prefix = prefix; 138 | } 139 | 140 | public String getName() { 141 | return name; 142 | } 143 | 144 | public void setName(String name) { 145 | this.name = name; 146 | } 147 | 148 | public String getDescription() { 149 | return description; 150 | } 151 | 152 | public void setDescription(String description) { 153 | this.description = description; 154 | } 155 | 156 | public SourceType getSource() { 157 | return source; 158 | } 159 | 160 | public void setSource(SourceType source) { 161 | this.source = source; 162 | } 163 | 164 | public Long getId() { 165 | return id; 166 | } 167 | 168 | public void setId(Long id) { 169 | this.id = id; 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/IndexableTermInfo.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import org.springframework.data.neo4j.annotation.QueryResult; 4 | 5 | /** 6 | * @author Simon Jupp 7 | * @since 27/03/2017 8 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 9 | * 10 | * This is a convenience object that is a stripped down version of a term, with only the information needed to create the Document for saving in the Document repository 11 | * 12 | */ 13 | @QueryResult 14 | public class IndexableTermInfo { 15 | 16 | private String curie; 17 | private String id; 18 | private String uri; 19 | private String[] alternatePrefixes; 20 | 21 | public String getCurie() { 22 | return curie; 23 | } 24 | 25 | public void setCurie(String curie) { 26 | this.curie = curie; 27 | } 28 | 29 | public String getId() { 30 | return id; 31 | } 32 | 33 | public void setId(String id) { 34 | this.id = id; 35 | } 36 | 37 | public String getUri() { 38 | return uri; 39 | } 40 | 41 | public void setUri(String uri) { 42 | this.uri = uri; 43 | } 44 | 45 | public String[] getAlternatePrefixes() { 46 | return alternatePrefixes; 47 | } 48 | 49 | public void setAlternatePrefixes(String[] alternatePrefixes) { 50 | this.alternatePrefixes = alternatePrefixes; 51 | } 52 | 53 | public IndexableTermInfo(String curie, String id, String uri, String[] alternatePrefixes) { 54 | 55 | this.curie = curie; 56 | this.id = id; 57 | this.uri = uri; 58 | this.alternatePrefixes = alternatePrefixes; 59 | } 60 | 61 | public IndexableTermInfo() { 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/Mapping.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import org.neo4j.ogm.annotation.*; 4 | import org.neo4j.ogm.annotation.typeconversion.Convert; 5 | import org.neo4j.ogm.annotation.typeconversion.DateString; 6 | import uk.ac.ebi.spot.util.DatasourceConverter; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * @author Simon Jupp 12 | * @since 11/05/2016 13 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 14 | */ 15 | @RelationshipEntity(type = "MAPPING") 16 | public class Mapping { 17 | 18 | @GraphId 19 | private Long mappingId; 20 | 21 | @Convert(DatasourceConverter.class) 22 | private Datasource datasource; 23 | 24 | @Property 25 | private String sourcePrefix; 26 | 27 | @Property 28 | private SourceType sourceType = SourceType.MANUAL; 29 | 30 | @Property 31 | private SourceType predicate; 32 | 33 | @StartNode 34 | private Term fromTerm; 35 | 36 | @EndNode 37 | private Term toTerm; 38 | 39 | @Property 40 | private Scope scope = Scope.RELATED; 41 | 42 | @DateString("yy-MM-dd") 43 | private Date date; 44 | 45 | public Mapping() { 46 | } 47 | 48 | public Long getMappingId() { 49 | return mappingId; 50 | } 51 | 52 | public void setMappingId(Long mappingId) { 53 | this.mappingId = mappingId; 54 | } 55 | 56 | public Term getFromTerm() { 57 | return fromTerm; 58 | } 59 | 60 | public SourceType getSourceType() { 61 | return sourceType; 62 | } 63 | 64 | public void setSourceType(SourceType sourceType) { 65 | this.sourceType = sourceType; 66 | } 67 | 68 | public void setFromTerm(Term fromTerm) { 69 | this.fromTerm = fromTerm; 70 | } 71 | 72 | public Term getToTerm() { 73 | return toTerm; 74 | } 75 | 76 | public void setToTerm(Term toTerm) { 77 | this.toTerm = toTerm; 78 | } 79 | 80 | public void setScope(Scope scope) { 81 | this.scope = scope; 82 | } 83 | 84 | public SourceType getPredicate() { 85 | return predicate; 86 | } 87 | 88 | public void setPredicate(SourceType predicate) { 89 | this.predicate = predicate; 90 | } 91 | 92 | public void setDate(Date date) { 93 | this.date = date; 94 | } 95 | 96 | public void setDatasource(Datasource datasource) { 97 | this.datasource = datasource; 98 | } 99 | 100 | public void setSourcePrefix(String sourcePrefix) { 101 | this.sourcePrefix = sourcePrefix; 102 | } 103 | 104 | public Datasource getDatasource() { 105 | return datasource; 106 | } 107 | 108 | public String getSourcePrefix() { 109 | return sourcePrefix; 110 | } 111 | 112 | public Scope getScope() { 113 | return scope; 114 | } 115 | 116 | public Date getDate() { 117 | return date; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/MappingRequest.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 09/08/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class MappingRequest { 9 | 10 | private String fromId; 11 | private String toId; 12 | private String datasourcePrefix; 13 | private SourceType sourceType; 14 | private Scope scope; 15 | 16 | public MappingRequest(String fromId, String toId, String datasourcePrefix, SourceType sourceType, Scope scope) { 17 | this.fromId = fromId; 18 | this.toId = toId; 19 | this.datasourcePrefix = datasourcePrefix; 20 | this.sourceType = sourceType; 21 | this.scope = scope; 22 | } 23 | 24 | public MappingRequest() { 25 | 26 | } 27 | 28 | public String getFromId() { 29 | return fromId; 30 | } 31 | 32 | public void setFromId(String fromId) { 33 | this.fromId = fromId; 34 | } 35 | 36 | public String getToId() { 37 | return toId; 38 | } 39 | 40 | public void setToId(String toId) { 41 | this.toId = toId; 42 | } 43 | 44 | public String getDatasourcePrefix() { 45 | return datasourcePrefix; 46 | } 47 | 48 | public void setDatasourcePrefix(String datasourcePrefix) { 49 | this.datasourcePrefix = datasourcePrefix; 50 | } 51 | 52 | public SourceType getSourceType() { 53 | return sourceType; 54 | } 55 | 56 | public void setSourceType(SourceType sourceType) { 57 | this.sourceType = sourceType; 58 | } 59 | 60 | public Scope getScope() { 61 | return scope; 62 | } 63 | 64 | public void setScope(Scope scope) { 65 | this.scope = scope; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/MappingSource.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import uk.ac.ebi.spot.model.Datasource; 4 | import uk.ac.ebi.spot.model.Mapping; 5 | 6 | import java.util.Collection; 7 | 8 | /** 9 | * @author Simon Jupp 10 | * @since 13/05/2016 11 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 12 | */ 13 | public class MappingSource { 14 | 15 | Datasource datasource; 16 | Collection mappings; 17 | 18 | public Datasource getDatasource() { 19 | return datasource; 20 | } 21 | 22 | public Collection getMappings() { 23 | return mappings; 24 | } 25 | 26 | public MappingSource(Datasource datasource, Collection mappings) { 27 | 28 | this.datasource = datasource; 29 | this.mappings = mappings; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/Scope.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 11/05/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public enum Scope { 9 | EXACT, 10 | // NARROW, 11 | // BROAD, 12 | NARROWER, 13 | BROADER, 14 | RELATED, 15 | PREDICTED 16 | } 17 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/SourceType.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 11/05/2016 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public enum SourceType { 9 | ONTOLOGY, 10 | DATABASE, 11 | ALGORITHM, 12 | USER, 13 | MANUAL 14 | } 15 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/model/Term.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.neo4j.ogm.annotation.GraphId; 5 | import org.neo4j.ogm.annotation.NodeEntity; 6 | import org.neo4j.ogm.annotation.Property; 7 | import org.neo4j.ogm.annotation.Relationship; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.io.Serializable; 11 | 12 | /** 13 | * @author Simon Jupp 14 | * @since 11/05/2016 15 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 16 | */ 17 | @NodeEntity(label="Term") 18 | public class Term implements Serializable { 19 | 20 | 21 | @GraphId 22 | @JsonIgnore 23 | private Long id; 24 | 25 | @Property(name="curie") 26 | private String curie; 27 | 28 | @Property(name="identifier") 29 | private String identifier; 30 | 31 | @Property(name="uri") 32 | private String uri; 33 | 34 | @Property(name="label") 35 | private String label; 36 | 37 | @Relationship(type="HAS_SOURCE", direction=Relationship.OUTGOING) 38 | private Datasource datasource; 39 | 40 | public Term() { 41 | 42 | } 43 | 44 | public Term(String curie, String identifier, String uri, String label, Datasource datasource) { 45 | this.curie = curie; 46 | this.identifier = identifier; 47 | this.uri = uri; 48 | this.label = label; 49 | this.datasource = datasource; 50 | } 51 | 52 | public void setId(Long id) { 53 | this.id = id; 54 | } 55 | 56 | public Datasource getDatasource() { 57 | return datasource; 58 | } 59 | 60 | public void setDatasource(Datasource datasource) { 61 | this.datasource = datasource; 62 | } 63 | 64 | public String getCurie() { 65 | return curie; 66 | } 67 | 68 | public void setCurie(String curie) { 69 | this.curie = curie; 70 | } 71 | 72 | public Long getId() { 73 | return id; 74 | } 75 | 76 | public String getIdentifier() { 77 | return identifier; 78 | } 79 | 80 | public void setIdentifier(String identifier) { 81 | this.identifier = identifier; 82 | } 83 | 84 | public String getUri() { 85 | return uri; 86 | } 87 | 88 | public void setUri(String uri) { 89 | this.uri = uri; 90 | } 91 | 92 | public String getLabel() { 93 | return label; 94 | } 95 | 96 | public void setLabel(String label) { 97 | this.label = label; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/repository/DatasourceRepository.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.repository; 2 | 3 | import org.springframework.cache.annotation.Cacheable; 4 | import org.springframework.data.neo4j.annotation.Query; 5 | import org.springframework.data.neo4j.repository.GraphRepository; 6 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 7 | import org.springframework.stereotype.Repository; 8 | import uk.ac.ebi.spot.model.Datasource; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author Simon Jupp 14 | * @since 11/05/2016 15 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 16 | */ 17 | @Repository 18 | @RepositoryRestResource(exported = false) 19 | public interface DatasourceRepository extends GraphRepository { 20 | 21 | @Query("match (n:Datasource) WHERE n.prefix = {0} OR {0} IN n.alternatePrefix return n") 22 | Datasource findByPrefix(String prefix); 23 | 24 | @Query("match (n:Datasource)<-[:HAS_SOURCE]-(:Term) RETURN distinct n ORDER BY n.name") 25 | @Cacheable("dataSourcesWithMappings") 26 | List getDatasourcesWithMappings(); 27 | 28 | @Query("MATCH ()-[r:MAPPING]->()\n" + 29 | "WITH collect (distinct r.sourcePrefix) as prefixes\n" + 30 | "UNWIND prefixes as p1\n" + 31 | "MATCH (d:Datasource) WHERE p1 in d.alternatePrefix\n" + 32 | "return d") 33 | List getMappingDatasources(); 34 | } 35 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/repository/MappingRepository.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.repository; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.neo4j.repository.GraphRepository; 7 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 8 | import org.springframework.stereotype.Repository; 9 | import uk.ac.ebi.spot.model.Datasource; 10 | import uk.ac.ebi.spot.model.Mapping; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author Simon Jupp 16 | * @since 11/05/2016 17 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 18 | */ 19 | @Repository 20 | @RepositoryRestResource(exported = false) 21 | public interface MappingRepository extends GraphRepository { 22 | Iterable findAllBySourcePrefix(String sourcePrefix); 23 | 24 | 25 | @Query("MATCH (td)-[m:MAPPING]-(ft)-[HAS_SOURCE]-(d:Datasource)\n" + 26 | "WHERE d.prefix = {0} or m.sourcePrefix = {0}\n" + 27 | "RETURN m") 28 | List findAllByAnySource(String sourcePrefix); 29 | 30 | @Query("MATCH (td)-[m:MAPPING]-(ft)-[HAS_SOURCE]-(d:Datasource)\n" + 31 | "WHERE d.prefix = {0} or m.sourcePrefix = {0}\n" + 32 | "RETURN m SKIP {1} LIMIT {2}") 33 | List findAllByAnySource(String sourcePrefix, long skip, long limit); 34 | 35 | @Query("match (f:Term)-[r:MAPPING]-(t:Term) WHERE f.curie = {0} AND t.curie = {1} and r.sourcePrefix = {2} and r.scope = {3} return r") 36 | Mapping findOneByMappingBySourceAndId(String fromId, String toId, String source, String scope); 37 | 38 | @Query("match (f:Term)-[r:MAPPING]-(t:Term) WHERE f.curie = {0} AND t.curie = {1} return r") 39 | List findMappingsById(String fromId, String toId); 40 | 41 | @Query("match (f:Term)-[r:MAPPING]-(t:Term) WHERE f.curie = {0} AND t.curie = {1} return r SKIP {2} LIMIT {3}") 42 | List findMappingsById(String fromId, String toId, long skip, long limit); 43 | 44 | @Query("match (f:Term)-[r:MAPPING]-(t:Term) WHERE f.curie = {0} return r") 45 | List findMappingsById(String fromId); 46 | 47 | @Query("match (f:Term)-[r:MAPPING]-(t:Term) WHERE f.curie = {0} return r SKIP {1} LIMIT {2}") 48 | List findMappingsById(String fromId, long skip, long limit); 49 | 50 | 51 | @Query("match path = allShortestPaths ( (f:Term)-[r:MAPPING*1..3]-(t:Term) ) WHERE f.curie = {0} AND t.curie = {1} with rels(path) as m, length(path) as l WHERE l> 1 return m") 52 | List findInferredMappingsById(String fromId, String toId); 53 | 54 | 55 | @Query("MATCH (td)-[m:MAPPING]-()\n" + 56 | "WHERE m.sourcePrefix = {0}\n" + 57 | "RETURN count(m)") 58 | int getMappingsCountBySource(String prefix); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/repository/TermGraphRepository.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.repository; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.neo4j.repository.GraphRepository; 7 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 8 | import uk.ac.ebi.spot.model.IndexableTermInfo; 9 | import uk.ac.ebi.spot.model.Term; 10 | 11 | import java.util.Collection; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 12/05/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | @RepositoryRestResource(exported = false) 19 | public interface TermGraphRepository extends GraphRepository { 20 | 21 | Term findByCurie(String curie); 22 | 23 | @Query(value = "MATCH (n:Term)-[HAS_SOURCE]->(d:Datasource) WHERE d.prefix = {0} RETURN n SKIP {1} LIMIT {2}") 24 | Collection findByDatasource(String prefix, long skip, long limit); 25 | 26 | @Query(value = "MATCH (n:Term)-[HAS_SOURCE]->(d:Datasource) WHERE d.prefix = {0} RETURN count(n)") 27 | int getTermCountBySource(String prefix); 28 | 29 | @Query(value = "MATCH (n:Term)-[HAS_SOURCE]->(d:Datasource) RETURN count(DISTINCT n)") 30 | int getIndexableTermCount(); 31 | 32 | @Query(value = "Match (t:Term)-[:HAS_SOURCE]->(d:Datasource) RETURN DISTINCT t.curie as curie, t.id as id, t.uri as uri, d.alternatePrefix as alternatePrefixes") 33 | Iterable getAllIndexableTerms(); 34 | 35 | @Query(value = "Match (t:Term)-[:HAS_SOURCE]->(d:Datasource) RETURN DISTINCT t.curie as curie, t.id as id, t.uri as uri, d.alternatePrefix as alternatePrefixes ORDER BY curie SKIP {0} LIMIT {1}") 36 | Iterable getAllIndexableTerms(long skip, long limit); 37 | } 38 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/DatasourceService.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import org.neo4j.cypher.CypherException; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.dao.DuplicateKeyException; 8 | import org.springframework.data.domain.Page; 9 | import org.springframework.data.domain.PageRequest; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.stereotype.Service; 12 | import org.springframework.transaction.annotation.Transactional; 13 | import uk.ac.ebi.spot.exception.InvalidCurieException; 14 | import uk.ac.ebi.spot.exception.UnknownDatasourceException; 15 | import uk.ac.ebi.spot.index.Document; 16 | import uk.ac.ebi.spot.index.DocumentRepository; 17 | import uk.ac.ebi.spot.model.Datasource; 18 | import uk.ac.ebi.spot.model.Term; 19 | import uk.ac.ebi.spot.repository.DatasourceRepository; 20 | import uk.ac.ebi.spot.repository.TermGraphRepository; 21 | 22 | import javax.xml.crypto.Data; 23 | import java.util.*; 24 | import java.util.stream.Collectors; 25 | 26 | /** 27 | * @author Simon Jupp 28 | * @since 12/05/2016 29 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 30 | */ 31 | @Service 32 | public class DatasourceService { 33 | 34 | @Autowired 35 | public DatasourceRepository datasourceRepository; 36 | 37 | @Autowired 38 | public DocumentRepository documentRepository; 39 | 40 | @Autowired 41 | private TermGraphRepository termGraphRepository; 42 | 43 | private Logger log = LoggerFactory.getLogger(getClass()); 44 | 45 | /** 46 | * This gets a datasource by prefix and also search alternate prefixes 47 | * @param prefix 48 | * @return 49 | */ 50 | public Datasource getDatasource (String prefix) { 51 | return datasourceRepository.findByPrefix(prefix.toLowerCase()); 52 | } 53 | 54 | public Page getDatasources(Pageable pageable) { 55 | return datasourceRepository.findAll(pageable,0); 56 | } 57 | 58 | private List cachedDatasourcesWithMappings = new ArrayList<>(); 59 | public List getDatasourceWithMappings() { 60 | // if (cachedDatasourcesWithMappings.isEmpty()) { 61 | // cachedDatasourcesWithMappings = datasourceRepository.getDatasourcesWithMappings(); 62 | // } 63 | // return cachedDatasourcesWithMappings; 64 | return datasourceRepository.getDatasourcesWithMappings(); 65 | } 66 | 67 | public List getMappingSources() { 68 | 69 | return datasourceRepository.getMappingDatasources(); 70 | } 71 | 72 | @Transactional("transactionManager") 73 | public Datasource save (Datasource datasource) throws DuplicateKeyException { 74 | try { 75 | 76 | if (datasourceRepository.findByPrefix(datasource.getPrefix()) != null) { 77 | throw new DuplicateKeyException("Duplicate key exception, datasource already exists using this prefix: " + datasource.getPrefix()); 78 | } 79 | 80 | datasource.getAlternatePrefix().add(datasource.getPrefix()); 81 | Set lcStrings = datasource.getAlternatePrefix().stream().map(String::toLowerCase).collect(Collectors.toSet()); 82 | datasource.getAlternatePrefix().addAll(lcStrings); 83 | return datasourceRepository.save(datasource); 84 | } catch (org.neo4j.ogm.exception.CypherException e) { 85 | if (e.getCode().contains("ConstraintValidationFailed")) { 86 | throw new DuplicateKeyException("Duplicate key exception, datasource already exists: " + datasource.getPrefix()); 87 | } 88 | throw new RuntimeException("Error saving datasource", e); 89 | } 90 | } 91 | 92 | @Transactional("transactionManager") 93 | public Datasource update (Datasource datasource) throws InvalidCurieException, DuplicateKeyException { 94 | Datasource d = datasourceRepository.findByPrefix(datasource.getPrefix()); 95 | 96 | // don't allow prefixes to be edited 97 | if (d == null) { 98 | throw new InvalidCurieException("You can't change an existing prefix for a datasource"); 99 | } 100 | 101 | datasource.setId(d.getId()); 102 | datasource.setPrefix(d.getPrefix()); 103 | d = datasourceRepository.save(datasource); 104 | Collection terms = termGraphRepository.findByDatasource(d.getPrefix(), 0, Integer.MAX_VALUE); 105 | 106 | Collection documents = new HashSet<>(); 107 | 108 | for (Term t : terms) { 109 | documentRepository.delete(t.getCurie()); 110 | documents.add(DocumentBuilder.getDocumentFromTerm(t)); 111 | } 112 | documentRepository.save(documents); 113 | 114 | return d; 115 | } 116 | 117 | 118 | 119 | 120 | public Datasource getOrCreateDatasource (Datasource datasource){ 121 | Datasource existingSource = datasourceRepository.findByPrefix(datasource.getPrefix()); 122 | 123 | if (existingSource == null) { 124 | return save(datasource); 125 | } 126 | return existingSource; 127 | 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/DocumentBuilder.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import uk.ac.ebi.spot.index.Document; 4 | import uk.ac.ebi.spot.model.Datasource; 5 | import uk.ac.ebi.spot.model.IndexableTermInfo; 6 | import uk.ac.ebi.spot.model.Term; 7 | 8 | import javax.xml.crypto.Data; 9 | import java.util.HashSet; 10 | import java.util.Set; 11 | import java.util.stream.Collectors; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 04/08/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | public class DocumentBuilder { 19 | 20 | private static String COLON=":"; 21 | 22 | static Document getDocumentFromTerm (Term term) { 23 | 24 | Datasource datasource = term.getDatasource(); 25 | 26 | return getDocumentFromTerm(new IndexableTermInfo(term.getCurie(), term.getIdentifier(), term.getUri(), datasource.getAlternatePrefix().toArray(new String [datasource.getAlternatePrefix().size()]))); 27 | 28 | } 29 | 30 | public static Document getDocumentFromTerm(IndexableTermInfo term) { 31 | Set identifiers = new HashSet<>(); 32 | 33 | identifiers.add(term.getCurie()); 34 | identifiers.add(term.getCurie().replaceAll(":", "_")); 35 | identifiers.add(term.getId()); 36 | if (term.getUri() != null) { 37 | identifiers.add(term.getUri()); 38 | } 39 | for (String s: term.getAlternatePrefixes()) { 40 | identifiers.add(s+COLON+term.getId()); 41 | } 42 | return new Document(term.getCurie(), identifiers); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/MappingBuilder.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import uk.ac.ebi.spot.model.*; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * @author Simon Jupp 9 | * @since 11/05/2016 10 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 11 | */ 12 | public class MappingBuilder { 13 | 14 | private Term fromTerm; 15 | 16 | private Term toTerm; 17 | 18 | private Scope scope; 19 | private SourceType source; 20 | private Date date; 21 | 22 | private Datasource mappingSource; 23 | 24 | public MappingBuilder( 25 | 26 | Term fromTerm, 27 | Term toTerm, 28 | Datasource mappingSource) { 29 | this.date = new Date(); 30 | this.scope = Scope.RELATED; 31 | this.source = SourceType.MANUAL; 32 | this.mappingSource = mappingSource; 33 | this.fromTerm = fromTerm; 34 | this.toTerm = toTerm; 35 | 36 | } 37 | 38 | public MappingBuilder setFromId(Term fromTerm) { 39 | this.fromTerm = fromTerm; 40 | return this; 41 | } 42 | 43 | 44 | public MappingBuilder setToId(Term toTerm) { 45 | this.toTerm = toTerm; 46 | return this; 47 | } 48 | 49 | 50 | 51 | 52 | public MappingBuilder setScope(Scope scope) { 53 | this.scope = scope; 54 | return this; 55 | } 56 | 57 | public MappingBuilder setSource(SourceType source) { 58 | this.source = source; 59 | return this; 60 | } 61 | 62 | public MappingBuilder setDate(Date date) { 63 | this.date = date; 64 | return this; 65 | } 66 | 67 | public MappingBuilder setMappingSource(Datasource mappingSource) { 68 | this.mappingSource = mappingSource; 69 | return this; 70 | } 71 | 72 | public Mapping build() { 73 | 74 | Mapping mapping; 75 | 76 | mapping = new Mapping(); 77 | 78 | 79 | mapping.setDatasource(this.mappingSource); 80 | mapping.setSourcePrefix(this.mappingSource.getPrefix()); 81 | mapping.setFromTerm(fromTerm); 82 | mapping.setToTerm(toTerm); 83 | mapping.setDate(this.date); 84 | mapping.setScope(this.scope); 85 | mapping.setSourceType(this.source); 86 | 87 | 88 | return mapping; 89 | } 90 | 91 | 92 | 93 | } 94 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/MappingQueryService.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import uk.ac.ebi.spot.model.IndexableTermInfo; 6 | 7 | import java.util.Collection; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * @author Simon Jupp 13 | * @since 30/08/2016 14 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 15 | */ 16 | public interface MappingQueryService { 17 | 18 | /** 19 | * Get a summary mapping results by searching mappings 20 | * @param id the id to search 21 | * @param distance the distance to search for mappings, default 1, use -1 for unlimited 22 | * @param sourcePrefix list of mapping source prefixes to filter on 23 | * @param targetPrefix list of mappingf target profiuces to filter 24 | * @return 25 | */ 26 | SearchResult getMappingResponseSearchById (String id, int distance, Collection sourcePrefix, Collection targetPrefix); 27 | 28 | /** 29 | * Get a summary mapping results by searching mappings 30 | * @param fromDatasource the id to search 31 | * @param distance the distance to search for mappings, default 1, use -1 for unlimited 32 | * @param sourcePrefix list of mapping source prefixes to filter on 33 | * @param targetPrefix list of mappingf target profiuces to filter 34 | * @return 35 | */ 36 | Page getMappingResponseSearchByDatasource (String fromDatasource, int distance, Collection sourcePrefix, Collection targetPrefix, Pageable pageable); 37 | 38 | /** 39 | * Get a graph representation of the mappings for the existing id 40 | * @param curie 41 | * @return 42 | */ 43 | Object getMappingSummaryGraph(String curie, int distance); 44 | 45 | /** 46 | * Get an Object that reflects a mapping summary 47 | */ 48 | Object getMappingSummary(); 49 | 50 | /** 51 | * Get an Object that reflects a mapping summary by datasource 52 | */ 53 | Object getMappingSummary(String sourcePrefix); 54 | 55 | /** 56 | * Get a list of curies for a given target datasource and distance. This is an optimised convenience query used by the UI 57 | * @param fromDatasource the from datasource 58 | * @param targetDatasource the target datasource for mappings 59 | * @param distance defaults to 3 60 | * @return 61 | */ 62 | List getMappedTermCuries(String fromDatasource, String targetDatasource, int distance); 63 | 64 | /** 65 | * Get a list of target datasources and counts for a given input source and distance. This is an optimised convenience query used by the UI 66 | * @param fromDatasource the from datasoource 67 | * @param distance defaults to 3 68 | * @return 69 | */ 70 | Map getMappedTargetCounts(String fromDatasource, int distance); 71 | 72 | } 73 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/MappingResponse.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * @author Simon Jupp 7 | * @since 30/08/2016 8 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 9 | */ 10 | public class MappingResponse { 11 | 12 | private String curie; 13 | private String label; 14 | private Collection sourcePrefixes; 15 | private String targetPrefix; 16 | private int distance; 17 | 18 | public MappingResponse() { 19 | } 20 | 21 | public MappingResponse(String curie, String label, Collection sourcePrefixes, String targetPrefix, int distance) { 22 | this.curie = curie; 23 | this.label = label; 24 | this.sourcePrefixes = sourcePrefixes; 25 | this.targetPrefix = targetPrefix; 26 | this.distance = distance; 27 | } 28 | 29 | public String getCurie() { 30 | return curie; 31 | } 32 | 33 | public void setCurie(String curie) { 34 | this.curie = curie; 35 | } 36 | 37 | public String getLabel() { 38 | return label; 39 | } 40 | 41 | public void setLabel(String label) { 42 | this.label = label; 43 | } 44 | 45 | public Collection getSourcePrefixes() { 46 | return sourcePrefixes; 47 | } 48 | 49 | public void setSourcePrefixes(Collection sourcePrefixes) { 50 | this.sourcePrefixes = sourcePrefixes; 51 | } 52 | 53 | public String getTargetPrefix() { 54 | return targetPrefix; 55 | } 56 | 57 | public void setTargetPrefix(String targetPrefix) { 58 | this.targetPrefix = targetPrefix; 59 | } 60 | 61 | public int getDistance() { 62 | return distance; 63 | } 64 | 65 | public void setDistance(int distance) { 66 | this.distance = distance; 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/SearchResult.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Simon Jupp 7 | * @since 05/09/2016 8 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 9 | */ 10 | public class SearchResult { 11 | 12 | String queryId; 13 | String querySource; 14 | String curie; 15 | String label; 16 | List mappingResponseList; 17 | 18 | public SearchResult() { 19 | } 20 | 21 | public SearchResult(String queryId, String querySource, String curie, String label, List mappingResponseList) { 22 | this.queryId = queryId; 23 | this.querySource = querySource; 24 | this.curie = curie; 25 | this.label = label; 26 | this.mappingResponseList = mappingResponseList; 27 | } 28 | 29 | public String getQueryId() { 30 | return queryId; 31 | } 32 | 33 | public void setQueryId(String queryId) { 34 | this.queryId = queryId; 35 | } 36 | 37 | public String getQuerySource() { 38 | return querySource; 39 | } 40 | 41 | public void setQuerySource(String querySource) { 42 | this.querySource = querySource; 43 | } 44 | 45 | public String getCurie() { 46 | return curie; 47 | } 48 | 49 | public void setCurie(String curie) { 50 | this.curie = curie; 51 | } 52 | 53 | public String getLabel() { 54 | return label; 55 | } 56 | 57 | public void setLabel(String label) { 58 | this.label = label; 59 | } 60 | 61 | public List getMappingResponseList() { 62 | return mappingResponseList; 63 | } 64 | 65 | public void setMappingResponseList(List mappingResponseList) { 66 | this.mappingResponseList = mappingResponseList; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/SearchResultsCsvBuilder.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | import au.com.bytecode.opencsv.CSVWriter; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.io.IOException; 7 | import java.io.OutputStream; 8 | import java.io.OutputStreamWriter; 9 | import java.util.ArrayList; 10 | import java.util.Iterator; 11 | import java.util.List; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 05/10/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | //@Component 19 | public class SearchResultsCsvBuilder { 20 | 21 | private CSVWriter csvWriter; 22 | 23 | public SearchResultsCsvBuilder (char seperator, OutputStream outputStream) { 24 | OutputStreamWriter writer = new OutputStreamWriter(outputStream); 25 | this.csvWriter = new CSVWriter(writer, seperator); 26 | 27 | } 28 | 29 | static String [] HEADERS = {"curie_id", "label", "mapped_curie", "mapped_label", "mapping_source_prefix", "mapping_target_prefix", "distance" }; 30 | 31 | public void writeHeaders() { 32 | csvWriter.writeNext( 33 | HEADERS 34 | ); 35 | try { 36 | csvWriter.flush(); 37 | } catch (IOException e) { 38 | e.printStackTrace(); 39 | } 40 | } 41 | 42 | public void writeResultsAsCsv(List searchResultList ) { 43 | 44 | 45 | try { 46 | Iterator r = searchResultList.iterator(); 47 | while (r.hasNext()) { 48 | 49 | SearchResult result = (SearchResult) r.next(); 50 | 51 | 52 | for (MappingResponse response : result.getMappingResponseList()) { 53 | List row = new ArrayList<>(); 54 | row.add(result.getCurie()); 55 | row.add(result.getLabel()); 56 | 57 | row.add(response.getCurie()); 58 | row.add(response.getLabel()); 59 | row.add(StringUtils.join(response.getSourcePrefixes(), ',')); 60 | row.add(response.getTargetPrefix()); 61 | row.add(String.valueOf(response.getDistance())); 62 | 63 | csvWriter.writeNext(row.toArray(new String [row.size()])); 64 | } 65 | csvWriter.flush(); 66 | 67 | } 68 | 69 | } catch (IOException e) { 70 | e.printStackTrace(); 71 | } 72 | } 73 | 74 | public void close() { 75 | try { 76 | csvWriter.close(); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/service/SimpleCache.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.service; 2 | 3 | 4 | import org.apache.commons.collections4.MapIterator; 5 | import org.apache.commons.collections4.map.LRUMap; 6 | 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.Iterator; 10 | import java.util.Map; 11 | 12 | /** 13 | * @author Simon Jupp 14 | * @since 29/03/2017 15 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 16 | */ 17 | public class SimpleCache { 18 | 19 | private long timeToLive; 20 | private LRUMap crunchifyCacheMap; 21 | 22 | protected class CrunchifyCacheObject { 23 | public long lastAccessed = System.currentTimeMillis(); 24 | public T value; 25 | 26 | protected CrunchifyCacheObject(T value) { 27 | this.value = value; 28 | } 29 | } 30 | 31 | public SimpleCache(long crunchifyTimeToLive, final long crunchifyTimerInterval, int maxItems) { 32 | this.timeToLive = crunchifyTimeToLive * 1000; 33 | 34 | crunchifyCacheMap = new LRUMap(maxItems); 35 | 36 | if (timeToLive > 0 && crunchifyTimerInterval > 0) { 37 | 38 | Thread t = new Thread(new Runnable() { 39 | public void run() { 40 | while (true) { 41 | try { 42 | Thread.sleep(crunchifyTimerInterval * 1000); 43 | } catch (InterruptedException ex) { 44 | } 45 | cleanup(); 46 | } 47 | } 48 | }); 49 | 50 | t.setDaemon(true); 51 | t.start(); 52 | } 53 | } 54 | 55 | public void put(K key, T value) { 56 | synchronized (crunchifyCacheMap) { 57 | crunchifyCacheMap.put(key, new CrunchifyCacheObject(value)); 58 | } 59 | } 60 | 61 | @SuppressWarnings("unchecked") 62 | public T get(K key) { 63 | synchronized (crunchifyCacheMap) { 64 | CrunchifyCacheObject c = (CrunchifyCacheObject) crunchifyCacheMap.get(key); 65 | 66 | if (c == null) 67 | return null; 68 | else { 69 | c.lastAccessed = System.currentTimeMillis(); 70 | return c.value; 71 | } 72 | } 73 | } 74 | 75 | public void remove(K key) { 76 | synchronized (crunchifyCacheMap) { 77 | crunchifyCacheMap.remove(key); 78 | } 79 | } 80 | 81 | public int size() { 82 | synchronized (crunchifyCacheMap) { 83 | return crunchifyCacheMap.size(); 84 | } 85 | } 86 | 87 | @SuppressWarnings("unchecked") 88 | public void cleanup() { 89 | 90 | long now = System.currentTimeMillis(); 91 | ArrayList deleteKey = null; 92 | 93 | synchronized (crunchifyCacheMap) { 94 | MapIterator itr = crunchifyCacheMap.mapIterator(); 95 | 96 | deleteKey = new ArrayList((crunchifyCacheMap.size() / 2) + 1); 97 | K key = null; 98 | CrunchifyCacheObject c = null; 99 | 100 | while (itr.hasNext()) { 101 | key = (K) itr.next(); 102 | c = (CrunchifyCacheObject) itr.getValue(); 103 | 104 | if (c != null && (now > (timeToLive + c.lastAccessed))) { 105 | deleteKey.add(key); 106 | } 107 | } 108 | } 109 | 110 | for (K key : deleteKey) { 111 | synchronized (crunchifyCacheMap) { 112 | crunchifyCacheMap.remove(key); 113 | } 114 | 115 | Thread.yield(); 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/util/CurieUtils.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.util; 2 | 3 | import uk.ac.ebi.spot.exception.InvalidCurieException; 4 | import uk.ac.ebi.spot.model.Curie; 5 | 6 | import java.util.Optional; 7 | 8 | 9 | /** 10 | * @author Simon Jupp 11 | * @since 04/08/2016 12 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 13 | */ 14 | public class CurieUtils { 15 | 16 | public static String getPrefixFromCurie (String curie) throws InvalidCurieException{ 17 | 18 | if (curie.split(":").length == 2) { 19 | return curie.split(":")[0]; 20 | } 21 | else { 22 | throw new InvalidCurieException("Id is not a valid curie, should be QNAME:"); 23 | } 24 | } 25 | 26 | public static String getLocalFromCurie (String curie) throws InvalidCurieException{ 27 | 28 | if (curie.split(":").length == 2) { 29 | return curie.split(":")[1]; 30 | } 31 | else { 32 | throw new InvalidCurieException("Id is not a valid curie, should be QNAME:"); 33 | } 34 | } 35 | 36 | public static Curie getCurie (String prefix, String local){ 37 | return new Curie(prefix, local); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/util/DatasourceConverter.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.util; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.neo4j.ogm.typeconversion.AttributeConverter; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import uk.ac.ebi.spot.model.Datasource; 8 | import uk.ac.ebi.spot.repository.DatasourceRepository; 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * @author Simon Jupp 14 | * @since 11/05/2016 15 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 16 | */ 17 | public class DatasourceConverter implements AttributeConverter { 18 | 19 | // does not actually get autowired because DatasourceConverter is not 20 | // instantiated by Spring 21 | @Autowired 22 | DatasourceRepository datasourceRepository; 23 | 24 | @Override 25 | public String toGraphProperty(Datasource value) { 26 | 27 | //return value.getPrefix(); 28 | // 29 | ObjectMapper mapper = new ObjectMapper(); 30 | try { 31 | return mapper.writeValueAsString(value); 32 | } catch (JsonProcessingException e) { 33 | e.printStackTrace(); 34 | } 35 | return ""; 36 | } 37 | 38 | @Override 39 | public Datasource toEntityAttribute(String value) { 40 | 41 | //return datasourceRepository.findByPrefix(value); 42 | // 43 | ObjectMapper mapper = new ObjectMapper(); 44 | try { 45 | return mapper.readValue(value, Datasource.class); 46 | } catch (IOException e) { 47 | e.printStackTrace(); 48 | } 49 | return new Datasource(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /oxo-model/src/main/java/uk/ac/ebi/spot/util/MappingDistance.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.util; 2 | 3 | /** 4 | * @author Simon Jupp 5 | * @since 28/03/2017 6 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 7 | */ 8 | public class MappingDistance { 9 | public static int DEFAULT_MAPPING_DISTANCE = 1; 10 | } 11 | -------------------------------------------------------------------------------- /oxo-model/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.org.neo4j.ogm=ERROR 2 | logging.level.root=INFO 3 | security.user.password test -------------------------------------------------------------------------------- /oxo-model/src/main/resources/ogm-2.properties: -------------------------------------------------------------------------------- 1 | driver=org.neo4j.ogm.drivers.http.driver.HttpDriver 2 | URI=http://neo4j:dba@localhost:7474 -------------------------------------------------------------------------------- /oxo-web/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /oxo-web/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | oxo-web 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /oxo-web/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM maven:3.6-jdk-8 AS build 3 | RUN mkdir /opt/oxo 4 | COPY pom.xml /opt/oxo/pom.xml 5 | COPY oxo-web /opt/oxo/oxo-web 6 | COPY oxo-model /opt/oxo/oxo-model 7 | COPY oxo-indexer /opt/oxo/oxo-indexer 8 | COPY lib /opt/oxo/lib 9 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/sping-security-orcid-stateless-0.0.8.jar -DgroupId=uk.ac.ebi.spot -DartifactId=sping-security-orcid-stateless -Dversion=0.0.8 10 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/spring-security-core-4.1.4.RELEASE.jar -DgroupId=org.springframework.security -DartifactId=spring-security-core -Dversion=4.1.4.RELEASE 11 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/spring-security-oauth2-2.0.13.RELEASE.jar -DgroupId=org.springframework.security.oauth -DartifactId=spring-security-oauth2 -Dversion=2.0.13.RELEASE 12 | RUN mvn install:install-file -DcreateChecksum=true -Dpackaging=jar -Dfile=/opt/oxo/lib/spring-data-jpa-1.10.8.RELEASE.jar -DgroupId=org.springframework.data -DartifactId=spring-data-jpa -Dversion=1.10.8.RELEASE 13 | RUN cd /opt/oxo && mvn clean package -DskipTests 14 | 15 | FROM openjdk:8-jre-alpine 16 | RUN apk add bash 17 | COPY --from=build /opt/oxo/oxo-web/target/oxo-web.war /opt/oxo-web.war 18 | EXPOSE 8080 19 | ENTRYPOINT ["java", "-jar", "/opt/oxo-web.war"] 20 | 21 | -------------------------------------------------------------------------------- /oxo-web/src/main/asciidoc/developer.adoc: -------------------------------------------------------------------------------- 1 | == Developer Resources 2 | 3 | === OxO source code 4 | * You can obtain the source code at https://github.com/EBISPOT/OxO 5 | 6 | === OxO REST API 7 | * Information about the API access to our services can be found link:../docs/api[here] 8 | 9 | 10 | -------------------------------------------------------------------------------- /oxo-web/src/main/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | == OxO Documentation 2 | 3 | === What are you looking for? 4 | 5 | link:website[Website documentation]:: Documentation on how to use the OxO website 6 | link:developer[Developer documentation]:: Documentation for developers including how to use the OxO REST API. 7 | 8 | == FAQ 9 | 10 | * Where can I get help with OxO? + 11 | e-mail ols-support@ebi.ac.uk or open an issue on link:https://github.com/EBISPOT/oxo/issues[Github] 12 | * How can I hear about updates to OxO? + 13 | Sign up to the link:https://listserver.ebi.ac.uk/mailman/listinfo/ols-announce[OLS announce mailing list] or follow us on link:https://twitter.com/EBIOLS[Twitter] 14 | //* How can I build a local version of OxO? ? + 15 | //See the documentation link:installation-guide[here] -------------------------------------------------------------------------------- /oxo-web/src/main/asciidoc/website.adoc: -------------------------------------------------------------------------------- 1 | == Ontology Xrefs 2 | OxO provides a database of ontology cross-references (or xrefs). These xrefs have been extrated from various sources including ontologies loaded into the Ontology Lookup Service and from sources such as the UMLS. OxO also allows users to upload their own mappings. 3 | 4 | == How to use the website 5 | The OxO website provides an interface for search the OxO database. From the homepage you can search for mappings for a given identifier. OxO supports searching by a range of identifier types including both orefixed CURIE identifeirs and full 6 | ontology term URIs. OxO contains an extensive set of known identifier prefixes that it uses to resolve identifiers (e.g. both MSH and MeSH are known prefixes used to identify terms from the MesH vocabulary) 7 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/OxoWebApp.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | //import org.springframework.boot.context.web.SpringBootServletInitializer; 7 | import org.springframework.boot.web.support.SpringBootServletInitializer; 8 | import org.springframework.cache.annotation.EnableCaching; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.context.annotation.ScopedProxyMode; 11 | 12 | /** 13 | * @author Simon Jupp 14 | * @since 14/06/2016 15 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 16 | */ 17 | @SpringBootApplication 18 | //@EnableAutoConfiguration 19 | @ComponentScan(scopedProxy = ScopedProxyMode.TARGET_CLASS) 20 | @EnableCaching 21 | public class OxoWebApp extends SpringBootServletInitializer { 22 | public static void main(String[] args) { 23 | SpringApplication.run(OxoWebApp.class, args); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/config/CustomBackendIdConverter.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.rest.webmvc.spi.BackendIdConverter; 5 | import org.springframework.stereotype.Component; 6 | import uk.ac.ebi.spot.model.Datasource; 7 | import uk.ac.ebi.spot.model.Term; 8 | import uk.ac.ebi.spot.repository.DatasourceRepository; 9 | import uk.ac.ebi.spot.repository.TermGraphRepository; 10 | 11 | import java.io.Serializable; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 05/08/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | @Component 19 | public class CustomBackendIdConverter implements BackendIdConverter { 20 | 21 | @Autowired 22 | TermGraphRepository termGraphRepository; 23 | 24 | @Autowired 25 | DatasourceRepository datasourceRepository; 26 | 27 | 28 | @Override 29 | public Serializable fromRequestId(String id, Class entityType) { 30 | 31 | if(entityType.equals(Term.class)) { 32 | Term term = termGraphRepository.findByCurie(id); 33 | if (term != null) { 34 | return term.getId(); 35 | } 36 | } 37 | 38 | if(entityType.equals(Datasource.class)) { 39 | Datasource datasource = datasourceRepository.findByPrefix(id); 40 | if (datasource != null) { 41 | return datasource.getId(); 42 | } 43 | } 44 | throw new IllegalArgumentException("Unrecognized class " + entityType); 45 | } 46 | 47 | @Override 48 | public String toRequestId(Serializable id, Class entityType) { 49 | if(entityType.equals(Term.class)) { 50 | Term term = termGraphRepository.findOne((Long) id); 51 | if (term != null) { 52 | return term.getCurie(); 53 | } 54 | } 55 | if(entityType.equals(Datasource.class)) { 56 | Datasource datasource = datasourceRepository.findOne((Long) id); 57 | if (datasource != null) { 58 | return datasource.getPrefix(); 59 | } 60 | } 61 | throw new IllegalArgumentException("Unrecognized class " + entityType); 62 | } 63 | 64 | @Override 65 | public boolean supports(Class delimiter) { 66 | return true; 67 | } 68 | } -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/config/FormatFilter.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.*; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletRequestWrapper; 10 | import javax.servlet.http.HttpServletResponse; 11 | import java.io.IOException; 12 | import java.util.*; 13 | 14 | /** 15 | * @author Simon Jupp 16 | * @since 06/10/2016 17 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 18 | * 19 | * filter that will detect url params format=tsv or format-csv and set the appropriate request header for content negotiation 20 | * 21 | */ 22 | @Component 23 | public class FormatFilter implements Filter { 24 | private Logger log = LoggerFactory.getLogger(getClass()); 25 | 26 | protected Logger getLog() { 27 | return log; 28 | } 29 | 30 | @Override 31 | public void init(FilterConfig filterConfig) throws ServletException { 32 | } 33 | 34 | @Override 35 | public void doFilter(ServletRequest request, ServletResponse response, 36 | FilterChain chain) throws IOException, ServletException { 37 | 38 | HttpServletRequest req = (HttpServletRequest) request; 39 | HeaderMapRequestWrapper requestWrapper = new HeaderMapRequestWrapper(req); 40 | if (req.getParameter("format") != null) { 41 | String format = req.getParameter("format"); 42 | if (format.equals("csv")) { 43 | requestWrapper.addHeader("Accept", "text/csv");; 44 | }else if (format.equals("tsv")) { 45 | requestWrapper.addHeader("Accept", "text/tsv");; 46 | } 47 | 48 | } 49 | chain.doFilter(requestWrapper, response); // Goes to default servlet. 50 | } 51 | 52 | 53 | @Override 54 | public void destroy() { 55 | } 56 | 57 | public class HeaderMapRequestWrapper extends HttpServletRequestWrapper { 58 | /** 59 | * construct a wrapper for this request 60 | * 61 | * @param request 62 | */ 63 | public HeaderMapRequestWrapper(HttpServletRequest request) { 64 | super(request); 65 | } 66 | 67 | private Map headerMap = new HashMap(); 68 | 69 | /** 70 | * add a header with given name and value 71 | * 72 | * @param name 73 | * @param value 74 | */ 75 | public void addHeader(String name, String value) { 76 | headerMap.put(name, value); 77 | } 78 | 79 | @Override 80 | public String getHeader(String name) { 81 | String headerValue = super.getHeader(name); 82 | if (headerMap.containsKey(name)) { 83 | headerValue = headerMap.get(name); 84 | } 85 | return headerValue; 86 | } 87 | 88 | /** 89 | * get the Header names 90 | */ 91 | @Override 92 | public Enumeration getHeaderNames() { 93 | List names = Collections.list(super.getHeaderNames()); 94 | for (String name : headerMap.keySet()) { 95 | names.add(name); 96 | } 97 | return Collections.enumeration(names); 98 | } 99 | 100 | @Override 101 | public Enumeration getHeaders(String name) { 102 | List values = Collections.list(super.getHeaders(name)); 103 | if (headerMap.containsKey(name)) { 104 | values.add(headerMap.get(name)); 105 | } 106 | return Collections.enumeration(values); 107 | } 108 | 109 | } 110 | 111 | } -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/config/OxOWebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 8 | 9 | /** 10 | * @author Simon Jupp 11 | * @since 21/03/2017 12 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 13 | */ 14 | @Configuration 15 | public class OxOWebMvcConfig extends WebMvcConfigurerAdapter { 16 | @Bean 17 | public ReadOnlyMVHandlerInterceptor getReadOnlyHandlerInterceptor() { 18 | return new ReadOnlyMVHandlerInterceptor(); 19 | } 20 | @Override 21 | public void addInterceptors(InterceptorRegistry registry) { 22 | registry.addInterceptor(getReadOnlyHandlerInterceptor()); 23 | 24 | } 25 | 26 | @Override 27 | public void configurePathMatch(PathMatchConfigurer configurer) { 28 | // UrlPathHelper urlPathHelper = new UrlPathHelper(); 29 | // urlPathHelper.setUrlDecode(false); 30 | // configurer.setUrlPathHelper(urlPathHelper); 31 | configurer 32 | .setUseSuffixPatternMatch(false); 33 | 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/config/RESTConfig.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.data.rest.core.config.RepositoryRestConfiguration; 6 | import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter; 7 | import org.springframework.http.MediaType; 8 | import uk.ac.ebi.spot.security.service.*; 9 | 10 | /** 11 | * @author Simon Jupp 12 | * @since 14/06/2016 13 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 14 | */ 15 | @Configuration 16 | public class RESTConfig extends RepositoryRestConfigurerAdapter { 17 | 18 | 19 | @Override 20 | public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { 21 | config.getMetadataConfiguration().setAlpsEnabled(false); 22 | config.setBasePath("/api"); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/config/ReadOnlyMVHandlerInterceptor.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.web.servlet.ModelAndView; 5 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 6 | 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * @author Simon Jupp 13 | * @since 21/03/2017 14 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 15 | */ 16 | public class ReadOnlyMVHandlerInterceptor extends HandlerInterceptorAdapter { 17 | 18 | public ReadOnlyMVHandlerInterceptor() { 19 | } 20 | 21 | @Value("${oxo.access.readonly:false}") 22 | boolean readonly; 23 | 24 | 25 | @Override 26 | public void postHandle(final HttpServletRequest request, 27 | final HttpServletResponse response, final Object handler, 28 | final ModelAndView modelAndView) throws Exception { 29 | 30 | // check for an API key 31 | 32 | if (modelAndView != null) { 33 | modelAndView.getModelMap().addAttribute("readonly", readonly); 34 | } 35 | 36 | 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/api/DatasourceAssembler.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.api; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.hateoas.EntityLinks; 5 | import org.springframework.hateoas.Link; 6 | import org.springframework.hateoas.Resource; 7 | import org.springframework.hateoas.ResourceAssembler; 8 | import org.springframework.hateoas.mvc.ControllerLinkBuilder; 9 | import org.springframework.stereotype.Component; 10 | import uk.ac.ebi.spot.model.Datasource; 11 | 12 | /** 13 | * @author Simon Jupp 14 | * @since 09/08/2016 15 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 16 | */ 17 | @Component 18 | public class DatasourceAssembler implements ResourceAssembler> { 19 | 20 | @Autowired 21 | EntityLinks entityLinks; 22 | 23 | @Override 24 | public Resource toResource(Datasource datasource) { 25 | Resource resource = new Resource(datasource); 26 | String id = datasource.getPrefix(); 27 | final ControllerLinkBuilder lb = ControllerLinkBuilder.linkTo( 28 | ControllerLinkBuilder.methodOn(DatasourceController.class).getDatasource(id)); 29 | 30 | final ControllerLinkBuilder ml = ControllerLinkBuilder.linkTo( 31 | ControllerLinkBuilder.methodOn(TermController.class).terms(id, null, null)); 32 | 33 | resource.add(lb.withSelfRel()); 34 | resource.add(new Link( 35 | ml.toUriComponentsBuilder().build().toUriString(), 36 | "terms" 37 | )); 38 | return resource; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/api/MappingAssembler.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.api; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.hateoas.EntityLinks; 5 | import org.springframework.hateoas.Resource; 6 | import org.springframework.hateoas.ResourceAssembler; 7 | import org.springframework.hateoas.mvc.ControllerLinkBuilder; 8 | import org.springframework.stereotype.Component; 9 | import uk.ac.ebi.spot.model.Mapping; 10 | 11 | /** 12 | * @author Simon Jupp 13 | * @since 09/08/2016 14 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 15 | */ 16 | @Component 17 | public class MappingAssembler implements ResourceAssembler> { 18 | 19 | @Autowired 20 | EntityLinks entityLinks; 21 | 22 | @Override 23 | public Resource toResource(Mapping mapping) { 24 | Resource resource = new Resource(mapping); 25 | Long id = mapping.getMappingId(); 26 | final ControllerLinkBuilder lb = ControllerLinkBuilder.linkTo( 27 | ControllerLinkBuilder.methodOn(MappingController.class).getMapping(id.toString())); 28 | 29 | final ControllerLinkBuilder fromLink = ControllerLinkBuilder.linkTo( 30 | ControllerLinkBuilder.methodOn(TermController.class).getTerm(mapping.getFromTerm().getCurie())); 31 | final ControllerLinkBuilder linkTo = ControllerLinkBuilder.linkTo( 32 | ControllerLinkBuilder.methodOn(TermController.class).getTerm(mapping.getToTerm().getCurie())); 33 | 34 | resource.add(lb.withSelfRel()); 35 | resource.add(fromLink.withRel("fromTerm")); 36 | resource.add(linkTo.withRel("toTerm")); 37 | 38 | return resource; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/api/SearchResultAssembler.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.api; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.hateoas.EntityLinks; 5 | import org.springframework.hateoas.Link; 6 | import org.springframework.hateoas.Resource; 7 | import org.springframework.hateoas.ResourceAssembler; 8 | import org.springframework.hateoas.mvc.ControllerLinkBuilder; 9 | import org.springframework.stereotype.Component; 10 | import uk.ac.ebi.spot.model.Term; 11 | import uk.ac.ebi.spot.service.SearchResult; 12 | 13 | /** 14 | * @author Simon Jupp 15 | * @since 05/09/2016 16 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 17 | */ 18 | @Component 19 | public class SearchResultAssembler implements ResourceAssembler> { 20 | 21 | @Autowired 22 | EntityLinks entityLinks; 23 | 24 | @Override 25 | public Resource toResource(SearchResult searchResult) { 26 | Resource resource = new Resource(searchResult); 27 | 28 | // only add links if valid term as non results are also retruned in a search 29 | 30 | if (searchResult.getCurie()!=null) { 31 | String id = searchResult.getCurie(); 32 | final ControllerLinkBuilder lb = ControllerLinkBuilder.linkTo( 33 | ControllerLinkBuilder.methodOn(TermController.class).getTerm(id)); 34 | 35 | final ControllerLinkBuilder ml = ControllerLinkBuilder.linkTo( 36 | ControllerLinkBuilder.methodOn(MappingController.class).mappings(null, null, searchResult.getCurie(), null)); 37 | 38 | 39 | resource.add(lb.withSelfRel()); 40 | resource.add(new Link( 41 | ml.toUriComponentsBuilder().build().toUriString(), 42 | "mappings" 43 | )); 44 | } 45 | 46 | return resource; 47 | } 48 | 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/api/TermAssembler.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.api; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.hateoas.EntityLinks; 5 | import org.springframework.hateoas.Link; 6 | import org.springframework.hateoas.Resource; 7 | import org.springframework.hateoas.ResourceAssembler; 8 | import org.springframework.hateoas.mvc.ControllerLinkBuilder; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.web.util.UriComponents; 11 | import org.springframework.web.util.UriComponentsBuilder; 12 | import uk.ac.ebi.spot.model.Datasource; 13 | import uk.ac.ebi.spot.model.SourceType; 14 | import uk.ac.ebi.spot.model.Term; 15 | import uk.ac.ebi.spot.service.TermService; 16 | 17 | /** 18 | * @author Simon Jupp 19 | * @since 08/08/2016 20 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 21 | */ 22 | @Component 23 | public class TermAssembler implements ResourceAssembler> { 24 | 25 | @Autowired 26 | EntityLinks entityLinks; 27 | 28 | @Autowired 29 | private TermService termService; 30 | 31 | //private static String olsBase = "https://www.ebi.ac.uk/ols/api/terms?id="; 32 | private static String olsBase = "https://www.ebi.ac.uk/ols/api/terms?obo_id="; 33 | @Override 34 | public Resource toResource(Term term) { 35 | Resource resource = new Resource(term); 36 | String id = term.getCurie(); 37 | final ControllerLinkBuilder lb = ControllerLinkBuilder.linkTo( 38 | ControllerLinkBuilder.methodOn(TermController.class).getTerm(id)); 39 | 40 | final ControllerLinkBuilder ml = ControllerLinkBuilder.linkTo( 41 | ControllerLinkBuilder.methodOn(MappingController.class).mappings(null, null, term.getCurie(), null)); 42 | 43 | Datasource datasource = term.getDatasource(); 44 | if (datasource == null) { 45 | datasource= termService.getTerm(term.getCurie()).getDatasource(); 46 | } 47 | final ControllerLinkBuilder dl = ControllerLinkBuilder.linkTo( 48 | ControllerLinkBuilder.methodOn(DatasourceController.class).getDatasource(datasource.getPrefix())); 49 | 50 | 51 | resource.add(lb.withSelfRel()); 52 | resource.add(dl.withRel("datasource")); 53 | resource.add(new Link( 54 | ml.toUriComponentsBuilder().build().toUriString(), 55 | "mappings" 56 | )); 57 | 58 | if (term.getDatasource().getSource().equals(SourceType.ONTOLOGY)) { 59 | resource.add(new Link( 60 | olsBase+id, 61 | "ols" 62 | )); 63 | } 64 | 65 | return resource; 66 | } 67 | } -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/ui/CustomisationProperties.java: -------------------------------------------------------------------------------- 1 | 2 | package uk.ac.ebi.spot.controller.ui; 3 | 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.ui.Model; 8 | 9 | @ConfigurationProperties(prefix = "oxo.customisation") 10 | @Configuration("customisationProperties") 11 | public class CustomisationProperties { 12 | 13 | @Value("${oxo.customisation.debrand:false}") 14 | private boolean debrand; 15 | 16 | @Value("${oxo.customisation.logo:/img/OXO_logo_2017_colour_background.png") 17 | private String logo; 18 | 19 | @Value("${oxo.customisation.title:Ontology Xref Service}") 20 | private String title; 21 | 22 | @Value("${oxo.customisation.short-title:OxO}") 23 | private String shortTitle; 24 | 25 | @Value("${oxo.customisation.org:EMBL-EBI}") 26 | private String org; 27 | 28 | @Value("${oxo.customisation.olsUrl:https://www.ebi.ac.uk/ols}") 29 | private String olsUrl; 30 | 31 | public void setCustomisationModelAttributes(Model model) { 32 | model.addAttribute("debrand", debrand); 33 | model.addAttribute("logo", logo); 34 | model.addAttribute("title", title); 35 | model.addAttribute("shortTitle", shortTitle); 36 | model.addAttribute("org", org); 37 | model.addAttribute("olsUrl", olsUrl); 38 | } 39 | 40 | public boolean getDebrand() { 41 | return debrand; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/ui/DatasourceControllerUI.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.ui; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.http.MediaType; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RequestParam; 14 | import uk.ac.ebi.spot.model.Datasource; 15 | import uk.ac.ebi.spot.model.Mapping; 16 | import uk.ac.ebi.spot.model.Term; 17 | import uk.ac.ebi.spot.service.DatasourceService; 18 | import uk.ac.ebi.spot.service.MappingService; 19 | import uk.ac.ebi.spot.service.TermService; 20 | import uk.ac.ebi.spot.util.MappingDistance; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Collection; 24 | import java.util.List; 25 | import java.util.stream.Collectors; 26 | 27 | /** 28 | * @author Simon Jupp 29 | * @since 31/08/2016 30 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 31 | */ 32 | @Controller 33 | @RequestMapping("datasources") 34 | public class DatasourceControllerUI { 35 | 36 | @Autowired 37 | DatasourceService datasourceService; 38 | 39 | @Autowired 40 | MappingService mappingService; 41 | 42 | @Autowired 43 | TermService termService; 44 | 45 | @Autowired 46 | CustomisationProperties customisationProperties; 47 | 48 | @RequestMapping(path = "/{prefix}", produces = {MediaType.TEXT_HTML_VALUE}, method = RequestMethod.GET) 49 | public String getDatasource (@PathVariable("prefix") String prefix, Model model, Pageable pageable) { 50 | 51 | Datasource datasource = datasourceService.getDatasource(prefix); 52 | if (datasource == null) { 53 | model.addAttribute("error", "Datasource not found"); 54 | 55 | } else { 56 | 57 | 58 | // termService.getTermsBySource(datasource.getPrefix(), new PageRequest(0, 100000)); 59 | // 60 | // List ids =mappingService.getMappingBySource(datasource.getPrefix()) 61 | // .parallelStream().map(Mapping::getFromTerm).collect(Collectors.toSet()) 62 | // .parallelStream().map(Term::getCurie).collect(Collectors.toList()); 63 | 64 | // model.addAttribute("ids",ids); 65 | 66 | // model.addAttribute("mappingCount",mappingService.getMappedTargetCounts(prefix, 3)); 67 | model.addAttribute("datasource",datasource); 68 | model.addAttribute("distance", MappingDistance.DEFAULT_MAPPING_DISTANCE); 69 | } 70 | 71 | customisationProperties.setCustomisationModelAttributes(model); 72 | 73 | return "datasource"; 74 | 75 | 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/ui/IndexController.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.ui; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.security.access.annotation.Secured; 7 | import org.springframework.security.core.annotation.AuthenticationPrincipal; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import uk.ac.ebi.spot.model.Datasource; 13 | import uk.ac.ebi.spot.model.Mapping; 14 | import uk.ac.ebi.spot.model.Term; 15 | import uk.ac.ebi.spot.security.model.OrcidPrinciple; 16 | import uk.ac.ebi.spot.service.DatasourceService; 17 | import uk.ac.ebi.spot.service.MappingService; 18 | import uk.ac.ebi.spot.service.TermService; 19 | import uk.ac.ebi.spot.util.MappingDistance; 20 | 21 | import java.util.Collection; 22 | import java.util.List; 23 | import java.util.stream.Collectors; 24 | 25 | /** 26 | * @author Simon Jupp 27 | * @since 16/08/2016 28 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 29 | */ 30 | @Controller 31 | @RequestMapping("") 32 | public class IndexController { 33 | 34 | @Autowired 35 | DatasourceService datasourceService; 36 | 37 | @Autowired 38 | TermService termService; 39 | 40 | @Autowired 41 | MappingService mappingService; 42 | 43 | @Autowired 44 | CustomisationProperties customisationProperties; 45 | 46 | @RequestMapping(path = {"", "index"}) 47 | public String home(Model model) { 48 | 49 | model.addAttribute("datasources",datasourceService.getDatasourceWithMappings()); 50 | model.addAttribute("distance", MappingDistance.DEFAULT_MAPPING_DISTANCE); 51 | 52 | customisationProperties.setCustomisationModelAttributes(model); 53 | 54 | return "index"; 55 | } 56 | 57 | /* 58 | @RequestMapping({"docs"}) 59 | public String showDocsIndex(Model model) { 60 | return "redirect:docs/"; 61 | } 62 | // ok, this is bad, need to find a way to deal with trailing slashes and constructing relative URLs in the thymeleaf template... 63 | @RequestMapping({"docs/"}) 64 | public String showDocsIndex2(Model model) {*/ 65 | /* 66 | @RequestMapping(path = "docs") 67 | public String docs(Model model) { 68 | return "docs"; 69 | } 70 | 71 | @RequestMapping({"docs/{page}"}) 72 | public String showDocs(@PathVariable("page") String pageName, Model model) { 73 | model.addAttribute("page", pageName); 74 | return "docs-template"; 75 | }*/ 76 | 77 | @RequestMapping(path = "about") 78 | public String about(Model model) { 79 | return "about"; 80 | } 81 | 82 | @RequestMapping(path = "contact") 83 | public String contact(Model model) { 84 | return "contact"; 85 | } 86 | 87 | 88 | @Secured("ROLE_USER") 89 | @RequestMapping(path = "myaccount") 90 | public String myAccount(Model model, @AuthenticationPrincipal OrcidPrinciple principle, Pageable pageable) { 91 | 92 | Datasource datasource = datasourceService.getDatasource(principle.getOrcid()); 93 | if (datasource == null) { 94 | model.addAttribute("error", "Datasource not found"); 95 | 96 | } else { 97 | List mappings = mappingService.getMappingBySource(datasource.getPrefix()); 98 | model.addAttribute("mappings",mappings); 99 | 100 | } 101 | 102 | customisationProperties.setCustomisationModelAttributes(model); 103 | 104 | return "myaccount"; 105 | } 106 | 107 | 108 | 109 | 110 | 111 | @RequestMapping({"docs"}) 112 | public String showDocsIndex(Model model) { 113 | return "redirect:docs/index"; 114 | } 115 | // ok, this is bad, need to find a way to deal with trailing slashes and constructing relative URLs in the thymeleaf template... 116 | @RequestMapping({"docs/"}) 117 | public String showDocsIndex2(Model model) { 118 | return "redirect:index"; 119 | } 120 | 121 | @RequestMapping({"docs/{page}"}) 122 | public String showDocs(@PathVariable("page") String pageName, Model model) { 123 | model.addAttribute("page", pageName); 124 | customisationProperties.setCustomisationModelAttributes(model); 125 | return "docs-template"; 126 | } 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | } 135 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/ui/SearchControllerUI.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.ui; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.ui.Model; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.ModelAttribute; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import uk.ac.ebi.spot.model.Datasource; 12 | import uk.ac.ebi.spot.model.MappingSearchRequest; 13 | import uk.ac.ebi.spot.service.DatasourceService; 14 | import uk.ac.ebi.spot.service.MappingService; 15 | import uk.ac.ebi.spot.service.TermService; 16 | 17 | import java.util.*; 18 | 19 | /** 20 | * @author Simon Jupp 21 | * @since 30/08/2016 22 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 23 | */ 24 | @Controller 25 | @RequestMapping("search") 26 | public class SearchControllerUI { 27 | 28 | @Autowired 29 | MappingService mappingService; 30 | 31 | @Autowired 32 | TermService termService; 33 | 34 | @Autowired 35 | DatasourceService datasourceService; 36 | 37 | @Autowired 38 | CustomisationProperties customisationProperties; 39 | 40 | 41 | @GetMapping 42 | public String search() { 43 | return "index"; 44 | } 45 | 46 | @PostMapping 47 | public String search( 48 | MappingSearchRequest request, 49 | Model model, 50 | Pageable pageable 51 | 52 | ) { 53 | 54 | List ids = new ArrayList<>(request.getIds()); 55 | 56 | if (!request.getIds().isEmpty()) { 57 | model.addAttribute("ids", ids); 58 | 59 | if (!request.getMappingTarget().isEmpty()) { 60 | model.addAttribute("mappingTarget", request.getMappingTarget()); 61 | } 62 | } else if (request.getInputSource() !=null && !request.getMappingTarget().isEmpty()) { 63 | 64 | String source = request.getInputSource(); 65 | Set target = request.getMappingTarget(); 66 | model.addAttribute("inputSource", source); 67 | model.addAttribute("mappingTarget", target); 68 | } 69 | 70 | model.addAttribute("request", request); 71 | 72 | customisationProperties.setCustomisationModelAttributes(model); 73 | 74 | return "search"; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/controller/ui/TermControllerUI.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.controller.ui; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.MediaType; 5 | import org.springframework.security.access.annotation.Secured; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 12 | import uk.ac.ebi.spot.model.MappingRequest; 13 | import uk.ac.ebi.spot.model.Scope; 14 | import uk.ac.ebi.spot.model.SourceType; 15 | import uk.ac.ebi.spot.model.Term; 16 | import uk.ac.ebi.spot.service.MappingResponse; 17 | import uk.ac.ebi.spot.service.MappingService; 18 | import uk.ac.ebi.spot.service.TermService; 19 | import uk.ac.ebi.spot.util.MappingDistance; 20 | 21 | import java.util.Collections; 22 | import java.util.LinkedHashMap; 23 | import java.util.List; 24 | 25 | /** 26 | * @author Simon Jupp 27 | * @since 31/08/2016 28 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 29 | */ 30 | @Controller 31 | @RequestMapping("terms") 32 | public class TermControllerUI { 33 | 34 | @Autowired 35 | TermService termService; 36 | 37 | @Autowired 38 | MappingService mappingService; 39 | 40 | @Autowired 41 | CustomisationProperties customisationProperties; 42 | 43 | @RequestMapping(path = "/{curie}", produces = {MediaType.TEXT_HTML_VALUE}, method = RequestMethod.GET) 44 | public String getTerms (@PathVariable("curie") String curie, Model model, final RedirectAttributes redirectAttributes) { 45 | 46 | Term t = termService.getTerm(curie); 47 | 48 | if (t == null) { 49 | model.addAttribute("error", "Term with this id not found"); 50 | 51 | } else { 52 | model.addAttribute("id", t.getCurie()); 53 | model.addAttribute("term", t); 54 | MappingRequest mappingRequest = new MappingRequest(); 55 | mappingRequest.setFromId(curie); 56 | mappingRequest.setSourceType(SourceType.USER); 57 | mappingRequest.setScope(Scope.EXACT); 58 | model.addAttribute("mappingRequest", mappingRequest); 59 | model.addAttribute("distance", MappingDistance.DEFAULT_MAPPING_DISTANCE); 60 | } 61 | 62 | customisationProperties.setCustomisationModelAttributes(model); 63 | 64 | return "terms"; 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/model/MappingQuery.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import uk.ac.ebi.spot.util.MappingDistance; 4 | 5 | /** 6 | * @author Simon Jupp 7 | * @since 14/06/2016 8 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 9 | */ 10 | public class MappingQuery { 11 | 12 | private String id; 13 | private String sourcePrefix = null; 14 | private int distance = MappingDistance.DEFAULT_MAPPING_DISTANCE; 15 | 16 | public MappingQuery() { 17 | } 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getSourcePrefix() { 28 | return sourcePrefix; 29 | } 30 | 31 | public void setSourcePrefix(String sourcePrefix) { 32 | this.sourcePrefix = sourcePrefix; 33 | } 34 | 35 | public int getDistance() { 36 | return distance; 37 | } 38 | 39 | public void setDistance(int distance) { 40 | this.distance = distance; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /oxo-web/src/main/java/uk/ac/ebi/spot/model/MappingSearchRequest.java: -------------------------------------------------------------------------------- 1 | package uk.ac.ebi.spot.model; 2 | 3 | import uk.ac.ebi.spot.util.MappingDistance; 4 | 5 | import java.util.ArrayList; 6 | import java.util.HashSet; 7 | import java.util.List; 8 | import java.util.Set; 9 | 10 | /** 11 | * @author Simon Jupp 12 | * @since 30/08/2016 13 | * Samples, Phenotypes and Ontologies Team, EMBL-EBI 14 | */ 15 | public class MappingSearchRequest { 16 | 17 | private List ids = new ArrayList<>();; 18 | private String inputSource; 19 | private Set mappingTarget = new HashSet<>(); 20 | private Set mappingSource = new HashSet<>(); 21 | private int distance = MappingDistance.DEFAULT_MAPPING_DISTANCE; 22 | 23 | public MappingSearchRequest(List ids, Set mappingSource, Set mappingTarget) { 24 | this.ids = ids; 25 | this.mappingSource = mappingSource; 26 | this.mappingTarget = mappingTarget; 27 | } 28 | 29 | public MappingSearchRequest(List ids, String inputSource, Set mappingSource, Set mappingTarget) { 30 | this.ids = ids; 31 | this.inputSource = inputSource; 32 | this.mappingSource = mappingSource; 33 | this.mappingTarget = mappingTarget; 34 | } 35 | 36 | public String getInputSource() { 37 | return inputSource; 38 | } 39 | 40 | public void setInputSource(String inputSource) { 41 | this.inputSource = inputSource; 42 | } 43 | 44 | public int getDistance() { 45 | return distance; 46 | } 47 | 48 | public void setDistance(int distance) { 49 | this.distance = distance; 50 | } 51 | 52 | public List getIds() { 53 | return ids; 54 | } 55 | 56 | public void setIds(List ids) { 57 | this.ids = ids; 58 | } 59 | 60 | public Set getMappingSource() { 61 | return mappingSource; 62 | } 63 | 64 | public void setMappingSource(Set mappingSource) { 65 | this.mappingSource = mappingSource; 66 | } 67 | 68 | public Set getMappingTarget() { 69 | return mappingTarget; 70 | } 71 | 72 | public void setMappingTarget(Set mappingTarget) { 73 | this.mappingTarget = mappingTarget; 74 | } 75 | 76 | public MappingSearchRequest() { 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #oxo.customisation.debrand=true 2 | #oxo.customisation.logo=/custom/test.png 3 | #oxo.customisation.title=Ontology Xref Service 4 | #oxo.customisation.org=EMBL-EBI 5 | #oxo.customisation.short-title=OxO 6 | #oxo.customisation.olsUrl=https://www.ebi.ac.uk/ols 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/css/oxo-d3.css: -------------------------------------------------------------------------------- 1 | .node { 2 | font: 300 13px "Helvetica Neue", Helvetica, Arial, sans-serif; 3 | fill: #bbb; 4 | } 5 | 6 | .node:hover { 7 | fill: #000; 8 | } 9 | 10 | .link { 11 | stroke: steelblue; 12 | stroke-opacity: .4; 13 | fill: none; 14 | pointer-events: none; 15 | } 16 | 17 | .node:hover, 18 | .node--source, 19 | .node--target { 20 | font-weight: 700; 21 | cursor: pointer; 22 | } 23 | 24 | .node--source { 25 | fill: #2ca02c; 26 | } 27 | 28 | .node--target { 29 | fill: #d62728; 30 | } 31 | 32 | .link--source, 33 | .link--target { 34 | stroke-opacity: 1; 35 | stroke-width: 2px; 36 | } 37 | 38 | .link--source { 39 | stroke: #d62728; 40 | } 41 | 42 | .link--target { 43 | stroke: #2ca02c; 44 | } 45 | 46 | .no-mapping{ 47 | background-color: #ff0100; 48 | padding:2px; 49 | padding-right:4px; 50 | color: white; 51 | /*font-size: larger;*/ 52 | border-radius: 3px; 53 | display: inline-block; 54 | margin-right: 4px; 55 | vertical-align: middle; 56 | } -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/css/oxo.css: -------------------------------------------------------------------------------- 1 | h1,h2,h3,h4,h5,h6 { 2 | font-weight: normal; 3 | } 4 | div#local-title.logo-title span { 5 | margin-top: 1.1em; 6 | } 7 | 8 | .no-mapping{ 9 | background-color: #ff0100; 10 | padding:2px; 11 | padding-right:4px; 12 | color: white; 13 | /*font-size: larger; 14 | border-radius: 3px;*/ 15 | display: inline-block; 16 | margin-right: 4px; 17 | vertical-align: middle; 18 | } 19 | 20 | 21 | .context-help-wrapper { 22 | position: relative; 23 | top: 20px; 24 | left: 20px; 25 | z-index: 1; 26 | display: none; 27 | } 28 | 29 | .context-help-content { 30 | position: absolute; 31 | border: 1px solid #000000; 32 | background-color: #f7f7f7; 33 | display: none; 34 | } 35 | 36 | .context-help-label { 37 | font-weight: inherit; 38 | color: inherit; 39 | } 40 | 41 | 42 | .context-help-label:after { 43 | font-family: 'EBI-Generic'; 44 | font-size: 70%; 45 | color: inherit !important; 46 | content: attr(data-icon); 47 | vertical-align: super; 48 | margin: 0 0 0 0; 49 | } 50 | 51 | .clickable { 52 | cursor: pointer; 53 | } 54 | 55 | /* Here we introduce new css for the new version*/ 56 | .alert-warning{ 57 | background-color: #faebcc; 58 | margin-bottom: 10px; 59 | margin-top: 5px; 60 | padding: 10px 10px 10px 10px; 61 | border-radius: 0px; 62 | } 63 | 64 | .grayBackground{ 65 | background-color: #f2f2f2; 66 | /*border-radius: 25px;*/ 67 | padding: 10px 10px 10px 10px; 68 | margin: 10px; 69 | } 70 | 71 | 72 | .marginTop{ 73 | margin-top:60px; 74 | } 75 | 76 | .marginBottom{ 77 | margin-bottom:80px; 78 | } 79 | 80 | #network{ 81 | height:500px; 82 | width: 100%; 83 | border: 0px black solid; 84 | } 85 | 86 | 87 | 88 | /*Migrated fomr fomrs.lens.css*/ 89 | label { 90 | display: inline-block !important; 91 | max-width: 100%; 92 | margin-bottom: 5px; 93 | font-weight: 700; 94 | 95 | } 96 | 97 | 98 | /* Migrated from OLS css (used previously by OxO) to the oxo.css*/ 99 | .term-source { 100 | background-color: #ffac1b; 101 | padding: 2px; 102 | padding-right: 2px; 103 | padding-right: 4px; 104 | color: white; 105 | font-size: larger; 106 | border-radius: 3px; 107 | display: inline-block; 108 | margin-right: 4px; 109 | vertical-align: middle; 110 | } 111 | 112 | a .ontology-source { 113 | background-color: #5FBDCE; 114 | padding: 2px; 115 | padding-right: 2px; 116 | padding-right: 4px; 117 | color: white; 118 | font-size: larger; 119 | border-radius: 3px; 120 | display: inline-block; 121 | margin-right: 4px; 122 | vertical-align: middle; 123 | border-bottom: none; 124 | } 125 | 126 | 127 | /* datatable customizing */ 128 | .dataTables_length { 129 | white-space: nowrap; 130 | } 131 | 132 | .dataTables_info{ 133 | margin-top: 30px; 134 | } 135 | 136 | #example_length select{ 137 | width:60px; 138 | } 139 | 140 | 141 | /*Help Pages*/ 142 | 143 | /* API doc*/ 144 | 145 | .listingblock{ 146 | background: #ededed; 147 | color: #fff; 148 | text-shadow: none; 149 | padding: 3%; 150 | border-width: 1px; 151 | border-style: dotted; 152 | overflow: auto; 153 | } 154 | 155 | .listingblock .content .highlight{ 156 | white-space: pre !important; 157 | 158 | } 159 | 160 | #docs-content h1 { 161 | color: black !important; 162 | } 163 | 164 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/img/OXO_logo_2017_colour_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/oxo-web/src/main/resources/static/img/OXO_logo_2017_colour_background.png -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/img/infinity.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EBISPOT/OXO/7a911bbc5c3975eae314e2db418b008e623444fd/oxo-web/src/main/resources/static/img/infinity.gif -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/js/docs.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | // read the window location to set the breadcrumb 4 | var path = window.location.pathname; 5 | var pagename = path.substr(path.lastIndexOf('/') + 1); 6 | if (pagename == 'docs') { 7 | pagename = "/index"; 8 | } 9 | var url_header = "../documents/".concat(pagename).concat(".html #header"); 10 | var url_footer = "../documents/".concat(pagename).concat(".html #footer"); 11 | var url = "../documents/".concat(pagename).concat(".html #content"); 12 | //console.log("Documentation should be loaded from " + url + "..."); 13 | 14 | $("#docs-header").load (url_header); 15 | $("#docs-content").load (url); 16 | $("#docs-footer").load (url_footer); 17 | 18 | if (pagename == 'about') { 19 | $('#local-nav-about').addClass('active'); 20 | } else { 21 | $('#local-nav-docs').addClass('active'); 22 | 23 | } 24 | 25 | }); 26 | 27 | 28 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/js/oxo-hchart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by jupp on 02/03/2017. 3 | */ 4 | 5 | $(document).ready(function() { 6 | console.log("Document ready, let's refresh data") 7 | refreshChartData() 8 | 9 | /* 10 | $("#distanceDropDown").on('change', function() { 11 | $("input[name=distance]").val(this.value) 12 | refreshChartData() 13 | }) */ 14 | 15 | 16 | $('.slider').on('moved.zf.slider', function(){ 17 | console.log("Slider action dedected") 18 | if ($("input[name=distance]").val()!==$(".slider input").val()){ //Check if there was a change, if there is, update stuff 19 | $("input[name=distance]").val($(".slider input").val()) 20 | refreshChartData() 21 | } 22 | }); 23 | 24 | }); 25 | 26 | 27 | function refreshChartData() { 28 | $("#graphic").html(''); 29 | $("#mapping-vis").show() 30 | 31 | var prefix = $("#graphic").data("prefix"); 32 | var distance = $("input[name=distance]").val() ? $("input[name=distance]").val() : 1; 33 | 34 | console.log("Got prefix, it is "+prefix) 35 | console.log("Got distance, it is "+distance) 36 | 37 | $.ajax({ 38 | url: '../api/mappings/summary/counts?datasource='+prefix+'&distance='+distance, 39 | dataType: 'json', 40 | method: 'GET', 41 | contentType: "application/json; charset=utf-8", 42 | context: this, 43 | success: function (data) { 44 | drawChart(data) 45 | } 46 | }); 47 | } 48 | 49 | function drawChart(data) { 50 | 51 | var reformatted = []; 52 | 53 | // console.log(Object.keys(data)) 54 | $.each(data,function(key,value){ 55 | reformatted.push( [key, value]) 56 | $("#mapping-vis").hide() 57 | }); 58 | 59 | console.log(JSON.stringify(reformatted)) 60 | 61 | var chart = Highcharts.chart('graphic', { 62 | chart: { 63 | type: 'bar' 64 | }, 65 | credits:{ 66 | enabled:false 67 | }, 68 | title: { 69 | text: 'Mappings by target' 70 | }, 71 | xAxis: { 72 | type: 'category', 73 | labels: { 74 | // rotation: -45, 75 | style: { 76 | fontSize: '13px', 77 | fontFamily: 'Verdana, sans-serif' 78 | }, 79 | formatter: function(){ 80 | return "" + this.value + "" 81 | }, 82 | useHTML: true, 83 | step : 1 84 | }, 85 | categories: Object.keys(data), 86 | 87 | }, 88 | yAxis: { 89 | min: 0, 90 | title: { 91 | text: 'Number of mappings' 92 | } 93 | }, 94 | legend: { 95 | enabled: false 96 | }, 97 | plotOptions: { 98 | series: { 99 | cursor: 'pointer', 100 | point: { 101 | events: { 102 | click: function () { 103 | console.log('clicked ' + this.category) 104 | $('#mappingTarget').val(this.category) 105 | $('#distance-slide').val($('#distanceDropDown').val()) 106 | //msg="We got following parameters: "+$('#mappingTarget').val()+" "+$('#distance-slider').val()+" "+$('#inputSource').val() 107 | //alert(msg) 108 | $('#mapping-count-form').submit() 109 | } 110 | } 111 | }, 112 | minPointLength: 3, 113 | events: { 114 | legendItemClick: function(ev) { 115 | // console.log(ev.point.category) 116 | } 117 | } 118 | } 119 | }, 120 | events: { 121 | redraw: function(event) { 122 | console.log("size" + this.xAxis.categories) 123 | } 124 | }, 125 | series: [{ 126 | name: 'Mappings', 127 | data: reformatted 128 | }] 129 | }); 130 | 131 | var height = reformatted.length * 40; 132 | if (height < 200) { 133 | height = 200; 134 | } 135 | chart.setSize(undefined, height) 136 | 137 | } 138 | 139 | 140 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/static/js/oxo.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | function markupContextHelp() { 4 | $('.context-help').each(function(index, element) { 5 | // grab each element with context-help class 6 | var $element = $(element); 7 | 8 | // get the label and linkify 9 | var $label = $element.find(".context-help-label").first(); 10 | $label.attr("data-icon", "?"); 11 | $label.addClass("clickable"); 12 | $label.click(function() { 13 | toggleContextHelp($label); 14 | return false; 15 | }); 16 | 17 | // get the help content 18 | var $content = $element.find(".context-help-content").first(); 19 | // style and wrap it 20 | $content.prepend("
" + 21 | "" + 22 | "" + 23 | "
"); 24 | $content.wrap("
"); 25 | $content.show(); 26 | }); 27 | } 28 | 29 | function toggleContextHelp(element) { 30 | // run the effect 31 | var $parent = $(element).parents(".context-help").first(); 32 | var $content = $parent.find(".context-help-wrapper").first(); 33 | $content.toggle(); 34 | return false; 35 | } 36 | 37 | 38 | function populateExamples() { 39 | $('#identifiers').val("EFO:0001360\nDOID:162\nOMIM:180200\nMESH:D009202\nUBERON_0002107\nHP_0005978"); 40 | } 41 | 42 | function exportData(format) { 43 | 44 | // console.log("fomart " + format) 45 | var filterForm = $('#filter-form'); 46 | if (filterForm) { 47 | filterForm.attr('action', 'api/search?format='+format); 48 | filterForm.submit(); 49 | filterForm.attr('action', 'search'); 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /oxo-web/src/main/resources/templates/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | [[${title}]] < [[${org}]] 12 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 |

OxO is an database of ontology cross-references (xrefs) extracted from public ontologies and databases. Most of these cross-references have been extracted from ontologies in the 33 | Ontology Lookup Service by searching for database cross-reference annotations on terms. We have supplemented these cross-references with 34 | mappings from a subset of vocabularies in the UMLS.

35 | 36 |

37 | The semantics of a cross-reference are weakly specified, in most cases they mean some kind of operational equivalence, but there is no guarantee. 38 | Sometimes cross-references are used to indicate other types of relationships such as parent/child or that the terms are related in some other way (such as linking a disease concept to a pathway accession that is somehow related to that disease). 39 | OxO aims to provide simple and convenient access to cross-references, but is not a mapping prediction service, so always treat these xrefs with caution, especially if you are seeking true equivalence between two ontologies. 40 |

41 | 42 |

43 | OxO gives you access to existing mappings, you can also explore the neighbourhood of a mapping using the distance controller. By default OxO shows you direct asserted mappings, but you can use the slider on various pages to look for mappings that are up to 44 | three hops away. You may see some terms that don't have labels associated to them, we are doing our best to find labels for all of these terms, but sometimes the labels are missing from the sources that we extract mappings from. 45 |

46 | 47 |

48 | OxO is developed by the Samples, Phenotypes and Ontologies team. If you have any questions about OxO please contact us. 49 |

50 | 51 |
52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/templates/docs-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | [[${title}]] < [[${org}]] 12 | 20 | 21 | 22 | 23 | 24 | 25 |
26 |
27 | 28 | 30 | 31 |
32 | 33 |
34 | 35 | 37 | 38 | 39 |
40 |
41 | 42 | 43 | 44 | 45 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/templates/fragments/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 | 21 |
22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 52 | 53 |
54 |
55 |
56 | 57 |
58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/templates/fragments/slider.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |
9 | Mapping Distance 10 |
11 | 12 | 13 | 14 |
15 |
16 | 1 17 | 2 18 | 3 19 |
20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /oxo-web/src/main/resources/templates/mapping.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | [[${title}]] < [[${org}]] 12 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 |
33 | Success message goes here. 34 |
35 | 36 | 37 |
38 | Error message goes here. 39 |
40 | 41 | 42 |
43 |
44 |

Mapping info

45 |
46 |
47 | 63 |
64 | Scope: id... 65 |
66 |
67 | Created date: id... 68 |
69 |
70 | Mapping source: 71 | id... 72 | id... 73 |
74 | 75 |
76 | Source type: id... 77 |
78 | 79 |
80 | 81 |
82 | 83 |
84 |
85 |
86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /paxo-loader/config/listprocessing_dummy_config.ini: -------------------------------------------------------------------------------- 1 | [Basics] 2 | olsAPIURL=https://www.ebi.ac.uk/ols/api/ 3 | oxoURL=https://www.ebi.ac.uk/spot/oxo/api/ 4 | inputFile=/path/input-file.csv 5 | resultFile=/path/output-file.csv 6 | logFile=listprocessing.log 7 | detailLevel=0 8 | targetOntology=doid 9 | delimiter=, 10 | StopwordsList=of,the 11 | fuzzyUpperLimit=0.8 12 | fuzzyLowerLimit=0.6 13 | fuzzyUpperFactor=1 14 | fuzzyLowerFactor=0.6 15 | oxoDistanceOne=1 16 | oxoDistanceTwo=0.3 17 | oxoDistanceThree=0.1 18 | synFuzzyFactor=0.6 19 | synOxoFactor=0.4 20 | bridgeOxoFactor=1 21 | threshold=1 22 | -------------------------------------------------------------------------------- /paxo-loader/config/paxo_dummy_config.ini: -------------------------------------------------------------------------------- 1 | [Basics] 2 | olsAPIURL=https://www.ebi.ac.uk/ols/api/ 3 | oxoURL=https://www.ebi.ac.uk/spot/oxo/api/ 4 | logFile=../paxo.log 5 | neoURL=bolt://localhost:7687 6 | neoUser=neo4j 7 | neoPW=neopassword 8 | 9 | [Params] 10 | scoringTargetFolder=../data/scoring/ 11 | predictedTargetFolder=../data/predicted/ 12 | validationTargetFolder=../data/evaluation/O2/ 13 | ; Neo needs full path! 14 | neoFolder=/path/path/neo_export/ 15 | StopwordsList=of,the 16 | writeToDiscFlag=True 17 | uniqueMaps=False 18 | mapSmallest=True 19 | useLocalOnly=True 20 | 21 | [mp_hp] 22 | sourceOntology=mp 23 | targetOntology=hp 24 | standard=silver 25 | silver=standard/std_hp-mp.tsv 26 | uri1silver=2 27 | uri2silver=0 28 | scorePositionsilver=4 29 | delimitersilver=t 30 | fuzzyUpperLimit=0.8 31 | fuzzyLowerLimit=0.6 32 | fuzzyUpperFactor=1 33 | fuzzyLowerFactor=0.6 34 | oxoDistanceOne=1 35 | oxoDistanceTwo=0.3 36 | oxoDistanceThree=0.1 37 | synFuzzyFactor=0.6 38 | synOxoFactor=0.4 39 | bridgeOxoFactor=1 40 | threshold=0.6 41 | -------------------------------------------------------------------------------- /paxo-loader/listprocessing.py: -------------------------------------------------------------------------------- 1 | #import clientOperations as paxo 2 | import paxo_internals 3 | import csv 4 | import requests 5 | import time 6 | import logging 7 | 8 | def runListProcessing(options, params, scoreParams): 9 | 10 | inputFile=options["inputFile"] 11 | resultFile=options["resultFile"] 12 | delimiter=options["delimiter"] 13 | targetOntology=options["targetOntology"] 14 | detailLevel=options["detailLevel"] 15 | synonymSplitChar=options["synonymSplitChar"] 16 | 17 | #Open the input file 18 | with open(inputFile) as csvfile: 19 | readCSV = csv.reader(csvfile, delimiter=str(delimiter)) 20 | next(readCSV) #Skip the headers 21 | 22 | try: 23 | replyList=[] 24 | 25 | #Adding Headers to the result file 26 | replyList.append(['inputID','inputLabel','mappedId',"mappedLabel","Score"]) 27 | counter=0 28 | #tmpReadCSV=readCSV 29 | #totalLength=len(list(tmpReadCSV)) 30 | logging.info("Start going through input csv") 31 | for index,row in enumerate(readCSV): 32 | potentialReply=[] 33 | #Execute label in the first row 34 | prefLabel=row[1].encode(encoding='UTF-8') 35 | 36 | if len(row)>2: 37 | synList=row[2].split(synonymSplitChar) 38 | else: 39 | synList=[] 40 | 41 | #print prefLabel 42 | tmpReply=paxo_internals.scoreTermLabel(prefLabel, targetOntology, scoreParams, params) 43 | 44 | if tmpReply!=[]: 45 | potentialReply.append(tmpReply) 46 | 47 | for syn in synList: 48 | #print " --> "+syn 49 | tmpReply=paxo_internals.scoreTermLabel(syn.strip().encode(encoding='UTF-8'), targetOntology, scoreParams, params) 50 | if tmpReply!=[]: 51 | potentialReply.append(tmpReply) 52 | 53 | #Sort all potential replies via the score, so the highest score is first 54 | try: 55 | potentialReply=sorted(potentialReply, key=lambda potentialReply:potentialReply[0]['finaleScore'], reverse=True)[0] 56 | if detailLevel<1: 57 | replyList.append([row[0].encode(encoding='UTF-8'),prefLabel,potentialReply[0]['iri'].encode(encoding='UTF-8'),"", potentialReply[0]['fuzzyScore']]) 58 | elif detailLevel==1: 59 | detail=[] 60 | for tmpReply in potentialReply: 61 | detail.append({"mappedIRI":tmpReply['iri'], "score":tmpReply['fuzzyScore']}) 62 | replyList.append([row[0].encode(encoding='UTF-8'),prefLabel,potentialReply[0]['iri'].encode(encoding='UTF-8'),"", potentialReply[0]['fuzzyScore'], detail]) 63 | elif detailLevel>1: 64 | replyList.append([row[0].encode(encoding='UTF-8'),prefLabel,potentialReply[0]['iri'].encode(encoding='UTF-8'),"", potentialReply[0]['fuzzyScore'], potentialReply]) 65 | except Exception as e: 66 | #If the exception just arises because of and empty reply, we simply did not find a match and can move on 67 | if potentialReply==[]: 68 | replyList.append([row[0].encode(encoding='UTF-8'),prefLabel, "no match found", "", 0]) 69 | #Another error occured, this is something to look into! 70 | else: 71 | print e 72 | print "Problem getting results for "+prefLabel+" - the reply was "+potentialReply 73 | logging.error("Problem getting results for "+prefLabel+" - the reply was "+potentialReply) 74 | logging.error(e) 75 | raise 76 | 77 | #This is just to print feedback - if we work on a large list 78 | counter=counter+1 79 | if counter%20==0: 80 | print "Processed "+str(counter)+" entries" 81 | logging.info("Processed "+str(counter)+" entries") 82 | 83 | ### annotating file 84 | print "Done processing input list, now annotate the result" 85 | olsurl=params['ols']+"search" 86 | for row in replyList[1:]: 87 | if row[2]=="no match found": 88 | row[3]="no label found" 89 | else: 90 | data={'q':row[2],'queryFields':'iri', 'fieldList': 'label', "ontology":targetOntology, "type":"class", "local":True} 91 | r = requests.get(olsurl, data) 92 | jsonReply=r.json() 93 | try: 94 | row[3]=jsonReply['response']['docs'][0]['label'].encode(encoding='UTF-8') 95 | except Exception as e: 96 | row[3]="no label found" 97 | logging.error("No label found for "+row[2]) 98 | logging.error(e) 99 | 100 | ### write to file 101 | print "Done annotating file, now write result to file" 102 | logging.info("Done annotating file, now write result to file") 103 | #Writing result to output file 104 | with open(resultFile, 'wb') as f: 105 | writer = csv.writer(f) 106 | writer.writerows(replyList) 107 | f.close() 108 | 109 | #In case there is an error, print the exception 110 | except Exception as e: 111 | print "Error while processing file" 112 | print e 113 | logging.error("Error while processing file") 114 | logging.error(e) 115 | -------------------------------------------------------------------------------- /paxo-loader/listprocessing_config.ini: -------------------------------------------------------------------------------- 1 | [Basics] 2 | olsAPIURL=https://www.ebi.ac.uk/ols/api/ 3 | oxoURL=https://www.ebi.ac.uk/spot/oxo/api/search 4 | inputFile=/path/input-file.csv 5 | resultFile=/path/output-file.csv 6 | logFile=listprocessing.log 7 | detailLevel=0 8 | targetOntology=doid 9 | delimiter=, 10 | synonymSplitChar=| 11 | StopwordsList=of,the 12 | fuzzyUpperLimit=0.8 13 | fuzzyLowerLimit=0.6 14 | fuzzyUpperFactor=1 15 | fuzzyLowerFactor=0.6 16 | oxoDistanceOne=1 17 | oxoDistanceTwo=0.3 18 | oxoDistanceThree=0.1 19 | synFuzzyFactor=0.6 20 | synOxoFactor=0.4 21 | bridgeOxoFactor=1 22 | threshold=1 23 | 24 | [Params] 25 | StopwordsList=of,the 26 | writeToDiscFlag=True 27 | uniqueMaps=True 28 | -------------------------------------------------------------------------------- /paxo-loader/paxo_config.ini: -------------------------------------------------------------------------------- 1 | [Basics] 2 | olsAPIURL=https://www.ebi.ac.uk/ols/api/ 3 | oxoURL=https://www.ebi.ac.uk/spot/oxo/api/search 4 | logFile=../paxo.log 5 | neoURL=bolt://localhost:7687 6 | neoUser=neo4j 7 | neoPW=neopassword 8 | 9 | [Params] 10 | scoringTargetFolder=../data/scoring/ 11 | predictedTargetFolder=../data/predicted/ 12 | validationTargetFolder=../data/evaluation/ 13 | ; Neo needs full path! 14 | neoFolder=/path/path/neo_export/ 15 | StopwordsList=of,the 16 | writeToDiscFlag=True 17 | uniqueMaps=False 18 | 19 | [mp_hp] 20 | sourceOntology=mp 21 | targetOntology=hp 22 | standard=silver 23 | silver=standard/std_hp-mp.tsv 24 | uri1silver=2 25 | uri2silver=0 26 | scorePositionsilver=4 27 | delimitersilver=t 28 | fuzzyUpperLimit=0.8 29 | fuzzyLowerLimit=0.6 30 | fuzzyUpperFactor=1 31 | fuzzyLowerFactor=0.6 32 | oxoDistanceOne=1 33 | oxoDistanceTwo=0.3 34 | oxoDistanceThree=0.1 35 | synFuzzyFactor=0.6 36 | synOxoFactor=0.4 37 | bridgeOxoFactor=1 38 | threshold=0.6 39 | -------------------------------------------------------------------------------- /paxo-loader/readme.md: -------------------------------------------------------------------------------- 1 | 2 | scripts to generate predicted mappings. 3 | You can evaluate paxo using a gold standard set of mappings. The *standard folder* contains an example of how the gold standard mapppings needs to be formatted. 4 | 5 | ### Prerequisite 6 | 7 | - In order to install dependencies, first ensure that you have Python 2.7 and a corresponding version of pip. 8 | - With pip 2.7, you need to install the prerequisite python modules listed specifically in this directory, thus: 9 | > `pip install -r requirements.txt` 10 | - Paxo tries to predict mappings between two ontologies, that are present in the Ontology Lookup Service (OLS). It's also possible to try to map a list of terms with one target ontology in OLS. 11 | 12 | ### Usage (short) 13 | 14 | 1. First create a raw score with 15 | > python paxo.py paxo_config.ini -s 16 | 17 | 2. Calculate a score with: 18 | > python paxo.py paxo_config.ini -c 19 | 20 | 3. Calculate and Validated a primary score: 21 | > python paxo.py paxo_config.ini -cv 22 | 23 | 4. Create a csv file that is compatible with oxo. Based on a previously calculated score 24 | > python paxo.py paxo_config.ini -n 25 | 26 | 5. Create a mapping file, given not a "real" ontology but a list of terms 27 | > python paxo.py listprocessing_config.ini -l 28 | 29 | ### More about usage 30 | **About 1:** The primary, 'raw' score is the base for the calculation of the mapping score. This has to execute many calls to the OLS and Oxo API and can take a long time. The files created by this step thus are somewhat of a 'checkpoint'. 31 | 32 | **About 2:** Reading in the raw score, created by the -s option, this function calculates the actual score and tries to predict mappings. The final result is strongly influenced by the parameters defined in the config file (e.g. threshold). 33 | 34 | **About 3:** If validation files (a 'standard') is available, the calculated result can be evaluated against this standard by using the -cv flag (first a score is calculated, then validated) 35 | 36 | **About 4:** The option -n creates a csv file that can be loaded into OxO. This option reads in file create by the -c option. 37 | 38 | **About 5:** To create a mapping file between a list of terms and an ontology, start paxo with -l 39 | 40 | ### Parameter explanation 41 | To run paxo it is mandatory to provide a config file with context. The dummy config files in the config folder should provide an easy start into creating your own config file. The structure of the config file for the mapping of ontologies (flag:-s,-c, -cv) and the listprocessing (flag:-l) are slightly different, most parameters are the same. Most parameters should be self-explanatory, others are described here in a few words. 42 | 43 | #### Shared values for all configs 44 | **StopwordsList** Words that are cut out before string compare. Candidates for this are e.g. 'the' or 'of' but could also be words you don't want to consider e.g. 'abnormality' 45 | 46 | **fuzzyUpperLimit** Upper limit of a fuzzy label score. A score above this limit is multiplied with the fuzzyUpperFactor. A fuzzy score of 1 is the highest, so equivalent labels (exact match) 47 | 48 | **fuzzyUpperFactor** Factor for a fuzzy label score above the fuzzy upper limit 49 | 50 | **fuzzyLowerLimit** A fuzzy label score between the upper and lower limit is multiplied by the fuzzyLowerFactor for the final score. A score below thus limit is discarded and leads to a fuzzy score of 0. 51 | 52 | **fuzzyLowerFactor** Factor for a fuzzy label score between the upper and the lower limit 53 | 54 | **oxoDistanceOne** Score for a connection of distance 1 in Oxo 55 | 56 | **oxoDistanceTwo** Score for a connection of distance 2 in Oxo 57 | 58 | **oxoDistanceThree** Score for a connection of distance 3 in Oxo 59 | 60 | **synFuzzyFactor** Factor to weight a fuzzy label matching of a synonym 61 | 62 | **synOxoFactor** Weight for a link that was found in Oxo but via a synonym and not the preferred label 63 | 64 | **bridgeOxoFactor** Weight for a bridge term 65 | 66 | **threshold** Threshold for the mappings. Only the final score above this threshold is considered as a mapping and printed to the file 67 | 68 | 69 | #### Config for listprocessing 70 | **inputFile** Path to the input file, consisting of 3 rows (ids, labels, optional synonyms) 71 | 72 | **resultFile** /path/output-file.csv 73 | 74 | **detailLevel** Value can be 0,1 or 2 depending on how much detail should be printed to the final file. Value 2 is the verbose mode, where one could spot alternatives to the suggested map 75 | 76 | **delimiter** delimiter of the input file, in most cases e.g. *,* 77 | 78 | **synonymSplitChar** delimiter of the synonyms that are located in the 3 row, could be e.g. *|* or *;* ... 79 | -------------------------------------------------------------------------------- /paxo-loader/requirements.txt: -------------------------------------------------------------------------------- 1 | pyyaml 2 | requests 3 | python-levenshtein 4 | flask 5 | neo4j-driver 6 | -------------------------------------------------------------------------------- /paxo-loader/standard/dummy-standard.csv: -------------------------------------------------------------------------------- 1 | #URI 1,Label 1,URI 2,Label 2,Confidence 2 | http://purl.obolibrary.org/obo/DOID_0060263,porencephaly,http://id.nlm.nih.gov/mesh/2017/D065708,familial porencephalic white matter disease,1 -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | uk.ac.ebi.spot 6 | oxo 7 | 0.0.17-SNAPSHOT 8 | 9 | oxo-web 10 | oxo-model 11 | oxo-indexer 12 | 13 | pom 14 | 15 | EMBL-EBI ontology cross-reference service (OxO) 16 | Web applications for hosting ontology xrefs 17 | https://github.com/EBISPOT/OLS-mapping-service 18 | 19 | EMBL-EBI European Bioinformatics Institute 20 | http://www.ebi.ac.uk 21 | 22 | 23 | 24 | 25 | Apache License, Version 2.0 26 | http://www.apache.org/licenses/LICENSE-2.0 27 | 28 | 29 | 30 | 31 | simonjupp 32 | Simon Jupp 33 | jupp at ebi.ac.uk 34 | EMBL-EBI European Bioinformatics Institute 35 | http://www.ebi.ac.uk 36 | 37 | Project lead 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | EMBL-EBI Samples, Phenotypes and Ontologies Team 47 | ontology-tools-support@ebi.ac.uk 48 | 49 | 50 | 51 | 52 | 53 | github 54 | https://github.com/EBISPOT/OLS-mapping-service/issues 55 | 56 | 57 | 58 | scm:git:https://github.com/EBISPOT/OLS-mapping-service.git 59 | http://github.com/EBISPOT/OLS-mapping-service 60 | scm:git:https://github.com/EBISPOT/OLS-mapping-service.git 61 | HEAD 62 | 63 | 64 | 65 | 66 | nexus-release 67 | Releases 68 | https://www.ebi.ac.uk/spot/nexus/repository/maven-releases/ 69 | 70 | 71 | nexus-snapshot 72 | Snapshot 73 | https://www.ebi.ac.uk/spot/nexus/repository/maven-snapshots/ 74 | 75 | 76 | nexus-site 77 | dav:https://www.ebi.ac.uk/spot/nexus/repository/spot-oxo-site/ 78 | 79 | 80 | 81 | 82 | org.springframework.boot 83 | spring-boot-starter-parent 84 | 1.4.5.RELEASE 85 | 86 | 87 | 88 | 89 | UTF-8 90 | 1.8 91 | 92 | 93 | 94 | 95 | org.apache.maven.wagon 96 | wagon-webdav-jackrabbit 97 | 2.12 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | org.springframework.boot 109 | spring-boot-starter-test 110 | test 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | spring-milestone 119 | Spring Milestone Repository 120 | https://repo.spring.io/milestone 121 | 122 | 123 | nexus-public 124 | Public Repository 125 | https://www.ebi.ac.uk/spot/nexus/repository/maven-public/ 126 | 127 | true 128 | 129 | 130 | true 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | org.apache.maven.plugins 139 | maven-release-plugin 140 | 2.5.3 141 | 142 | @{project.version} 143 | true 144 | 145 | 146 | 147 | org.apache.maven.plugins 148 | maven-javadoc-plugin 149 | 2.10.4 150 | 151 | 152 | maven-site-plugin 153 | 3.5.1 154 | 155 | 156 | org.apache.maven.wagon 157 | wagon-webdav-jackrabbit 158 | 2.12 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | org.apache.maven.plugins 169 | maven-project-info-reports-plugin 170 | RELEASE 171 | 172 | 173 | org.apache.maven.plugins 174 | maven-javadoc-plugin 175 | 2.8.1 176 | 177 | 178 | aggregate 179 | 180 | aggregate 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /queries.txt: -------------------------------------------------------------------------------- 1 | 2 | # Get mappings distance 2 filtering by either source or datsource target 3 | MATCH path= shortestPath( (ft:Term)-[m:MAPPING*1..2]-(tt:Term)) 4 | WHERE ft.curie = 'EFO:0004230' 5 | WITH tt,path, extract ( r in m | r.sourcePrefix) as source 6 | MATCH (tt)-[HAS_SOURCE]-(td) 7 | WHERE 'KEGG' in td.prefix and 'efo' in source 8 | UNWIND source as source1 9 | RETURN tt.curie, tt.label,collect (distinct td.prefix), collect (distinct source1), length(path) as dist 10 | ORDER BY dist 11 | 12 | 13 | # old experimental stuff below 14 | 15 | CREATE CONSTRAINT ON (i:Identifier) ASSERT i.term IS UNIQUE 16 | CREATE CONSTRAINT ON (i:Uri) ASSERT i.term IS UNIQUE 17 | CREATE CONSTRAINT ON (i:Cui) ASSERT i.term IS UNIQUE 18 | CREATE CONSTRAINT ON (i:PrefixedCui) ASSERT i.term IS UNIQUE 19 | CREATE CONSTRAINT ON (i:Datasource) ASSERT i.prefix IS UNIQUE 20 | 21 | CREATE INDEX ON :Datasource(source) 22 | CREATE INDEX ON :MAPPING(sourceName) 23 | CREATE INDEX ON :MAPPING(scope) 24 | 25 | 26 | Queries 27 | 28 | Get direct xrefs for a term (show sources) 29 | 30 | 31 | Match (u:Uri)-[r1:XREF]->(x:PrefixedCui)<-[r2:XREF]-(u1:Uri) 32 | Where u.term = 'http://www.ebi.ac.uk/efo/EFO_0000349' 33 | Return u1.term, collect (distinct r1.sourcePrefix) + collect(distinct r2.sourcePrefix) 34 | 35 | 36 | Get derived xrefs (1 hop) - high score 37 | 38 | term -> xref -> term -> xref 39 | 40 | Get derived xrefs (4 hops) - low score 41 | 42 | Get lexical mappings 43 | - search zooma, get best hits, get high score mappings for those 44 | 45 | 46 | Mapping project 47 | 48 | 1. Take HP, hit Zooma with each label, get ORDO hits. 49 | 2. Take HP, hit Zooma, with each id hit, get mappings to ordo. 50 | 51 | 52 | MATCH (c:Identifier)-[*1..5]-(m:Uri) 53 | WHERE c.term = 'HP:0000819' 54 | WITH m as mappedUri 55 | MATCH (mappedUri)-[:DATASOURCE]->(d:Datasource { prefix : 'ordo'}) 56 | WITH mappedUri as ordoUri 57 | MATCH (ordoUri)-[ATLID]->(ordoP:PrefixedCui) 58 | RETURN distinct ordoP.term 59 | 60 | 61 | MATCH (source:Uri)-[DATASOURCE]->(d:Datasource { prefix : 'efo'}) 62 | WITH source 63 | MATCH path = allShortestPaths ( (c:Identifier)-[:ALTID|:XREF*..10]-(source) ) 64 | WHERE c.term = 'DOID_4467' 65 | RETURN distinct source.term , length(path) as dist 66 | ORDER BY dist 67 | 68 | 69 | // find a Uri 70 | 71 | MATCH (i:Identifier)-[*0..1]-(u:Uri) 72 | WHERE i.term = 'EFO_0000001' 73 | RETURN u.term 74 | 75 | 76 | 77 | // Use case 78 | 79 | Given set of ids 80 | 81 | 1. Get all mappings (don't map to own datasource) 82 | 83 | x1 mapped to y1 (1 sources) 84 | x1 mapped to y2 (2 sources) 85 | x1 mapped to z3 (2 sources) (inferred) (show) 86 | 87 | 2. Get mappings to ontology (e..g HP) 88 | 89 | x1 mapped to y1 (1 sources) 90 | x1 mapped to y2 (2 sources) 91 | x1 mapped to z3 (2 sources) (inferred) (show) 92 | 93 | 3. Need ability to validate 94 | 95 | 4. Ability to add new mapping -------------------------------------------------------------------------------- /solr-config/mapping/conf/_rest_managed.json: -------------------------------------------------------------------------------- 1 | {"initArgs":{},"managedList":[]} 2 | -------------------------------------------------------------------------------- /solr-config/mapping/conf/lang/stopwords_en.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # a couple of test stopwords to test that the words are really being 17 | # configured from this file: 18 | stopworda 19 | stopwordb 20 | 21 | # Standard english stop words taken from Lucene's StopAnalyzer 22 | a 23 | an 24 | and 25 | are 26 | as 27 | at 28 | be 29 | but 30 | by 31 | for 32 | if 33 | in 34 | into 35 | is 36 | it 37 | no 38 | not 39 | of 40 | on 41 | or 42 | such 43 | that 44 | the 45 | their 46 | then 47 | there 48 | these 49 | they 50 | this 51 | to 52 | was 53 | will 54 | with 55 | -------------------------------------------------------------------------------- /solr-config/mapping/conf/protwords.txt: -------------------------------------------------------------------------------- 1 | # The ASF licenses this file to You under the Apache License, Version 2.0 2 | # (the "License"); you may not use this file except in compliance with 3 | # the License. You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | #----------------------------------------------------------------------- 14 | # Use a protected word file to protect against the stemmer reducing two 15 | # unrelated words to the same base word. 16 | 17 | # Some non-words that normally won't be encountered, 18 | # just to test that they won't be stemmed. 19 | dontstems 20 | zwhacky 21 | 22 | -------------------------------------------------------------------------------- /solr-config/mapping/conf/stopwords.txt: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | -------------------------------------------------------------------------------- /solr-config/mapping/conf/synonyms.txt: -------------------------------------------------------------------------------- 1 | # The ASF licenses this file to You under the Apache License, Version 2.0 2 | # (the "License"); you may not use this file except in compliance with 3 | # the License. You may obtain a copy of the License at 4 | # 5 | # http://www.apache.org/licenses/LICENSE-2.0 6 | # 7 | # Unless required by applicable law or agreed to in writing, software 8 | # distributed under the License is distributed on an "AS IS" BASIS, 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | # See the License for the specific language governing permissions and 11 | # limitations under the License. 12 | 13 | #----------------------------------------------------------------------- 14 | #some test synonym mappings unlikely to appear in real input text 15 | aaafoo => aaabar 16 | bbbfoo => bbbfoo bbbbar 17 | cccfoo => cccbar cccbaz 18 | fooaaa,baraaa,bazaaa 19 | 20 | # Some synonym groups specific to this example 21 | GB,gib,gigabyte,gigabytes 22 | MB,mib,megabyte,megabytes 23 | Television, Televisions, TV, TVs 24 | #notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming 25 | #after us won't split it into two words. 26 | 27 | # Synonym mappings can be used for spelling correction too 28 | pixima => pixma 29 | 30 | -------------------------------------------------------------------------------- /solr-config/mapping/core.properties: -------------------------------------------------------------------------------- 1 | #Written by CorePropertiesLocator 2 | #Tue Oct 14 12:47:52 BST 2014 3 | name=mapping 4 | dataDir=${solr.data.dir}/data 5 | -------------------------------------------------------------------------------- /solr-config/solr.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | ${host:} 35 | ${jetty.port:8983} 36 | ${hostContext:solr} 37 | 38 | ${genericCoreNodeNames:true} 39 | 40 | ${zkClientTimeout:30000} 41 | ${distribUpdateSoTimeout:600000} 42 | ${distribUpdateConnTimeout:60000} 43 | 44 | 45 | 46 | 48 | ${socketTimeout:600000} 49 | ${connTimeout:60000} 50 | 51 | 52 | 53 | --------------------------------------------------------------------------------