-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create PDBe partial markup from web services
- Loading branch information
Showing
10 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"env", { | ||
"targets": { | ||
"ie": 11 | ||
}, | ||
"modules": false | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"external-helpers" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.DS_Store | ||
|
||
npm-debug.log | ||
yarn.lock | ||
|
||
dist | ||
node_modules | ||
package-lock.json | ||
|
||
.idea | ||
*.log | ||
coverage | ||
.info | ||
.coveralls.yml | ||
.sass-cache | ||
.project | ||
.settings | ||
config.rb | ||
*.iml | ||
reports | ||
_includes | ||
_posts | ||
_sass | ||
_site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<title>bioschemas-pdbe-adapter-demo</title> | ||
|
||
</head> | ||
<body> | ||
<bioschemas-pdbe-adapter id="adapter1"> | ||
<data-loader id="loader1"> | ||
<source src="http://www.ebi.ac.uk/pdbe/api/pdb/entry/summary/1BZG" /> | ||
</data-loader> | ||
</bioschemas-pdbe-adapter> | ||
|
||
<!-- Required for IE11 --> | ||
<script src="../node_modules/babel-polyfill/dist/polyfill.min.js"></script> | ||
<!-- Web component polyfill (only loads what it needs) --> | ||
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js" charset="utf-8"></script> | ||
<!-- Required to polyfill modern browsers as code is ES5 for IE... --> | ||
<script src="../node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js" charset="utf-8"></script> | ||
|
||
<script src="../node_modules/protvista-uniprot-entry-adapter/dist/ProtVistaUniProtEntryAdapter.js" charset="utf-8" defer></script> | ||
<script src="../node_modules/data-loader/dist/index.js" charset="utf-8" defer></script> | ||
<script src="../dist/BioschemasPDBeAdapter.js" charset="utf-8" defer></script> | ||
|
||
|
||
<script> | ||
for (const adapter of document.querySelectorAll('bioschemas-pdbe-adapter')) { | ||
adapter.addEventListener( | ||
'load', | ||
e => { | ||
console.log('Data loaded'); | ||
console.log(e.target); | ||
console.log(e.detail); | ||
} | ||
); | ||
adapter.addEventListener( | ||
'error', | ||
e => { | ||
console.log('error'); | ||
console.log(e.target); | ||
console.log(e.detail); | ||
} | ||
); | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<title>bioschemas-pdbe-adapter-demo</title> | ||
|
||
</head> | ||
<body> | ||
<bioschemas-pdbe-adapter id="adapter1"> | ||
<data-loader id="loader1"> | ||
<source src="http://www.ebi.ac.uk/pdbe/api/pdb/entry/summary/1BZG" /> | ||
</data-loader> | ||
</bioschemas-pdbe-adapter> | ||
|
||
|
||
<!-- Required for IE11 --> | ||
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script> | ||
<!-- Web component polyfill (only loads what it needs) --> | ||
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/webcomponents-lite.js" charset="utf-8"></script> | ||
<!-- Required to polyfill modern browsers as code is ES5 for IE... --> | ||
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js" charset="utf-8"></script> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/protvista-uniprot-entry-adapter/dist/ProtVistaUniProtEntryAdapter.js" charset="utf-8" defer></script> | ||
<script src="https://cdn.jsdelivr.net/npm/data-loader@latest/dist/index.js" charset="utf-8" defer></script> | ||
<script src="https://cdn.jsdelivr.net/npm/protvista-feature-adapter/dist/BioschemasPDBeAdapter.js" charset="utf-8" defer></script> | ||
|
||
|
||
<script> | ||
for (const adapter of document.querySelectorAll('bioschemas-pdbe-adapter')) { | ||
adapter.addEventListener( | ||
'load', | ||
e => { | ||
console.log('Data loaded'); | ||
console.log(e.target); | ||
console.log(e.detail); | ||
} | ||
); | ||
adapter.addEventListener( | ||
'error', | ||
e => { | ||
console.log('error'); | ||
console.log(e.target); | ||
console.log(e.detail); | ||
} | ||
); | ||
} | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "bioschemas-pdbe-adapter", | ||
"version": "0.0.1", | ||
"description": "Adapter/Converter from PDBe services to Bioschemas JSON-LD ", | ||
"main": "dist/BioschemasPDBeAdapter.js", | ||
"module": "src/index.js", | ||
"jsnext:main": "src/index.js", | ||
"scripts": { | ||
"build": "rimraf ./dist && mkdirp ./dist && rollup -c", | ||
"rollup-watch": "rollup -cw", | ||
"browser-sync": "browser-sync start --server -f dist/**/*.*", | ||
"serve": "npm run rollup-watch & npm run browser-sync", | ||
"npm-linkall": "npm link protvista-uniprot-entry-adapter data-loader" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/bioschemas/bioschemas-pdbe-adapter.git" | ||
}, | ||
"keywords": [ | ||
"Bioschemas", | ||
"dataloader", | ||
"parser" | ||
], | ||
"author": "ljgarcia", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/bioschemas/bioschemas-pdbe-adapter/issues" | ||
}, | ||
"homepage": "https://github.com/bioschemas/bioschemas-pdbe-adapter#readme", | ||
"devDependencies": { | ||
"@webcomponents/webcomponentsjs": "^1.0.19", | ||
"babel-cli": "^6.24.1", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-env": "^1.6.1", | ||
"browser-sync": "^2.18.13", | ||
"mkdirp": "^0.5.1", | ||
"rimraf": "^2.6.1", | ||
"rollup": "^0.49.3", | ||
"rollup-plugin-babel": "^2.7.1", | ||
"rollup-plugin-node-resolve": "^3.0.0" | ||
}, | ||
"dependencies": { | ||
"lodash-es": "^4.17.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import babel from 'rollup-plugin-babel'; | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
|
||
export default { | ||
input: 'src/index.js', | ||
output: { | ||
file: 'dist/BioschemasPDBeAdapter.js', | ||
format: 'iife', | ||
name: 'BioschemasPDBeAdapter', | ||
sourcemap: true, | ||
globals: { | ||
'protvista-uniprot-entry-adapter': 'ProtVistaUniProtEntryAdapter' | ||
} | ||
}, | ||
external: ['protvista-uniprot-entry-adapter'], | ||
plugins: [ | ||
nodeResolve({jsnext: true}), | ||
babel({ | ||
exclude: 'node_modules/**' | ||
}) | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*jslint node: true */ | ||
"use strict"; | ||
|
||
import ProtVistaUniProtEntryAdapter from 'protvista-uniprot-entry-adapter'; | ||
import ParserHelper from './ParserHelper'; | ||
|
||
export default class BioschemasPDBeAdapter extends ProtVistaUniProtEntryAdapter { | ||
constructor() { | ||
super(); | ||
this._parser = new ParserHelper(); | ||
} | ||
|
||
parseEntry(data) { | ||
this._adaptedData = this._parser.adaptData(data); | ||
this._renderEntry(); | ||
return this._adaptedData; | ||
} | ||
|
||
_renderEntry() { | ||
const s = document.createElement('script'); | ||
s.type = 'application/ld+json'; | ||
s.innerHTML = JSON.stringify(this._adaptedData, null, 2); | ||
document.body.appendChild(s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export const context = { | ||
"@context": [ | ||
"http://schema.org", | ||
{ | ||
"@base": "http://schema.org" | ||
}, | ||
{ | ||
"ProteinStructure": { | ||
"@id": "http://semanticscience.org/resource/SIO_011119" | ||
}, | ||
"Protein": { | ||
"@id": "http://purl.obolibrary.org/obo/PR_000000001" | ||
}, | ||
"structureDeterminationMethod": { | ||
"@id": "structureDeterminationMethod", | ||
"@type": "@id" | ||
}, | ||
"resolution": { | ||
"@id": "resolution", | ||
"@type": "@id" | ||
}, | ||
"Domain": "http://semanticscience.org/resource/SIO_001379.rdf", | ||
"boundMolecule": { | ||
"@id": "boundMolecule", | ||
"@type": "@id" | ||
}, | ||
"Organism": { | ||
"@id": "http://semanticscience.org/resource/SIO_010000" | ||
} | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*jslint node: true */ | ||
"use strict"; | ||
|
||
import _filter from 'lodash-es/filter'; | ||
import _assign from 'lodash-es/assign'; | ||
import _map from 'lodash-es/map'; | ||
import {context} from './Context'; | ||
|
||
export default class ParserHelper { | ||
constructor() { | ||
this._accession = null; | ||
this._adaptedData = _assign({}, context); | ||
this._entry = {}; | ||
} | ||
|
||
adaptData(entry) { | ||
this._accession = Object.keys(entry)[0]; | ||
this._entry = entry[this._accession][0]; | ||
this._adaptRecord(); | ||
this._adaptMinimum(); | ||
return this._adaptedData; | ||
} | ||
|
||
_adaptRecord() { | ||
this._adaptedData = _assign(this._adaptedData, { | ||
"@type": "DataRecord", | ||
"@id": `http://www.identifiers.org/pdbe:${this._accession}`, | ||
"identifier": this._accession, | ||
"url": `http://pdbe.org/${this._accession}`, | ||
"datePublished": this._entry.revision_date, | ||
"distribution": { | ||
"@type": "DataDownload", | ||
"url": `http://www.ebi.ac.uk/pdbe/entry-files/download/${this._accession}.cif` | ||
} | ||
}); | ||
} | ||
|
||
|
||
_adaptMinimum() { | ||
this._adaptedData.mainEntity = { | ||
"@type": ["BioChemEntity", "ProteinStructure"], | ||
"identifier": this._accession | ||
}; | ||
try { | ||
this._adaptedData.mainEntity.name = this._entry.title; | ||
this._adaptedData.mainEntity.structureDeterminationMethod = this._entry.experimental_method; | ||
} catch (e) { | ||
this._adaptedData.mainEntity.name = this._accession; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import BioschemasPDBeAdapter from './BioschemasPDBeAdapter'; | ||
|
||
if (window.customElements) { | ||
customElements.define('bioschemas-pdbe-adapter', BioschemasPDBeAdapter); | ||
} | ||
|
||
export default BioschemasPDBeAdapter; |