Skip to content

Commit

Permalink
individual download
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaofei Zhao committed Apr 28, 2021
1 parent 054f43e commit 96e922a
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,6 @@ export class ResultsViewPageStore {
NumericGeneMolecularData[]
>({
await: () => [
this.studyToDataQueryFilter,
this.genes,
this.nonSelectedDownloadableMolecularProfiles,
this.samples,
Expand Down
118 changes: 112 additions & 6 deletions src/pages/resultsView/download/DownloadTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {
getSingleGeneResultKey,
getMultipleGeneResultKey,
excludeSpecialMolecularProfiles,
} from '../ResultsViewPageStoreUtils';
import { CoverageInformation } from 'shared/lib/GenePanelUtils';
import {
Expand Down Expand Up @@ -66,6 +67,9 @@ import {
Sample,
CancerStudy,
GenericAssayData,
SampleMolecularIdentifier,
Gene,
MolecularDataMultipleStudyFilter,
} from 'cbioportal-ts-api-client';
import ErrorMessage from '../../../shared/components/ErrorMessage';
import AlterationFilterWarning from '../../../shared/components/banners/AlterationFilterWarning';
Expand All @@ -77,6 +81,8 @@ import FontAwesome from 'react-fontawesome';
import CaseFilterWarning from '../../../shared/components/banners/CaseFilterWarning';
import { If, Then, Else } from 'react-if';
import { ResultsViewTab } from '../ResultsViewPageHelpers';
import client from 'shared/api/cbioportalClientInstance';
import { REQUEST_ARG_ENUM } from 'shared/constants';

export interface IDownloadTabProps {
store: ResultsViewPageStore;
Expand Down Expand Up @@ -1328,13 +1334,113 @@ export default class DownloadTab extends React.Component<

@autobind
private handleOtherMolecularProfileDownload(profileName: string) {
onMobxPromise(
this.allOtherMolecularProfileDownloadDataGroupByProfileName,
downloadDataGroupByProfileName => {
const textMap = this.downloadDataTextGroupByKey(
downloadDataGroupByProfileName
onMobxPromise<any>(
[
this.props.store.nonSelectedDownloadableMolecularProfiles,
this.props.store.samples,
this.props.store.genes,
this.props.store.coverageInformation,
],
async (
nonSelectedDownloadableMolecularProfiles,
samples,
genes,
coverageInformation
) => {
// STEP 1: fetch data
// we get mutations with mutations endpoint, structural variants and fusions with structural variant endpoint.
// filter out mutation genetic profile and structural variant profiles
const selectedProfiles: MolecularProfile[] = nonSelectedDownloadableMolecularProfiles.filter(
(profile: MolecularProfile) => profile.name === profileName
);
fileDownload(textMap[profileName], `${profileName}.txt`);

if (
selectedProfiles.length &&
genes != undefined &&
genes.length
) {
const selectedProfilesGroupByStudyId = _.groupBy(
selectedProfiles,
profile => profile.studyId
);
// find samples which share studyId with profile and add identifier
const sampleIdentifiers: SampleMolecularIdentifier[] = (samples as Sample[])
.filter(
sample =>
sample.studyId in selectedProfilesGroupByStudyId
)
.reduce((acc: SampleMolecularIdentifier[], sample) => {
acc = acc.concat(
selectedProfilesGroupByStudyId[
sample.studyId
].map(profile => {
return {
molecularProfileId:
profile.molecularProfileId,
sampleId: sample.sampleId,
} as SampleMolecularIdentifier;
})
);
return acc;
}, []);

let molecularData: any[] = [];
if (sampleIdentifiers.length) {
molecularData = await client.fetchMolecularDataInMultipleMolecularProfilesUsingPOST(
{
projection:
REQUEST_ARG_ENUM.PROJECTION_DETAILED,
molecularDataMultipleStudyFilter: {
entrezGeneIds: _.map(
genes,
(gene: Gene) => gene.entrezGeneId
),
sampleMolecularIdentifiers: sampleIdentifiers,
} as MolecularDataMultipleStudyFilter,
}
);
}

// STEP 2: fetch data
// const data = {
// samples: _.groupBy(
// this.props.store.nonSelectedDownloadableMolecularData
// .result!,
// data => data.uniqueSampleKey
// ),
// } as CaseAggregatedData<ExtendedAlteration>;
// const allOtherMolecularProfileDataGroupByProfileName: {
// [profileName: string]: {
// [key: string]: ExtendedAlteration[];
// };
// } = _.reduce(
// profileNames,
// (
// allOtherMolecularProfileDataGroupByProfileName,
// profileName
// ) => {
// allOtherMolecularProfileDataGroupByProfileName[
// profileName
// ] = generateOtherMolecularProfileData(
// this.props.store.nonSelectedDownloadableMolecularProfilesGroupByName.result[
// profileName
// ].map(profile => profile.molecularProfileId),
// data
// );
// return allOtherMolecularProfileDataGroupByProfileName;
// },
// {} as {
// [profileName: string]: {
// [key: string]: ExtendedAlteration[];
// };
// }
// );
}

// const textMap = this.downloadDataTextGroupByKey(
// downloadDataGroupByProfileName
// );
// fileDownload(textMap[profileName], `${profileName}.txt`);
}
);
}
Expand Down

0 comments on commit 96e922a

Please sign in to comment.