Skip to content

Conversation

@i-am-leslie
Copy link
Contributor

@i-am-leslie i-am-leslie commented Oct 13, 2025

Fix #11640

Migrate Mutation to Clean Architecture with ClickHouse Support

This PR refactors mutation data endpoints from legacy architecture to clean architecture with ClickHouse support, as part of the broader backend migration to ClickHouse and clean architecture patterns

ARCHITECTURAL CHANGES

Usecase Layer

FetchAllMetaMutationsInProfileUseCase- Use case for retrieving MetaMutation data
FetchAllMutationsInProfileUseCase- Use case for retrieving Mutation data
GetMutationDataUseCases- provides a centralized way to access and utilize the use cases

Repository

MutationRepository- Interface that defines the methods for retrieving data from the repository

Infrastructure

ClickhouseMutationMapper- Maps the repository methods to the ClickhouseMutationMapper.xml file
ClickhouseMutationRepository- Implements the MutationRepository methods used to communicate with the database using ClickhouseMutationMapper.

Rest Layer

ColumnMutationController- New @Profile("clickhouse") rest controller supporting retrieval of Mutation and MutationMeta data

MapStruct Integration

  • MutationMapper: Main mapper with computed uniqueKey fields
  • AlleleSpecificCopyNumberMapper: Nested object transformation
  • GeneMapper : Nested object transformation

###Simple Flow Diagram
Screenshot 2025-08-17 at 5 37 49 PM

Limitations

In the effort to reduce the number of joins and ensure the population of all required fields needed for the Mutation object in SUMMARY and DETAILED projections, I faced a cartesian effect due to no unique combination of values in genomic_event_derived. Please take a look at this draft PR for more details #11650

Reviewer Notes
Please feel free to review the overall structure and approach. Feedback on the direction, naming, or anything architectural is welcome, especially in the use case logic, queries and dependency setup.

* @param fetchAllMetaMutationsInProfileUseCase
* @param fetchAllMutationsInProfileUseCase
*/
public record GetMutationUseCases(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this and usages to MutationUseCases

import org.cbioportal.legacy.web.parameter.Direction;
import org.cbioportal.shared.enums.ProjectionType;

public record MutationSearchCriteria(ProjectionType projection,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good design to package parameters. Maybe rename to MutationQueryOptions since there's no search involved?


public ClickhouseMutationRepository(ClickhouseMutationMapper clickhouseMutationMapper) {
this.mapper = clickhouseMutationMapper;
this.molecularProfileCaseIdentifierUtil = new MolecularProfileCaseIdentifierUtil();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this from new instance to injection (include it in the parameters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, High-level modules should not depend on low-level modules

… for grouping profiles and removing duplicates
…e information to clickhouse for faster processing and reducing the risk of doing redundant joins
@alisman alisman force-pushed the master-clean-arch-mutation-legacy-query branch from 7376578 to 80c981e Compare October 27, 2025 16:32
Signed-off-by: Zhaoyuan (Ryan) Fu <[email protected]>
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-mutation-legacy-query branch from 80c981e to 7773b1f Compare October 28, 2025 15:08
Copy link
Contributor

@fuzhaoyuan fuzhaoyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Great job!

@alisman alisman merged commit cf3183e into cBioPortal:master Oct 28, 2025
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate mutations endpoint to clean architecture with ClickHouse support

3 participants