|
@@ -10,33 +10,43 @@ export async function fetchDescriptor(entryId: string) {
|
|
|
|
|
|
export function descriptorChainToTrackData(descriptor: any) {
|
|
|
const tracks = [] as any[];
|
|
|
- descriptor.Predictions.Prediction.forEach((prediction: any) => {
|
|
|
- const trackData = {
|
|
|
- trackHeight: 20,
|
|
|
- trackColor: "#F9F9F9",
|
|
|
- displayType: RcsbFvDisplayTypes.COMPOSITE,
|
|
|
- rowTitle: prediction['@attributes'].name,
|
|
|
- displayConfig: [] as any[]
|
|
|
- };
|
|
|
+
|
|
|
+ if (Array.isArray(descriptor.Topology.Region)) {
|
|
|
+ const trackData = createNewTrack('Topology', descriptor.Topology.Region);
|
|
|
tracks.push(trackData);
|
|
|
+ }
|
|
|
|
|
|
- if (!Array.isArray(prediction.Region)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- prediction.Region.forEach((region: any) => {
|
|
|
- trackData.displayConfig.push(createDisplayItem({
|
|
|
- begin: parseInt(region['@attributes'].from),
|
|
|
- end: parseInt(region['@attributes'].to),
|
|
|
- location: region['@attributes'].loc
|
|
|
- }));
|
|
|
- });
|
|
|
+ descriptor.Predictions.Prediction.forEach((prediction: any) => {
|
|
|
+ const trackData = createNewTrack(prediction['@attributes'].name, prediction.Region);
|
|
|
+ tracks.push(trackData);
|
|
|
});
|
|
|
|
|
|
console.log(tracks);
|
|
|
return tracks;
|
|
|
}
|
|
|
|
|
|
+function createNewTrack(rowTitle: string, regions: any[]) {
|
|
|
+ const trackData = {
|
|
|
+ trackHeight: 20,
|
|
|
+ trackColor: "#F9F9F9",
|
|
|
+ displayType: RcsbFvDisplayTypes.COMPOSITE,
|
|
|
+ rowTitle: rowTitle,
|
|
|
+ displayConfig: [] as any[]
|
|
|
+ };
|
|
|
+ if (!Array.isArray(regions)) {
|
|
|
+ return trackData;
|
|
|
+ }
|
|
|
+ regions.forEach((region: any) => {
|
|
|
+ trackData.displayConfig.push(createDisplayItem({
|
|
|
+ begin: parseInt(region['@attributes'].from),
|
|
|
+ end: parseInt(region['@attributes'].to),
|
|
|
+ location: region['@attributes'].loc
|
|
|
+ }));
|
|
|
+ });
|
|
|
+
|
|
|
+ return trackData;
|
|
|
+}
|
|
|
+
|
|
|
function createDisplayItem(params: any) {
|
|
|
return {
|
|
|
displayType: RcsbFvDisplayTypes.BLOCK,
|