Skip to content

Commit

Permalink
wip: updating models, making variable casing consistent, converting d…
Browse files Browse the repository at this point in the history
…escriptors
  • Loading branch information
katiestahl committed Jul 29, 2024
1 parent d95f2d5 commit 77f3088
Show file tree
Hide file tree
Showing 29 changed files with 389 additions and 415 deletions.
36 changes: 18 additions & 18 deletions client/src/components/Pages/Assay/Assay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,52 +61,52 @@ export const Assay: React.FC<Props> = () => {

// initialize field values
const [fusionDetection, setFusionDetection] = useState(
fusion?.assay?.fusion_detection !== undefined
? fusion?.assay?.fusion_detection
fusion?.assay?.fusionDetection !== undefined
? fusion?.assay?.fusionDetection
: null
);

const [assayName, setAssayName] = useState(
fusion?.assay?.assay_name !== undefined ? fusion?.assay?.assay_name : ""
fusion?.assay?.assayName !== undefined ? fusion?.assay?.assayName : ""
);

const [assayId, setAssayId] = useState(
fusion?.assay?.assay_id !== undefined ? fusion?.assay?.assay_id : ""
fusion?.assay?.assayId !== undefined ? fusion?.assay?.assayId : ""
);

const [methodUri, setMethodUri] = useState(
fusion?.assay?.method_uri !== undefined ? fusion?.assay?.method_uri : ""
fusion?.assay?.methodUri !== undefined ? fusion?.assay?.methodUri : ""
);

const handleEvidenceChange = (event: FormEvent<HTMLInputElement>) => {
const evidence_value = event.currentTarget.value;
if (fusion?.assay?.fusion_detection !== evidence_value) {
if (fusion?.assay?.fusionDetection !== evidence_value) {
setFusionDetection(evidence_value);
const assay = JSON.parse(JSON.stringify(fusion.assay));
assay["fusion_detection"] = evidence_value;
assay["fusionDetection"] = evidence_value;
setFusion({ ...fusion, assay: assay });
}
};

const propertySetterMap = {
assayName: [setAssayName, "assay_name"],
assayId: [setAssayId, "assay_id"],
methodUri: [setMethodUri, "method_uri"],
assayName: [setAssayName, "assayName"],
assayId: [setAssayId, "assayId"],
methodUri: [setMethodUri, "methodUri"],
};

// live update fields
useEffect(() => {
if (fusion?.assay?.fusion_detection !== fusionDetection) {
setFusionDetection(fusion?.assay?.fusion_detection);
if (fusion?.assay?.fusionDetection !== fusionDetection) {
setFusionDetection(fusion?.assay?.fusionDetection);
}
if (fusion?.assay?.assay_name !== assayName) {
setAssayName(fusion?.assay?.assay_name);
if (fusion?.assay?.assayName !== assayName) {
setAssayName(fusion?.assay?.assayName);
}
if (fusion?.assay?.assay_id !== assayId) {
setAssayId(fusion?.assay?.assay_id);
if (fusion?.assay?.assayId !== assayId) {
setAssayId(fusion?.assay?.assayId);
}
if (fusion?.assay?.method_uri !== methodUri) {
setMethodUri(fusion?.assay?.method_uri);
if (fusion?.assay?.methodUri !== methodUri) {
setMethodUri(fusion?.assay?.methodUri);
}
}, [fusion]);

Expand Down
18 changes: 9 additions & 9 deletions client/src/components/Pages/CausativeEvent/CausativeEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ export const CausativeEvent: React.FC<Props> = () => {
const { fusion, setFusion } = useContext(FusionContext);

const [eventType, setEventType] = useState<string>(
fusion.causative_event?.event_type || ""
fusion.causativeEvent?.eventType || ""
);
const [eventDescription, setEventDescription] = useState<string>(
fusion.causative_event?.event_type || ""
fusion.causativeEvent?.eventType || ""
);

/**
* Ensure that causative event object exists for getter/setter purposes
*/
const ensureEventInitialized = () => {
if (!fusion.causative_event) {
setFusion({ ...fusion, causative_event: {} });
if (!fusion.causativeEvent) {
setFusion({ ...fusion, causativeEvent: {} });
}
};

Expand All @@ -56,8 +56,8 @@ export const CausativeEvent: React.FC<Props> = () => {
if (eventType !== value) {
setEventType(value);
}
const newCausativeEvent = { event_type: value, ...fusion.causative_event };
setFusion({ causative_event: newCausativeEvent, ...fusion });
const newCausativeEvent = { eventType: value, ...fusion.causativeEvent };
setFusion({ causativeEvent: newCausativeEvent, ...fusion });
};

/**
Expand All @@ -72,10 +72,10 @@ export const CausativeEvent: React.FC<Props> = () => {
setEventDescription(value);
}
const newCausativeEvent = {
event_description: value,
...fusion.causative_event,
eventDescription: value,
...fusion.causativeEvent,
};
setFusion({ causative_event: newCausativeEvent, ...fusion });
setFusion({ causativeEvent: newCausativeEvent, ...fusion });
};

return (
Expand Down
18 changes: 9 additions & 9 deletions client/src/components/Pages/Domains/DomainForm/DomainForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const useStyles = makeStyles((theme) => ({
const DomainForm: React.FC = () => {
// // TODO: shouldn't be necessary
useEffect(() => {
if (fusion.critical_functional_domains === undefined) {
setFusion({ ...fusion, ...{ critical_functional_domains: [] } });
if (fusion.criticalFunctionalDomains === undefined) {
setFusion({ ...fusion, ...{ criticalFunctionalDomains: [] } });
}
}, []);

Expand Down Expand Up @@ -65,7 +65,7 @@ const DomainForm: React.FC = () => {

const handleAdd = () => {
const domainParams = domainOptions[gene].find(
(domainOption: DomainParams) => domainOption.interpro_id == domain
(domainOption: DomainParams) => domainOption.interproId == domain
);
getFunctionalDomain(domainParams, status as DomainStatus, gene).then(
(response) => {
Expand All @@ -74,11 +74,11 @@ const DomainForm: React.FC = () => {
domain_id: uuid(),
...response.domain,
};
const cloneArray = Array.from(fusion["critical_functional_domains"]);
const cloneArray = Array.from(fusion["criticalFunctionalDomains"]);
cloneArray.push(newDomain);
setFusion({
...fusion,
...{ critical_functional_domains: cloneArray },
...{ criticalFunctionalDomains: cloneArray },
});

setStatus("default");
Expand Down Expand Up @@ -107,11 +107,11 @@ const DomainForm: React.FC = () => {
if (domainOptions[gene]) {
const uniqueInterproIds: Set<string> = new Set();
domainOptions[gene].forEach((domain: DomainParams, index: number) => {
if (!uniqueInterproIds.has(domain.interpro_id)) {
uniqueInterproIds.add(domain.interpro_id);
if (!uniqueInterproIds.has(domain.interproId)) {
uniqueInterproIds.add(domain.interproId);
domainOptionMenuItems.push(
<MenuItem key={index} value={domain.interpro_id}>
{domain.domain_name}
<MenuItem key={index} value={domain.interproId}>
{domain.domainName}
</MenuItem>
);
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/Pages/Domains/Main/Domains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Domain: React.FC<Props> = () => {
const { fusion, setFusion } = useContext(FusionContext);

const { globalGenes } = useContext(GeneContext);
const domains = fusion.critical_functional_domains || [];
const domains = fusion.criticalFunctionalDomains || [];

const { colorTheme } = useColorTheme();
const useStyles = makeStyles(() => ({
Expand Down Expand Up @@ -73,14 +73,14 @@ export const Domain: React.FC<Props> = () => {

const handleRemove = (domain: ClientFunctionalDomain) => {
let cloneArray: ClientFunctionalDomain[] = Array.from(
fusion.critical_functional_domains
fusion.criticalFunctionalDomains
);
cloneArray = cloneArray.filter((obj) => {
return obj["domain_id"] !== domain["domain_id"];
});
setFusion({
...fusion,
...{ critical_functional_domains: cloneArray || [] },
...{ criticalFunctionalDomains: cloneArray || [] },
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const StructureDiagram: React.FC = () => {
});

const regEls = [];
suggestion.regulatory_elements.forEach((el) => {
regEls.push(el.gene_descriptor.label);
suggestion.regulatoryElements.forEach((el) => {
regEls.push(el.gene.label);
});

return (
Expand Down
18 changes: 9 additions & 9 deletions client/src/components/Pages/ReadingFrame/ReadingFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ export const ReadingFrame: React.FC<Props> = ({ index }) => {
};

const [rFramePreserved, setRFramePreserved] = useState(
assignRadioValue(fusion.r_frame_preserved)
assignRadioValue(fusion.readingFramePreserved)
);

useEffect(() => {
if (
fusion.r_frame_preserved &&
fusion.r_frame_preserved !== rFramePreserved
fusion.readingFramePreserved &&
fusion.readingFramePreserved !== rFramePreserved
) {
setRFramePreserved(assignRadioValue(fusion.r_frame_preserved));
setRFramePreserved(assignRadioValue(fusion.readingFramePreserved));
}

if (fusion.r_frame_preserved === undefined) {
setFusion({ ...fusion, r_frame_preserved: null });
if (fusion.readingFramePreserved === undefined) {
setFusion({ ...fusion, readingFramePreserved: null });
}
}, [fusion]);

Expand All @@ -71,13 +71,13 @@ export const ReadingFrame: React.FC<Props> = ({ index }) => {
if (value !== rFramePreserved) {
if (value === "yes") {
setRFramePreserved("yes");
setFusion({ ...fusion, r_frame_preserved: true });
setFusion({ ...fusion, readingFramePreserved: true });
} else if (value === "no") {
setRFramePreserved("no");
setFusion({ ...fusion, r_frame_preserved: false });
setFusion({ ...fusion, readingFramePreserved: false });
} else {
setRFramePreserved("unspecified");
setFusion({ ...fusion, r_frame_preserved: null });
setFusion({ ...fusion, readingFramePreserved: null });
}
}
};
Expand Down
Loading

0 comments on commit 77f3088

Please sign in to comment.