|
@@ -20,6 +20,11 @@ import {StructureSelectionHistoryEntry} from 'molstar/lib/mol-plugin-state/manag
|
|
|
import {StructureElement} from 'molstar/lib/mol-model/structure/structure';
|
|
|
import {ToggleSelectionModeButton} from 'molstar/lib/mol-plugin-ui/structure/selection';
|
|
|
|
|
|
+// TODO use prod
|
|
|
+// const ADVANCED_SEARCH_URL = 'https://strucmotif-dev.rcsb.org/search?request=';
|
|
|
+const ADVANCED_SEARCH_URL = 'http://localhost:8080/search?request=';
|
|
|
+const MAX_MOTIF_SIZE = 10;
|
|
|
+
|
|
|
export class StrucmotifSubmitControls extends CollapsableControls {
|
|
|
protected defaultState() {
|
|
|
return {
|
|
@@ -57,13 +62,72 @@ export class SubmitControls extends PurePluginUIComponent<{}, { isBusy: boolean
|
|
|
}
|
|
|
|
|
|
submitSearch = () => {
|
|
|
+ // TODO ensure selection is from single structure
|
|
|
+ // TODO ensure selection references only polymeric entities
|
|
|
+ // TODO ensure selection granularity is/was residue
|
|
|
+ const pdbId: Set<string> = new Set();
|
|
|
+ const residueIds = [
|
|
|
+ { label_asym_id: 'B', struct_oper_id: '1', label_seq_id: 42 },
|
|
|
+ { label_asym_id: 'B', struct_oper_id: '1', label_seq_id: 87 },
|
|
|
+ { label_asym_id: 'C', struct_oper_id: '1', label_seq_id: 47 }
|
|
|
+ ];
|
|
|
const loci = this.plugin.managers.structure.selection.additionsHistory;
|
|
|
- // this.plugin.managers.structure.measurement.addAngle(loci[0].loci, loci[1].loci, loci[2].loci);
|
|
|
- console.log(loci[0].loci.elements);
|
|
|
- window.open('https://rcsb.org', '_blank');
|
|
|
+ console.log(loci[0].loci.structure);
|
|
|
+ for (let l of loci) {
|
|
|
+ pdbId.add(l.loci.structure.model.entry);
|
|
|
+ }
|
|
|
+ if (pdbId.size > 1) {
|
|
|
+ console.warn('motifs can only be extracted from a single model');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (residueIds.length > MAX_MOTIF_SIZE) {
|
|
|
+ console.warn(`maximum motif size is ${MAX_MOTIF_SIZE} residues`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const query = {
|
|
|
+ 'query': {
|
|
|
+ 'type': 'group',
|
|
|
+ 'logical_operator': 'and',
|
|
|
+ 'nodes': [{
|
|
|
+ 'type': 'terminal',
|
|
|
+ 'service': 'strucmotif',
|
|
|
+ 'parameters': {
|
|
|
+ 'value': {
|
|
|
+ 'data': '4CHA'/* pdbId.values().next().value as string*/,
|
|
|
+ 'residue_ids': residueIds
|
|
|
+ },
|
|
|
+ 'score_cutoff': 5,
|
|
|
+ 'exchanges': []
|
|
|
+ },
|
|
|
+ 'label': 'strucmotif',
|
|
|
+ 'node_id': 0
|
|
|
+ }],
|
|
|
+ 'label': 'query-builder'
|
|
|
+ },
|
|
|
+ 'return_type': 'assembly',
|
|
|
+ 'request_options': {
|
|
|
+ 'pager': {
|
|
|
+ 'start': 0,
|
|
|
+ 'rows': 100
|
|
|
+ },
|
|
|
+ 'scoring_strategy': 'combined',
|
|
|
+ 'sort': [{
|
|
|
+ 'sort_by': 'score',
|
|
|
+ 'direction': 'desc'
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ // TODO needed?
|
|
|
+ // 'request_info': {
|
|
|
+ // 'src': 'ui',
|
|
|
+ // 'query_id': 'a4efda380aee3ef202dc59447a419e80'
|
|
|
+ // }
|
|
|
+ };
|
|
|
+ // TODO figure out of Mol* can compose sierra/BioJava operator
|
|
|
+ // TODO probably there should be a sierra-endpoint that handles mapping of Mol* operator ids to sierra/BioJava ones
|
|
|
+ console.log(encodeURIComponent(JSON.stringify(query)).replace('%22', '"'));
|
|
|
+ window.open(ADVANCED_SEARCH_URL + encodeURIComponent(JSON.stringify(query)), '_blank');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
get actions(): ActionMenu.Items {
|
|
|
const history = this.selection.additionsHistory;
|
|
|
const ret: ActionMenu.Item[] = [
|