Skip to content

Commit

Permalink
rcsb provider: remove mmtf support, always use https
Browse files Browse the repository at this point in the history
RCSB redirects calls from http to https, but the redirection is not handled by the Streamer code.
MMTF support has now been removed from RCSB. Default to bfic for compatibility and log warnings.
  • Loading branch information
ppillot committed Jun 23, 2024
1 parent 04b4ebc commit 8484421
Showing 1 changed file with 14 additions and 20 deletions.
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 8484421

Please sign in to comment.