Skip to content

Commit

Permalink
refacator: format codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz committed Dec 12, 2024
1 parent 79db679 commit 72c5d49
Show file tree
Hide file tree
Showing 106 changed files with 933 additions and 1,146 deletions.
2 changes: 1 addition & 1 deletion apps/platform/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,4 @@ export const populationMap = {
nfe: "non-Finnish Europeans",
eas: "East Asian",
amr: "Admixed American",
};
};
35 changes: 13 additions & 22 deletions apps/platform/src/pages/CredibleSetPage/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,33 @@ type HeaderProps = {
studyId: string;
};

function Header({
loading,
variantId,
referenceAllele,
alternateAllele,
studyId
}: HeaderProps) {

function Header({ loading, variantId, referenceAllele, alternateAllele, studyId }: HeaderProps) {
return (
<HeaderBase
loading={loading}
title="Credible set"
title="Credible set"
Icon={faDiagramProject}
externalLinks={
<>
<ExternalLink
title="Lead variant"
id={variantId &&
<DisplayVariantId
variantId={variantId}
referenceAllele={referenceAllele}
alternateAllele={alternateAllele}
expand={false}
/>
id={
variantId && (
<DisplayVariantId
variantId={variantId}
referenceAllele={referenceAllele}
alternateAllele={alternateAllele}
expand={false}
/>
)
}
url={`../variant/${variantId}`}
/>
<ExternalLink
title="Study ID"
id={studyId}
url={`../study/${studyId}`}
/>
<ExternalLink title="Study ID" id={studyId} url={`../study/${studyId}`} />
</>
}
/>
);
}

export default Header;
export default Header;
2 changes: 1 addition & 1 deletion apps/platform/src/pages/DiseasePage/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const DISEASE_PROFILE_QUERY = gql`
...DiseaseProfileHeaderFragment
...DiseaseProfileSummaryFragment
}
studies(diseaseIds: [$efoId], page: { size: 1, index: 0}) {
studies(diseaseIds: [$efoId], page: { size: 1, index: 0 }) {
count
}
}
Expand Down
6 changes: 4 additions & 2 deletions apps/platform/src/pages/SearchPage/SearchContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
faDna,
faMapPin,
faPrescriptionBottleAlt,
faStethoscope
faStethoscope,
} from "@fortawesome/free-solid-svg-icons";
import { ErrorBoundary } from "ui";

Expand Down Expand Up @@ -71,7 +71,9 @@ const SearchFilters = ({ entities, entitiesCount, setEntity }) => {
/>
<FormControlLabel
className={classes.label}
control={<Checkbox checked={entities.includes("variant")} onChange={setEntity("variant")} />}
control={
<Checkbox checked={entities.includes("variant")} onChange={setEntity("variant")} />
}
label={
<>
<FontAwesomeIcon icon={faMapPin} fixedWidth className={classes.labelIcon} />
Expand Down
52 changes: 19 additions & 33 deletions apps/platform/src/pages/SearchPage/VariantDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { Link, DisplayVariantId, LongText } from "ui";
function VariantDetail({ data }) {
return (
<CardContent>
<Typography color="primary" variant="h5"
<Typography
color="primary"
variant="h5"
sx={{
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
}}
>
<Link to={`/variant/${data.id}`}>
Expand All @@ -26,52 +28,36 @@ function VariantDetail({ data }) {
<FontAwesomeIcon icon={faMapPin} /> Variant
</Typography>
<LongText lineLimit={4}>{data.variantDescription}</LongText>
{data.rsIds.length > 0 &&
{data.rsIds.length > 0 && (
<>
<Typography variant="subtitle1">
Ensembl
</Typography>
<Typography variant="body2">
{data.rsIds.join(", ")}
</Typography>
<Typography variant="subtitle1">Ensembl</Typography>
<Typography variant="body2">{data.rsIds.join(", ")}</Typography>
</>
}
<Typography variant="subtitle1">
GRCh38
</Typography>
)}
<Typography variant="subtitle1">GRCh38</Typography>
<Typography variant="body2">
{data.chromosome}:{data.position}
</Typography>
<Typography variant="subtitle1">
Reference Allele
</Typography>
<Typography variant="subtitle1">Reference Allele</Typography>
<Typography component="div" variant="body2">
<LongText lineLimit={2}>
<span style={{ textWrap: "wrap", wordWrap: "break-word" }}>
{data.referenceAllele}
</span>
<span style={{ textWrap: "wrap", wordWrap: "break-word" }}>{data.referenceAllele}</span>
</LongText>
</Typography>
<Typography variant="subtitle1">
Alternate Allele
</Typography>
<Typography variant="subtitle1">Alternate Allele</Typography>
<Typography component="div" variant="body2">
<LongText lineLimit={2}>
<span style={{ textWrap: "wrap", wordWrap: "break-word" }}>
{data.alternateAllele}
</span>
<span style={{ textWrap: "wrap", wordWrap: "break-word" }}>{data.alternateAllele}</span>
</LongText>
</Typography>
{data.mostSevereConsequence &&
{data.mostSevereConsequence && (
<>
<Typography variant="subtitle1">
Most Severe Consequence
</Typography>
<Typography variant="subtitle1">Most Severe Consequence</Typography>
<Typography variant="body2">
{data.mostSevereConsequence.label.replace(/_/g, ' ')}
{data.mostSevereConsequence.label.replace(/_/g, " ")}
</Typography>
</>
}
)}
</CardContent>
);
}
Expand Down
10 changes: 4 additions & 6 deletions apps/platform/src/pages/SearchPage/VariantResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ function VariantResult({ data, highlights }) {
<Typography variant="body2" component="div">
<LongText lineLimit={4}>{data.variantDescription}</LongText>
</Typography>
{data.rsIds.length > 0 &&
<Typography variant="body2">
Ensembl: {data.rsIds.join(", ")}
</Typography>
}
{data.rsIds.length > 0 && (
<Typography variant="body2">Ensembl: {data.rsIds.join(", ")}</Typography>
)}
<Highlights highlights={highlights} />
</div>
);
}

export default VariantResult;
export default VariantResult;
65 changes: 30 additions & 35 deletions apps/platform/src/pages/StudyPage/StudyProfileHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import STUDY_PROFILE_HEADER_FRAGMENT from "./StudyProfileHeader.gql";
function ProfileHeader() {
const { loading, error, data } = usePlatformApi();

// TODO: Errors!
// TODO: Errors!
if (error) return null;

const {
Expand Down Expand Up @@ -48,7 +48,6 @@ function ProfileHeader() {

return (
<BaseProfileHeader>

<Box>
<Field loading={loading} title="Study type">
{studyType?.replace(/(qtl|gwas)/gi, match => match.toUpperCase())}
Expand Down Expand Up @@ -80,7 +79,7 @@ function ProfileHeader() {
)}
</>
)}
{studyType !== "gwas" && ( // QTL
{studyType !== "gwas" && ( // QTL
<>
{projectId && (
<Field loading={loading} title="Project">
Expand All @@ -94,10 +93,7 @@ function ProfileHeader() {
)}
{biosample?.biosampleId && (
<Field loading={loading} title="Affected cell/tissue">
<Link
external
to={`https://www.ebi.ac.uk/ols4/search?q=${biosample.biosampleId}`}
>
<Link external to={`https://www.ebi.ac.uk/ols4/search?q=${biosample.biosampleId}`}>
{biosample.biosampleName}
</Link>
</Field>
Expand All @@ -113,53 +109,53 @@ function ProfileHeader() {
{publicationDate?.slice(0, 4)})
</Field>
)}
{pubmedId &&
{pubmedId && (
<Field loading={loading} title="PubMed">
<PublicationsDrawer
name={pubmedId}
entries={[{ name: pubmedId }]}
/>
<PublicationsDrawer name={pubmedId} entries={[{ name: pubmedId }]} />
</Field>
}
)}
</Box>

