Skip to content

Commit

Permalink
Merge pull request nglviewer#1043 from ppillot/rcsb-provider-fixes
Browse files Browse the repository at this point in the history
Rcsb provider critical fixes

MMTF deprecation seems to be already effective. 
Using RCSB provider on http://localhost fails due to http protocol being used and redirection to https not being followed.
  • Loading branch information
ppillot authored Jun 23, 2024
2 parents 5d64dbe + 8484421 commit 598e005
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/datasource/pdbe-datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PDBeDatasource extends Datasource {

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

Expand Down
34 changes: 14 additions & 20 deletions src/datasource/rcsb-datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
*/

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

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/'
const protocol = 'https:'

class RcsbDatasource extends Datasource {
getUrl (src: string) {
Expand All @@ -22,35 +19,32 @@ class RcsbDatasource extends Datasource {
// XXXX defaults to XXXX.cif
const info = getFileInfo(src)
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')
return protocol + baseUrl + info.path
}

if (info.ext === 'mmtf') {
Log.warn('MMTF files distribution has been discontinued by RCSB PDB as of July 2024.\n Defaulting to 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
Log.warn('Backbone only files are not available from RCSB PDB anymore.')
}
} else if (info.ext === 'bcif' &&
(info.compressed === false || info.compressed === 'gz')
) {
url = bcifBaseUrl + info.path
} else if (!info.ext) {
info.ext = ''
}

if (!info.ext) {
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 = bcifBaseUrl + pdbid + '.bcif.gz'
}
return getProtocol() + url

return protocol + bcifBaseUrl + pdbid + '.bcif.gz'
}

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

Expand Down

0 comments on commit 598e005

Please sign in to comment.