Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasblum committed Nov 8, 2023
2 parents 4c03e36 + dcc6399 commit 08014f2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/components/Matches/EntriesOnProtein/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const EntriesOnProtein = ({ matches, match }: Props) => {
const { entry, protein } = match || {};

useEffect(() => {
if (!matches.length || !entry || !protein) return;
if (matches === undefined || !matches.length || !entry || !protein) return;

setData(
matches.map((loc) => ({
Expand All @@ -39,7 +39,8 @@ const EntriesOnProtein = ({ matches, match }: Props) => {
);
}, [entry, protein]);

if (!matches.length || !entry || !protein) return null;
if (matches === undefined || !matches.length || !entry || !protein)
return null;

return (
<div className={css('track-in-table')}>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Related/RelatedAdvanced/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const mapStateToPropsAdvanced = createSelector(
(value: EndpointPartialLocation) => !!value.isFilter && value.order !== 1
),
(mainType, [focusType, focusObj], otherFilters) => ({
mainType,
mainType:
(mainType as string) === 'result' ? ('protein' as Endpoint) : mainType,
focusType: focusType as Endpoint,
focusDB: (focusObj as EndpointLocation)?.db,
otherFilters: otherFilters as Array<EndpointFilter>,
Expand Down
34 changes: 24 additions & 10 deletions src/subPages/SimilarProteins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,37 @@ const schemaProcessData = (data) => {

const formatDomainsPayload = (payload, loading, ida) => {
if (loading || !payload) return null;
const namesMap = {};
payload.results.forEach((result) => {
if (result.metadata.source_database.toLowerCase() === 'interpro') {
const acc = result.metadata.accession;
namesMap[acc.toLowerCase()] = result?.extra_fields?.short_name || acc;
}
});

const domainsMap = {};
payload.results.forEach((result) => {
domainsMap[result.metadata.accession.toLowerCase()] = [
...result.proteins[0].entry_protein_locations,
];
if (result.metadata.integrated) {
domainsMap[result.metadata.integrated.toLowerCase()] = [
if (result.metadata.source_database.toLowerCase() === 'pfam') {
const acc = result.metadata.accession;
namesMap[acc.toLowerCase()] = result?.extra_fields?.short_name || acc;

domainsMap[acc.toLowerCase()] = [
...result.proteins[0].entry_protein_locations,
];

if (result.metadata.integrated) {
domainsMap[result.metadata.integrated.toLowerCase()] = [
...result.proteins[0].entry_protein_locations,
];
}
}
});
const domains = [];
ida.split(/[:-]/).forEach((domain) => {
domains.push({
entry: domain.toUpperCase(),
coordinates: domainsMap[domain.toLowerCase()].splice(0, 1),
name:
payload.results?.[0]?.extra_fields?.short_name || domain.toUpperCase(),
name: namesMap[domain.toLowerCase()] || domain,
});
});
return {
Expand Down Expand Up @@ -158,14 +171,14 @@ const getUrlForIDA = createSelector(
});
},
);
const getUrlForPfamDomains = createSelector(
const getUrlForDomains = createSelector(
(state) => state.settings.api,
(state) => state.customLocation.description,
(state) => state.customLocation.search,
({ protocol, hostname, port, root }, description) => {
const newDescription = {
main: { key: 'entry' },
entry: { db: 'pfam' },
entry: { db: 'all' },
protein: {
accession: description.protein.accession,
db: 'uniprot',
Expand All @@ -180,6 +193,7 @@ const getUrlForPfamDomains = createSelector(
pathname: root + descriptionToPath(newDescription),
query: {
extra_fields: 'short_name',
page_size: 100,
},
});
},
Expand All @@ -194,7 +208,7 @@ const mapStateToPropsAccessionDB = createSelector(
);

const SimilarProteinsHeader = loadData({
getUrl: getUrlForPfamDomains,
getUrl: getUrlForDomains,
propNamespace: 'Domain',
})(
loadData({
Expand Down

0 comments on commit 08014f2

Please sign in to comment.