Skip to content

Commit

Permalink
- RC of #1190
Browse files Browse the repository at this point in the history
  • Loading branch information
boriskovar-m2ms committed Dec 13, 2023
1 parent 1debb80 commit 3b4e7a7
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 92 deletions.
1 change: 1 addition & 0 deletions docker-compose.dev.vector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ services:
AUTHENTICATE_UPLOAD: 'False'
CELERY_TASK_ALWAYS_EAGER: 'True'
DEBUG_FRAGALYSIS: 'True'
PROXY_FORWARDED_PROTO_HEADER: 'http'
depends_on:
database:
condition: service_healthy
Expand Down
8 changes: 4 additions & 4 deletions js/components/preview/molecule/moleculeList.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export const MoleculeList = memo(({ hideProjects }) => {
categories.length > 0
) {
dispatch(initializeFilter(object_selection, joinedMoleculeLists));
dispatch(initializeMolecules(majorViewStage));
// dispatch(initializeMolecules(majorViewStage));
wereMoleculesInitialized.current = true;
}
if (
Expand All @@ -494,7 +494,7 @@ export const MoleculeList = memo(({ hideProjects }) => {
noTagsReceived
) {
dispatch(initializeFilter(object_selection, joinedMoleculeLists));
dispatch(initializeMolecules(majorViewStage));
// dispatch(initializeMolecules(majorViewStage));
wereMoleculesInitialized.current = true;
}
}
Expand Down Expand Up @@ -1157,11 +1157,11 @@ export const MoleculeList = memo(({ hideProjects }) => {
wrap="nowrap"
>
<Grid item container justifyContent="flex-start" direction="row">
{Object.keys(moleculeProperty).map(key => (
{/* {Object.keys(moleculeProperty).map(key => (
<Grid item key={key} className={classes.rightBorder}>
{moleculeProperty[key]}
</Grid>
))}
))} */}
</Grid>
</Grid>
</Grid>
Expand Down
18 changes: 9 additions & 9 deletions js/components/preview/molecule/moleculeView/moleculeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,15 @@ const MoleculeView = memo(

const getCalculatedProps = useCallback(
() => [
{ name: moleculeProperty.mw, value: data.mw ?? 0 },
{ name: moleculeProperty.logP, value: data.logp ?? 0 },
{ name: moleculeProperty.tpsa, value: data.tpsa ?? 0 },
{ name: moleculeProperty.ha, value: data.ha ?? 0 },
{ name: moleculeProperty.hacc, value: data.hacc ?? 0 },
{ name: moleculeProperty.hdon, value: data.hdon ?? 0 },
{ name: moleculeProperty.rots, value: data.rots ?? 0 },
{ name: moleculeProperty.rings, value: data.rings ?? 0 },
{ name: moleculeProperty.velec, value: data.velec ?? 0 }
// { name: moleculeProperty.mw, value: data.mw ?? 0 },
// { name: moleculeProperty.logP, value: data.logp ?? 0 },
// { name: moleculeProperty.tpsa, value: data.tpsa ?? 0 },
// { name: moleculeProperty.ha, value: data.ha ?? 0 },
// { name: moleculeProperty.hacc, value: data.hacc ?? 0 },
// { name: moleculeProperty.hdon, value: data.hdon ?? 0 },
// { name: moleculeProperty.rots, value: data.rots ?? 0 },
// { name: moleculeProperty.rings, value: data.rings ?? 0 },
// { name: moleculeProperty.velec, value: data.velec ?? 0 }
// { name: moleculeProperty.vectors, value: countOfVectors },
// { name: moleculeProperty.cpd, value: cmpds }
],
Expand Down
106 changes: 41 additions & 65 deletions js/components/preview/molecule/observationCmpList.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
const categories = useSelector(state => state.apiReducers.categoryList);

const lhsCompoundsList = useSelector(state => getLHSCompoundsList(state));
const visibleObservations = useSelector(state => selectJoinedMoleculeList(state));

const proteinsHasLoaded = useSelector(state => state.nglReducers.proteinsHasLoaded);

Expand All @@ -330,29 +331,6 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
// setCurrentPage(0);
}, [object_selection]);*/

let filteredLHSCompoundsList = useMemo(() => {
return lhsCompoundsList;
}, [lhsCompoundsList]);

let compoundMolecules = useMemo(() => {
const compoundMolecules = {};

filteredLHSCompoundsList.forEach(compound => {
const molsForCmp = allMoleculesList.filter(molecule => molecule.cmpd === compound.id);
compoundMolecules[compound.id] = molsForCmp.sort((a, b) => {
if (a.code < b.code) {
return -1;
}
if (a.code > b.code) {
return 1;
}
return 0;
});
});

return compoundMolecules;
}, [filteredLHSCompoundsList, allMoleculesList]);

let joinedMoleculeLists = useMemo(() => {
// const searchedString = currentActionList.find(action => action.type === 'SEARCH_STRING_HIT_NAVIGATOR');
if (searchString) {
Expand Down Expand Up @@ -499,7 +477,11 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
const wereMoleculesInitialized = useRef(false);

useEffect(() => {
if ((proteinsHasLoaded === true || proteinsHasLoaded === null) && all_mol_lists.length > 0) {
if (
(proteinsHasLoaded === true || proteinsHasLoaded === null) &&
all_mol_lists?.length > 0 &&
lhsCompoundsList?.length > 0
) {
if (!directAccessProcessed && directDisplay && directDisplay.molecules && directDisplay.molecules.length > 0) {
dispatch(applyDirectSelection(majorViewStage));
wereMoleculesInitialized.current = true;
Expand Down Expand Up @@ -533,6 +515,7 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
}
}, [
list_type,
lhsCompoundsList,
majorViewStage,
dispatch,
hideProjects,
Expand Down Expand Up @@ -735,6 +718,36 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
return null;
};

let filteredLHSCompoundsList = useMemo(() => {
const compounds = [];
lhsCompoundsList.forEach(compound => {
const molsForCmp = joinedMoleculeLists.filter(molecule => molecule.cmpd === compound.id);
if (molsForCmp.length > 0) {
compounds.push(compound);
}
});
return compounds;
}, [lhsCompoundsList, joinedMoleculeLists]);

let compoundMolecules = useMemo(() => {
const compoundMolecules = {};

filteredLHSCompoundsList.forEach(compound => {
const molsForCmp = allMoleculesList.filter(molecule => molecule.cmpd === compound.id);
compoundMolecules[compound.id] = molsForCmp.sort((a, b) => {
if (a.code < b.code) {
return -1;
}
if (a.code > b.code) {
return 1;
}
return 0;
});
});

return compoundMolecules;
}, [filteredLHSCompoundsList, allMoleculesList]);

const isLigandOn = changeButtonClassname(fragmentDisplayList, joinedLigandMatchLength);
const isProteinOn = changeButtonClassname(proteinList, joinedProteinMatchLength);
const isComplexOn = changeButtonClassname(complexList, joinedComplexMatchLength);
Expand Down Expand Up @@ -935,7 +948,8 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
}
}}
color={'inherit'}
disabled={/*!joinedMoleculeListsCopy.length || */ predefinedFilter !== 'none'}
// disabled={predefinedFilter !== 'none'}
disabled={true}
>
<Tooltip title="Filter/Sort">
<FilterList />
Expand Down Expand Up @@ -1178,11 +1192,11 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
wrap="nowrap"
>
<Grid item container justifyContent="flex-start" direction="row">
{Object.keys(moleculeProperty).map(key => (
{/* {Object.keys(moleculeProperty).map(key => (
<Grid item key={key} className={classes.rightBorder}>
{moleculeProperty[key]}
</Grid>
))}
))} */}
</Grid>
</Grid>
</Grid>
Expand Down Expand Up @@ -1216,44 +1230,6 @@ export const ObservationCmpList = memo(({ hideProjects }) => {
}
useWindow={false}
>
{/* <GroupNglControlButtonsContext.Provider value={groupNglControlButtonsDisabledState}>
{currentMolecules.map((data, index, array) => {
const selected = allSelectedMolecules.some(molecule => molecule.id === data.id);
const isTagEditorInvokedByMolecule = data.id === molForTagEditId;
return (
<MoleculeView
key={data.id}
index={index}
imageHeight={imgHeight}
imageWidth={imgWidth}
data={data}
previousItemData={index > 0 && array[index - 1]}
nextItemData={index < array?.length && array[index + 1]}
setRef={setTagEditorAnchorEl}
removeSelectedTypes={removeSelectedTypes}
L={fragmentDisplayList.includes(data.id)}
P={proteinList.includes(data.id)}
C={complexList.includes(data.id)}
S={surfaceList.includes(data.id)}
D={densityList.includes(data.id)}
D_C={densityListCustom.includes(data.id)}
Q={qualityList.includes(data.id)}
V={vectorOnList.includes(data.id)}
I={informationList.includes(data.id)}
eventInfo={data?.proteinData?.event_info || null}
sigmaaInfo={data?.proteinData?.sigmaa_info || null}
diffInfo={data?.proteinData?.diff_info || null}
isTagEditorInvokedByMolecule={isTagEditorInvokedByMolecule}
isTagEditorOpen={isTagEditorInvokedByMolecule && isTagEditorOpen}
selected={selected}
disableL={selected && groupNglControlButtonsDisabledState.ligand}
disableP={selected && groupNglControlButtonsDisabledState.protein}
disableC={selected && groupNglControlButtonsDisabledState.complex}
/>
);
})}
</GroupNglControlButtonsContext.Provider> */}
{filteredLHSCompoundsList.map((data, index, array) => {
const molsForCmp = compoundMolecules[data.id];
const selected = allSelectedLHSCmps.some(molecule => molecule.id === data.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ const ObservationCmpView = memo(
const { getNglView } = useContext(NglContext);
const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;

const getFirstObservation = () => {
const getFirstObservation = useCallback(() => {
let result = null;

if (observations && observations.length > 0) {
result = observations[0];
}

return result;
};
}, [observations]);

const getAllObservationsSelectedInList = list => {
let result = [];
Expand Down Expand Up @@ -436,15 +436,15 @@ const ObservationCmpView = memo(

const getCalculatedProps = useCallback(
() => [
{ name: moleculeProperty.mw, value: data.mw ?? 0 },
{ name: moleculeProperty.logP, value: data.logp ?? 0 },
{ name: moleculeProperty.tpsa, value: data.tpsa ?? 0 },
{ name: moleculeProperty.ha, value: data.ha ?? 0 },
{ name: moleculeProperty.hacc, value: data.hacc ?? 0 },
{ name: moleculeProperty.hdon, value: data.hdon ?? 0 },
{ name: moleculeProperty.rots, value: data.rots ?? 0 },
{ name: moleculeProperty.rings, value: data.rings ?? 0 },
{ name: moleculeProperty.velec, value: data.velec ?? 0 }
// { name: moleculeProperty.mw, value: data.mw ?? 0 },
// { name: moleculeProperty.logP, value: data.logp ?? 0 },
// { name: moleculeProperty.tpsa, value: data.tpsa ?? 0 },
// { name: moleculeProperty.ha, value: data.ha ?? 0 },
// { name: moleculeProperty.hacc, value: data.hacc ?? 0 },
// { name: moleculeProperty.hdon, value: data.hdon ?? 0 },
// { name: moleculeProperty.rots, value: data.rots ?? 0 },
// { name: moleculeProperty.rings, value: data.rings ?? 0 },
// { name: moleculeProperty.velec, value: data.velec ?? 0 }
// { name: moleculeProperty.vectors, value: countOfVectors },
// { name: moleculeProperty.cpd, value: cmpds }
],
Expand Down
32 changes: 29 additions & 3 deletions js/components/preview/molecule/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { readQualityInformation } from '../../../nglView/renderingHelpers';
import { addSelectedTag } from '../../tags/redux/dispatchActions';
import { CATEGORY_TYPE } from '../../../../constants/constants';
import { selectJoinedMoleculeList } from './selectors';
import { compareTagsAsc } from '../../tags/utils/tagUtils';
// import { molFile, pdbApo } from './testData';

/**
Expand Down Expand Up @@ -657,14 +658,15 @@ export const initializeMolecules = majorView => (dispatch, getState) => {
const isSnapshot = state.apiReducers.isSnapshot;

if (!isSnapshot) {
const firstTag = dispatch(getFirstTag());
const firstTag = dispatch(getFirstTagAlphabetically());
let firstMolecule = null;
if (firstTag) {
dispatch(addSelectedTag(firstTag));
firstMolecule = dispatch(getFirstMoleculeForTag(firstTag.id));
// firstMolecule = dispatch(getFirstMoleculeForTag(firstTag.id));
} else if (noTagsReceived) {
firstMolecule = dispatch(getFirstMolecule());
// firstMolecule = dispatch(getFirstMolecule());
}
firstMolecule = dispatch(getFirstMolOfFirstCompound());
if (firstMolecule) {
dispatch(addHitProtein(majorView, firstMolecule, colourList[firstMolecule.id % colourList.length], true)).then(
() => {
Expand All @@ -688,6 +690,30 @@ export const getFirstTag = () => (dispatch, getState) => {
}
};

export const getFirstTagAlphabetically = () => (dispatch, getState) => {
const state = getState();
const tagsList = state.apiReducers.tagList;
const sortedTags = tagsList.sort(compareTagsAsc);
return sortedTags && sortedTags.length > 0 ? sortedTags[0] : null;
};

export const getFirstMolOfFirstCompound = () => (dispatch, getState) => {
const state = getState();
const compoundsList = state.apiReducers.lhs_compounds_list;
const firstCompound = compoundsList[0];
if (firstCompound) {
const molList = state.apiReducers.all_mol_lists;
const firstMols = molList?.filter(m => m.cmpd === firstCompound.id);
if (firstMols && firstMols.length > 0) {
return firstMols[0];
} else {
return null;
}
} else {
return null;
}
};

export const getFirstMoleculeForTag = tagId => (dispatch, getState) => {
const state = getState();
const molList = state.apiReducers.all_mol_lists;
Expand Down
9 changes: 9 additions & 0 deletions js/components/preview/tags/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ export const loadMoleculesAndTagsNew = targetId => async (dispatch, getState) =>
const siteObs = allMolecules.find(m => m.cmpd === c.id);
c['smiles'] = siteObs ? siteObs.smiles : '';
});
compounds.sort((a, b) => {
if (a.smiles < b.smiles) {
return -1;
}
if (a.smiles > b.smiles) {
return 1;
}
return 0;
});
dispatch(setLHSCompoundsLIst([...compounds]));
});
};

0 comments on commit 3b4e7a7

Please sign in to comment.