|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
*
|
|
|
* @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
|
*/
|
|
@@ -7,22 +7,21 @@
|
|
|
import { Model } from '../../mol-model/structure/model';
|
|
|
import { Task } from '../../mol-task';
|
|
|
import { ModelFormat } from './format';
|
|
|
-import { _parse_mmCif } from './mmcif/parser';
|
|
|
import { GroFile, GroAtoms } from '../../mol-io/reader/gro/schema';
|
|
|
-import { CifCategory, CifField } from '../../mol-io/reader/cif';
|
|
|
-import { Column } from '../../mol-data/db';
|
|
|
-import { mmCIF_Schema } from '../../mol-io/reader/cif/schema/mmcif';
|
|
|
+import { Column, Table } from '../../mol-data/db';
|
|
|
import { guessElementSymbolString } from './util';
|
|
|
import { MoleculeType, getMoleculeType } from '../../mol-model/structure/model/types';
|
|
|
import { ComponentBuilder } from './common/component';
|
|
|
import { getChainId } from './common/util';
|
|
|
import { EntityBuilder } from './common/entity';
|
|
|
+import { BasicData, BasicSchema, createBasic } from './basic/schema';
|
|
|
+import { createModels } from './basic/parser';
|
|
|
|
|
|
// TODO multi model files
|
|
|
|
|
|
-function getCategories(atoms: GroAtoms) {
|
|
|
- const auth_atom_id = CifField.ofColumn(atoms.atomName)
|
|
|
- const auth_comp_id = CifField.ofColumn(atoms.residueName)
|
|
|
+function getBasic(atoms: GroAtoms): BasicData {
|
|
|
+ const auth_atom_id = atoms.atomName
|
|
|
+ const auth_comp_id = atoms.residueName
|
|
|
|
|
|
const entityIds = new Array<string>(atoms.count)
|
|
|
const asymIds = new Array<string>(atoms.count)
|
|
@@ -69,57 +68,57 @@ function getCategories(atoms: GroAtoms) {
|
|
|
ids[i] = i
|
|
|
}
|
|
|
|
|
|
- const auth_asym_id = CifField.ofColumn(Column.ofStringArray(asymIds))
|
|
|
+ const auth_asym_id = Column.ofStringArray(asymIds)
|
|
|
|
|
|
- const atom_site: CifCategory.SomeFields<mmCIF_Schema['atom_site']> = {
|
|
|
+ const atom_site = Table.ofPartialColumns(BasicSchema.atom_site, {
|
|
|
auth_asym_id,
|
|
|
auth_atom_id,
|
|
|
auth_comp_id,
|
|
|
- auth_seq_id: CifField.ofColumn(atoms.residueNumber),
|
|
|
- B_iso_or_equiv: CifField.ofColumn(Column.Undefined(atoms.count, Column.Schema.float)),
|
|
|
- Cartn_x: CifField.ofNumbers(Column.mapToArray(atoms.x, x => x * 10, Float32Array)),
|
|
|
- Cartn_y: CifField.ofNumbers(Column.mapToArray(atoms.y, y => y * 10, Float32Array)),
|
|
|
- Cartn_z: CifField.ofNumbers(Column.mapToArray(atoms.z, z => z * 10, Float32Array)),
|
|
|
- group_PDB: CifField.ofColumn(Column.Undefined(atoms.count, Column.Schema.str)),
|
|
|
- id: CifField.ofColumn(Column.ofIntArray(ids)),
|
|
|
-
|
|
|
- label_alt_id: CifField.ofColumn(Column.Undefined(atoms.count, Column.Schema.str)),
|
|
|
+ auth_seq_id: atoms.residueNumber,
|
|
|
+ Cartn_x: Column.ofFloatArray(Column.mapToArray(atoms.x, x => x * 10, Float32Array)),
|
|
|
+ Cartn_y: Column.ofFloatArray(Column.mapToArray(atoms.y, y => y * 10, Float32Array)),
|
|
|
+ Cartn_z: Column.ofFloatArray(Column.mapToArray(atoms.z, z => z * 10, Float32Array)),
|
|
|
+ id: Column.ofIntArray(ids),
|
|
|
|
|
|
label_asym_id: auth_asym_id,
|
|
|
label_atom_id: auth_atom_id,
|
|
|
label_comp_id: auth_comp_id,
|
|
|
- label_seq_id: CifField.ofColumn(Column.ofIntArray(seqIds)),
|
|
|
- label_entity_id: CifField.ofColumn(Column.ofStringArray(entityIds)),
|
|
|
+ label_seq_id: Column.ofIntArray(seqIds),
|
|
|
+ label_entity_id: Column.ofStringArray(entityIds),
|
|
|
|
|
|
- occupancy: CifField.ofColumn(Column.ofConst(1, atoms.count, Column.Schema.float)),
|
|
|
- type_symbol: CifField.ofStrings(Column.mapToArray(atoms.atomName, s => guessElementSymbolString(s))),
|
|
|
+ occupancy: Column.ofConst(1, atoms.count, Column.Schema.float),
|
|
|
+ type_symbol: Column.ofStringArray(Column.mapToArray(atoms.atomName, s => guessElementSymbolString(s))),
|
|
|
|
|
|
- pdbx_PDB_ins_code: CifField.ofColumn(Column.Undefined(atoms.count, Column.Schema.str)),
|
|
|
- pdbx_PDB_model_num: CifField.ofColumn(Column.ofConst('1', atoms.count, Column.Schema.str)),
|
|
|
- }
|
|
|
+ pdbx_PDB_model_num: Column.ofConst(1, atoms.count, Column.Schema.int),
|
|
|
+ }, atoms.count)
|
|
|
|
|
|
- return {
|
|
|
- entity: entityBuilder.getEntityCategory(),
|
|
|
- chem_comp: componentBuilder.getChemCompCategory(),
|
|
|
- atom_site: CifCategory.ofFields('atom_site', atom_site)
|
|
|
- }
|
|
|
+ return createBasic({
|
|
|
+ entity: entityBuilder.getEntityTable(),
|
|
|
+ chem_comp: componentBuilder.getChemCompTable(),
|
|
|
+ atom_site
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-function groToMmCif(gro: GroFile) {
|
|
|
- const categories = getCategories(gro.structures[0].atoms)
|
|
|
+//
|
|
|
+
|
|
|
+export { GroFormat }
|
|
|
|
|
|
- return {
|
|
|
- header: gro.structures[0].header.title,
|
|
|
- categoryNames: Object.keys(categories),
|
|
|
- categories
|
|
|
- };
|
|
|
+type GroFormat = ModelFormat<GroFile>
|
|
|
+
|
|
|
+namespace GroFormat {
|
|
|
+ export function is(x: ModelFormat): x is GroFormat {
|
|
|
+ return x.kind === 'gro'
|
|
|
+ }
|
|
|
+
|
|
|
+ export function fromGro(gro: GroFile): GroFormat {
|
|
|
+ return { kind: 'gro', name: gro.structures[0].header.title, data: gro };
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
export function trajectoryFromGRO(gro: GroFile): Task<Model.Trajectory> {
|
|
|
return Task.create('Parse GRO', async ctx => {
|
|
|
- await ctx.update('Converting to mmCIF');
|
|
|
- const cif = groToMmCif(gro);
|
|
|
- const format = ModelFormat.mmCIF(cif);
|
|
|
- return _parse_mmCif(format, ctx);
|
|
|
+ const format = GroFormat.fromGro(gro);
|
|
|
+ const basic = getBasic(gro.structures[0].atoms)
|
|
|
+ return createModels(basic, format, ctx);
|
|
|
})
|
|
|
}
|