<Box>
<Field loading={loading} title="Summary statistics">
{!hasSumstats
? "Not Available"
: sumstatQCValues
? <DetailPopover title="Available">
<SummaryStatsTable sumstatQCValues={sumstatQCValues} />
</DetailPopover>
: "Available"
}
{!hasSumstats ? (
"Not Available"
) : sumstatQCValues ? (
<DetailPopover title="Available">
<SummaryStatsTable sumstatQCValues={sumstatQCValues} />
</DetailPopover>
) : (
"Available"
)}
</Field>
{qualityControls?.length > 0 &&
{qualityControls?.length > 0 && (
<Box>
<DetailPopover title="QC warnings">
<ul style={{
display: "flex",
flexDirection: "column",
gap: "0.25rem",
padding: 0,
margin: "0 0 0 1rem"
}}>
<ul
style={{
display: "flex",
flexDirection: "column",
gap: "0.25rem",
padding: 0,
margin: "0 0 0 1rem",
}}
>
{qualityControls.map(warning => (
<li key={warning}>{warning}</li>
))}
</ul>
</DetailPopover>
</Box>
}
{nSamples &&
)}
{nSamples && (
<Field loading={loading} title="Sample size">
<DisplaySampleSize
nSamples={nSamples}
cohorts={cohorts}
initialSampleSize={initialSampleSize}
/>
</Field>
}
)}
<Field loading={loading} title="N cases">
{/* do not show anything when value 0 */}
{nCases ? nCases?.toLocaleString() : null}
Expand All @@ -171,7 +167,7 @@ function ProfileHeader() {
<Field loading={loading} title="Analysis">
{analysisFlags?.join(", ")}
</Field>
{ldPopulationStructure?.length > 0 &&
{ldPopulationStructure?.length > 0 && (
<Box display="flex" sx={{ gap: 1 }}>
{ldPopulationStructure.map(({ ldPopulation, relativeSampleSize }) => (
<LabelChip
Expand All @@ -182,9 +178,8 @@ function ProfileHeader() {
/>
))}
</Box>
}
)}
</Box>

</BaseProfileHeader>
);
}
Expand Down
Loading

0 comments on commit 72c5d49

Please sign in to comment.