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

tweaks for coarse/backbone only models

parent 78ee23a8
No related branches found
No related tags found
No related merge requests found
...@@ -66,8 +66,8 @@ entity_poly.entity_id ...@@ -66,8 +66,8 @@ entity_poly.entity_id
entity_poly.type entity_poly.type
entity_poly.nstd_linkage entity_poly.nstd_linkage
entity_poly.nstd_monomer entity_poly.nstd_monomer
entity_poly.pdbx_seq_one_letter_code entity_poly.pdbx_seq_one_letter_code
entity_poly.pdbx_seq_one_letter_code_can entity_poly.pdbx_seq_one_letter_code_can
entity_poly.pdbx_strand_id entity_poly.pdbx_strand_id
entity_poly.pdbx_target_identifier entity_poly.pdbx_target_identifier
......
...@@ -22,7 +22,8 @@ export function getQualityProps(props: Partial<QualityProps>, structure?: Struct ...@@ -22,7 +22,8 @@ export function getQualityProps(props: Partial<QualityProps>, structure?: Struct
let linearSegments = defaults(props.linearSegments, 8) let linearSegments = defaults(props.linearSegments, 8)
if (quality === 'auto' && structure) { if (quality === 'auto' && structure) {
const score = structure.elementCount let score = structure.elementCount
if (structure.isCoarse) score *= 10
if (score > 500_000) { if (score > 500_000) {
quality = 'lowest' quality = 'lowest'
} else if (score > 100_000) { } else if (score > 100_000) {
......
...@@ -22,13 +22,13 @@ function getMoleculeType(compId: string, chemicalComponentMap: ChemicalComponent ...@@ -22,13 +22,13 @@ function getMoleculeType(compId: string, chemicalComponentMap: ChemicalComponent
return cc ? cc.moleculeType : MoleculeType.unknown return cc ? cc.moleculeType : MoleculeType.unknown
} }
function getElementIndexForAtomId(rI: ResidueIndex, atomId: string, data: AtomicData, segments: AtomicSegments, ): ElementIndex { function getElementIndexForAtomId(rI: ResidueIndex, atomId: string, data: AtomicData, segments: AtomicSegments): ElementIndex {
const { offsets } = segments.residueAtomSegments const { offsets } = segments.residueAtomSegments
const { label_atom_id } = data.atoms const { label_atom_id } = data.atoms
for (let j = offsets[rI], _j = offsets[rI + 1]; j < _j; j++) { for (let j = offsets[rI], _j = offsets[rI + 1]; j < _j; j++) {
if (label_atom_id.value(j) === atomId) return j as ElementIndex if (label_atom_id.value(j) === atomId) return j
} }
return offsets[rI] as ElementIndex return offsets[rI]
} }
function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, chemicalComponentMap: ChemicalComponentMap) { function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, chemicalComponentMap: ChemicalComponentMap) {
...@@ -46,7 +46,7 @@ function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data: ...@@ -46,7 +46,7 @@ function areBackboneConnected(riStart: ResidueIndex, riEnd: ResidueIndex, data:
const { x, y, z } = conformation const { x, y, z } = conformation
const pStart = Vec3.create(x[eiStart], y[eiStart], z[eiStart]) const pStart = Vec3.create(x[eiStart], y[eiStart], z[eiStart])
const pEnd = Vec3.create(x[eiEnd], y[eiEnd], z[eiEnd]) const pEnd = Vec3.create(x[eiEnd], y[eiEnd], z[eiEnd])
return Vec3.distance(pStart, pEnd) < 2 return Vec3.distance(pStart, pEnd) < 10
} }
export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, chemicalComponentMap: ChemicalComponentMap): AtomicRanges { export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conformation: AtomicConformation, chemicalComponentMap: ChemicalComponentMap): AtomicRanges {
...@@ -90,6 +90,13 @@ export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conf ...@@ -90,6 +90,13 @@ export function getAtomicRanges(data: AtomicData, segments: AtomicSegments, conf
startIndex = residueSegment.start startIndex = residueSegment.start
} else if (!residueIt.hasNext) { } else if (!residueIt.hasNext) {
polymerRanges.push(startIndex, residueSegment.end - 1) polymerRanges.push(startIndex, residueSegment.end - 1)
} else {
const riStart = segments.residueAtomSegments.index[residueSegment.start]
const riEnd = segments.residueAtomSegments.index[prevEnd - 1]
if (!areBackboneConnected(riStart, riEnd, data, segments, conformation, chemicalComponentMap)) {
polymerRanges.push(startIndex, prevEnd - 1)
startIndex = residueSegment.start
}
} }
} else { } else {
startIndex = residueSegment.start // start polymer startIndex = residueSegment.start // start polymer
......
...@@ -40,7 +40,8 @@ class Structure { ...@@ -40,7 +40,8 @@ class Structure {
models?: ReadonlyArray<Model>, models?: ReadonlyArray<Model>,
hashCode: number, hashCode: number,
elementCount: number, elementCount: number,
} = { hashCode: -1, elementCount: 0 }; polymerResidueCount: number,
} = { hashCode: -1, elementCount: 0, polymerResidueCount: 0 };
subsetBuilder(isSorted: boolean) { subsetBuilder(isSorted: boolean) {
return new StructureSubsetBuilder(this, isSorted); return new StructureSubsetBuilder(this, isSorted);
...@@ -51,6 +52,18 @@ class Structure { ...@@ -51,6 +52,18 @@ class Structure {
return this._props.elementCount; return this._props.elementCount;
} }
/** Count of all polymer residues in the structure */
get polymerResidueCount() {
return this._props.polymerResidueCount;
}
/** Coarse structure, defined as Containing less than twice as many elements as polymer residues */
get isCoarse() {
const ec = this.elementCount
const prc = this.polymerResidueCount
return prc && ec ? ec / prc < 2 : false
}
get hashCode() { get hashCode() {
if (this._props.hashCode !== -1) return this._props.hashCode; if (this._props.hashCode !== -1) return this._props.hashCode;
return this.computeHash(); return this.computeHash();
...@@ -123,12 +136,14 @@ class Structure { ...@@ -123,12 +136,14 @@ class Structure {
constructor(units: ArrayLike<Unit>) { constructor(units: ArrayLike<Unit>) {
const map = IntMap.Mutable<Unit>(); const map = IntMap.Mutable<Unit>();
let elementCount = 0; let elementCount = 0;
let polymerResidueCount = 0;
let isSorted = true; let isSorted = true;
let lastId = units.length > 0 ? units[0].id : 0; let lastId = units.length > 0 ? units[0].id : 0;
for (let i = 0, _i = units.length; i < _i; i++) { for (let i = 0, _i = units.length; i < _i; i++) {
const u = units[i]; const u = units[i];
map.set(u.id, u); map.set(u.id, u);
elementCount += u.elements.length; elementCount += u.elements.length;
polymerResidueCount += u.polymerElements.length;
if (u.id < lastId) isSorted = false; if (u.id < lastId) isSorted = false;
lastId = u.id; lastId = u.id;
} }
...@@ -136,6 +151,7 @@ class Structure { ...@@ -136,6 +151,7 @@ class Structure {
this.unitMap = map; this.unitMap = map;
this.units = units as ReadonlyArray<Unit>; this.units = units as ReadonlyArray<Unit>;
this._props.elementCount = elementCount; this._props.elementCount = elementCount;
this._props.polymerResidueCount = polymerResidueCount;
} }
} }
......
...@@ -21,7 +21,7 @@ export function getAtomicPolymerElements(unit: Unit.Atomic) { ...@@ -21,7 +21,7 @@ export function getAtomicPolymerElements(unit: Unit.Atomic) {
while (residueIt.hasNext) { while (residueIt.hasNext) {
const residueSegment = residueIt.move() const residueSegment = residueIt.move()
const { start, end, index } = residueSegment const { start, end, index } = residueSegment
if (OrderedSet.areIntersecting(Interval.ofBounds(elements[start], elements[end - 1]), elements)) { if (OrderedSet.areIntersecting(Interval.ofRange(elements[start], elements[end - 1]), elements)) {
const elementIndex = getElementIndexForAtomRole(model, index, 'trace') const elementIndex = getElementIndexForAtomRole(model, index, 'trace')
indices.push(elementIndex === -1 ? residueAtomSegments.offsets[index] : elementIndex) indices.push(elementIndex === -1 ? residueAtomSegments.offsets[index] : elementIndex)
} }
......
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