|
@@ -2,22 +2,30 @@ import { RcsbFvDisplayTypes } from "@rcsb/rcsb-saguaro";
|
|
|
|
|
|
import { getColorByLocation, getLabelByLocation } from "./UniTmpColor";
|
|
|
|
|
|
-export async function fetchDescriptor(entryId: string) {
|
|
|
- const response = await fetch(`https://htp.unitmp.org/api/v1/entry/${entryId}.json`);
|
|
|
+export async function fetchHtpDescriptor(entryId: string) {
|
|
|
+ return fetchDescriptor(`https://htp.unitmp.org/api/v1/entry/${entryId}.json`);
|
|
|
+}
|
|
|
+
|
|
|
+export async function fetchPdbtmJsvLibDescriptor(entryId: string) {
|
|
|
+ return fetchDescriptor(`https://pdbtm.unitmp.org/api/v1/jsvlib/${entryId}`);
|
|
|
+}
|
|
|
+
|
|
|
+async function fetchDescriptor(url: string) {
|
|
|
+ const response = await fetch(url);
|
|
|
const descriptor = await response.json();
|
|
|
return descriptor;
|
|
|
}
|
|
|
|
|
|
-export function descriptorChainToTrackData(descriptor: any) {
|
|
|
+export function htpDescriptorToTrackData(descriptor: any) {
|
|
|
const tracks = [] as any[];
|
|
|
|
|
|
if (Array.isArray(descriptor.Topology.Region)) {
|
|
|
- const trackData = createNewTrack('Topology', descriptor.Topology.Region);
|
|
|
+ const trackData = createNewTrack('Topology', descriptor.Topology.Region, displayParamsFromHtpRegion);
|
|
|
tracks.push(trackData);
|
|
|
}
|
|
|
|
|
|
descriptor.Predictions.Prediction.forEach((prediction: any) => {
|
|
|
- const trackData = createNewTrack(prediction['@attributes'].name, prediction.Region);
|
|
|
+ const trackData = createNewTrack(prediction['@attributes'].name, prediction.Region, displayParamsFromHtpRegion);
|
|
|
tracks.push(trackData);
|
|
|
});
|
|
|
|
|
@@ -25,7 +33,19 @@ export function descriptorChainToTrackData(descriptor: any) {
|
|
|
return tracks;
|
|
|
}
|
|
|
|
|
|
-function createNewTrack(rowTitle: string, regions: any[]) {
|
|
|
+export function jsvLibDescriptorToTrackData(descriptor: any) {
|
|
|
+ const tracks = [] as any[];
|
|
|
+
|
|
|
+ if (Array.isArray(descriptor.regions)) {
|
|
|
+ const trackData = createNewTrack(descriptor.code, descriptor.regions, displayParamsFromJsvLibRegion);
|
|
|
+ tracks.push(trackData);
|
|
|
+ }
|
|
|
+ console.log(tracks);
|
|
|
+ return tracks;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function createNewTrack(rowTitle: string, regions: any[], paramsConverter: (region: any) => { begin: number, end: number, location: string }) {
|
|
|
const trackData = {
|
|
|
trackHeight: 20,
|
|
|
trackColor: "#F9F9F9",
|
|
@@ -37,11 +57,7 @@ function createNewTrack(rowTitle: string, regions: any[]) {
|
|
|
return trackData;
|
|
|
}
|
|
|
regions.forEach((region: any) => {
|
|
|
- trackData.displayConfig.push(createDisplayItem({
|
|
|
- begin: parseInt(region['@attributes'].from),
|
|
|
- end: parseInt(region['@attributes'].to),
|
|
|
- location: region['@attributes'].loc
|
|
|
- }));
|
|
|
+ trackData.displayConfig.push(createDisplayItem(paramsConverter(region)));
|
|
|
});
|
|
|
|
|
|
return trackData;
|
|
@@ -59,3 +75,19 @@ function createDisplayItem(params: any) {
|
|
|
}]
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+function displayParamsFromHtpRegion(region: any) {
|
|
|
+ return {
|
|
|
+ begin: parseInt(region['@attributes'].from),
|
|
|
+ end: parseInt(region['@attributes'].to),
|
|
|
+ location: region['@attributes'].loc
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+function displayParamsFromJsvLibRegion(region: any) {
|
|
|
+ return {
|
|
|
+ begin: parseInt(region.start) + 1,
|
|
|
+ end: parseInt(region.end) + 1,
|
|
|
+ location: region.type
|
|
|
+ };
|
|
|
+}
|