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

domain server tweaks

parent 8d9604ed
No related branches found
No related tags found
No related merge requests found
......@@ -11,12 +11,17 @@ import { getCategoryInstanceProvider } from './utils'
export default function create(allData: any) {
const mols = Object.keys(allData);
if (!mols.length) return '#';
const enc = createEncoder();
enc.startDataBlock(mols[0]);
if (!mols.length) return enc.getData();
const data = allData[mols[0]];
const enc = createEncoder();
enc.startDataBlock(mols[0]);
const sources = getSources(data);
if (!sources._rowCount) return enc.getData();
enc.writeCategory(getCategoryInstanceProvider(`pdbx_domain_annotation_sources`, sources));
for (const cat of Object.keys(S.categories)) {
writeDomain(enc, getDomain(cat, (S.categories as any)[cat], data));
......@@ -37,6 +42,17 @@ function writeDomain(enc: CIFEncoder<any>, domain: DomainAnnotation | undefined)
enc.writeCategory(getCategoryInstanceProvider(`pdbx_${domain.name}_domain_mapping`, domain.mappings));
}
function getSources(data: any): Table<S.Sources> {
const rows: Table.Row<S.Sources>[] = [];
let id = 1;
for (const name of Object.keys(S.categories)) {
if (!data[name]) continue;
const row: Table.Row<S.Sources> = { id: id++, name, count: Object.keys(data[name]).length };
if (row.count > 0) rows.push(row);
}
return Table.ofRows(S.Sources, rows);
}
function getMappings(startId: number, group_id: number, mappings: any): MappingRow[] {
const rows: MappingRow[] = [];
......
......@@ -8,6 +8,13 @@ import { Column } from 'mol-base/collections/database'
import Type = Column.Type
export const Sources = {
id: Type.int,
name: Type.str,
count: Type.int
}
export type Sources = typeof Sources
export const Base = {
id: Type.str,
identifier: Type.str,
......
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