Skip to content
Snippets Groups Projects
Commit ab2031f7 authored by David Sehnal's avatar David Sehnal
Browse files

data model (part 2 of ???)

parent 641f9b13
No related branches found
No related tags found
No related merge requests found
/**
* Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
interface BitFlags<Flags> { '@type': Flags }
namespace BitFlags {
export function has<F>(flags: BitFlags<F>, flag: F) { return ((flags as any) & (flag as any)) !== 0; }
}
export default BitFlags
\ No newline at end of file
......@@ -6,7 +6,7 @@
import * as Formats from './model/formats'
//import CommonProperties from './model/properties/common'
import MacromoleculeProperties from './model/properties/macromolecule'
import HierarchyProperties from './model/properties/hierarchy'
import Conformation from './model/properties/conformation'
import Segmentation from '../mol-base/collections/integer/segmentation'
......@@ -23,7 +23,7 @@ interface Model extends Readonly<{
sourceData: Formats.RawData,
//common: CommonProperties,
macromolecule: MacromoleculeProperties,
macromolecule: HierarchyProperties,
conformation: Conformation,
// used for diffing.
......
/**
* Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
import Column from '../../../mol-base/collections/column'
export type Table<Data> = { [E in keyof Data]: Column<Data[E]> }
export interface ElementSymbol extends String { '@type': 'element-symbol' }
export function ElementSymbol(s: string): ElementSymbol {
// TODO: optimize?
return s.toUpperCase() as any;
}
export interface Atoms extends Table<{
name: string,
elementSymbol: ElementSymbol,
}> { }
interface Common {
}
export default Common
\ No newline at end of file
......@@ -4,13 +4,25 @@
* @author David Sehnal <david.sehnal@gmail.com>
*/
interface Conformation {
import { SecondaryStructureFlag as SSF } from './secondary-structure'
import BitFlags from '../../../mol-base/utils/bit-flags'
import Segmentation from '../../../mol-base/collections/integer/segmentation'
interface Positions {
x: ArrayLike<number>,
y: ArrayLike<number>,
z: ArrayLike<number>,
z: ArrayLike<number>
}
// Assign a secondary structure type to each residue.
secondaryStructureType: ArrayLike<any>
interface SecondaryStructure {
ofResidue: ArrayLike<BitFlags<SSF>>,
// atom segmentation
segments: Segmentation
}
interface Conformation {
positions: Positions,
secondaryStructureType: SecondaryStructure
}
export default Conformation
......@@ -7,57 +7,47 @@
import Column from '../../../mol-base/collections/column'
import { Shape as mmCIF } from '../../../mol-io/reader/cif/schema/mmcif'
export type Table<Data> = { [E in keyof Data]: Column<Data[E]> }
export interface ElementSymbol extends String { '@type': 'element-symbol' }
export function ElementSymbol(s: string): ElementSymbol {
// TODO: optimize?
return s.toUpperCase() as any;
}
export interface Atoms extends Table<{
// unique number for each atom
key: number,
id: number,
type_symbol: ElementSymbol,
label_atom_id: string,
auth_atom_id: string,
label_alt_id: string,
auth_alt_id: string,
pdbx_formal_charge: string,
occupancy: number,
B_iso_or_equiv: number
}> { }
export interface Residues extends Table<{
// unique number for each residue
key: number,
group_PDB: string,
label_comp_id: string,
auth_comp_id: string,
label_seq_id: number,
auth_seq_id: number,
pdbx_PDB_ins_code: string
}> { }
export interface Chains extends Table<{
// unique number for each chain
key: number,
label_asym_id: string,
auth_asym_id: string
}> { }
type Key = { key: Column<number> }
type _Atoms = Pick<mmCIF['atom_site'],
| 'type_symbol'
| 'label_atom_id'
| 'auth_atom_id'
| 'label_alt_id'
| 'pdbx_formal_charge'
| 'occupancy'
| 'B_iso_or_equiv'>
& Key
export interface Atoms extends _Atoms {
source_row: Column<number>
}
export interface Entities extends Table<{
// unique number for each entity
// row index to the EntityData table
key: number,
label_entity_id: string,
pdbx_PDB_model_num: number
}> { }
type _Residues = Pick<mmCIF['atom_site'],
| 'group_PDB'
| 'label_comp_id'
| 'auth_comp_id'
| 'label_seq_id'
| 'auth_seq_id'
| 'pdbx_PDB_ins_code'>
& Key
export interface Residues extends _Residues { }
type _Chains = Pick<mmCIF['atom_site'],
| 'label_asym_id'
| 'auth_asym_id'
| 'auth_comp_id'
| 'label_entity_id'
| 'pdbx_PDB_model_num'>
& Key
export interface Chains extends _Chains {
enityDataIndex: Column<number>
}
type _EntityData = mmCIF['entity']
export interface EntityData extends _EntityData { }
......@@ -66,7 +56,7 @@ export interface Macromolecule {
atoms: Atoms,
residues: Residues,
chains: Chains,
entities: Entities
entityData: EntityData
}
export default Macromolecule
\ No newline at end of file
/**
* Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
const enum SSF {
None = 0x0,
// category
DoubleHelix = 0x1,
Helix = 0x2,
Beta = 0x4,
Turn = 0x8,
// category variant
LeftHanded = 0x10, // helix
RightHanded = 0x20,
ClassicTurn = 0x40, // turn
InverseTurn = 0x80,
// sub-category
HelixOther = 0x100, // protein
Helix27 = 0x200,
Helix3Ten = 0x400,
HelixAlpha = 0x800,
HelixGamma = 0x1000,
HelixOmega = 0x2000,
HelixPi = 0x4000,
HelixPolyproline = 0x8000,
DoubleHelixOther = 0x10000, // nucleic
DoubleHelixZ = 0x20000,
DoubleHelixA = 0x40000,
DoubleHelixB = 0x80000,
BetaOther = 0x100000, // protein
BetaStrand = 0x200000, // single strand
BetaSheet = 0x400000, // multiple hydrogen bonded strands
BetaBarell = 0x800000, // closed series of sheets
TurnOther = 0x1000000, // protein
Turn1 = 0x2000000,
Turn2 = 0x4000000,
Turn3 = 0x8000000,
NA = 0x10000000, // not applicable/available
}
export { SSF as SecondaryStructureFlag }
export const SecondaryStructureMmcif: { [value: string]: number } = {
HELX_LH_27_P: SSF.Helix | SSF.LeftHanded | SSF.Helix27, // left-handed 2-7 helix (protein)
HELX_LH_3T_P: SSF.Helix | SSF.LeftHanded | SSF.Helix3Ten, // left-handed 3-10 helix (protein)
HELX_LH_AL_P: SSF.Helix | SSF.LeftHanded | SSF.HelixAlpha, // left-handed alpha helix (protein)
HELX_LH_A_N: SSF.DoubleHelix | SSF.LeftHanded | SSF.DoubleHelixA, // left-handed A helix (nucleic acid)
HELX_LH_B_N: SSF.DoubleHelix | SSF.LeftHanded | SSF.DoubleHelixB, // left-handed B helix (nucleic acid)
HELX_LH_GA_P: SSF.Helix | SSF.LeftHanded | SSF.HelixGamma, // left-handed gamma helix (protein)
HELX_LH_N: SSF.DoubleHelix | SSF.LeftHanded, // left-handed helix with type not specified (nucleic acid)
HELX_LH_OM_P: SSF.Helix | SSF.LeftHanded | SSF.HelixOmega, // left-handed omega helix (protein)
HELX_LH_OT_N: SSF.DoubleHelix | SSF.LeftHanded | SSF.DoubleHelixOther, // left-handed helix with type that does not conform to an accepted category (nucleic acid)
HELX_LH_OT_P: SSF.Helix | SSF.LeftHanded | SSF.HelixOther, // left-handed helix with type that does not conform to an accepted category (protein)
HELX_LH_P: SSF.Helix | SSF.LeftHanded, // left-handed helix with type not specified (protein)
HELX_LH_PI_P: SSF.Helix | SSF.LeftHanded | SSF.HelixPi, // left-handed pi helix (protein)
HELX_LH_PP_P: SSF.Helix | SSF.LeftHanded | SSF.HelixPolyproline, // left-handed polyproline helix (protein)
HELX_LH_Z_N: SSF.DoubleHelix | SSF.LeftHanded | SSF.DoubleHelixZ, // left-handed Z helix (nucleic acid)
HELX_N: SSF.DoubleHelix, // helix with handedness and type not specified (nucleic acid)
HELX_OT_N: SSF.DoubleHelix, // helix with handedness and type that do not conform to an accepted category (nucleic acid)
HELX_OT_P: SSF.Helix, // helix with handedness and type that do not conform to an accepted category (protein)
HELX_P: SSF.Helix, // helix with handedness and type not specified (protein)
HELX_RH_27_P: SSF.Helix | SSF.RightHanded | SSF.Helix27, // right-handed 2-7 helix (protein)
HELX_RH_3T_P: SSF.Helix | SSF.RightHanded | SSF.Helix3Ten, // right-handed 3-10 helix (protein)
HELX_RH_AL_P: SSF.Helix | SSF.RightHanded | SSF.HelixAlpha, // right-handed alpha helix (protein)
HELX_RH_A_N: SSF.DoubleHelix | SSF.RightHanded | SSF.DoubleHelixA, // right-handed A helix (nucleic acid)
HELX_RH_B_N: SSF.DoubleHelix | SSF.RightHanded | SSF.DoubleHelixB, // right-handed B helix (nucleic acid)
HELX_RH_GA_P: SSF.Helix | SSF.RightHanded | SSF.HelixGamma, // right-handed gamma helix (protein)
HELX_RH_N: SSF.DoubleHelix | SSF.RightHanded, // right-handed helix with type not specified (nucleic acid)
HELX_RH_OM_P: SSF.Helix | SSF.RightHanded | SSF.HelixOmega, // right-handed omega helix (protein)
HELX_RH_OT_N: SSF.DoubleHelix | SSF.RightHanded | SSF.DoubleHelixOther, // right-handed helix with type that does not conform to an accepted category (nucleic acid)
HELX_RH_OT_P: SSF.Helix | SSF.RightHanded | SSF.HelixOther, // right-handed helix with type that does not conform to an accepted category (protein)
HELX_RH_P: SSF.Helix | SSF.RightHanded, // right-handed helix with type not specified (protein)
HELX_RH_PI_P: SSF.Helix | SSF.RightHanded | SSF.HelixPi, // right-handed pi helix (protein)
HELX_RH_PP_P: SSF.Helix | SSF.RightHanded | SSF.HelixPolyproline, // right-handed polyproline helix (protein)
HELX_RH_Z_N: SSF.DoubleHelix | SSF.RightHanded | SSF.DoubleHelixZ, // right-handed Z helix (nucleic acid)
STRN: SSF.Beta | SSF.BetaStrand, // beta strand (protein)
TURN_OT_P: SSF.Turn | SSF.TurnOther, // turn with type that does not conform to an accepted category (protein)
TURN_P: SSF.Turn, // turn with type not specified (protein)
TURN_TY1P_P: SSF.Turn | SSF.InverseTurn | SSF.Turn1, // type I prime turn (protein)
TURN_TY1_P: SSF.Turn | SSF.ClassicTurn | SSF.Turn1, // type I turn (protein)
TURN_TY2P_P: SSF.Turn | SSF.InverseTurn | SSF.Turn2, // type II prime turn (protein)
TURN_TY2_P: SSF.Turn | SSF.ClassicTurn | SSF.Turn2, // type II turn (protein)
TURN_TY3P_P: SSF.Turn | SSF.InverseTurn | SSF.Turn3, // type III prime turn (protein)
TURN_TY3_P: SSF.Turn | SSF.ClassicTurn | SSF.Turn3, // type III turn (protein)
}
export const SecondaryStructurePdb: { [value: string]: number } = {
1: SSF.Helix | SSF.RightHanded | SSF.HelixAlpha, // Right-handed alpha (default)
2: SSF.Helix | SSF.RightHanded | SSF.HelixOmega, // Right-handed omega
3: SSF.Helix | SSF.RightHanded | SSF.HelixPi, // Right-handed pi
4: SSF.Helix | SSF.RightHanded | SSF.HelixGamma, // Right-handed gamma
5: SSF.Helix | SSF.RightHanded | SSF.Helix3Ten, // Right-handed 310
6: SSF.Helix | SSF.LeftHanded | SSF.HelixAlpha, // Left-handed alpha
7: SSF.Helix | SSF.LeftHanded | SSF.HelixOmega, // Left-handed omega
8: SSF.Helix | SSF.LeftHanded | SSF.HelixGamma, // Left-handed gamma
9: SSF.Helix | SSF.Helix27, // 27 ribbon/helix
10: SSF.Helix | SSF.HelixPolyproline, // Polyproline
}
export const SecondaryStructureStride: { [value: string]: number } = {
H: SSF.Helix | SSF.HelixAlpha, // Alpha helix
G: SSF.Helix | SSF.Helix3Ten, // 3-10 helix
I: SSF.Helix | SSF.HelixPi, // PI-helix
E: SSF.Beta | SSF.BetaSheet, // Extended conformation
B: SSF.Beta | SSF.BetaStrand, // Isolated bridge
b: SSF.Beta | SSF.BetaStrand, // Isolated bridge
T: SSF.Turn, // Turn
C: SSF.NA, // Coil (none of the above)
}
export const SecondaryStructureDssp: { [value: string]: number } = {
H: SSF.Helix | SSF.HelixAlpha, // alpha-helix
B: SSF.Beta | SSF.BetaStrand, // residue in isolated beta-bridge
E: SSF.Beta | SSF.BetaSheet, // extended strand, participates in beta ladder
G: SSF.Helix | SSF.Helix3Ten, // 3-helix (310 helix)
I: SSF.Helix | SSF.HelixPi, // 5 helix (pi-helix)
T: SSF.Turn, // hydrogen bonded turn
S: SSF.Turn, // bend
}
\ No newline at end of file
/**
* Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
// TODO: symmetry and assebmlies descriptors
//import Column from '../../../mol-base/collections/column'
\ No newline at end of file
......@@ -5,7 +5,7 @@
*/
import Structure from './structure'
import Selection from './selection'
import Selection from './query/selection'
interface Query { (s: Structure): Selection }
......
......@@ -4,7 +4,7 @@
* @author David Sehnal <david.sehnal@gmail.com>
*/
import Structure from './structure'
import Structure from './../structure'
type Selection =
| Structure // each atom is interpreted as a singleton structure
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment