/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import * as React from 'react' import { View } from '../view'; import { SequenceViewController } from '../../controller/visualization/sequence-view'; import { Structure, StructureSequence, Queries, Selection } from 'mol-model/structure'; import { Context } from '../../context/context'; import { InteractivityEvents } from '../../event/basic'; import { SyncRuntimeContext } from 'mol-task/execution/synchronous'; export class SequenceView extends View { render() { const s = this.controller.latestState.structure; if (!s) return
No structure available.
; const seqs = Structure.getModels(s)[0].sequence.sequences; return
{seqs.map((seq, i) => )}
; } } function createQuery(entityId: string, label_seq_id: number) { return Queries.generators.atoms({ entityTest: l => Queries.props.entity.id(l) === entityId, residueTest: l => Queries.props.residue.label_seq_id(l) === label_seq_id }); } // TODO: this is really ineffective and should be done using a canvas. class EntitySequence extends React.Component<{ ctx: Context, seq: StructureSequence.Entity, structure: Structure }> { async raiseInteractityEvent(seqId?: number) { if (typeof seqId === 'undefined') { InteractivityEvents.HighlightElementLoci.dispatch(this.props.ctx, void 0); return; } const query = createQuery(this.props.seq.entityId, seqId); const loci = Selection.toLoci(await query(this.props.structure, SyncRuntimeContext)); if (loci.elements.length === 0) InteractivityEvents.HighlightElementLoci.dispatch(this.props.ctx, void 0); else InteractivityEvents.HighlightElementLoci.dispatch(this.props.ctx, loci); } render() { const { ctx, seq } = this.props; const { offset, sequence } = seq.sequence; const elems: JSX.Element[] = []; for (let i = 0, _i = sequence.length; i < _i; i++) { elems[elems.length] = ; } return
{this.props.seq.entityId}:{offset}  {elems}
; } } class ResidueView extends React.Component<{ ctx: Context, seqId: number, letter: string, parent: EntitySequence }, { isHighlighted: boolean }> { state = { isHighlighted: false } mouseEnter = () => { this.setState({ isHighlighted: true }); this.props.parent.raiseInteractityEvent(this.props.seqId); } mouseLeave = () => { this.setState({ isHighlighted: false }); this.props.parent.raiseInteractityEvent(); } render() { return {this.props.letter} ; } }