Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Refactor code: RAS/RAF alterations in colorectal c… #4907

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 42 additions & 43 deletions src/shared/components/oncoprint/ResultsViewOncoprint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,10 @@ export default class ResultsViewOncoprint extends React.Component<
' ; ' +
remainingGeneAfterDeletion
);
} else if (geneticSublabel) {
} else if (
geneticSublabel &&
(geneListFromURL.includes('%20') || geneListFromURL.includes('%25'))
) {
//OQL Queries logic
const isSublabelInURL = this.isSublabelInURL(
geneListArrayFromURL,
Expand All @@ -1447,7 +1450,7 @@ export default class ResultsViewOncoprint extends React.Component<
geneListArrayFromURL = geneListArrayFromURL.filter(
item => item !== GeneticTrackToBeDeleted
);
const testRemainingArray = remainingGeneAfterDeletionString; // Split testRemaining into an array
const testRemainingArray = remainingGeneAfterDeletionString;
let startIdx = 0;

for (let i = 1; i < testRemainingArray.length; i++) {
Expand Down Expand Up @@ -1507,57 +1510,53 @@ export default class ResultsViewOncoprint extends React.Component<
return updatedGeneList;
}

private isSublabelInURL(
private sliceURLBasedOnSublabel(
geneListArrayFromURL: string[],
geneticSublabel: string
): boolean {
const sublabelWords = geneticSublabel.split(/[ :=]/).filter(Boolean);
let currentIndex = 0;

for (const word of sublabelWords) {
const index = geneListArrayFromURL.indexOf(word, currentIndex);
if (index === -1) {
return false;
geneticSublabel: string,
geneticTrackToBeDeleted: string
): string[] | null {
const decodedTrackToBeDeleted = decodeURIComponent(
geneticTrackToBeDeleted
).trim();

for (let i = 0; i < geneListArrayFromURL.length; i++) {
const currentGene = decodeURIComponent(
geneListArrayFromURL[i]
).trim();

if (currentGene.startsWith(decodedTrackToBeDeleted)) {
let endIndex = i;
while (
endIndex + 1 < geneListArrayFromURL.length &&
!geneListArrayFromURL[endIndex + 1].includes(':')
) {
endIndex++;
}
const slicedURL = [
...geneListArrayFromURL.slice(0, i),
...geneListArrayFromURL.slice(endIndex + 1),
];
return slicedURL;
}
currentIndex = index + 1;
}

return true;
return geneListArrayFromURL;
}

private sliceURLBasedOnSublabel(
private isSublabelInURL(
geneListArrayFromURL: string[],
geneticSublabel: string,
geneticTrackToBeDeleted: string
): string[] | null {
const sublabelWords = geneticSublabel.split(/[ :=]/).filter(Boolean);
let currentIndex = 0;
geneticSublabel: string
): boolean {
const sublabelWords = geneticSublabel.split(/[ :=]/);

for (const word of sublabelWords) {
const index = geneListArrayFromURL.indexOf(word, currentIndex);
if (index === -1) {
return null;
for (const gene of geneListArrayFromURL) {
for (const word of sublabelWords) {
if (gene.includes(word)) {
return true;
}
}
currentIndex = index + 1;
}

const startIndex = geneListArrayFromURL.indexOf(sublabelWords[0]);
const endIndex = geneListArrayFromURL.indexOf(
sublabelWords[sublabelWords.length - 1]
);
const trackWithoutColon = geneListArrayFromURL[startIndex - 1].endsWith(
':'
)
? geneListArrayFromURL[startIndex - 1].slice(0, -1) // Remove ':' if it's the last character
: geneListArrayFromURL[startIndex - 1];
if (trackWithoutColon === geneticTrackToBeDeleted) {
const slicedURL = [
...geneListArrayFromURL.slice(0, startIndex - 1),
...geneListArrayFromURL.slice(endIndex + 1),
];
return slicedURL;
}
return null;
return false;
}

/**
Expand Down
Loading