Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1015 binary cif support #1040

Merged
merged 29 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
27af64d
Types inference improvements: Structure in StructureParser
papillot Apr 19, 2024
12b3a39
Add molstar as a dependency (importing mol-io)
papillot Apr 19, 2024
06f9638
Allow async parsing methods
papillot Apr 24, 2024
5c8512c
Parsing single model binary cif from RCSB
papillot Apr 24, 2024
d22fde3
Implement core and chem_comp schema
papillot Apr 25, 2024
7cc5177
Use DSSP codes from struct_conf for alpha fold ss assignation
papillot Apr 25, 2024
0a98d4c
Handle `asTrajectory` and `firstModelOnly` flags
papillot Apr 26, 2024
8600fb3
Get connectivity from chem_comp_bond
papillot Apr 27, 2024
562bcee
Update RCSB datasource to default to binary cif files
papillot Apr 27, 2024
5142a68
Add PDBe server as datasource
papillot Apr 27, 2024
1c49703
Use PDBe by default when opening PDB codes
papillot Apr 27, 2024
7b4520c
remove cif-parser.ts file
papillot Apr 27, 2024
e753c61
Rename bcif-parser to cif-parser
papillot Apr 27, 2024
913bc68
type Structure.extraData.cif
papillot Apr 27, 2024
6d5036f
update alphafold datasource suffix
papillot Apr 27, 2024
0be4bdd
ebi.ac.uk does not support requests made on http:// protocol
papillot Apr 27, 2024
36ea60f
fix import
papillot Apr 27, 2024
6a47681
fix: jest cannot import modules from molstar dir
papillot Apr 28, 2024
38136c1
fix: origx property is malformed
papillot Apr 28, 2024
b17f3de
fix: parse connections is broken
papillot Apr 28, 2024
3445e65
fix default export must be CifParser (backwards compatibility)
papillot Apr 28, 2024
c3acca1
remove unused code
papillot Apr 28, 2024
e2b9ec0
fix: float(i) returns 0 if value is missing
papillot Apr 28, 2024
72e1106
4CWU superseded by 6CGV
papillot May 4, 2024
0bca727
fix: operator expression with parentheses breaks parser
papillot May 4, 2024
1974924
fix: compressed cif files are parsed as binary
papillot May 21, 2024
f1e6471
fix: alt-loc is always empty
papillot May 21, 2024
ac675d2
update file header
papillot May 21, 2024
cc34e1d
fix: some entities might be defined but not have any coordinates
papillot May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/js/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ NGL.MenubarFileWidget = function (stage) {

function onPdbInputKeyDown (e) {
if (e.keyCode === 13) {
stage.loadFile('rcsb://' + e.target.value.trim(), {
const val = e.target.value.trim()
const protocol = val.startsWith('AF_') ? 'rcsb://' : 'pdbe://'
stage.loadFile(protocol + val, {
defaultRepresentation: true
})
e.target.value = ''
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/showcase/viruses.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function createElement (name, properties, style) {
return el
}

var pdbs = [ '1stm', '3nap', '1sid', '2ft1', '4cwu' ]
var pdbs = [ '1stm', '3nap', '1sid', '2ft1', '6cgv' ]
var colors = [ 'red', 'yellow', 'green', 'lightblue', 'violet' ]

Promise.all(pdbs.map(function (id) {
Expand Down
21,160 changes: 5,959 additions & 15,201 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 6 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prebuild": "npm run lint",
"build": "npm run dts && rollup -c",
"postbuild": "node ./scripts/makeScriptsList.js",
"test": "jest",
"test": "vitest --globals",
"preversion": "npm test",
"version": "npm run build-min && git add -A dist",
"postversion": "git push && git push --tags",
Expand All @@ -27,17 +27,6 @@
"prerelease": "./scripts/release.sh prerelease",
"build-min": "npm run lint && npm run dts && rollup -c rollup.config.dist.js"
},
"jest": {
"moduleFileExtensions": [
"ts",
"js"
],
"transform": {
"\\.ts$": "ts-jest",
"\\.es6\\.js": "babel-jest"
},
"testRegex": "\\.spec\\.ts|kin.*test.ts$"
},
"homepage": "https://github.com/arose/ngl#readme",
"repository": {
"type": "git",
Expand Down Expand Up @@ -67,24 +56,23 @@
"@rollup/plugin-typescript": "^8.1.1",
"@types/chroma-js": "^1.3.5",
"@types/jest": "^27.5.1",
"@types/node": "^10.17.9",
"@types/offscreencanvas": "^2019.6.4",
"@types/signals": "1.0.1",
"@types/sprintf-js": "^1.1.2",
"@types/three": "^0.158.2",
"@yushijinhun/three-minifier-rollup": "^0.3.1",
"babel-plugin-array-includes": "^2.0.3",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^24.0.0",
"rollup": "^2.38.5",
"standard": "^17.1.0",
"ts-jest": "^29.1.1",
"standard": "^11.0.1",
"tslib": "^2.3.1",
"typedoc": "^0.22.15",
"typescript": "^4.5.4"
"typescript": "^4.5.4",
"vitest": "^1.5.2"
},
"dependencies": {
"chroma-js": "^1.3.7",
"molstar": "^4.1.0",
"signals": "^1.0.0",
"sprintf-js": "^1.1.2",
"three": "^0.158.0"
Expand Down
5 changes: 2 additions & 3 deletions src/datasource/alphafold-datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
*/

import { Log, DatasourceRegistry } from '../globals'
import { getProtocol } from '../utils'
import { getFileInfo } from '../loader/loader-utils'
import Datasource from './datasource'

const baseUrl = '//alphafold.ebi.ac.uk/files/AF-'
const suffixURL = '-F1-model_v2.pdb'
const suffixURL = '-F1-model_v4.pdb'

class AlphafoldDatasource extends Datasource {
getUrl (src: string) {
Expand All @@ -23,7 +22,7 @@ class AlphafoldDatasource extends Datasource {
Log.warn('unsupported AF ext', info.ext)
url = baseUrl + uniprotid + suffixURL
}
return getProtocol() + url
return 'https://' + url
}

getExt (src: string) {
Expand Down
58 changes: 58 additions & 0 deletions src/datasource/pdbe-datasource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @file PDB Europe Datasource
* @author Paul Pillot <[email protected]>
* @private
*/

import { Log, DatasourceRegistry } from '../globals'
import { getFileInfo } from '../loader/loader-utils'
import Datasource from './datasource'

const baseUrl = '//www.ebi.ac.uk/pdbe/entry-files/download/'

// Examples:
//https://www.ebi.ac.uk/pdbe/entry-files/download/5z6y_updated.cif
//https://www.ebi.ac.uk/pdbe/entry-files/download/pdb5z6y.ent
//https://www.ebi.ac.uk/pdbe/entry-files/download/5z6y.bcif

class PDBeDatasource extends Datasource {
getUrl (src: string) {
// valid path are
// XXXX.pdb, XXXX.ent, XXXX.cif, XXXX.bcif
// XXXX defaults to XXXX.bcif
const info = getFileInfo(src)
let pdbid = info.name.indexOf('_') > -1 ? info.name : info.name.substring(0, 4) // Allow extended pdb codes
let url
switch (info.ext) {
case 'cif':
url = baseUrl + pdbid + '_updated.cif' // "Updated mmcif" files contain connectivity
break
case 'pdb':
case 'ent':
if (!pdbid.startsWith('pdb')) {
pdbid = 'pdb' + pdbid
}
url = baseUrl + pdbid + '.ent'
break
case 'bcif':
url = baseUrl + info.path
break
case '':
url = baseUrl + pdbid + '.bcif'
break
default:
Log.warn('unsupported ext', info.ext)
url = baseUrl + pdbid + '.bcif'
}
return 'https://' + url
}

getExt (src: string) {
const ext = getFileInfo(src).ext
return ext ? ext : 'mmtf'
}
}

DatasourceRegistry.add('pdbe', new PDBeDatasource())

export default PDBeDatasource
13 changes: 10 additions & 3 deletions src/datasource/rcsb-datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,37 @@ const baseUrl = '//files.rcsb.org/download/'
const mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'
const mmtfFullUrl = mmtfBaseUrl + 'full/'
const mmtfReducedUrl = mmtfBaseUrl + 'reduced/'
const bcifBaseUrl = '//models.rcsb.org/'

class RcsbDatasource extends Datasource {
getUrl (src: string) {
// valid path are
// XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf
// XXXX defaults to XXXX.cif
const info = getFileInfo(src)
const pdbid = info.name.substr(0, 4)
const pdbid = info.name.indexOf('_') > -1 ? info.name : info.name.substring(0, 4) // Allow extended pdb codes and alphafold codes
let url
if ([ 'pdb', 'cif' ].includes(info.ext) &&
(info.compressed === false || info.compressed === 'gz')
) {
url = baseUrl + info.path
} else if (info.ext === 'mmtf') {
Log.warn('MMTF files distribution is discontinued by RCSB PDB as of July 2, 2024.\n Consider using bcif format instead. See https://www.rcsb.org/news/65a1af31c76ca3abcc925d0c for the deprecation notice')
if (info.base.endsWith('.bb')) {
url = mmtfReducedUrl + pdbid
} else {
url = mmtfFullUrl + pdbid
}
} else if (info.ext === 'bcif' &&
(info.compressed === false || info.compressed === 'gz')
) {
url = bcifBaseUrl + info.path
} else if (!info.ext) {
url = mmtfFullUrl + pdbid
Log.warn('mmCif files available from RCSB PDB lack connectivity information.\n Consider using PDBe as the data provider for using "Updated mmCif files" that contain residues connectivity records.')
url = bcifBaseUrl + pdbid + '.bcif.gz'
} else {
Log.warn('unsupported ext', info.ext)
url = mmtfFullUrl + pdbid
url = bcifBaseUrl + pdbid + '.bcif.gz'
}
return getProtocol() + url
}
Expand Down
1 change: 1 addition & 0 deletions src/ngl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ import './utils/gzip-decompressor'
//

import './datasource/rcsb-datasource'
import './datasource/pdbe-datasource'
import './datasource/pubchem-datasource'
import './datasource/passthrough-datasource'
import './datasource/alphafold-datasource'
Expand Down
Loading
Loading