diff --git a/src/mol-model-formats/structure/cif-core.ts b/src/mol-model-formats/structure/cif-core.ts index e3e3bd296329072f95c87faf1c1348c541f7b86e..75af4d45f5bdaf629e11dbde45f0818ec7c75457 100644 --- a/src/mol-model-formats/structure/cif-core.ts +++ b/src/mol-model-formats/structure/cif-core.ts @@ -251,8 +251,8 @@ type CifCoreFormat = ModelFormat<CifCoreFormat.Data> namespace CifCoreFormat { export type Data = { db: CifCore_Database, frame: CifFrame } - export function is(x: ModelFormat): x is CifCoreFormat { - return x.kind === 'cifCore'; + export function is(x?: ModelFormat): x is CifCoreFormat { + return x?.kind === 'cifCore'; } export function fromFrame(frame: CifFrame, db?: CifCore_Database): CifCoreFormat { diff --git a/src/mol-model-formats/structure/cube.ts b/src/mol-model-formats/structure/cube.ts index 9983693f094727d89f92e1e3e91708f7e8bb3cef..1c04f685de8291fe2a3aa0fa9b64ad23d6c57098 100644 --- a/src/mol-model-formats/structure/cube.ts +++ b/src/mol-model-formats/structure/cube.ts @@ -69,8 +69,8 @@ export { CubeFormat }; type CubeFormat = ModelFormat<CubeFile> namespace MolFormat { - export function is(x: ModelFormat): x is CubeFormat { - return x.kind === 'cube'; + export function is(x?: ModelFormat): x is CubeFormat { + return x?.kind === 'cube'; } export function create(cube: CubeFile): CubeFormat { diff --git a/src/mol-model-formats/structure/gro.ts b/src/mol-model-formats/structure/gro.ts index af13e6c015866896c1b37f4fde48c6e44a74647e..33f0efac50abb1af1d80e2036485ed2cac25dca7 100644 --- a/src/mol-model-formats/structure/gro.ts +++ b/src/mol-model-formats/structure/gro.ts @@ -106,8 +106,8 @@ export { GroFormat }; type GroFormat = ModelFormat<GroFile> namespace GroFormat { - export function is(x: ModelFormat): x is GroFormat { - return x.kind === 'gro'; + export function is(x?: ModelFormat): x is GroFormat { + return x?.kind === 'gro'; } export function fromGro(gro: GroFile): GroFormat { diff --git a/src/mol-model-formats/structure/mmcif.ts b/src/mol-model-formats/structure/mmcif.ts index 67caefba3cf944ee898cf3463440739a5e8a96c2..9ccb7d28d6ddc16a7a383255a545dcc917b0f01a 100644 --- a/src/mol-model-formats/structure/mmcif.ts +++ b/src/mol-model-formats/structure/mmcif.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> * @author Alexander Rose <alexander.rose@weirdbyte.de> @@ -79,14 +79,22 @@ export { MmcifFormat }; type MmcifFormat = ModelFormat<MmcifFormat.Data> namespace MmcifFormat { - export type Data = { db: mmCIF_Database, frame: CifFrame } - export function is(x: ModelFormat): x is MmcifFormat { - return x.kind === 'mmCIF'; + export type Data = { + db: mmCIF_Database, + frame: CifFrame, + /** + * Original source format. Some formats, including PDB, are converted + * to mmCIF before further processing. + */ + source?: ModelFormat + } + export function is(x?: ModelFormat): x is MmcifFormat { + return x?.kind === 'mmCIF'; } - export function fromFrame(frame: CifFrame, db?: mmCIF_Database): MmcifFormat { + export function fromFrame(frame: CifFrame, db?: mmCIF_Database, source?: ModelFormat): MmcifFormat { if (!db) db = CIF.schema.mmCIF(frame); - return { kind: 'mmCIF', name: db._name, data: { db, frame } }; + return { kind: 'mmCIF', name: db._name, data: { db, frame, source } }; } } diff --git a/src/mol-model-formats/structure/mol.ts b/src/mol-model-formats/structure/mol.ts index 51f45c0d0da3eaec92caea70227bd5f71cbfb0df..fb66c34e8e2e80da8dce161d42c7f768e10707ad 100644 --- a/src/mol-model-formats/structure/mol.ts +++ b/src/mol-model-formats/structure/mol.ts @@ -81,8 +81,8 @@ export { MolFormat }; type MolFormat = ModelFormat<MolFile> namespace MolFormat { - export function is(x: ModelFormat): x is MolFormat { - return x.kind === 'mol'; + export function is(x?: ModelFormat): x is MolFormat { + return x?.kind === 'mol'; } export function create(mol: MolFile): MolFormat { diff --git a/src/mol-model-formats/structure/mol2.ts b/src/mol-model-formats/structure/mol2.ts index 43772c8ad2b1d2f75d73b749771b65da77aa2ecc..ec9565fe0caabdd0f4e44392d7fbb947b27af68b 100644 --- a/src/mol-model-formats/structure/mol2.ts +++ b/src/mol-model-formats/structure/mol2.ts @@ -99,8 +99,8 @@ export { Mol2Format }; type Mol2Format = ModelFormat<Mol2File> namespace Mol2Format { - export function is(x: ModelFormat): x is Mol2Format { - return x.kind === 'mol2'; + export function is(x?: ModelFormat): x is Mol2Format { + return x?.kind === 'mol2'; } export function create(mol2: Mol2File): Mol2Format { diff --git a/src/mol-model-formats/structure/pdb.ts b/src/mol-model-formats/structure/pdb.ts index 87c6006e9a0ea202bcf80a33d803849f1f539090..8f794c32806d42cb4b5f391c69e733e1725d5935 100644 --- a/src/mol-model-formats/structure/pdb.ts +++ b/src/mol-model-formats/structure/pdb.ts @@ -13,12 +13,27 @@ import { createModels } from './basic/parser'; import { Column } from '../../mol-data/db'; import { AtomPartialCharge } from './property/partial-charge'; import { Trajectory } from '../../mol-model/structure'; +import { ModelFormat } from '../format'; + +export { PdbFormat }; + +type PdbFormat = ModelFormat<PdbFile> + +namespace PdbFormat { + export function is(x?: ModelFormat): x is PdbFormat { + return x?.kind === 'pdb'; + } + + export function create(pdb: PdbFile): PdbFormat { + return { kind: 'pdb', name: pdb.id || '', data: pdb }; + } +} export function trajectoryFromPDB(pdb: PdbFile): Task<Trajectory> { return Task.create('Parse PDB', async ctx => { await ctx.update('Converting to mmCIF'); const cif = await pdbToMmCif(pdb); - const format = MmcifFormat.fromFrame(cif); + const format = MmcifFormat.fromFrame(cif, undefined, PdbFormat.create(pdb)); const models = await createModels(format.data.db, format, ctx); const partial_charge = cif.categories['atom_site']?.getField('partial_charge'); if (partial_charge) { diff --git a/src/mol-model-formats/structure/psf.ts b/src/mol-model-formats/structure/psf.ts index 344795f7992ca48c8381d0f80310a70a0ce7bf54..362cf9f22e151f5eefa7acebb5f901ade65a3f24 100644 --- a/src/mol-model-formats/structure/psf.ts +++ b/src/mol-model-formats/structure/psf.ts @@ -103,8 +103,8 @@ export { PsfFormat }; type PsfFormat = ModelFormat<PsfFile> namespace PsfFormat { - export function is(x: ModelFormat): x is PsfFormat { - return x.kind === 'psf'; + export function is(x?: ModelFormat): x is PsfFormat { + return x?.kind === 'psf'; } export function fromPsf(psf: PsfFile): PsfFormat { diff --git a/src/mol-model-formats/volume/ccp4.ts b/src/mol-model-formats/volume/ccp4.ts index c86cb08b1635228f12cd2df156512ec4116cd9ca..753713c95c1fddacea461eafd3401d400a781f53 100644 --- a/src/mol-model-formats/volume/ccp4.ts +++ b/src/mol-model-formats/volume/ccp4.ts @@ -98,8 +98,8 @@ export { Ccp4Format }; type Ccp4Format = ModelFormat<Ccp4File> namespace Ccp4Format { - export function is(x: ModelFormat): x is Ccp4Format { - return x.kind === 'ccp4'; + export function is(x?: ModelFormat): x is Ccp4Format { + return x?.kind === 'ccp4'; } export function create(ccp4: Ccp4File): Ccp4Format { diff --git a/src/mol-model-formats/volume/cube.ts b/src/mol-model-formats/volume/cube.ts index 224812fd5c461cd820d50d3bd59f53f55d4ece93..6ff8ea4c07d2a8487e8a2c6dd90fef51c8321336 100644 --- a/src/mol-model-formats/volume/cube.ts +++ b/src/mol-model-formats/volume/cube.ts @@ -71,8 +71,8 @@ export { CubeFormat }; type CubeFormat = ModelFormat<CubeFile> namespace CubeFormat { - export function is(x: ModelFormat): x is CubeFormat { - return x.kind === 'cube'; + export function is(x?: ModelFormat): x is CubeFormat { + return x?.kind === 'cube'; } export function create(cube: CubeFile): CubeFormat { diff --git a/src/mol-model-formats/volume/density-server.ts b/src/mol-model-formats/volume/density-server.ts index 5e8a3ab5d41ec34d4dd61b2baffa9024436fac4b..65b88fb502ab7a420e945d2fa1bca8c5b1e270c6 100644 --- a/src/mol-model-formats/volume/density-server.ts +++ b/src/mol-model-formats/volume/density-server.ts @@ -62,8 +62,8 @@ export { DscifFormat }; type DscifFormat = ModelFormat<DensityServer_Data_Database> namespace DscifFormat { - export function is(x: ModelFormat): x is DscifFormat { - return x.kind === 'dscif'; + export function is(x?: ModelFormat): x is DscifFormat { + return x?.kind === 'dscif'; } export function create(dscif: DensityServer_Data_Database): DscifFormat { diff --git a/src/mol-model-formats/volume/dsn6.ts b/src/mol-model-formats/volume/dsn6.ts index 75196b04a93bb5a40cc6427fd03aa00ff46998f3..ae197343839414d83b43f45c87a71796e72bf6c2 100644 --- a/src/mol-model-formats/volume/dsn6.ts +++ b/src/mol-model-formats/volume/dsn6.ts @@ -60,8 +60,8 @@ export { Dsn6Format }; type Dsn6Format = ModelFormat<Dsn6File> namespace Dsn6Format { - export function is(x: ModelFormat): x is Dsn6Format { - return x.kind === 'dsn6'; + export function is(x?: ModelFormat): x is Dsn6Format { + return x?.kind === 'dsn6'; } export function create(dsn6: Dsn6File): Dsn6Format { diff --git a/src/mol-model-formats/volume/dx.ts b/src/mol-model-formats/volume/dx.ts index e850511c4e3cf80ce1f6c74bfd66b712696a1952..d27e7c94ccba1b3330aa172fb61ad4404648c936 100644 --- a/src/mol-model-formats/volume/dx.ts +++ b/src/mol-model-formats/volume/dx.ts @@ -48,8 +48,8 @@ export { DxFormat }; type DxFormat = ModelFormat<DxFile> namespace DxFormat { - export function is(x: ModelFormat): x is DxFormat { - return x.kind === 'dx'; + export function is(x?: ModelFormat): x is DxFormat { + return x?.kind === 'dx'; } export function create(dx: DxFile): DxFormat {