Skip to content
Snippets Groups Projects
Commit c6b50e59 authored by Alexander Rose's avatar Alexander Rose
Browse files

Merge branch 'master' into bond-repr

parents 566f979e dd6dcdda
No related branches found
No related tags found
No related merge requests found
...@@ -196,7 +196,7 @@ async function run(mmcif: mmCIF_Database) { ...@@ -196,7 +196,7 @@ async function run(mmcif: mmCIF_Database) {
//printIHMModels(models[0]); //printIHMModels(models[0]);
printUnits(structure); printUnits(structure);
//printRings(structure); //printRings(structure);
printLinks(structure, true, true); //printLinks(structure, true, true);
//printModRes(models[0]); //printModRes(models[0]);
//printSecStructure(models[0]); //printSecStructure(models[0]);
} }
......
...@@ -94,25 +94,27 @@ namespace Structure { ...@@ -94,25 +94,27 @@ namespace Structure {
export function create(units: ReadonlyArray<Unit>): Structure { return new Structure(units); } export function create(units: ReadonlyArray<Unit>): Structure { return new Structure(units); }
/**
* Construct a Structure from a model.
*
* Generally, a single unit corresponds to a single chain, with the exception
* of consecutive "single atom chains".
*/
export function ofModel(model: Model): Structure { export function ofModel(model: Model): Structure {
const chains = model.atomicHierarchy.chainSegments; const chains = model.atomicHierarchy.chainSegments;
const builder = new StructureBuilder(); const builder = new StructureBuilder();
const { residueSegments: { segmentMap: residueIndex } } = model.atomicHierarchy;
for (let c = 0; c < chains.count; c++) { for (let c = 0; c < chains.count; c++) {
const start = chains.segments[c]; const start = chains.segments[c];
let end = chains.segments[c + 1];
let rStart = residueIndex[start], rEnd = residueIndex[end - 1]; // merge all consecutive "single atom chains"
while (rEnd - rStart <= 1 && c + 1 < chains.count) { while (c + 1 < chains.count
&& chains.segments[c + 1] - chains.segments[c] === 1
&& chains.segments[c + 2] - chains.segments[c + 1] === 1) {
c++; c++;
end = chains.segments[c + 1];
rStart = rEnd;
rEnd = residueIndex[end - 1];
} }
const elements = SortedArray.ofBounds(start, end); const elements = SortedArray.ofBounds(start, chains.segments[c + 1]);
builder.addUnit(Unit.Kind.Atomic, model, SymmetryOperator.Default, elements); builder.addUnit(Unit.Kind.Atomic, model, SymmetryOperator.Default, elements);
} }
......
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