Skip to content

Commit

Permalink
Temporal fix for UniprotID missing
Browse files Browse the repository at this point in the history
  • Loading branch information
p3rcypj committed Jan 29, 2024
1 parent f98c2d1 commit b7cab48
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface Data {
type DataRequests = { [K in keyof Data]-?: Future<RequestError, Data[K] | undefined> };

interface Options {
proteinId: string;
proteinId: Maybe<string>;
pdbId: Maybe<string>;
chainId: string;
}
Expand All @@ -103,34 +103,33 @@ export class ApiPdbRepository implements PdbRepository {
debugVariable({ apiData: data });
const { proteinId } = options;

const variants = getVariants(
data.ebiVariation,
data.mutagenesis,
data.genomicVariantsCNCB,
proteinId
);
const variants = proteinId
? getVariants(data.ebiVariation, data.mutagenesis, data.genomicVariantsCNCB, proteinId)
: undefined;

// prettier-ignore
const fragmentsList = {
featureFragments: on(data.features, features => getFeatureFragments(options.proteinId, features)),
pfamDomainFragments: on(data.pfamAnnotations, pfamAnnotations => getPfamDomainFragments(pfamAnnotations, proteinId)),
smartDomainFragments: on(data.smartAnnotations, smartAnnotations => getSmartDomainFragments(smartAnnotations, proteinId)),
interproFragments: on(data.interproAnnotations, interproAnnotations => getInterproDomainFragments(interproAnnotations, proteinId)),
elmdbFragments: on(data.elmdbUniprot, elmdbUniprot => getElmdbUniprotFragments(elmdbUniprot, proteinId)),
functionalMappingFragments: on(data.cv19Tracks, getFunctionalMappingFragments),
structureCoverageFragments: on(data.coverage, coverage => getStructureCoverageFragments(coverage, options.chainId)),
emValidationFragments: on(data.pdbAnnotations, pdbAnnotations => getEmValidationFragments(pdbAnnotations, options.chainId)),
mobiFragments: on(data.mobiUniprot, mobiUniprot => getMobiUniprotFragments(mobiUniprot, proteinId)),
proteomicsFragments: on(data.proteomics, proteomics => getProteomicsFragments(proteomics, proteinId)),
pdbRedoFragments: on(data.pdbRedo, pdbRedo => getPdbRedoFragments(pdbRedo, options.chainId)),
epitomesFragments: on(data.iedb, getEpitomesFragments),
phosphiteFragments: on(data.phosphositeUniprot, phosphositeUniprot => getPhosphiteFragments(phosphositeUniprot, proteinId)),
dbPtmFragments: on(data.dbPtm, dbPtm => getDbPtmFragments(dbPtm, proteinId)),
molprobityFragments: on(data.molprobity, molprobity => getMolprobityFragments(molprobity, options.chainId)),
antigenFragments: on(data.antigenic, antigenic => getAntigenicFragments(antigenic, proteinId)),
// emValidationFragments: on(data.pdbAnnotations, pdbAnnotations => getEmValidationFragments(pdbAnnotations, options.chainId)),
// pdbRedoFragments: on(data.pdbRedo, pdbRedo => getPdbRedoFragments(pdbRedo, options.chainId)),
// molprobityFragments: on(data.molprobity, molprobity => getMolprobityFragments(molprobity, options.chainId)),
// ...(proteinId ? {
// featureFragments: on(data.features, features => getFeatureFragments(proteinId, features)),
// functionalMappingFragments: on(data.cv19Tracks, getFunctionalMappingFragments),
// epitomesFragments: on(data.iedb, getEpitomesFragments),
// pfamDomainFragments: on(data.pfamAnnotations, pfamAnnotations => getPfamDomainFragments(pfamAnnotations, proteinId)),
// smartDomainFragments: on(data.smartAnnotations, smartAnnotations => getSmartDomainFragments(smartAnnotations, proteinId)),
// interproFragments: on(data.interproAnnotations, interproAnnotations => getInterproDomainFragments(interproAnnotations, proteinId)),
// elmdbFragments: on(data.elmdbUniprot, elmdbUniprot => getElmdbUniprotFragments(elmdbUniprot, proteinId)),
// mobiFragments: on(data.mobiUniprot, mobiUniprot => getMobiUniprotFragments(mobiUniprot, proteinId)),
// proteomicsFragments: on(data.proteomics, proteomics => getProteomicsFragments(proteomics, proteinId)),
// phosphiteFragments: on(data.phosphositeUniprot, phosphositeUniprot => getPhosphiteFragments(phosphositeUniprot, proteinId)),
// dbPtmFragments: on(data.dbPtm, dbPtm => getDbPtmFragments(dbPtm, proteinId)),
// antigenFragments: on(data.antigenic, antigenic => getAntigenicFragments(antigenic, proteinId))
// } : {}),
};

const protein = getProtein(proteinId, data.uniprot);
const protein = proteinId ? getProtein(proteinId, data.uniprot) : undefined;
const experiment = on(data.pdbExperiment, pdbExperiment =>
options.pdbId ? getExperiment(options.pdbId, pdbExperiment) : undefined
);
Expand Down Expand Up @@ -227,31 +226,35 @@ function getData(options: Options): FutureData<Partial<Data>> {

// Move URLS to each track module?
//prettier-ignore
const data$: DataRequests = {
uniprot: getXML(`${routes.uniprot}/uniprotkb/${proteinId}.xml`),
pdbEmdbsEmValidations,
features: getJSON(`${ebiProteinsApiUrl}/features/${proteinId}`),
cv19Tracks: getJSON(`${bioUrl}/cv19_annotations/${proteinId}_annotations.json`),
const data$: Partial<DataRequests> = {
//PDBID
pdbSummary: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/summary/${pdbId}`)),
pdbAnnotations: onF(pdbId, pdbId => getJSON(`${pdbAnnotUrl}/all/${pdbId}/${chainId}/?format=json`)),
pdbPublications,
coverage: onF(pdbId, pdbId => getJSON(`${bioUrl}/api/alignments/Coverage/${pdbId}${chainId}`)),
pdbSummary: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/summary/${pdbId}`)),
ebiVariation: getJSON(`${ebiProteinsApiUrl}/variation/${proteinId}`),
mobiUniprot: getJSON(`${bioUrl}/api/annotations/mobi/Uniprot/${proteinId}`),
phosphositeUniprot: getJSON(`${bioUrl}/api/annotations/Phosphosite/Uniprot/${proteinId}`),
dbPtm: getJSON(`${bioUrl}/api/annotations/dbptm/Uniprot/${proteinId}`),
pfamAnnotations: getJSON(`${bioUrl}/api/annotations/Pfam/Uniprot/${proteinId}`),
smartAnnotations: getJSON(`${bioUrl}/api/annotations/SMART/Uniprot/${proteinId}`),
interproAnnotations: getJSON(`${bioUrl}/api/annotations/interpro/Uniprot/${proteinId}`),
proteomics: getJSON(`${ebiProteinsApiUrl}/proteomics/${proteinId}`),
pdbRedo: onF(pdbId, pdbId => getJSON(`${bioUrl}/api/annotations/PDB_REDO/${pdbId}`)),
iedb: getJSON(`${bioUrl}/api/annotations/IEDB/Uniprot/${proteinId}`),
pdbExperiment: onF(pdbId, pdbId => getJSON(`${ebiBaseUrl}/pdbe/api/pdb/entry/experiment/${pdbId}`)),
elmdbUniprot: getJSON(`${bioUrl}/api/annotations/elmdb/Uniprot/${proteinId}`),
molprobity: onF(pdbId, pdbId => getJSON(`${bioUrl}/compute/molprobity/${pdbId}`)),
antigenic: getJSON(`${ebiProteinsApiUrl}/antigen/${proteinId}`),
mutagenesis: getJSON(`${bioUrl}/api/annotations/biomuta/Uniprot/${proteinId}`),
genomicVariantsCNCB: getJSON(`${bioUrl}/ws/lrs/features/variants/Genomic_Variants_CNCB/${proteinId}/`),
//UNIPROT
...(proteinId ? {
uniprot: getXML(`${routes.uniprot}/uniprotkb/${proteinId}.xml`),
pdbEmdbsEmValidations,
features: getJSON(`${ebiProteinsApiUrl}/features/${proteinId}`),
cv19Tracks: getJSON(`${bioUrl}/cv19_annotations/${proteinId}_annotations.json`),
ebiVariation: getJSON(`${ebiProteinsApiUrl}/variation/${proteinId}`),
mobiUniprot: getJSON(`${bioUrl}/api/annotations/mobi/Uniprot/${proteinId}`),
phosphositeUniprot: getJSON(`${bioUrl}/api/annotations/Phosphosite/Uniprot/${proteinId}`),
dbPtm: getJSON(`${bioUrl}/api/annotations/dbptm/Uniprot/${proteinId}`),
pfamAnnotations: getJSON(`${bioUrl}/api/annotations/Pfam/Uniprot/${proteinId}`),
smartAnnotations: getJSON(`${bioUrl}/api/annotations/SMART/Uniprot/${proteinId}`),
interproAnnotations: getJSON(`${bioUrl}/api/annotations/interpro/Uniprot/${proteinId}`),
proteomics: getJSON(`${ebiProteinsApiUrl}/proteomics/${proteinId}`),
iedb: getJSON(`${bioUrl}/api/annotations/IEDB/Uniprot/${proteinId}`),
elmdbUniprot: getJSON(`${bioUrl}/api/annotations/elmdb/Uniprot/${proteinId}`),
antigenic: getJSON(`${ebiProteinsApiUrl}/antigen/${proteinId}`),
mutagenesis: getJSON(`${bioUrl}/api/annotations/biomuta/Uniprot/${proteinId}`),
genomicVariantsCNCB: getJSON(`${bioUrl}/ws/lrs/features/variants/Genomic_Variants_CNCB/${proteinId}/`)
} : {}),
ligands,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface Pdb {
title: Maybe<string>;
experiment: Maybe<Experiment>;
emdbs: Emdb[];
protein: Protein;
protein: Maybe<Protein>;
chainId: string;
sequence: string;
length: number;
Expand Down Expand Up @@ -108,10 +108,12 @@ export function getEntityLinks(pdb: Pdb, entity: PdbEntity): Link[] {
}));
}
case "uniprot": {
if (!pdb.protein) return [];
const proteinId = pdb.protein.id.toUpperCase();
return [{ name: proteinId, url: `https://www.uniprot.org/uniprot/${proteinId}` }];
}
case "geneBank": {
if (!pdb.protein) return [];
return pdb.protein.genBank
? pdb.protein.genBank?.map(id => ({
name: id ?? "-",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface PdbInfo {
name: string;
shortName: string;
chainId: ChainId;
protein: Protein;
protein: Maybe<Protein>;
}>;
ligands: Ligand[];
}
Expand Down Expand Up @@ -45,6 +45,20 @@ export function buildPdbInfo(options: BuildPdbInfoOptions): PdbInfo {
.sortBy(obj => obj.chainId)
.value();

if (_.isEmpty(chains) && _.isEmpty(options.proteins))
return {
...options,
chains: [
{
id: "A",
name: "A",
shortName: "A",
chainId: "A",
protein: undefined,
},
],
};

return { ...options, chains };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface PdbRepository {
}

export interface PdbOptions {
proteinId: ProteinId;
proteinId: Maybe<ProteinId>;
pdbId: Maybe<PdbId>;
chainId: ChainId;
chainId: Maybe<ChainId>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function getItems(pdb: Pdb) {
const resolution = pdb.experiment?.resolution;

const items: Item[] = _.compact([
{ name: i18n.t("Organism"), value: pdb.protein.organism },
pdb.protein ? { name: i18n.t("Organism"), value: pdb.protein.organism } : undefined,
{
name: i18n.t("Biological function"),
isDisabled: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ const Child: React.FC<ChildProps> = props => {

function getItems(pdb: Pdb): Item[] {
return _.compact([
{ name: i18n.t("Gene Name"), value: pdb.protein.gen },
{
name: i18n.t("Gene Bank ID"),
value: pdb.protein.genBank ? <Links links={getEntityLinks(pdb, "geneBank")} /> : "-",
},
pdb.protein ? { name: i18n.t("Gene Name"), value: pdb.protein.gen } : undefined,
pdb.protein
? {
name: i18n.t("Gene Bank ID"),
value: pdb.protein.genBank ? (
<Links links={getEntityLinks(pdb, "geneBank")} />
) : (
"-"
),
}
: undefined,
{
name: i18n.t("Uniprot ID"),
value: <Links links={getEntityLinks(pdb, "uniprot")} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface GeneViewerProps {

export const GeneViewer: React.FC<GeneViewerProps> = props => {
const { trackDef, pdb } = props;
if (!pdb.protein) throw new Error("No UniprotID to show GeneViewer");
const src = routes.bionotes + `/genomicIFrame?uniprot_acc=${pdb.protein.id.toUpperCase()}`;
const title = `${trackDef.name}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface InfoAlignmentFromNetwork {
}

export function getInfoAlignmentFromPdb(pdb: Pdb): Maybe<InfoAlignment> {
if (!pdb.protein) return undefined;
if (pdb.proteinNetwork) {
return {
origin: "interactome3d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ export const ProtvistaViewer: React.FC<ProtvistaViewerProps> = props => {

const geneName = React.useMemo(
() =>
pdb.protein.gen
? i18n.t(" encoded by the gene {{geneName}}", { geneName: pdb.protein.gen })
pdb.protein?.gen
? i18n.t(" encoded by the gene {{geneName}}", { geneName: pdb.protein?.gen })
: undefined,
[pdb.protein]
);

const geneBankEntry = React.useMemo(
() =>
!_.isEmpty(pdb.protein.genBank)
!_.isEmpty(pdb.protein?.genBank)
? i18n.t(" (GeneBank {{geneBankEntry}})", {
geneBankEntry: pdb.protein.genBank?.join(", "),
geneBankEntry: pdb.protein?.genBank?.join(", "),
})
: undefined,
[pdb.protein]
Expand All @@ -71,11 +71,11 @@ export const ProtvistaViewer: React.FC<ProtvistaViewerProps> = props => {
() => ({
poorQualityRegionMax: _.first(pdb.emdbs)?.emv?.stats?.quartile75,
poorQualityRegionMin: _.first(pdb.emdbs)?.emv?.stats?.quartile25,
proteinName: pdb.protein.name,
proteinName: pdb.protein?.name,
ligandsAndSmallMoleculesCount,
resolution: _.first(pdb.emdbs)?.emv?.stats?.resolutionMedian,
chain: pdb.chainId,
chainWithProtein: `${pdb.chainId}${pdb.protein.name ? " - " + pdb.protein.name : ""}`,
chainWithProtein: `${pdb.chainId}${pdb.protein?.name ? " - " + pdb.protein.name : ""}`,
uniprotId: getEntityLinks(pdb, "uniprot")
.map(link => link.name)
.join(", "),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ProtvistaGrouped: React.FC<ProtvistaGroupedProps> = React.memo(() =

return (
<ViewerBlock block={block} namespace={namespace}>
{i18n.t("Protein")}: {loader.data.protein.id} | {i18n.t("PDB")}: {loader.data.id} |
{i18n.t("Protein")}: {loader.data.protein?.id} | {i18n.t("PDB")}: {loader.data.id} |
{i18n.t("Chain")}: {loader.data.chainId}
<ProtvistaPdb pdb={loader.data} block={block} showAllTracks={false} />
</ViewerBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ToolsButton: React.FC<ToolsButtonProps> = props => {
return updateLoader(
"exportAnnotations",
compositionRoot.exportAllAnnotations
.execute({ proteinId: protein.id, pdbId: id, chainId, emdbs })
.execute({ proteinId: protein?.id, pdbId: id, chainId, emdbs })
.toPromise()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ const Tools: React.FC<{ pdb: Pdb; subtrack: Subtrack; fragment: FragmentP }> = p
return (
<TooltipRow
title={i18n.t("Tools")}
object={getFragmentToolsLink({ protein: pdb.protein.id, subtrack, fragment })}
object={
pdb.protein
? getFragmentToolsLink({ protein: pdb.protein.id, subtrack, fragment })
: undefined
}
>
{link => <Link name={link.name} url={link.url} />}
</TooltipRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ export function getPdbOptions(
.get(chainId, defaultChain)
: defaultChain;

return chain ? { pdbId, proteinId: chain.protein.id, chainId: chain.chainId } : undefined;
return chain ? { pdbId, proteinId: chain.protein?.id, chainId: chain.chainId } : undefined;
}

0 comments on commit b7cab48

Please sign in to comment.