Skip to content

Commit

Permalink
MultipleEntryPropertyCollector includes polymer entity prd ids
Browse files Browse the repository at this point in the history
  • Loading branch information
bioinsilico committed Nov 27, 2023
1 parent 44540bc commit 71f159a
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[Semantic Versioning](https://semver.org/)

## [6.0.1] - 2023-11-27
### Improvement
- `MultipleEntryPropertyCollector` includes polymer entity prd ids

## [6.0.0] - 2023-11-22
### Breaking changes
- Types are not anymore exposed from `build/src`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rcsb/rcsb-saguaro-app",
"version": "6.0.0",
"version": "6.0.1",
"description": "RCSB 1D Saguaro Web App",
"main": "build/app.js",
"files": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
import {rcsbClient, RcsbClient} from "../../RcsbGraphQL/RcsbClient";
import {CoreEntry, QueryEntriesArgs} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Yosemite/GqlTypes";
import {
CoreEntry,
CorePolymerEntity,
QueryEntriesArgs
} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Yosemite/GqlTypes";
import {StructureDeterminationMethodology} from "@rcsb/rcsb-api-tools/build/RcsbDw/Types/DwEnums";
import {Assertions} from "../../RcsbUtils/Helpers/Assertions";
import assertDefined = Assertions.assertDefined;
import assertElementListDefined = Assertions.assertElementListDefined;

export interface EntryPropertyIntreface {
export interface EntryPropertyInterface {
rcsbId: string;
entryId: string;
experimentalMethod: string;
resolution?: number;
name: string;
taxNames: Array<string>;
entryMolecularWeight?: number;
description:Array<string>;
description: Array<string>;
entityToInstance: Map<string,Array<string>>;
structureDeterminationMethodology: StructureDeterminationMethodology;
nonPolymerEntityToInstance: Map<string,Array<string>>;
instanceToOperator: Map<string,Map<string,Array<string>>>;
entityToPrd: Map<string,string>;
}

export class MultipleEntryPropertyCollector {
private readonly rcsbFvQuery: RcsbClient = rcsbClient;

public async collect(requestConfig: QueryEntriesArgs): Promise<Array<EntryPropertyIntreface>> {
public async collect(requestConfig: QueryEntriesArgs): Promise<Array<EntryPropertyInterface>> {
const result: Array<CoreEntry> = await this.rcsbFvQuery.requestMultipleEntriesProperties(requestConfig);
return result.map(r=>MultipleEntryPropertyCollector.getEntryProperties(r));
}

private static getEntryProperties(r:CoreEntry): EntryPropertyIntreface{
private static getEntryProperties(r:CoreEntry): EntryPropertyInterface{
return {
rcsbId: r.rcsb_id,
entryId: r.rcsb_id,
Expand All @@ -43,7 +48,8 @@ export class MultipleEntryPropertyCollector {
structureDeterminationMethodology: r.rcsb_entry_info.structure_determination_methodology as StructureDeterminationMethodology,
nonPolymerEntityToInstance: r.nonpolymer_entities?.map(pe=>([pe?.rcsb_id, pe?.nonpolymer_entity_instances?.map(pei=>pei?.rcsb_id)] as [string,string[]]))
.reduce((r:Map<string, string[]>,x:[string, string[]])=>r.set(x[0],x[1]),new Map<string, string[]>()) ?? new Map<string, string[]>(),
instanceToOperator: MultipleEntryPropertyCollector.instanceToOperator(r)
instanceToOperator: MultipleEntryPropertyCollector.instanceToOperator(r),
entityToPrd: r.polymer_entities?.filter((pe): pe is CorePolymerEntity => typeof pe != "undefined").map( pe=> [pe?.rcsb_id ?? "", pe?.entity_poly?.rcsb_prd_id ?? ""]).reduce((map, pair)=>map.set(pair[0],pair[1]), new Map<string,string>()) ?? new Map()
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {range} from "lodash";
import {PlainAlignmentTrackFactory} from "./PlainAlignmentTrackFactory";
import {TrackUtils} from "./Helper/TrackUtils";
import {rcsbRequestCtxManager} from "../../../../RcsbRequest/RcsbRequestContextManager";
import {EntryPropertyIntreface} from "../../../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {EntryPropertyInterface} from "../../../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {Assertions} from "../../../../RcsbUtils/Helpers/Assertions";
import assertDefined = Assertions.assertDefined;
import {TagDelimiter} from "@rcsb/rcsb-api-tools/build/RcsbUtils/TagDelimiter";
Expand Down Expand Up @@ -50,7 +50,7 @@ export class PlainObservedAlignmentTrackFactory implements TrackFactoryInterface
return uor.target_id.split(TagDelimiter.instance)[0]
}));
//TODO define a Translator class for multiple entry entry data
const entryProperties: EntryPropertyIntreface[] = (await Promise.all<EntryPropertyIntreface[]>(Operator.arrayChunk(entryIds, 100).map(ids => rcsbRequestCtxManager.getEntryProperties(ids)))).flat();
const entryProperties: EntryPropertyInterface[] = (await Promise.all<EntryPropertyInterface[]>(Operator.arrayChunk(entryIds, 100).map(ids => rcsbRequestCtxManager.getEntryProperties(ids)))).flat();
entryProperties.forEach(ep=>{
ep.entityToInstance.forEach((instanceList,entityId)=>{
this.entityInstanceNumberMap.set(entityId, instanceList.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {range} from "lodash";
import {PlainAlignmentTrackFactory} from "./PlainAlignmentTrackFactory";
import {TrackUtils} from "./Helper/TrackUtils";
import {rcsbRequestCtxManager} from "../../../../RcsbRequest/RcsbRequestContextManager";
import {EntryPropertyIntreface} from "../../../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {EntryPropertyInterface} from "../../../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {Assertions} from "../../../../RcsbUtils/Helpers/Assertions";
import assertDefined = Assertions.assertDefined;
import {TagDelimiter} from "@rcsb/rcsb-api-tools/build/RcsbUtils/TagDelimiter";
Expand Down Expand Up @@ -65,7 +65,7 @@ export class PositionalScoreAlignmentTrackFactory implements TrackFactoryInterfa
return uor.target_id.split(TagDelimiter.instance)[0];
}));
//TODO define a Translator class for multiple entry entry data
const entryProperties: EntryPropertyIntreface[] = (await Promise.all<EntryPropertyIntreface[]>(Operator.arrayChunk(entryIds, 100).map(ids => rcsbRequestCtxManager.getEntryProperties(ids)))).flat();
const entryProperties: EntryPropertyInterface[] = (await Promise.all<EntryPropertyInterface[]>(Operator.arrayChunk(entryIds, 100).map(ids => rcsbRequestCtxManager.getEntryProperties(ids)))).flat();
entryProperties.forEach(ep=>{
ep.entityToInstance.forEach((instanceList,entityId)=>{
instanceList.forEach(instanceId=>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {SearchQueryTools as SQT} from "../../../RcsbSeacrh/SearchQueryTools";
import {RcsbSearchMetadata} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchMetadata";
import {ReturnType, SortDirection} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchEnums";
import {
EntryPropertyIntreface
EntryPropertyInterface
} from "../../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {GroupProvenanceId} from "@rcsb/rcsb-api-tools/build/RcsbDw/Types/DwEnums";
import {rcsbRequestCtxManager} from "../../../RcsbRequest/RcsbRequestContextManager";
Expand Down Expand Up @@ -135,9 +135,9 @@ async function searchRequest(groupProvenanceId: GroupProvenanceId, groupId: stri
});
}

function parseItems(groupProvenanceId: GroupProvenanceId, propsList:Array<EntryPropertyIntreface>|Array<PolymerEntityInterface>): Array<ItemFeaturesInterface>{
function parseItems(groupProvenanceId: GroupProvenanceId, propsList:Array<EntryPropertyInterface>|Array<PolymerEntityInterface>): Array<ItemFeaturesInterface>{
return groupProvenanceId === GroupProvenanceId.ProvenanceMatchingDepositGroupId ?
(propsList as Array<EntryPropertyIntreface>).map((o)=>({...o, molecularWeight:o.entryMolecularWeight}))
(propsList as Array<EntryPropertyInterface>).map((o)=>({...o, molecularWeight:o.entryMolecularWeight}))
:
(propsList as Array<PolymerEntityInterface>).map((o)=>(o.instances)).flat().map((o)=>({...o, molecularWeight: o.entityMolecularWeight}));
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ query multiple_entries_properties($entry_ids: [String!]!){
}
rcsb_id
}
entity_poly {
rcsb_prd_id
}
}
nonpolymer_entities {
rcsb_id
Expand Down
10 changes: 5 additions & 5 deletions src/RcsbRequest/RcsbRequestContextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Yosemite/GqlTypes";
import {GroupMemberCollector} from "../RcsbCollectTools/DataCollectors/GroupMemberCollector";
import {
EntryPropertyIntreface,
EntryPropertyInterface,
MultipleEntryPropertyCollector
} from "../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {Operator} from "../RcsbUtils/Helpers/Operator";
Expand Down Expand Up @@ -61,7 +61,7 @@ class RcsbRequestContextManager {
private readonly searchRequestMap: Map<string,Promise<QueryResult|null>> = new Map<string, Promise<QueryResult|null>>();
private readonly interfaceToInstanceMap: Map<string,Promise<InterfaceInstanceTranslate>> = new Map<string, Promise<InterfaceInstanceTranslate>>();
private readonly assemblyInterfacesMap: Map<string,Promise<AssemblyInterfacesTranslate>> = new Map<string, Promise<AssemblyInterfacesTranslate>>();
private readonly entryPropertyMap: Map<string,Promise<EntryPropertyIntreface>> = new Map<string, Promise<EntryPropertyIntreface>>();
private readonly entryPropertyMap: Map<string,Promise<EntryPropertyInterface>> = new Map<string, Promise<EntryPropertyInterface>>();
private readonly entityPropertyMap: Map<string,Promise<PolymerEntityInterface>> = new Map<string, Promise<PolymerEntityInterface>>();
private readonly instanceSequenceMap: Map<string,Promise<InstanceSequenceInterface>> = new Map<string, Promise<InstanceSequenceInterface>>();

Expand All @@ -87,8 +87,8 @@ class RcsbRequestContextManager {
)
}

public async getEntryProperties(entryIds:string|Array<string>): Promise<Array<EntryPropertyIntreface>> {
return RRT.getMultipleObjectProperties<"entry_ids",EntryPropertyIntreface>(
public async getEntryProperties(entryIds:string|Array<string>): Promise<Array<EntryPropertyInterface>> {
return RRT.getMultipleObjectProperties<"entry_ids",EntryPropertyInterface>(
entryIds,
this.entryPropertyMap,
this.multipleEntryPropertyCollector,
Expand Down Expand Up @@ -142,7 +142,7 @@ class RcsbRequestContextManager {
this.groupPropertyMap,
async ()=>{
const result:Array<PolymerEntityInstanceInterface> = await this.groupMemberCollector.collect(groupQuery);
const entriesProperties: Array<EntryPropertyIntreface> = await this.multipleEntryPropertyCollector.collect({entry_ids:Operator.uniqueValues(result.map(r=>r.entryId))})
const entriesProperties: Array<EntryPropertyInterface> = await this.multipleEntryPropertyCollector.collect({entry_ids:Operator.uniqueValues(result.map(r=>r.entryId))})
return new GroupPropertiesProvider({entryProperties: entriesProperties});
}
);
Expand Down
6 changes: 3 additions & 3 deletions src/RcsbUtils/Groups/GroupPropertiesProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {EntryPropertyIntreface} from "../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";
import {EntryPropertyInterface} from "../../RcsbCollectTools/DataCollectors/MultipleEntryPropertyCollector";

export interface GroupPropertiesProviderInterface{
entryProperties: Array<EntryPropertyIntreface>;
entryProperties: Array<EntryPropertyInterface>;
}

interface ItemPropertyInterface {
Expand All @@ -13,7 +13,7 @@ export type GroupPropertyType = "experimental_method" | "resolution";

export class GroupPropertiesProvider {

private readonly entryProperties: Array<EntryPropertyIntreface>;
private readonly entryProperties: Array<EntryPropertyInterface>;

constructor(properties: GroupPropertiesProviderInterface) {
this.entryProperties = properties.entryProperties;
Expand Down

0 comments on commit 71f159a

Please sign in to comment.