From 3baf7c2a7d752c104ac549c637c25d537f66fb20 Mon Sep 17 00:00:00 2001 From: Manda Wilson <1458628+mandawilson@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:55:56 -0500 Subject: [PATCH 01/16] Remove support for FUSION datatype. Co-authored-by: Avery Wang <18199796+averyniceday@users.noreply.github.com> Co-authored-by: Manda Wilson <1458628+mandawilson@users.noreply.github.com> Co-authored-by: Robert Sheridan <7747489+sheridancbio@users.noreply.github.com> Co-authored-by: Karthik Kalletla --- .../org/mskcc/cbio/maf/FusionFileUtil.java | 119 ----------- .../java/org/mskcc/cbio/maf/FusionRecord.java | 152 -------------- .../mskcc/cbio/portal/dao/DaoMutation.java | 4 +- .../mskcc/cbio/portal/model/CancerStudy.java | 19 +- .../portal/model/GeneticAlterationType.java | 3 +- .../cbio/portal/model/SampleListCategory.java | 3 +- .../DiscreteDataTypeSetSpec.java | 4 - .../scripts/ImportExtendedMutationData.java | 2 +- .../cbio/portal/scripts/ImportFusionData.java | 181 ----------------- .../portal/scripts/ImportProfileData.java | 3 - .../portal/util/GeneticProfileReader.java | 84 +++----- .../portal/util/MutationKeywordUtils.java | 3 +- .../portal/dao/TestDaoGeneticProfile.java | 6 +- .../portal/scripts/TestImportFusionData.java | 144 ------------- .../portal/scripts/TestImportProfileData.java | 35 ---- .../portal/scripts/TestIntegrationTest.java | 22 +- .../portal/util/TestMutationKeywordUtils.java | 1 - core/src/test/resources/data_fusions.txt | 4 - .../test/resources/integrationTestScript.xml | 14 +- .../splitFusionsData/data_fusions.txt | 3 - .../splitFusionsData/data_fusions_gml.txt | 3 - .../splitFusionsData/meta_fusions.txt | 7 - .../splitFusionsData/meta_fusions_gml.txt | 8 - .../data_fusions_duplicate_entry.txt | 5 - .../test_data/study_es_0/data_fusions.txt | 6 - .../test_data/study_es_0/meta_fusions.txt | 8 - .../cbioportal/model/AlterationFilter.java | 15 +- .../org/cbioportal/model/AlterationType.java | 1 - .../cbioportal/model/MolecularProfile.java | 18 +- .../cbioportal/model/MutationEventType.java | 1 - .../java/org/cbioportal/model/Sample.java | 5 - .../persistence/AlterationRepository.java | 2 - .../persistence/MutationRepository.java | 20 +- .../mybatis/AlterationCountsMapper.java | 4 - .../mybatis/AlterationMyBatisRepository.java | 25 --- .../persistence/mybatis/MutationMapper.java | 5 +- .../mybatis/MutationMyBatisRepository.java | 64 ------ .../mybatis/AlterationCountsMapper.xml | 20 -- .../persistence/mybatis/MutationMapper.xml | 39 +--- .../AlterationMyBatisRepositoryTest.java | 124 +----------- ...screteCopyNumberMyBatisRepositoryTest.java | 2 - .../MutationMyBatisRepositoryTest.java | 24 --- .../src/test/resources/testSql.sql | 2 - .../service/AlterationCountService.java | 2 - .../cbioportal/service/MutationService.java | 12 -- .../impl/AlterationCountServiceImpl.java | 19 +- .../impl/AlterationEnrichmentServiceImpl.java | 2 - .../service/impl/GenePanelServiceImpl.java | 84 +------- .../service/impl/MutationServiceImpl.java | 25 --- .../service/impl/SampleServiceImpl.java | 15 -- .../impl/StructuralVariantServiceImpl.java | 145 +------------ .../service/util/MolecularProfileUtil.java | 46 +---- .../service/util/MutationMapperUtils.java | 191 ------------------ .../cbioportal/service/util/VariantType.java | 25 --- .../impl/AlterationCountServiceImplTest.java | 51 ----- .../AlterationEnrichmentServiceImplTest.java | 2 +- .../StructuralVariantServiceImplTest.java | 3 - .../util/MolecularProfileUtilTest.java | 12 +- .../service/util/MutationMapperUtilsTest.java | 50 ----- .../web/util/StudyViewFilterApplier.java | 15 +- .../web/StudyViewControllerTest.java | 30 +-- 61 files changed, 104 insertions(+), 1839 deletions(-) delete mode 100644 core/src/main/java/org/mskcc/cbio/maf/FusionFileUtil.java delete mode 100644 core/src/main/java/org/mskcc/cbio/maf/FusionRecord.java delete mode 100644 core/src/main/java/org/mskcc/cbio/portal/scripts/ImportFusionData.java delete mode 100644 core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportFusionData.java delete mode 100644 core/src/test/resources/data_fusions.txt delete mode 100644 core/src/test/resources/splitFusionsData/data_fusions.txt delete mode 100644 core/src/test/resources/splitFusionsData/data_fusions_gml.txt delete mode 100644 core/src/test/resources/splitFusionsData/meta_fusions.txt delete mode 100644 core/src/test/resources/splitFusionsData/meta_fusions_gml.txt delete mode 100644 core/src/test/scripts/test_data/data_fusions_duplicate_entry.txt delete mode 100644 core/src/test/scripts/test_data/study_es_0/data_fusions.txt delete mode 100644 core/src/test/scripts/test_data/study_es_0/meta_fusions.txt delete mode 100644 service/src/main/java/org/cbioportal/service/util/MutationMapperUtils.java delete mode 100644 service/src/main/java/org/cbioportal/service/util/VariantType.java delete mode 100644 service/src/test/java/org/cbioportal/service/util/MutationMapperUtilsTest.java diff --git a/core/src/main/java/org/mskcc/cbio/maf/FusionFileUtil.java b/core/src/main/java/org/mskcc/cbio/maf/FusionFileUtil.java deleted file mode 100644 index a324c155497..00000000000 --- a/core/src/main/java/org/mskcc/cbio/maf/FusionFileUtil.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2015 Memorial Sloan-Kettering Cancer Center. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS - * FOR A PARTICULAR PURPOSE. The software and documentation provided hereunder - * is on an "as is" basis, and Memorial Sloan-Kettering Cancer Center has no - * obligations to provide maintenance, support, updates, enhancements or - * modifications. In no event shall Memorial Sloan-Kettering Cancer Center be - * liable to any party for direct, indirect, special, incidental or - * consequential damages, including lost profits, arising out of the use of this - * software and its documentation, even if Memorial Sloan-Kettering Cancer - * Center has been advised of the possibility of such damage. - */ - -/* - * This file is part of cBioPortal. - * - * cBioPortal is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -*/ - -package org.mskcc.cbio.maf; - -import java.util.HashMap; - -/** - * Utility Class for Parsing Fusion Files. - * - * This utility class handles variable columns and column orderings - * within Fusion files. - * - * @author Selcuk Onur Sumer - */ -public class FusionFileUtil -{ - public static final String FUSION = "Fusion"; - public static final String DNA_SUPPORT = "DNA_support"; - public static final String RNA_SUPPORT = "RNA_support"; - public static final String METHOD = "Method"; - public static final String FRAME = "Frame"; - public static final String FUSION_STATUS = "Fusion_Status"; - - // number of headers in the header line - private int headerCount; - - // mapping for all column names (both standard and custom columns) - private HashMap columnIndexMap; - - /** - * Constructor. - * - * @param headerLine Header Line. - */ - public FusionFileUtil(String headerLine) - { - // init column index map - this.columnIndexMap = new HashMap(); - - // split header names - String parts[] = headerLine.split("\t"); - - // update header count - this.headerCount = parts.length; - - // find required header indices - for (int i=0; i. -*/ - -package org.mskcc.cbio.maf; - -/** - * Encapsulates details regarding a single row in a Fusion file. - * - * @author Selcuk Onur Sumer - */ -public class FusionRecord -{ - private String hugoGeneSymbol; - private long entrezGeneId; - private String center; // sequencing center - private String tumorSampleID; - private String fusion; - private String dnaSupport; - private String rnaSupport; - private String method; - private String frame; - private String fusionStatus; - - public String getHugoGeneSymbol() - { - return hugoGeneSymbol; - } - - public void setHugoGeneSymbol(String hugoGeneSymbol) - { - this.hugoGeneSymbol = hugoGeneSymbol; - } - - public long getEntrezGeneId() - { - return entrezGeneId; - } - - public void setEntrezGeneId(long entrezGeneId) - { - this.entrezGeneId = entrezGeneId; - } - - public String getCenter() - { - return center; - } - - public void setCenter(String center) - { - this.center = center; - } - - public String getTumorSampleID() - { - return tumorSampleID; - } - - public void setTumorSampleID(String tumorSampleID) - { - this.tumorSampleID = tumorSampleID; - } - - public String getFusion() - { - return fusion; - } - - public void setFusion(String fusion) - { - this.fusion = fusion; - } - - public String getDnaSupport() - { - return dnaSupport; - } - - public void setDnaSupport(String dnaSupport) - { - this.dnaSupport = dnaSupport; - } - - public String getRnaSupport() - { - return rnaSupport; - } - - public void setRnaSupport(String rnaSupport) - { - this.rnaSupport = rnaSupport; - } - - public String getMethod() - { - return method; - } - - public void setMethod(String method) - { - this.method = method; - } - - public String getFrame() - { - return frame; - } - - public void setFrame(String frame) - { - this.frame = frame; - } - - public String getFusionStatus() - { - return fusionStatus; - } - - public void setFusionStatus(String fusionStatus) - { - this.fusionStatus = fusionStatus; - } -} diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java index a8a85d110ee..84b5c8cdf7c 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java @@ -188,8 +188,7 @@ public static void createMutationCountClinicalData(GeneticProfile geneticProfile * We do not add the MUTATION_COUNT clinical data for the sample if * it's not profiled. If it *is* profiled but there are 0 * mutations, add a MUTATION_COUNT with 0 value record. Do not - * include germline and fusions (msk internal) when counting - * mutations. + * include germline when counting mutations. * * Use REPLACE (conditional INSERT/UPDATE) which inserts * new counts if they don't exist and overwrites them if they do. @@ -207,7 +206,6 @@ public static void createMutationCountClinicalData(GeneticProfile geneticProfile "LEFT JOIN mutation ON mutation.`SAMPLE_ID` = sample_profile.`SAMPLE_ID` " + "AND ( mutation.`MUTATION_STATUS` <> 'GERMLINE' OR mutation.`MUTATION_STATUS` IS NULL ) " + "LEFT JOIN mutation_event ON mutation.`MUTATION_EVENT_ID` = mutation_event.`MUTATION_EVENT_ID` " + - "AND ( mutation_event.`MUTATION_TYPE` <> 'Fusion' OR mutation_event.`MUTATION_TYPE` IS NULL ) " + "INNER JOIN genetic_profile ON genetic_profile.`GENETIC_PROFILE_ID` = sample_profile.`GENETIC_PROFILE_ID` " + "WHERE genetic_profile.`GENETIC_ALTERATION_TYPE` = 'MUTATION_EXTENDED' " + "AND genetic_profile.`GENETIC_PROFILE_ID`=? " + diff --git a/core/src/main/java/org/mskcc/cbio/portal/model/CancerStudy.java b/core/src/main/java/org/mskcc/cbio/portal/model/CancerStudy.java index 1cbc58fcd70..09522a9e52c 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/model/CancerStudy.java +++ b/core/src/main/java/org/mskcc/cbio/portal/model/CancerStudy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2016 Memorial Sloan-Kettering Cancer Center. + * Copyright (c) 2015 - 2022 Memorial Sloan-Kettering Cancer Center. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS @@ -445,23 +445,6 @@ public boolean hasSurvivalData() throws DaoException { attrs.contains(ClinicalAttribute.DFS_STATUS); } - /** - * Check if study has fusion data - * @return true if has fusion data, false when it's not - */ - public boolean hasFusionData() { - ArrayList geneticProfiles = DaoGeneticProfile.getAllGeneticProfiles(studyID); - boolean hasFusionData = false; - for (GeneticProfile geneticProfile : geneticProfiles) { - if (geneticProfile.getDatatype().equals("SV")) { // check if genetic profiles contains Structural Variant - // data type - hasFusionData = true; - break; - } - } - return hasFusionData; - } - public String getTypeOfCancer() throws DaoException { return DaoTypeOfCancer.getTypeOfCancerById(this.typeOfCancerId).getName(); } diff --git a/core/src/main/java/org/mskcc/cbio/portal/model/GeneticAlterationType.java b/core/src/main/java/org/mskcc/cbio/portal/model/GeneticAlterationType.java index bf260ea06f6..929a5f50c8c 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/model/GeneticAlterationType.java +++ b/core/src/main/java/org/mskcc/cbio/portal/model/GeneticAlterationType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2016 Memorial Sloan-Kettering Cancer Center. + * Copyright (c) 2015 - 2022 Memorial Sloan-Kettering Cancer Center. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS @@ -39,7 +39,6 @@ public enum GeneticAlterationType { // uncalled mutations (mskcc internal) for showing read counts even if // mutation wasn't called MUTATION_UNCALLED, - FUSION, STRUCTURAL_VARIANT, COPY_NUMBER_ALTERATION, MICRO_RNA_EXPRESSION, diff --git a/core/src/main/java/org/mskcc/cbio/portal/model/SampleListCategory.java b/core/src/main/java/org/mskcc/cbio/portal/model/SampleListCategory.java index 1a09888b87f..5454d2e4de4 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/model/SampleListCategory.java +++ b/core/src/main/java/org/mskcc/cbio/portal/model/SampleListCategory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Memorial Sloan-Kettering Cancer Center. + * Copyright (c) 2015 - 2022 Memorial Sloan-Kettering Cancer Center. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS @@ -42,7 +42,6 @@ public enum SampleListCategory { ALL_CASES_IN_STUDY("all_cases_in_study"), ALL_CASES_WITH_MUTATION_DATA("all_cases_with_mutation_data"), - ALL_CASES_WITH_FUSION_DATA("all_cases_with_fusion_data"), ALL_CASES_WITH_CNA_DATA("all_cases_with_cna_data"), ALL_CASES_WITH_LOG2_CNA_DNA("all_cases_with_log2_cna_data"), ALL_CASES_WITH_METHYLATION_DATA("all_cases_with_methylation_data"), diff --git a/core/src/main/java/org/mskcc/cbio/portal/oncoPrintSpecLanguage/DiscreteDataTypeSetSpec.java b/core/src/main/java/org/mskcc/cbio/portal/oncoPrintSpecLanguage/DiscreteDataTypeSetSpec.java index 19c04f29207..075476bbfbe 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/oncoPrintSpecLanguage/DiscreteDataTypeSetSpec.java +++ b/core/src/main/java/org/mskcc/cbio/portal/oncoPrintSpecLanguage/DiscreteDataTypeSetSpec.java @@ -304,10 +304,6 @@ else if (mutationPattern.equals("MS") || mutationPattern.equals("MISSENSE")) { specificMutationUpper.matches("E[0-9]+[\\+\\-][0-9]+")) { return true; } - } else if (mutationPattern.equals("FUSION")) { - if (specificMutationUpper.endsWith("FUSION")) { - return true; - } } } } diff --git a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java index 21612e80cac..a5d022ae865 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java +++ b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java @@ -504,7 +504,7 @@ public void importData() throws IOException, DaoException { } /* - * At MSKCC there are some MUTATION_UNCALLED and FUSION + * At MSKCC there are some MUTATION_UNCALLED * profiles that shouldn't be included when determining the number of * mutations for a sample */ diff --git a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportFusionData.java b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportFusionData.java deleted file mode 100644 index d54c48a79c1..00000000000 --- a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportFusionData.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2015 Memorial Sloan-Kettering Cancer Center. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS - * FOR A PARTICULAR PURPOSE. The software and documentation provided hereunder - * is on an "as is" basis, and Memorial Sloan-Kettering Cancer Center has no - * obligations to provide maintenance, support, updates, enhancements or - * modifications. In no event shall Memorial Sloan-Kettering Cancer Center be - * liable to any party for direct, indirect, special, incidental or - * consequential damages, including lost profits, arising out of the use of this - * software and its documentation, even if Memorial Sloan-Kettering Cancer - * Center has been advised of the possibility of such damage. - */ - -/* - * This file is part of cBioPortal. - * - * cBioPortal is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -*/ - -package org.mskcc.cbio.portal.scripts; - -import java.io.*; -import java.util.*; -import org.mskcc.cbio.maf.*; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.model.ExtendedMutation.MutationEvent; -import org.mskcc.cbio.portal.util.*; - -/** - * Imports a fusion file. - * Columns may be in any order. - * Creates an ExtendedMutation instances for each row. - * - * @author Selcuk Onur Sumer - */ -public class ImportFusionData { - public static final String FUSION = "Fusion"; - private File fusionFile; - private int geneticProfileId; - private String genePanelID; - private Set sampleSet = new HashSet<>(); - - public ImportFusionData(File fusionFile, int geneticProfileId, String genePanelID) { - this.fusionFile = fusionFile; - this.geneticProfileId = geneticProfileId; - this.genePanelID = genePanelID; - } - - public void importData() throws IOException, DaoException { - Map existingEvents = - new HashMap(); - Map mutations = new HashMap(); - long mutationEventId = DaoMutation.getLargestMutationEventId(); - GenePanel genePanel = null; - if (genePanelID != null) { - genePanel = DaoGenePanel.getGenePanelByStableId(genePanelID); - } - - // Initialize, this makes sure that mutation_events are always loaded before mutations: - MySQLbulkLoader.getMySQLbulkLoader("mutation_event"); - MySQLbulkLoader.getMySQLbulkLoader("mutation"); - - FileReader reader = new FileReader(this.fusionFile); - BufferedReader buf = new BufferedReader(reader); - DaoGeneOptimized daoGene = DaoGeneOptimized.getInstance(); - // The MAF File Changes fairly frequently, and we cannot use column index constants. - String line = buf.readLine(); - line = line.trim(); - FusionFileUtil fusionUtil = new FusionFileUtil(line); - boolean addEvent; - GeneticProfile geneticProfile = DaoGeneticProfile.getGeneticProfileById(geneticProfileId); - while ((line = buf.readLine()) != null) { - ProgressMonitor.incrementCurValue(); - ConsoleUtil.showProgress(); - if( !line.startsWith("#") && line.trim().length() > 0) { - FusionRecord record = fusionUtil.parseRecord(line); - // process case id - String barCode = record.getTumorSampleID(); - // backwards compatible part (i.e. in the new process, the sample should already be there. - //TODO - replace this workaround later with an exception: - Sample sample = DaoSample.getSampleByCancerStudyAndSampleId( - geneticProfile.getCancerStudyId(), - StableIdUtil.getSampleId(barCode)); - // can be null in case of 'normal' sample: - if (sample == null) { - if (StableIdUtil.isNormal(barCode)) { - line = buf.readLine(); - continue; - } - else { - throw new RuntimeException("Unknown sample id '" + barCode + "' found in tab-delimited file: " + this.fusionFile.getCanonicalPath()); - } - } - // Assume we are dealing with Entrez Gene Ids (this is the best / most stable option) - String geneSymbol = record.getHugoGeneSymbol(); - long entrezGeneId = record.getEntrezGeneId(); - CanonicalGene gene = null; - if (entrezGeneId != TabDelimitedFileUtil.NA_LONG) { - gene = daoGene.getGene(entrezGeneId); - } - if (gene == null) { - // If Entrez Gene ID Fails, try Symbol. - gene = daoGene.getNonAmbiguousGene(geneSymbol, true); - } - if(gene == null) { - ProgressMonitor.logWarning("Gene not found: " + geneSymbol + " [" - + entrezGeneId + "]. Ignoring it " - + "and all fusion data associated with it!"); - continue; - } - if (genePanel != null && !GeneticProfileUtil.geneInPanel(gene, genePanel)) { - ProgressMonitor.logWarning("Gene is not profiled in gene panel: " + geneSymbol + " [" - + entrezGeneId + "] " + genePanel.getStableId() + ". Ignoring it " - + "and all fusion data associated with it!"); - } else { - // create a mutation instance with default values - ExtendedMutation mutation = ExtendedMutationUtil.newMutation(); - mutation.setGeneticProfileId(geneticProfileId); - mutation.setSampleId(sample.getInternalId()); - mutation.setGene(gene); - mutation.setSequencingCenter(record.getCenter()); - mutation.setProteinChange(record.getFusion()); - // TODO we may need get mutation type from the file - // instead of defining a constant - mutation.setMutationType(FUSION); - mutation.setMutationStatus(record.getFusionStatus().toUpperCase()); - MutationEvent event = - existingEvents.containsKey(mutation.getEvent()) ? - existingEvents.get(mutation.getEvent()) : - DaoMutation.getMutationEvent(mutation.getEvent()); - if (event != null) { - mutation.setEvent(event); - addEvent = false; - } else { - mutation.setMutationEventId(++mutationEventId); - existingEvents.put(mutation.getEvent(), mutation.getEvent()); - addEvent = true; - } - // add fusion (as a mutation) - ExtendedMutation existingMutation = mutations.get(mutation); - if (existingMutation != null) { - ProgressMonitor.logWarning("Duplicate fusion entry found: " + mutation.getGeneSymbol() + " for " + mutation.getProteinChange() + ". Skipping."); - continue; - } else { - // add fusion (as a mutation) - DaoMutation.addMutation(mutation, addEvent); - mutations.put(mutation, mutation); - } - if (!sampleSet.contains(sample.getStableId()) && !DaoSampleProfile.sampleExistsInGeneticProfile(sample.getInternalId(), geneticProfileId)) { - Integer panelId = (genePanel == null) ? null : genePanel.getInternalId(); - DaoSampleProfile.addSampleProfile(sample.getInternalId(), geneticProfileId, panelId); - } - sampleSet.add(sample.getStableId()); - } - } - } - // run sanity check on `mutation_event` to determine whether duplicate - // events were introduced during current import - if (DaoMutation.hasDuplicateMutationEvents()) { - throw new DaoException("Duplicate mutation events were detected during the FUSIONS import. Aborting..."); - } - buf.close(); - if( MySQLbulkLoader.isBulkLoad()) { - MySQLbulkLoader.flushAll(); - } - } -} diff --git a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java index f8aed67b7cb..f3563242512 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java +++ b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java @@ -97,9 +97,6 @@ public void run() { throw new RuntimeException( "Unrecognized swissprot_identifier specification, must be 'name' or 'accession'."); } importer.importData(); - } else if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.FUSION) { - ImportFusionData importer = new ImportFusionData(dataFile, geneticProfile.getGeneticProfileId(), genePanel); - importer.importData(); } else if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.STRUCTURAL_VARIANT) { ImportStructuralVariantData importer = new ImportStructuralVariantData(dataFile, geneticProfile.getGeneticProfileId(), genePanel); importer.importData(); diff --git a/core/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileReader.java b/core/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileReader.java index 102c167e258..d076e269716 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileReader.java +++ b/core/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2016 Memorial Sloan-Kettering Cancer Center. + * Copyright (c) 2015 - 2022 Memorial Sloan-Kettering Cancer Center. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS @@ -81,22 +81,6 @@ public static GeneticProfile loadGeneticProfile(File file) throws IOException, D // anymore, so throw error telling user to remove existing profile first: throw new RuntimeException("Error: genetic_profile record found with same Stable ID as the one used in your data: " + existingGeneticProfile.getStableId() + ". Remove the existing genetic_profile record first."); - } else if (geneticProfile.getDatatype().equals("FUSION")) { - String svStableId = existingGeneticProfile.getStableId().replace("mutations", "fusion"); - // check if structural variant genetic profile already exists for fusions - // if an auto-generated _fusion genetic profile exists, do not attempt to add it again - // otherwise, exception is thrown causing import to exit - // populate the structural variant genetic profile for fusions - GeneticProfile existingSVGeneticProfile = DaoGeneticProfile.getGeneticProfileByStableId(svStableId); - if (existingSVGeneticProfile == null ) { - GeneticProfile gp = new GeneticProfile(geneticProfile); - gp.setGeneticAlterationType(GeneticAlterationType.STRUCTURAL_VARIANT); - gp.setStableId(svStableId); - DaoGeneticProfile.addGeneticProfile(gp); - } - // return existing mutation genetic profile for fusions that are currently stored in the mutation_event table - geneticProfile.setGeneticProfileId(existingGeneticProfile.getGeneticProfileId()); - return geneticProfile; } else { // For mutation data only we can have multiple files with the same genetic_profile. // There is a constraint in the mutation database table to prevent duplicated data @@ -118,16 +102,16 @@ public static GeneticProfile loadGeneticProfile(File file) throws IOException, D // This geneticProfileLink is required for the oncoprint in a GSVA study. In the future it might // be useful to make this a requirement for every expression zscore file. GeneticProfileLink geneticProfileLink = null; - if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.GENESET_SCORE || - (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.MRNA_EXPRESSION && - geneticProfile.getDatatype().equals("Z-SCORE") && - geneticProfile.getAllOtherMetadataFields().getProperty("source_stable_id") != null)) { + if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.GENESET_SCORE || + (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.MRNA_EXPRESSION && + geneticProfile.getDatatype().equals("Z-SCORE") && + geneticProfile.getAllOtherMetadataFields().getProperty("source_stable_id") != null)) { geneticProfileLink = createGeneticProfileLink(geneticProfile); - } + } - // For GSVA profiles, we want to check that the version in the meta file is + // For GSVA profiles, we want to check that the version in the meta file is // the same as the version of the gene sets in the database (genesets_info table). - if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.GENESET_SCORE) { + if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.GENESET_SCORE) { validateGenesetProfile(geneticProfile, file); } @@ -153,7 +137,7 @@ public static GeneticProfile loadGeneticProfile(File file) throws IOException, D // add genetic profile link if set if (geneticProfileLink != null) { // Set `REFERRING_GENETIC_PROFILE_ID` - int geneticProfileId = DaoGeneticProfile.getGeneticProfileByStableId(geneticProfile.getStableId()).getGeneticProfileId(); + int geneticProfileId = DaoGeneticProfile.getGeneticProfileByStableId(geneticProfile.getStableId()).getGeneticProfileId(); geneticProfileLink.setReferringGeneticProfileId(geneticProfileId); DaoGeneticProfileLink.addGeneticProfileLink(geneticProfileLink); } @@ -170,7 +154,7 @@ private static GeneticProfileLink createGeneticProfileLink(GeneticProfile geneti // Set `REFERRED_GENETIC_PROFILE_ID` String referredGeneticProfileStableId = parseStableId(geneticProfile.getAllOtherMetadataFields(), "source_stable_id"); if (referredGeneticProfileStableId == null) { - throw new RuntimeException("'source_stable_id' is required in meta file for " + geneticProfile.getStableId()); + throw new RuntimeException("'source_stable_id' is required in meta file for " + geneticProfile.getStableId()); } GeneticProfile referredGeneticProfile = DaoGeneticProfile.getGeneticProfileByStableId(referredGeneticProfileStableId); geneticProfileLink.setReferredGeneticProfileId(referredGeneticProfile.getGeneticProfileId()); @@ -179,45 +163,45 @@ private static GeneticProfileLink createGeneticProfileLink(GeneticProfile geneti // In the future with other types of genetic profile links, this should be configurable in the meta file. String referenceType; if (Arrays.asList("P-VALUE", "Z-SCORE").contains(geneticProfile.getDatatype())) { - referenceType = "STATISTIC"; + referenceType = "STATISTIC"; } else if (geneticProfile.getDatatype().equals("GSVA-SCORE")) { referenceType = "AGGREGATION"; } else { // not expected but might be useful for future genetic profile links - throw new RuntimeException("Unknown datatype '" + geneticProfile.getDatatype() + "' in meta file for " + geneticProfile.getStableId()); + throw new RuntimeException("Unknown datatype '" + geneticProfile.getDatatype() + "' in meta file for " + geneticProfile.getStableId()); } // Set `REFERENCE_TYPE` geneticProfileLink.setReferenceType(referenceType); return geneticProfileLink; - } + } - private static void validateGenesetProfile(GeneticProfile geneticProfile, File file) throws DaoException { + private static void validateGenesetProfile(GeneticProfile geneticProfile, File file) throws DaoException { String genesetVersion = DaoInfo.getGenesetVersion(); - // TODO Auto-generated method stub + // TODO Auto-generated method stub - // Check if version is present in database + // Check if version is present in database if (genesetVersion == null) { throw new RuntimeException("Attempted to import GENESET_SCORE data, but all gene set tables are empty.\n" + "Please load gene sets with ImportGenesetData.pl first. See:\n" + "https://github.com/cBioPortal/cbioportal/blob/master/docs/Import-Gene-Sets.md\n"); - // Check if version is present in meta file - } else if (geneticProfile.getOtherMetaDataField("geneset_def_version") == null) { + // Check if version is present in meta file + } else if (geneticProfile.getOtherMetaDataField("geneset_def_version") == null) { throw new RuntimeException("Missing geneset_def_version property in '" + file.getPath() + "'. This version must be " + "the same as the gene set version loaded with ImportGenesetData.pl ."); - // Check if version is same as database version - } else if (!geneticProfile.getOtherMetaDataField("geneset_def_version").equals(genesetVersion)) { + // Check if version is same as database version + } else if (!geneticProfile.getOtherMetaDataField("geneset_def_version").equals(genesetVersion)) { throw new RuntimeException("'geneset_def_version' property (" + geneticProfile.getOtherMetaDataField("geneset_def_version") + ") in '" + file.getPath() + "' differs from database version (" + genesetVersion + ")."); - } + } - // Prevent p-value profile to show up as selectable genomic profile - if (geneticProfile.getDatatype().equals("P-VALUE")) { - geneticProfile.setShowProfileInAnalysisTab(false); - } + // Prevent p-value profile to show up as selectable genomic profile + if (geneticProfile.getDatatype().equals("P-VALUE")) { + geneticProfile.setShowProfileInAnalysisTab(false); + } } /** @@ -239,7 +223,7 @@ private static void validateGenericAssay(GeneticProfile geneticProfile, File fil throw new RuntimeException("Missing `generic_assay_type` property in '" + file.getPath() + "' meta data file."); } - /** + /** * Load a GeneticProfile from a description file. * * @author Ethan Cerami @@ -321,22 +305,10 @@ private static String parseStableId(Properties properties, String stableIdPropNa if (!stableId.startsWith(cancerStudyIdentifier + "_")) { stableId = cancerStudyIdentifier + "_" + stableId; } - // Workaround to import fusion data as mutation genetic profile. This way fusion meta file can contain 'stable_id: fusion'. - // The validator will check for 'stable_id: fusion', and this section in the importer - // will convert it to 'stable_id: mutations'. See https://github.com/cBioPortal/cbioportal/pull/2506 - // TODO: This should be removed when other parts of cBioPortal have implemented support for a separate fusion profile". - if (stableId.equals(cancerStudyIdentifier + "_fusion")) { - String newStableId = cancerStudyIdentifier + "_mutations"; - GeneticProfile existingGeneticProfile = DaoGeneticProfile.getGeneticProfileByStableId(newStableId); - if (existingGeneticProfile == null) { - throw new IllegalArgumentException("Wrong order: FUSION data should be loaded after MUTATION data"); - } - stableId = newStableId; - } return stableId; - } + } - public static String loadGenePanelInformation(File file) throws Exception { + public static String loadGenePanelInformation(File file) throws Exception { Properties properties = new TrimmedProperties(); properties.load(new FileInputStream(file)); return properties.getProperty("gene_panel"); diff --git a/core/src/main/java/org/mskcc/cbio/portal/util/MutationKeywordUtils.java b/core/src/main/java/org/mskcc/cbio/portal/util/MutationKeywordUtils.java index 1853432c7b6..a6ed5666427 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/util/MutationKeywordUtils.java +++ b/core/src/main/java/org/mskcc/cbio/portal/util/MutationKeywordUtils.java @@ -128,8 +128,7 @@ public static String guessOncotatorMutationKeyword(String aminoAcidChange, Strin } } - if (mutationType.equals("Fusion") - || mutationType.equals("Exon skipping") + if (mutationType.equals("Exon skipping") || mutationType.equals("vIII deletion")) { return aminoAcidChange; } diff --git a/core/src/test/java/org/mskcc/cbio/portal/dao/TestDaoGeneticProfile.java b/core/src/test/java/org/mskcc/cbio/portal/dao/TestDaoGeneticProfile.java index bf51b5f7d74..6bfaee25782 100644 --- a/core/src/test/java/org/mskcc/cbio/portal/dao/TestDaoGeneticProfile.java +++ b/core/src/test/java/org/mskcc/cbio/portal/dao/TestDaoGeneticProfile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 - 2016 Memorial Sloan-Kettering Cancer Center. + * Copyright (c) 2015 - 2022 Memorial Sloan-Kettering Cancer Center. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS @@ -93,7 +93,7 @@ public void testDaoCreateGeneticProfile() throws DaoException { geneticProfile.setCancerStudyId(studyId); geneticProfile.setProfileName("test profile"); geneticProfile.setStableId("test"); - geneticProfile.setGeneticAlterationType(GeneticAlterationType.FUSION); + geneticProfile.setGeneticAlterationType(GeneticAlterationType.STRUCTURAL_VARIANT); geneticProfile.setDatatype("test"); DaoGeneticProfile.addGeneticProfile(geneticProfile); @@ -101,7 +101,7 @@ public void testDaoCreateGeneticProfile() throws DaoException { assertEquals(studyId, readGeneticProfile.getCancerStudyId()); assertEquals("test", readGeneticProfile.getStableId()); assertEquals("test profile", readGeneticProfile.getProfileName()); - assertEquals(GeneticAlterationType.FUSION, readGeneticProfile.getGeneticAlterationType()); + assertEquals(GeneticAlterationType.STRUCTURAL_VARIANT, readGeneticProfile.getGeneticAlterationType()); } @Test diff --git a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportFusionData.java b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportFusionData.java deleted file mode 100644 index 4a7a6a0feb8..00000000000 --- a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportFusionData.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2015 Memorial Sloan-Kettering Cancer Center. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS - * FOR A PARTICULAR PURPOSE. The software and documentation provided hereunder - * is on an "as is" basis, and Memorial Sloan-Kettering Cancer Center has no - * obligations to provide maintenance, support, updates, enhancements or - * modifications. In no event shall Memorial Sloan-Kettering Cancer Center be - * liable to any party for direct, indirect, special, incidental or - * consequential damages, including lost profits, arising out of the use of this - * software and its documentation, even if Memorial Sloan-Kettering Cancer - * Center has been advised of the possibility of such damage. - */ - -/* - * This file is part of cBioPortal. - * - * cBioPortal is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -*/ - -package org.mskcc.cbio.portal.scripts; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; -import org.springframework.test.annotation.Rollback; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.transaction.annotation.Transactional; - -import static org.junit.Assert.*; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; - -/** - * Test class to test functionality of ImportFusionData - * - * @author Selcuk Onur Sumer - */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath:/applicationContext-dao.xml" }) -@Rollback -@Transactional -public class TestImportFusionData -{ - - int studyId; - int geneticProfileId; - - @Before - public void setUp() throws DaoException - { - studyId = DaoCancerStudy.getCancerStudyByStableId("study_tcga_pub").getInternalId(); - geneticProfileId = DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_mutations").getGeneticProfileId(); - - } - - @Test - public void testImportFusionData() - { - try { - - MySQLbulkLoader.bulkLoadOn(); - - ProgressMonitor.setConsoleMode(false); - - // TODO change this to use getResourceAsStream() - File file = new File("target/test-classes/data_fusions.txt"); - ImportFusionData parser = new ImportFusionData(file, geneticProfileId, null); - - loadGenes(); - parser.importData(); - MySQLbulkLoader.flushAll(); - - checkImportedData(); - } - catch (IOException e) - { - e.printStackTrace(); - } - catch (DaoException e) - { - e.printStackTrace(); - } - } - - private void checkImportedData() throws DaoException - { - ArrayList list = DaoMutation.getAllMutations(); - - ArrayList fusions = new ArrayList(); - for(ExtendedMutation mut : list) { - if (mut.getEvent().getMutationType().equals("Fusion")) { - fusions.add(mut); - } - } - - assertEquals(2, fusions.size()); // all except "FAKE" - - list = DaoMutation.getMutations(geneticProfileId, DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SB-01").getInternalId()); - - assertEquals(1, list.size()); - assertEquals("saturn", list.get(0).getSequencingCenter()); - assertEquals("FGFR3", list.get(0).getGeneSymbol()); - assertEquals("Fusion", list.get(0).getMutationType()); - assertEquals("Fusion1", list.get(0).getProteinChange()); - - list = DaoMutation.getMutations(geneticProfileId, DaoSample.getSampleByCancerStudyAndSampleId(studyId, "TCGA-A1-A0SD-01").getInternalId()); - - assertEquals(1, list.size()); - assertEquals("jupiter", list.get(0).getSequencingCenter()); - assertEquals("ERBB2", list.get(0).getGeneSymbol()); - assertEquals("Fusion", list.get(0).getMutationType()); - assertEquals("Fusion2", list.get(0).getProteinChange()); - } - - private void loadGenes() throws DaoException - { - DaoGeneOptimized daoGene = DaoGeneOptimized.getInstance(); - - // genes for "data_fusions.txt" - daoGene.addGene(new CanonicalGene(2261L, "FGFR3")); - daoGene.addGene(new CanonicalGene(2064L, "ERBB2")); - - MySQLbulkLoader.flushAll(); - } -} diff --git a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java index 51987760b75..442f4be2687 100644 --- a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java +++ b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java @@ -219,41 +219,6 @@ public void testImportSplitMutationsFile() throws Exception { assertEquals("1", clinicalData.get(1).getAttrVal()); } - @Test - public void testImportSplitFusionsFile() throws Exception { - /* - * Check case where study has multiple fusions file. - * i.e somatic and germline fusions are in seperate files - * Check that an SV genetic profile is created. - * Check that the second fusion file does not insert duplicate genetic profile. - */ - String svStudyStableId = "study_tcga_pub_fusion"; - GeneticProfile svGeneticProfile = DaoGeneticProfile.getGeneticProfileByStableId(svStudyStableId); - assertNull(svGeneticProfile); - - String[] args = { - "--data","src/test/resources/splitFusionsData/data_fusions.txt", - "--meta","src/test/resources/splitFusionsData/meta_fusions.txt", - "--loadMode", "bulkLoad" - }; - ImportProfileData runner = new ImportProfileData(args); - runner.run(); - svGeneticProfile = DaoGeneticProfile.getGeneticProfileByStableId(svStudyStableId); - assertNotNull(svGeneticProfile); - - // load a second fusions file - new genetic profile not created - String[] secondArgs = { - "--data","src/test/resources/splitFusionsData/data_fusions_gml.txt", - "--meta","src/test/resources/splitFusionsData/meta_fusions_gml.txt", - "--loadMode", "bulkLoad" - }; - ImportProfileData secondRunner = new ImportProfileData(secondArgs); - secondRunner.run(); - svGeneticProfile = DaoGeneticProfile.getGeneticProfileByStableId(svStudyStableId); - assertNotNull(svGeneticProfile); - assertEquals(GeneticAlterationType.STRUCTURAL_VARIANT, svGeneticProfile.getGeneticAlterationType()); - } - @Test public void testImportGermlineOnlyFile() throws Exception { /* Mutations file split over two files with same stable id */ diff --git a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestIntegrationTest.java b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestIntegrationTest.java index 1f3d3a4e888..c0c4c6fd6e5 100644 --- a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestIntegrationTest.java +++ b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestIntegrationTest.java @@ -165,23 +165,9 @@ public void testLoadStudyEs0() throws Throwable { // ===== Check MUTATION data ======== List mutations = DaoMutation.getAllMutations(); // check number of mutation records in the database - // 3 in seed_mini.sql + 33 study_es_0/data_mutations_extended.maf (2 silent ignored) + 5 study_es_0/data_fusions.txt) - // so we expect 39 records in DB: - assertEquals(39, mutations.size()); - - // ===== Check FUSION data ======== - // Are there 3 fusion entries in mutation profile? true - int countFusions = 0; - for (ExtendedMutation mutation : mutations) { - if (mutation.getMutationType().equals("Fusion")) { - countFusions++; - } - } - assertEquals(countFusions, 5); - - // Is there a separate fusion profile? -> true - GeneticProfile geneticProfile = DaoGeneticProfile.getGeneticProfileByStableId("study_es_0_fusion"); - assertNotNull(geneticProfile); + // 3 in seed_mini.sql + 33 study_es_0/data_mutations_extended.maf (2 silent ignored)) + // so we expect 34 records in DB: + assertEquals(34, mutations.size()); //===== Check STRUCTURAL VARIANT data ======== // 45 structural variant events are imported, using 31 unique genes, using 39 samples @@ -203,7 +189,7 @@ public void testLoadStudyEs0() throws Throwable { DaoGeneticAlteration daoGeneticAlteration = DaoGeneticAlteration.getInstance(); ArrayList hugoGeneSymbols = new ArrayList(Arrays.asList("ACAP3","AGRN","ATAD3A","ATAD3B","ATAD3C","AURKAIP1","ERCC5")); ArrayList entrezIds = new ArrayList(Arrays.asList(116983L, 375790L, 55210L, 83858L, 219293L, 54998L, 2073L)); - geneticProfile = DaoGeneticProfile.getGeneticProfileByStableId("study_es_0_gistic"); + GeneticProfile geneticProfile = DaoGeneticProfile.getGeneticProfileByStableId("study_es_0_gistic"); int countAMP_DEL = 0; int profileDataSize = 0; for (Long entrezId : entrezIds) { diff --git a/core/src/test/java/org/mskcc/cbio/portal/util/TestMutationKeywordUtils.java b/core/src/test/java/org/mskcc/cbio/portal/util/TestMutationKeywordUtils.java index 2ad21d4e5b9..72148f6fb0f 100644 --- a/core/src/test/java/org/mskcc/cbio/portal/util/TestMutationKeywordUtils.java +++ b/core/src/test/java/org/mskcc/cbio/portal/util/TestMutationKeywordUtils.java @@ -94,7 +94,6 @@ public void testGuessOncotatorKeyword() throws Exception { // others assertEquals("Exon skipping", MutationKeywordUtils.guessOncotatorMutationKeyword("Exon skipping", "Exon skipping")); assertEquals("vIII deletion", MutationKeywordUtils.guessOncotatorMutationKeyword("vIII deletion", "vIII deletion")); - assertEquals("Fusion", MutationKeywordUtils.guessOncotatorMutationKeyword("Fusion", "Fusion")); } @Test diff --git a/core/src/test/resources/data_fusions.txt b/core/src/test/resources/data_fusions.txt deleted file mode 100644 index 307c30e0e23..00000000000 --- a/core/src/test/resources/data_fusions.txt +++ /dev/null @@ -1,4 +0,0 @@ -Hugo_Symbol Entrez_Gene_Id Center Tumor_Sample_Barcode Fusion DNA_support RNA_support Method Frame -FGFR3 2261 saturn TCGA-A1-A0SB-01 Fusion1 unknown unknown unknown unknown -ERBB2 2064 jupiter TCGA-A1-A0SD-01 Fusion2 unknown unknown unknown unknown -FAKE 6666 uranus TCGA-A1-A0SQ-01 Fusion unknown unknown unknown unknown \ No newline at end of file diff --git a/core/src/test/resources/integrationTestScript.xml b/core/src/test/resources/integrationTestScript.xml index 6e4f598434c..80f4000136a 100644 --- a/core/src/test/resources/integrationTestScript.xml +++ b/core/src/test/resources/integrationTestScript.xml @@ -118,18 +118,6 @@ --noprogress - - - org.mskcc.cbio.portal.scripts.ImportProfileData - --data - src/test/scripts/test_data/study_es_0/data_fusions.txt - --meta - src/test/scripts/test_data/study_es_0/meta_fusions.txt - --loadMode - bulkload - --noprogress - - org.mskcc.cbio.portal.scripts.ImportProfileData @@ -263,4 +251,4 @@ - \ No newline at end of file + diff --git a/core/src/test/resources/splitFusionsData/data_fusions.txt b/core/src/test/resources/splitFusionsData/data_fusions.txt deleted file mode 100644 index 584de8d64a3..00000000000 --- a/core/src/test/resources/splitFusionsData/data_fusions.txt +++ /dev/null @@ -1,3 +0,0 @@ -Hugo_Symbol Entrez_Gene_Id Center Tumor_Sample_Barcode Fusion DNA_support RNA_support Method Frame Comments -CD79B 0 MEDICAL-PLACE TCGA-AA-3664-01 TTLL7-CD79B fusion yes unknown unknown There are some comments about the fusion event. -TTLL7 0 MEDICAL-PLACE TCGA-AA-3664-01 TTLL7-CD79B fusion yes unknown unknown More comments about this sample. diff --git a/core/src/test/resources/splitFusionsData/data_fusions_gml.txt b/core/src/test/resources/splitFusionsData/data_fusions_gml.txt deleted file mode 100644 index 9d678b873cc..00000000000 --- a/core/src/test/resources/splitFusionsData/data_fusions_gml.txt +++ /dev/null @@ -1,3 +0,0 @@ -Hugo_Symbol Entrez_Gene_Id Center Tumor_Sample_Barcode Fusion DNA_support RNA_support Method Frame Comments Fusion_Status -PMS2 0 MEDICAL-PLACE TCGA-AA-3664-01 PMS2-intragenic loss yes unknown unknown This person has some data. GERMLINE -RB1 0 MEDICAL-PLACE TCGA-AA-3664-01 RB1-intragenic loss yes unknown unknown Some fake sentence to simulate a comment. GERMLINE diff --git a/core/src/test/resources/splitFusionsData/meta_fusions.txt b/core/src/test/resources/splitFusionsData/meta_fusions.txt deleted file mode 100644 index 7241057edd4..00000000000 --- a/core/src/test/resources/splitFusionsData/meta_fusions.txt +++ /dev/null @@ -1,7 +0,0 @@ -cancer_study_identifier: study_tcga_pub -stable_id: study_tcga_pub_mutations -datatype: FUSION -genetic_alteration_type: FUSION -show_profile_in_analysis_tab: true -profile_description: Fusions. -profile_name: Fusions diff --git a/core/src/test/resources/splitFusionsData/meta_fusions_gml.txt b/core/src/test/resources/splitFusionsData/meta_fusions_gml.txt deleted file mode 100644 index ffa574b5935..00000000000 --- a/core/src/test/resources/splitFusionsData/meta_fusions_gml.txt +++ /dev/null @@ -1,8 +0,0 @@ -cancer_study_identifier: study_tcga_pub -genetic_alteration_type: FUSION -datatype: FUSION -stable_id: study_tcga_pub_mutations -profile_name: Fusions (GML) -profile_description: Fusion data derived from mutation file. (GML) -show_profile_in_analysis_tab: false -data_filename: data_fusions_gml.txt diff --git a/core/src/test/scripts/test_data/data_fusions_duplicate_entry.txt b/core/src/test/scripts/test_data/data_fusions_duplicate_entry.txt deleted file mode 100644 index 969f377cdde..00000000000 --- a/core/src/test/scripts/test_data/data_fusions_duplicate_entry.txt +++ /dev/null @@ -1,5 +0,0 @@ -Hugo_Symbol Entrez_Gene_Id Center Tumor_Sample_Barcode Fusion DNA_support RNA_support Method Frame -FGFR3 2261 saturn TEST-A2B8-01 TMPRSS2-ERG fusion yes yes unknown unknown -ERBB2 2064 jupiter TEST-A2FF-01 Fusion2 yes yes unknown unknown -ERBB2 2064 uranus TCGA-GI-A2C8-01 ERBB2-TEST Fusion yes yes unknown frameshift -FGFR3 2261 saturn2 TEST-A2B8-01 TMPRSS2-ERG fusion yes yes unknown yes diff --git a/core/src/test/scripts/test_data/study_es_0/data_fusions.txt b/core/src/test/scripts/test_data/study_es_0/data_fusions.txt deleted file mode 100644 index 1cc8fcfaa09..00000000000 --- a/core/src/test/scripts/test_data/study_es_0/data_fusions.txt +++ /dev/null @@ -1,6 +0,0 @@ -Hugo_Symbol Entrez_Gene_Id Center Tumor_Sample_Barcode Fusion DNA_support RNA_support Method Frame Fusion_Status -FGFR3 2261 saturn TEST-A2B8-01 TMPRSS2-ERG fusion yes yes unknown unknown -ERBB2 2064 jupiter TEST-A2FF-01 Fusion2 yes yes unknown unknown -ERBB2 2064 uranus TCGA-GI-A2C8-01 ERBB2-TEST Fusion yes yes unknown frameshift -ACP3 55 moon TEST_SAMPLE_5 ACP3-TEST Fusion yes yes unknown frameshift -ACP3 55 moon TEST_SAMPLE_6 ACP3-TEST Fusion yes yes unknown frameshift diff --git a/core/src/test/scripts/test_data/study_es_0/meta_fusions.txt b/core/src/test/scripts/test_data/study_es_0/meta_fusions.txt deleted file mode 100644 index c59145488de..00000000000 --- a/core/src/test/scripts/test_data/study_es_0/meta_fusions.txt +++ /dev/null @@ -1,8 +0,0 @@ -cancer_study_identifier: study_es_0 -genetic_alteration_type: FUSION -datatype: FUSION -stable_id: fusion -profile_description: Fusions. -show_profile_in_analysis_tab: true -profile_name: Fusions -data_filename: data_fusions.txt diff --git a/model/src/main/java/org/cbioportal/model/AlterationFilter.java b/model/src/main/java/org/cbioportal/model/AlterationFilter.java index 6c22ca1309a..c10f8d697e7 100644 --- a/model/src/main/java/org/cbioportal/model/AlterationFilter.java +++ b/model/src/main/java/org/cbioportal/model/AlterationFilter.java @@ -85,19 +85,12 @@ public void setStructuralVariants(Boolean structuralVariants) { @JsonIgnore public Select getMutationTypeSelect() { - /* - * Appropriately add fusion mutation type depending on structural variant since fusions are still in mutation table - * TODO: do necessary changes once fusion data is cleaned up from mutation table - * */ - if (mutationTypeSelect != null) return mutationTypeSelect; if (mutationEventTypes == null || mutationEventTypes.getOrDefault(MutationEventType.any, false) || allOptionsSelected(mutationEventTypes, Arrays.asList(MutationEventType.any.toString()))) { - if(this.structuralVariants == null || this.structuralVariants == true) { - return Select.all(); - } + return Select.all(); } // if MutationEventType.other is true and not allOptionsSelected @@ -108,9 +101,6 @@ public Select getMutationTypeSelect() { .filter(e -> !e.getValue()) .map(Entry::getKey) .collect(Collectors.toList()); - if(this.structuralVariants == null || this.structuralVariants == false) { - unSelected.add(MutationEventType.fusion); - } Select select = Select.byValues(unSelected); // setting this would execute NOT IN clause in sql query select.inverse(true); @@ -122,9 +112,6 @@ public Select getMutationTypeSelect() { .filter(Entry::getValue) .map(Entry::getKey) .collect(Collectors.toList()); - if(this.structuralVariants != null && this.structuralVariants == true) { - selected.add(MutationEventType.fusion); - } return Select.byValues(selected); } } diff --git a/model/src/main/java/org/cbioportal/model/AlterationType.java b/model/src/main/java/org/cbioportal/model/AlterationType.java index 5b832d355ff..c7b77bea59d 100644 --- a/model/src/main/java/org/cbioportal/model/AlterationType.java +++ b/model/src/main/java/org/cbioportal/model/AlterationType.java @@ -2,6 +2,5 @@ public enum AlterationType { MUTATION, - FUSION, COPY_NUMBER_ALTERATION } diff --git a/model/src/main/java/org/cbioportal/model/MolecularProfile.java b/model/src/main/java/org/cbioportal/model/MolecularProfile.java index d8584478cee..0185fb2b5c0 100644 --- a/model/src/main/java/org/cbioportal/model/MolecularProfile.java +++ b/model/src/main/java/org/cbioportal/model/MolecularProfile.java @@ -12,7 +12,6 @@ public enum MolecularAlterationType { // uncalled mutations (mskcc internal) for showing read counts even if // mutation wasn't called MUTATION_UNCALLED, - FUSION, STRUCTURAL_VARIANT, COPY_NUMBER_ALTERATION, MICRO_RNA_EXPRESSION, @@ -80,16 +79,7 @@ public void setCancerStudyIdentifier(String cancerStudyIdentifier) { } public MolecularAlterationType getMolecularAlterationType() { - // TODO: remove this logic once all the fusions are migrated to structural variants - // most fusion profiles are imported as SV data but this also handles the archer - // study case where the fusions are imported under a mutations profile instead - // https://github.com/cBioPortal/cbioportal/blob/8704058562c386afeac3082e50f39c1097d47983/core/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileReader.java#L93 - // But somehow there was no migration for existing data. To resolve it replace FUSION alteration type by STRUCTURAL_VARIANT. - return (molecularAlterationType.equals(MolecularAlterationType.FUSION) || - (molecularAlterationType.equals(MolecularAlterationType.MUTATION_EXTENDED) - && this.datatype != null && this.datatype.equals("FUSION"))) - ? MolecularAlterationType.STRUCTURAL_VARIANT - : molecularAlterationType; + return molecularAlterationType; } public void setMolecularAlterationType(MolecularAlterationType molecularAlterationType) { @@ -121,11 +111,7 @@ public void setDescription(String description) { } public Boolean getShowProfileInAnalysisTab() { - // TODO: remove this logic once the data is fixed (when all the fusions are migrated to structural variants) - return showProfileInAnalysisTab - || ((molecularAlterationType.equals(MolecularAlterationType.STRUCTURAL_VARIANT) - || molecularAlterationType.equals(MolecularAlterationType.MUTATION_EXTENDED)) - && datatype.equals("FUSION")); + return showProfileInAnalysisTab; } public void setShowProfileInAnalysisTab(Boolean showProfileInAnalysisTab) { diff --git a/model/src/main/java/org/cbioportal/model/MutationEventType.java b/model/src/main/java/org/cbioportal/model/MutationEventType.java index 0423a2b3934..e1957f20e71 100644 --- a/model/src/main/java/org/cbioportal/model/MutationEventType.java +++ b/model/src/main/java/org/cbioportal/model/MutationEventType.java @@ -46,7 +46,6 @@ public enum MutationEventType { inframe("inframe"), truncating("truncating"), feature_truncation("feature_truncation"), - fusion("fusion"), silent("silent"), synonymous_variant("synonymous_variant"), any("any"), diff --git a/model/src/main/java/org/cbioportal/model/Sample.java b/model/src/main/java/org/cbioportal/model/Sample.java index c049eaa4f37..ec9f6165dc6 100644 --- a/model/src/main/java/org/cbioportal/model/Sample.java +++ b/model/src/main/java/org/cbioportal/model/Sample.java @@ -55,7 +55,6 @@ public String toString() { private String cancerStudyIdentifier; private Boolean sequenced; private Boolean copyNumberSegmentPresent; - private Boolean profiledForFusions; public Integer getInternalId() { return internalId; @@ -127,10 +126,6 @@ public void setCopyNumberSegmentPresent(Boolean copyNumberSegmentPresent) { this.copyNumberSegmentPresent = copyNumberSegmentPresent; } - public Boolean getProfiledForFusions() { return profiledForFusions; } - - public void setProfiledForFusions(Boolean profiledForFusions) { this.profiledForFusions = profiledForFusions; } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/AlterationRepository.java b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/AlterationRepository.java index c4f8baeb51a..160bd785008 100644 --- a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/AlterationRepository.java +++ b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/AlterationRepository.java @@ -13,13 +13,11 @@ public interface AlterationRepository { @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") List getSampleAlterationCounts(Set molecularProfileCaseIdentifiers, Select entrezGeneIds, - QueryElement searchFusions, AlterationFilter alterationFilter); @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") List getPatientAlterationCounts(List molecularProfileCaseIdentifiers, Select entrezGeneIds, - QueryElement searchFusions, AlterationFilter alterationFilter); @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") diff --git a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java index a0df5b15f8e..ac25c83f9ff 100644 --- a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java +++ b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java @@ -54,22 +54,4 @@ MutationMeta fetchMetaMutationsInMolecularProfile(String molecularProfileId, Lis @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") MutationCountByPosition getMutationCountByPosition(Integer entrezGeneId, Integer proteinPosStart, Integer proteinPosEnd); - - // TODO: cleanup once fusion/structural data is fixed in database - @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") - List getFusionsInMultipleMolecularProfiles(List molecularProfileIds, List sampleIds, - List entrezGeneIds, String projection, Integer pageSize, Integer pageNumber, String sortBy, - String direction); - - @Cacheable(cacheResolver = "generalRepositoryCacheResolver", condition = "@cacheEnabledConfig.getEnabled()") - List getFusionsInMultipleMolecularProfilesByGeneQueries(List molecularProfileIds, - List sampleIds, - List geneQueries, - String projection, - Integer pageSize, - Integer pageNumber, - String sortBy, - String direction); - - // TODO: cleanup once fusion/structural data is fixed in database -} \ No newline at end of file +} diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationCountsMapper.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationCountsMapper.java index 004b2900745..42e16655f2b 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationCountsMapper.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationCountsMapper.java @@ -15,7 +15,6 @@ public interface AlterationCountsMapper { * @param entrezGeneIds Gene ids to get counts for. * @param mutationTypes Types of mutations to include in alteration counts. * @param cnaTypes Types of discrete copy number alteration types to include in alteration counts. - * @param searchFusions 'ACTIVE': counts are limited to fusion type. 'INACTIVE': counts are limited to non-fusion alterations.'PASS': no filtering on mutation vs fusions (mutation types and cnaTypes are used) * @param includeDriver Include Variants of Unknown significance. Uses annotations loaded as 'custom driver annotations'. * @param includeVUS Include Variants of Unknown significance. Uses annotations loaded as 'custom driver annotations'. * @param includeUnknownOncogenicity Include variants that are not annotated as driver or VUS. Uses annotations loaded as 'custom driver annotations'. @@ -31,7 +30,6 @@ List getSampleAlterationCounts(List entrezGeneIds, Select mutationTypes, Select cnaTypes, - QueryElement searchFusions, boolean includeDriver, boolean includeVUS, boolean includeUnknownOncogenicity, @@ -45,7 +43,6 @@ List getSampleAlterationCounts(List getPatientAlterationCounts(List entrezGeneIds, Select mutationTypes, Select cnaTypes, - QueryElement searchFusions, boolean includeDriver, boolean includeVUS, boolean includeUnknownOncogenicity, diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepository.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepository.java index edd1060f7fb..b252f8868ae 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepository.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepository.java @@ -29,13 +29,8 @@ public class AlterationMyBatisRepository implements AlterationRepository { @Override public List getSampleAlterationCounts(Set molecularProfileCaseIdentifiers, Select entrezGeneIds, - QueryElement searchFusions, AlterationFilter alterationFilter) { - if (!alterationFilter.getMutationTypeSelect().hasAll() && searchFusions != QueryElement.PASS) - throw new IllegalArgumentException("Filtering for mutations vs. fusions and specifying mutation types" + - "simultaneously is not permitted."); - if ((alterationFilter.getMutationTypeSelect().hasNone() && alterationFilter.getCNAEventTypeSelect().hasNone()) || (molecularProfileCaseIdentifiers == null || molecularProfileCaseIdentifiers.isEmpty()) || allAlterationsExcludedDriverAnnotation(alterationFilter) @@ -58,19 +53,6 @@ public List getSampleAlterationCounts(Set profileTypeByProfileId.getOrDefault(e.getMolecularProfileId(), null))); - // TODO: Remove once fusions are removed from mutation table - // if fusions were imported as a "mutations" profile then replace STRUCTURAL_VARIANT in - // groupedIdentifiersByProfileType map with MUTATION_EXTENDED - for (MolecularProfile profile : molecularProfileRepository.getMolecularProfiles(molecularProfileIds, "SUMMARY")) { - if (profile.getStableId().endsWith("mutations") && profile.getDatatype().equals("FUSION") && - groupedIdentifiersByProfileType.get(MolecularAlterationType.STRUCTURAL_VARIANT) != null) { - groupedIdentifiersByProfileType.put(MolecularAlterationType.MUTATION_EXTENDED, - groupedIdentifiersByProfileType.get(MolecularAlterationType.STRUCTURAL_VARIANT)); - groupedIdentifiersByProfileType.remove(MolecularAlterationType.STRUCTURAL_VARIANT); - break; - } - } - return alterationCountsMapper.getSampleAlterationCounts( groupedIdentifiersByProfileType.get(MolecularAlterationType.MUTATION_EXTENDED), groupedIdentifiersByProfileType.get(MolecularAlterationType.COPY_NUMBER_ALTERATION), @@ -78,7 +60,6 @@ public List getSampleAlterationCounts(Set getSampleAlterationCounts(Set getPatientAlterationCounts(List molecularProfileCaseIdentifiers, Select entrezGeneIds, - QueryElement searchFusions, AlterationFilter alterationFilter) { - if (!alterationFilter.getMutationTypeSelect().hasAll() && searchFusions != QueryElement.PASS) - throw new IllegalArgumentException("Filtering for mutations vs. fusions and specifying mutation types" + - "simultaneously is not permitted."); - if ((alterationFilter.getMutationTypeSelect().hasNone() && alterationFilter.getCNAEventTypeSelect().hasNone()) || (molecularProfileCaseIdentifiers == null || molecularProfileCaseIdentifiers.isEmpty()) || allAlterationsExcludedDriverAnnotation(alterationFilter) @@ -129,7 +105,6 @@ public List getPatientAlterationCounts(List entrezGeneIds, Boolean snpOnly); - // TODO: cleanup searchFusions param once fusion/structural data is fixed in database List getMutationsInMultipleMolecularProfiles(List molecularProfileIds, List sampleIds, List entrezGeneIds, Boolean snpOnly, - boolean searchFusions, String projection, Integer limit, + String projection, Integer limit, Integer offset, String sortBy, String direction); - // TODO: cleanup searchFusions param once fusion/structural data is fixed in database List getMutationsInMultipleMolecularProfilesByGeneQueries(List molecularProfileIds, List sampleIds, Boolean snpOnly, - boolean searchFusions, String projection, Integer limit, Integer offset, diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java index eca8d2e8586..6adc902dd9e 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java @@ -47,7 +47,6 @@ public List getMutationsInMultipleMolecularProfiles(List molec String projection, Integer pageSize, Integer pageNumber, String sortBy, String direction) { - boolean searchFusions = false; return molecularProfileCaseIdentifierUtil .getGroupedCasesByMolecularProfileId(molecularProfileIds, sampleIds) .entrySet() @@ -57,7 +56,6 @@ public List getMutationsInMultipleMolecularProfiles(List molec new ArrayList<>(entry.getValue()), entrezGeneIds, null, - searchFusions, projection, pageSize, offsetCalculator.calculate(pageSize, pageNumber), @@ -78,7 +76,6 @@ public List getMutationsInMultipleMolecularProfilesByGeneQueries(List< if (geneQueries.isEmpty()) return Collections.emptyList(); - boolean searchFusions = false; return molecularProfileCaseIdentifierUtil .getGroupedCasesByMolecularProfileId(molecularProfileIds, sampleIds) .entrySet() @@ -87,7 +84,6 @@ public List getMutationsInMultipleMolecularProfilesByGeneQueries(List< Arrays.asList(entry.getKey()), new ArrayList<>(entry.getValue()), null, - searchFusions, projection, pageSize, offsetCalculator.calculate(pageSize, pageNumber), @@ -112,13 +108,11 @@ public List fetchMutationsInMolecularProfile(String molecularProfileId String projection, Integer pageSize, Integer pageNumber, String sortBy, String direction) { - boolean searchFusions = false; return mutationMapper.getMutationsInMultipleMolecularProfiles( Arrays.asList(molecularProfileId), new ArrayList<>(sampleIds), entrezGeneIds, snpOnly, - searchFusions, projection, pageSize, offsetCalculator.calculate(pageSize, pageNumber), @@ -140,62 +134,4 @@ public MutationCountByPosition getMutationCountByPosition(Integer entrezGeneId, return mutationMapper.getMutationCountByPosition(entrezGeneId, proteinPosStart, proteinPosEnd); } - // TODO: cleanup once fusion/structural data is fixed in database - @Override - public List getFusionsInMultipleMolecularProfiles(List molecularProfileIds, - List sampleIds, List entrezGeneIds, String projection, Integer pageSize, - Integer pageNumber, String sortBy, String direction) { - - boolean searchFusions = true; - return molecularProfileCaseIdentifierUtil - .getGroupedCasesByMolecularProfileId(molecularProfileIds, sampleIds) - .entrySet() - .stream() - .flatMap(entry -> mutationMapper.getMutationsInMultipleMolecularProfiles( - Arrays.asList(entry.getKey()), - new ArrayList<>(entry.getValue()), - entrezGeneIds, - null, - searchFusions, - projection, - pageSize, - offsetCalculator.calculate(pageSize, pageNumber), - sortBy, - direction).stream()) - .collect(Collectors.toList()); - } - - @Override - public List getFusionsInMultipleMolecularProfilesByGeneQueries(List molecularProfileIds, - List sampleIds, - List geneQueries, - String projection, - Integer pageSize, - Integer pageNumber, - String sortBy, - String direction) { - - if (geneQueries.isEmpty()) - return Collections.emptyList(); - - boolean searchFusions = true; - return molecularProfileCaseIdentifierUtil - .getGroupedCasesByMolecularProfileId(molecularProfileIds, sampleIds) - .entrySet() - .stream() - .flatMap(entry -> mutationMapper.getMutationsInMultipleMolecularProfilesByGeneQueries( - Arrays.asList(entry.getKey()), - new ArrayList<>(entry.getValue()), - null, - searchFusions, - projection, - pageSize, - offsetCalculator.calculate(pageSize, pageNumber), - sortBy, - direction, - geneQueries).stream()) - .collect(Collectors.toList()); - } - // TODO: cleanup once fusion/structural data is fixed in database - } diff --git a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml index 16d290b834c..c412a09c61d 100644 --- a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml +++ b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml @@ -267,17 +267,6 @@ - - - AND - LOWER(mutation_event.MUTATION_TYPE) = 'fusion' - - - AND - LOWER(mutation_event.MUTATION_TYPE) != 'fusion' - - - @@ -336,15 +325,6 @@ LOWER(#{type}) - - - - diff --git a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml index d8517b4291d..4d31d0a4413 100644 --- a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml +++ b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml @@ -97,16 +97,6 @@ - - - AND - mutation_event.MUTATION_TYPE = 'Fusion' - - - AND - mutation_event.MUTATION_TYPE != 'Fusion' - - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') @@ -180,16 +170,6 @@ - - - AND - mutation_event.MUTATION_TYPE = 'Fusion' - - - AND - mutation_event.MUTATION_TYPE != 'Fusion' - - AND mutation_event.REFERENCE_ALLELE IN ('A','T','C','G') AND mutation_event.TUMOR_SEQ_ALLELE IN ('A','T','C','G') @@ -309,8 +289,7 @@ SELECT - - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID AND mutation_event.MUTATION_TYPE != 'Fusion' + INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID @@ -332,8 +311,7 @@ COUNT(*) AS totalCount, COUNT(DISTINCT(mutation.SAMPLE_ID)) AS sampleCount - - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID AND mutation_event.MUTATION_TYPE != 'Fusion' + INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID @@ -341,7 +319,6 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID @@ -355,7 +332,6 @@ SELECT - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID @@ -370,8 +346,7 @@ COUNT(*) AS totalCount, COUNT(DISTINCT(mutation.SAMPLE_ID)) AS sampleCount - - INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID AND mutation_event.MUTATION_TYPE != 'Fusion' + INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID @@ -380,8 +355,7 @@ COUNT(*) AS totalCount, COUNT(DISTINCT(mutation.SAMPLE_ID)) AS sampleCount - - INNER JOIN mutation_event ON mutation_event.MUTATION_EVENT_ID = mutation.MUTATION_EVENT_ID AND mutation_event.MUTATION_TYPE != 'Fusion' + INNER JOIN mutation_event ON mutation_event.MUTATION_EVENT_ID = mutation.MUTATION_EVENT_ID @@ -392,8 +366,7 @@ COUNT(*) AS totalCount, COUNT(DISTINCT(mutation.SAMPLE_ID)) AS numberOfAlteredCases FROM mutation - - INNER JOIN mutation_event ON mutation_event.MUTATION_EVENT_ID = mutation.MUTATION_EVENT_ID AND mutation_event.MUTATION_TYPE != 'Fusion' + INNER JOIN mutation_event ON mutation_event.MUTATION_EVENT_ID = mutation.MUTATION_EVENT_ID INNER JOIN genetic_profile ON mutation.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID INNER JOIN sample ON mutation.SAMPLE_ID = sample.INTERNAL_ID INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID @@ -412,7 +385,5 @@ WHERE mutation_event.ENTREZ_GENE_ID = #{entrezGeneId} AND mutation_event.ONCOTATOR_PROTEIN_POS_START >= #{proteinPosStart} AND mutation_event.ONCOTATOR_PROTEIN_POS_END #{proteinPosEnd} - - AND mutation_event.MUTATION_TYPE != 'Fusion' diff --git a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepositoryTest.java index 8e7c8bcc97b..dd424b75be2 100644 --- a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepositoryTest.java +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/AlterationMyBatisRepositoryTest.java @@ -32,7 +32,6 @@ public class AlterationMyBatisRepositoryTest { // 7 672 BRCA1 6 MUTATION Nonsense_Mutation Putative_Driver Tier 2 TCGA-A1-A0SI germline // 12 672 BRCA1 6 MUTATION Splice_Site Putative_Passenger Tier 1 TCGA-A1-A0SO germline // 13 672 BRCA1 6 MUTATION Splice_Site Putative_Driver Tier 1 TCGA-A1-A0SP germline - // 7 2064 ERBB2 6 FUSION TCGA-A1-A0SI NA @Autowired private AlterationMyBatisRepository alterationMyBatisRepository; @@ -99,7 +98,6 @@ public void getSampleMutationCountAllDriverAnnotationsExcluded() throws Exceptio List result = alterationMyBatisRepository.getSampleAlterationCounts( new HashSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -112,7 +110,6 @@ public void getSampleMutationCountAllDriverTiersExcluded() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -125,7 +122,6 @@ public void getSampleMutationCountAllDriverTiersExcludedWithNullSelect() throws List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -139,7 +135,6 @@ public void getSampleMutationCountAllMutationStatusExcluded() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -150,7 +145,6 @@ public void getSampleMutationCount() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(3, result.size()); @@ -171,7 +165,6 @@ public void getSampleCnaCount() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(2, result.size()); @@ -188,7 +181,6 @@ public void getSampleMutationAndCnaCount() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(3, result.size()); @@ -213,35 +205,10 @@ public void whenSampleNotProfiledForCNA() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } - @Test - public void getSampleMutationCountFilterFusions() throws Exception { - alterationFilter.setCnaTypeSelect(Select.none()); - alterationFilter.setMutationTypeSelect(Select.all()); - List result = alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), - entrezGeneIds, - QueryElement.ACTIVE, - alterationFilter); - Assert.assertEquals(1, result.size()); - } - - @Test - public void getSampleMutationCountFilterFusionsViaType() throws Exception { - alterationFilter.setCnaTypeSelect(Select.none()); - alterationFilter.setMutationTypeSelect(Select.byValues(Arrays.asList(MutationEventType.fusion))); - List result = alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), - entrezGeneIds, - QueryElement.PASS, - alterationFilter); - Assert.assertEquals(1, result.size()); - } - @Test public void getPatientCnaCountAllDriverAnnotationsExcluded() throws Exception { alterationFilter.setIncludeDriver(false); @@ -251,7 +218,6 @@ public void getPatientCnaCountAllDriverAnnotationsExcluded() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -264,7 +230,6 @@ public void getPatientCnaCountAllDriverTiersExcluded() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -277,7 +242,6 @@ public void getPatientCnaCountAllDriverTiersExcludedNullSelect() throws Exceptio List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); } @@ -288,7 +252,6 @@ public void getPatientCnaCount() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); // For testSql.sql there are no more samples per patient for the investigated genes. @@ -353,7 +316,6 @@ public void getSampleAlterationCountsReturnsZeroForMutationsAndCnaSelectorsInNon List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(0, result.size()); @@ -366,48 +328,22 @@ public void getSampleAlterationCountsReturnsAllForMutationsAndCnaSelectorsInAll( List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, - alterationFilter); - - Assert.assertEquals(4, result.size()); - } - - @Test(expected = IllegalArgumentException.class) - public void disallowMutationTypesAndFusionSearchSamples() throws Exception { - alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), entrezGeneIds, QueryElement.ACTIVE, alterationFilter); - } - - @Test(expected = IllegalArgumentException.class) - public void disallowMutationTypesAndMutationSearchSamples() throws Exception { - alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), entrezGeneIds, QueryElement.INACTIVE, alterationFilter); - } - @Test(expected = IllegalArgumentException.class) - public void disallowMutationTypesAndFusionSearchPatients() throws Exception { - alterationMyBatisRepository.getPatientAlterationCounts( - sampleIdToProfileId, entrezGeneIds, QueryElement.ACTIVE, alterationFilter); - } - - @Test(expected = IllegalArgumentException.class) - public void disallowMutationTypesAndMutationSearchPatients() throws Exception { - alterationMyBatisRepository.getPatientAlterationCounts( - sampleIdToProfileId, entrezGeneIds, QueryElement.INACTIVE, alterationFilter); + Assert.assertEquals(3, result.size()); } @Test public void getSampleCountNullIds() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( - null, entrezGeneIds, QueryElement.PASS, new AlterationFilter()); + null, entrezGeneIds, new AlterationFilter()); Assert.assertEquals(0, result.size()); } @Test public void getPatientCountNullIds() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( - null, entrezGeneIds, QueryElement.PASS, new AlterationFilter()); + null, entrezGeneIds, new AlterationFilter()); Assert.assertEquals(0, result.size()); } @@ -425,7 +361,6 @@ public void getSampleCountIncludeOnlyDriver() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(2, result.size()); @@ -444,7 +379,6 @@ public void getSampleCountIncludeOnlyVus() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(3, result.size()); @@ -466,7 +400,6 @@ public void getSampleCountIncludeOnlyUnknownOncogenicity() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(1, result.size()); @@ -483,7 +416,6 @@ public void getSampleCountIncludeOnlyTiers() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(2, result.size()); @@ -501,7 +433,6 @@ public void getSampleCountIncludeUnknownTier() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( new TreeSet<>(sampleIdToProfileId), entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(1, result.size()); @@ -515,7 +446,6 @@ public void getPatientMutationAndCnaCount() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); // For testSql.sql there are no more samples per patient for the investigated genes. @@ -540,7 +470,6 @@ public void getPatientMutationCountIncludeOnlyGermline() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); // all but one mutations in testSql.sql are Germline mutations Assert.assertEquals(3, result.size()); @@ -563,7 +492,6 @@ public void getPatientMutationCountIncludeOnlySomatic() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); // all but one mutations in testSql.sql are Germline mutations Assert.assertEquals(0, result.size()); @@ -577,36 +505,11 @@ public void getPatientMutationCountIncludeOnlyUnknownStatus() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); // all but one mutations in testSql.sql are Germline mutations Assert.assertEquals(1, result.size()); } - @Test - public void getPatientMutationCountFilterFusions() throws Exception { - alterationFilter.setCnaTypeSelect(Select.none()); - alterationFilter.setMutationTypeSelect(Select.all()); - List result = alterationMyBatisRepository.getPatientAlterationCounts( - patientIdToProfileId, - entrezGeneIds, - QueryElement.ACTIVE, - alterationFilter); - Assert.assertEquals(1, result.size()); - } - - @Test - public void getPatientMutationCountFilterFusionsViaType() throws Exception { - alterationFilter.setCnaTypeSelect(Select.none()); - alterationFilter.setMutationTypeSelect(Select.byValues(Arrays.asList(MutationEventType.fusion))); - List result = alterationMyBatisRepository.getPatientAlterationCounts( - patientIdToProfileId, - entrezGeneIds, - QueryElement.PASS, - alterationFilter); - Assert.assertEquals(1, result.size()); - } - @Test public void getPatientCountIncludeOnlyDriver() throws Exception { alterationFilter.setIncludeVUS(false); @@ -614,7 +517,6 @@ public void getPatientCountIncludeOnlyDriver() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(2, result.size()); @@ -633,7 +535,6 @@ public void getPatientCountIncludeOnlyVUS() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(3, result.size()); @@ -655,7 +556,6 @@ public void getPatientCountIncludeOnlyUnknownOncogenicity() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(1, result.size()); @@ -672,7 +572,6 @@ public void getPatientCountIncludeOnlyTiers() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(2, result.size()); @@ -690,7 +589,6 @@ public void getPatientCountIncludeUnknownTier() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( patientIdToProfileId, entrezGeneIds, - QueryElement.PASS, alterationFilter); Assert.assertEquals(1, result.size()); @@ -839,43 +737,43 @@ public void getPatientCnaCountNullIds() throws Exception { @Test public void getSampleCountNullEntrezGeneIds() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), null, QueryElement.PASS, new AlterationFilter()); + new TreeSet<>(sampleIdToProfileId), null, new AlterationFilter()); Assert.assertEquals(0, result.size()); } @Test public void getSampleCountEmptyEntrezGeneIds() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), Select.none(), QueryElement.PASS, new AlterationFilter()); + new TreeSet<>(sampleIdToProfileId), Select.none(), new AlterationFilter()); Assert.assertEquals(0, result.size()); } @Test public void getSampleCountAllEntrezGeneIds() throws Exception { List result = alterationMyBatisRepository.getSampleAlterationCounts( - new TreeSet<>(sampleIdToProfileId), Select.all(), QueryElement.PASS, new AlterationFilter()); - Assert.assertEquals(4, result.size()); + new TreeSet<>(sampleIdToProfileId), Select.all(), new AlterationFilter()); + Assert.assertEquals(3, result.size()); } @Test public void getPatientCountNullEntrezGeneIds() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( - patientIdToProfileId, null, QueryElement.PASS, new AlterationFilter()); + patientIdToProfileId, null, new AlterationFilter()); Assert.assertEquals(0, result.size()); } @Test public void getPatientCountEmptyEntrezGeneIds() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( - patientIdToProfileId, Select.none(), QueryElement.PASS, new AlterationFilter()); + patientIdToProfileId, Select.none(), new AlterationFilter()); Assert.assertEquals(0, result.size()); } @Test public void getPatientCountAllEntrezGeneIds() throws Exception { List result = alterationMyBatisRepository.getPatientAlterationCounts( - patientIdToProfileId, Select.all(), QueryElement.PASS, new AlterationFilter()); - Assert.assertEquals(4, result.size()); + patientIdToProfileId, Select.all(), new AlterationFilter()); + Assert.assertEquals(3, result.size()); } @Test diff --git a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java index 01e42bc79b9..4f164ca3a9b 100644 --- a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java @@ -40,8 +40,6 @@ public class DiscreteCopyNumberMyBatisRepositoryTest { // 7 672 BRCA1 6 MUTATION Nonsense_Mutation Putative_Driver Tier 2 TCGA-A1-A0SI germline // 12 672 BRCA1 6 MUTATION Splice_Site Putative_Passenger Tier 1 TCGA-A1-A0SO germline // 13 672 BRCA1 6 MUTATION Splice_Site Putative_Driver Tier 1 TCGA-A1-A0SP germline - // 7 2064 ERBB2 6 FUSION TCGA-A1-A0SI NA - @Autowired private DiscreteCopyNumberMyBatisRepository discreteCopyNumberMyBatisRepository; diff --git a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java index f2598eb7e61..b84fa1a32a6 100644 --- a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java @@ -39,8 +39,6 @@ public class MutationMyBatisRepositoryTest { // 7 672 BRCA1 6 MUTATION Nonsense_Mutation Putative_Driver Tier 2 TCGA-A1-A0SI germline // 12 672 BRCA1 6 MUTATION Splice_Site Putative_Passenger Tier 1 TCGA-A1-A0SO germline // 13 672 BRCA1 6 MUTATION Splice_Site Putative_Driver Tier 1 TCGA-A1-A0SP germline - // 7 2064 ERBB2 6 FUSION TCGA-A1-A0SI NA - @Autowired private MutationMyBatisRepository mutationMyBatisRepository; @@ -490,28 +488,6 @@ public void getMutationsInMultipleMolecularProfilesByGeneQueriesMixed() throws E assert(result.stream().allMatch(r -> expectedSampleIds.contains(r.getSampleId()))); } - @Test - public void getFusionsInMultipleMolecularProfiles() throws Exception { - - List molecularProfileIds = new ArrayList<>(); - molecularProfileIds.add("acc_tcga_mutations"); - molecularProfileIds.add("study_tcga_pub_mutations"); - molecularProfileIds.add("study_tcga_pub_mutations"); - - List sampleIds = new ArrayList<>(); - sampleIds.add("TCGA-A1-B0SO-01"); - sampleIds.add("TCGA-A1-A0SH-01"); - sampleIds.add("TCGA-A1-A0SI-01"); - - List tiers = new ArrayList<>(); - List result = mutationMyBatisRepository.getFusionsInMultipleMolecularProfiles(molecularProfileIds, - sampleIds, null, "SUMMARY", null, null, null, null); - - // TODO: cleanup once fusion/structural data is fixed in database - // This test should correctly return entries from the structural_variant table (7 records) - Assert.assertEquals(1, result.size()); - } - @Test public void getMetaMutationsInMultipleMolecularProfiles() throws Exception { diff --git a/persistence/persistence-mybatis/src/test/resources/testSql.sql b/persistence/persistence-mybatis/src/test/resources/testSql.sql index 4a92467d052..8b5dd7a94dd 100644 --- a/persistence/persistence-mybatis/src/test/resources/testSql.sql +++ b/persistence/persistence-mybatis/src/test/resources/testSql.sql @@ -130,7 +130,6 @@ INSERT INTO mutation_event (MUTATION_EVENT_ID,ENTREZ_GENE_ID,CHR,START_POSITION, INSERT INTO mutation_event (MUTATION_EVENT_ID,ENTREZ_GENE_ID,CHR,START_POSITION,END_POSITION,REFERENCE_ALLELE,TUMOR_SEQ_ALLELE,PROTEIN_CHANGE,MUTATION_TYPE,FUNCTIONAL_IMPACT_SCORE,FIS_VALUE,LINK_XVAR,LINK_PDB,LINK_MSA,NCBI_BUILD,STRAND,VARIANT_TYPE,DB_SNP_RS,DB_SNP_VAL_STATUS,ONCOTATOR_DBSNP_RS,ONCOTATOR_REFSEQ_MRNA_ID,ONCOTATOR_CODON_CHANGE,ONCOTATOR_UNIPROT_ENTRY_NAME,ONCOTATOR_UNIPROT_ACCESSION,ONCOTATOR_PROTEIN_POS_START,ONCOTATOR_PROTEIN_POS_END,CANONICAL_TRANSCRIPT,KEYWORD) VALUES (2040,207,'17',41244748,41244748,'G','A','Q934*','Nonsense_Mutation','NA',0,'getma.org/?cm=var&var=hg19,17,41244748,G,A&fts=all','NA','NA','37','+','SNP','rs80357223','unknown','rs80357223','NM_007294','c.(2800-2802)CAG>TAG','BRCA1_HUMAN','P38398',934,934,1,'BRCA1 truncating'); INSERT INTO mutation_event (MUTATION_EVENT_ID,ENTREZ_GENE_ID,CHR,START_POSITION,END_POSITION,REFERENCE_ALLELE,TUMOR_SEQ_ALLELE,PROTEIN_CHANGE,MUTATION_TYPE,FUNCTIONAL_IMPACT_SCORE,FIS_VALUE,LINK_XVAR,LINK_PDB,LINK_MSA,NCBI_BUILD,STRAND,VARIANT_TYPE,DB_SNP_RS,DB_SNP_VAL_STATUS,ONCOTATOR_DBSNP_RS,ONCOTATOR_REFSEQ_MRNA_ID,ONCOTATOR_CODON_CHANGE,ONCOTATOR_UNIPROT_ENTRY_NAME,ONCOTATOR_UNIPROT_ACCESSION,ONCOTATOR_PROTEIN_POS_START,ONCOTATOR_PROTEIN_POS_END,CANONICAL_TRANSCRIPT,KEYWORD) VALUES (2041,207,'17',41258504,41258504,'A','C','C61G','Missense_Mutation','H',4.355,'getma.org/?cm=var&var=hg19,17,41258504,A,C&fts=all','getma.org/pdb.php?prot=BRCA1_HUMAN&from=24&to=64&var=C61G','getma.org/?cm=msa&ty=f&p=BRCA1_HUMAN&rb=24&re=64&var=C61G','37','+','SNP','rs28897672','byCluster','rs28897672','NM_007294','c.(181-183)TGT>GGT','BRCA1_HUMAN','P38398',61,61,1,'BRCA1 C61 missense'); INSERT INTO mutation_event (MUTATION_EVENT_ID,ENTREZ_GENE_ID,CHR,START_POSITION,END_POSITION,REFERENCE_ALLELE,TUMOR_SEQ_ALLELE,PROTEIN_CHANGE,MUTATION_TYPE,FUNCTIONAL_IMPACT_SCORE,FIS_VALUE,LINK_XVAR,LINK_PDB,LINK_MSA,NCBI_BUILD,STRAND,VARIANT_TYPE,DB_SNP_RS,DB_SNP_VAL_STATUS,ONCOTATOR_DBSNP_RS,ONCOTATOR_REFSEQ_MRNA_ID,ONCOTATOR_CODON_CHANGE,ONCOTATOR_UNIPROT_ENTRY_NAME,ONCOTATOR_UNIPROT_ACCESSION,ONCOTATOR_PROTEIN_POS_START,ONCOTATOR_PROTEIN_POS_END,CANONICAL_TRANSCRIPT,KEYWORD) VALUES (2042,208,'17',41276033,41276033,'C','T','C27_splice','Splice_Site','NA',1.4013e-45,'NA','NA','NA','37','+','SNP','rs80358010','byCluster','rs80358010','NM_007294','c.e2+1','NA','NA',-1,-1,1,'BRCA1 truncating'); -INSERT INTO mutation_event (MUTATION_EVENT_ID,ENTREZ_GENE_ID,CHR,START_POSITION,END_POSITION,REFERENCE_ALLELE,TUMOR_SEQ_ALLELE,PROTEIN_CHANGE,MUTATION_TYPE,FUNCTIONAL_IMPACT_SCORE,FIS_VALUE,LINK_XVAR,LINK_PDB,LINK_MSA,NCBI_BUILD,STRAND,VARIANT_TYPE,DB_SNP_RS,DB_SNP_VAL_STATUS,ONCOTATOR_DBSNP_RS,ONCOTATOR_REFSEQ_MRNA_ID,ONCOTATOR_CODON_CHANGE,ONCOTATOR_UNIPROT_ENTRY_NAME,ONCOTATOR_UNIPROT_ACCESSION,ONCOTATOR_PROTEIN_POS_START,ONCOTATOR_PROTEIN_POS_END,CANONICAL_TRANSCRIPT,KEYWORD) VALUES (1000,2064,'NA',-1,-1,'NA','','ERBB2-TEST Fusion','Fusion','NA',-1,'NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA',-1,-1,1,'ERBB2-TEST Fusion'); INSERT INTO alteration_driver_annotation (ALTERATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID, DRIVER_FILTER, DRIVER_FILTER_ANNOTATION, DRIVER_TIERS_FILTER, DRIVER_TIERS_FILTER_ANNOTATION) VALUES (2038,6,6, 'Putative_Driver', 'Pathogenic', 'Tier 1', 'Highly Actionable'); INSERT INTO alteration_driver_annotation (ALTERATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID, DRIVER_FILTER, DRIVER_FILTER_ANNOTATION, DRIVER_TIERS_FILTER, DRIVER_TIERS_FILTER_ANNOTATION) VALUES (22604,6,6, 'Putative_Passenger', 'Pathogenic', 'Tier 2', 'Potentially Actionable'); @@ -151,7 +150,6 @@ INSERT INTO mutation (MUTATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID,ENTREZ_GENE INSERT INTO mutation (MUTATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID,ENTREZ_GENE_ID,CENTER,SEQUENCER,MUTATION_STATUS,VALIDATION_STATUS,TUMOR_SEQ_ALLELE1,TUMOR_SEQ_ALLELE2,MATCHED_NORM_SAMPLE_BARCODE,MATCH_NORM_SEQ_ALLELE1,MATCH_NORM_SEQ_ALLELE2,TUMOR_VALIDATION_ALLELE1,TUMOR_VALIDATION_ALLELE2,MATCH_NORM_VALIDATION_ALLELE1,MATCH_NORM_VALIDATION_ALLELE2,VERIFICATION_STATUS,SEQUENCING_PHASE,SEQUENCE_SOURCE,VALIDATION_METHOD,SCORE,BAM_FILE,TUMOR_ALT_COUNT,TUMOR_REF_COUNT,NORMAL_ALT_COUNT,NORMAL_REF_COUNT,AMINO_ACID_CHANGE,ANNOTATION_JSON) VALUES (2041,6,2,207,'genome.wustl.edu','IlluminaGAIIx','Germline','Unknown','A','C','TCGA-A1-A0SH-10A-03D-A099-09','A','C','NA','NA','NA','NA','Unknown','Phase_IV','Capture','NA','1','dbGAP',0,-1,-1,-1,'cyclases/Protein','{"zygosity":{"status": "heterozygous"}}'); INSERT INTO mutation (MUTATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID,ENTREZ_GENE_ID,CENTER,SEQUENCER,MUTATION_STATUS,VALIDATION_STATUS,TUMOR_SEQ_ALLELE1,TUMOR_SEQ_ALLELE2,MATCHED_NORM_SAMPLE_BARCODE,MATCH_NORM_SEQ_ALLELE1,MATCH_NORM_SEQ_ALLELE2,TUMOR_VALIDATION_ALLELE1,TUMOR_VALIDATION_ALLELE2,MATCH_NORM_VALIDATION_ALLELE1,MATCH_NORM_VALIDATION_ALLELE2,VERIFICATION_STATUS,SEQUENCING_PHASE,SEQUENCE_SOURCE,VALIDATION_METHOD,SCORE,BAM_FILE,TUMOR_ALT_COUNT,TUMOR_REF_COUNT,NORMAL_ALT_COUNT,NORMAL_REF_COUNT,AMINO_ACID_CHANGE,ANNOTATION_JSON) VALUES (2042,6,3,208,'genome.wustl.edu','IlluminaGAIIx','Germline','Unknown','T','T','TCGA-A1-A0SO-10A-03D-A099-09','T','T','NA','NA','NA','NA','Unknown','Phase_IV','Capture','NA','1','dbGAP',-1,-1,-1,-1,'cyclases/Protein','{"zygosity":{"status": "heterozygous"}}'); INSERT INTO mutation (MUTATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID,ENTREZ_GENE_ID,CENTER,SEQUENCER,MUTATION_STATUS,VALIDATION_STATUS,TUMOR_SEQ_ALLELE1,TUMOR_SEQ_ALLELE2,MATCHED_NORM_SAMPLE_BARCODE,MATCH_NORM_SEQ_ALLELE1,MATCH_NORM_SEQ_ALLELE2,TUMOR_VALIDATION_ALLELE1,TUMOR_VALIDATION_ALLELE2,MATCH_NORM_VALIDATION_ALLELE1,MATCH_NORM_VALIDATION_ALLELE2,VERIFICATION_STATUS,SEQUENCING_PHASE,SEQUENCE_SOURCE,VALIDATION_METHOD,SCORE,BAM_FILE,TUMOR_ALT_COUNT,TUMOR_REF_COUNT,NORMAL_ALT_COUNT,NORMAL_REF_COUNT,AMINO_ACID_CHANGE,ANNOTATION_JSON) VALUES (2042,8,15,208,'genome.wustl.edu','IlluminaGAIIx','Germline','Unknown','T','T','TCGA-A1-A0SO-10A-03D-A099-09','T','T','NA','NA','NA','NA','Unknown','Phase_IV','Capture','NA','1','dbGAP',-1,-1,-1,-1,'cyclases/Protein','{"zygosity":{"status": "heterozygous"}}'); -INSERT INTO mutation (MUTATION_EVENT_ID,GENETIC_PROFILE_ID,SAMPLE_ID,ENTREZ_GENE_ID,CENTER,SEQUENCER,MUTATION_STATUS,VALIDATION_STATUS,TUMOR_SEQ_ALLELE1,TUMOR_SEQ_ALLELE2,MATCHED_NORM_SAMPLE_BARCODE,MATCH_NORM_SEQ_ALLELE1,MATCH_NORM_SEQ_ALLELE2,TUMOR_VALIDATION_ALLELE1,TUMOR_VALIDATION_ALLELE2,MATCH_NORM_VALIDATION_ALLELE1,MATCH_NORM_VALIDATION_ALLELE2,VERIFICATION_STATUS,SEQUENCING_PHASE,SEQUENCE_SOURCE,VALIDATION_METHOD,SCORE,BAM_FILE,TUMOR_ALT_COUNT,TUMOR_REF_COUNT,NORMAL_ALT_COUNT,NORMAL_REF_COUNT,AMINO_ACID_CHANGE,ANNOTATION_JSON) VALUES (1000,6,7,2064,'uranus','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA','NA',-1,-1,-1,-1,'','{"zygosity":{"status": "heterozygous"}}'); INSERT INTO gene_panel (INTERNAL_ID,STABLE_ID,DESCRIPTION) VALUES (1,'TESTPANEL1','A test panel consisting of a few genes'); INSERT INTO gene_panel (INTERNAL_ID,STABLE_ID,DESCRIPTION) VALUES (2,'TESTPANEL2','Another test panel consisting of a few genes'); diff --git a/service/src/main/java/org/cbioportal/service/AlterationCountService.java b/service/src/main/java/org/cbioportal/service/AlterationCountService.java index dd9a22221bd..a9107445b56 100644 --- a/service/src/main/java/org/cbioportal/service/AlterationCountService.java +++ b/service/src/main/java/org/cbioportal/service/AlterationCountService.java @@ -13,14 +13,12 @@ Pair, Long> getSampleAlterationCounts(List entrezGeneIds, boolean includeFrequency, boolean includeMissingAlterationsFromGenePanel, - QueryElement searchFusions, AlterationFilter alterationFilter); Pair, Long> getPatientAlterationCounts(List molecularProfileCaseIdentifiers, Select entrezGeneIds, boolean includeFrequency, boolean includeMissingAlterationsFromGenePanel, - QueryElement searchFusions, AlterationFilter alterationFilter); Pair, Long> getSampleMutationCounts(List molecularProfileCaseIdentifiers, diff --git a/service/src/main/java/org/cbioportal/service/MutationService.java b/service/src/main/java/org/cbioportal/service/MutationService.java index ef5346f0bd8..4f5b1f5d65f 100644 --- a/service/src/main/java/org/cbioportal/service/MutationService.java +++ b/service/src/main/java/org/cbioportal/service/MutationService.java @@ -44,16 +44,4 @@ MutationMeta fetchMetaMutationsInMolecularProfile(String molecularProfileId, Lis List fetchMutationCountsByPosition(List entrezGeneIds, List proteinPosStarts, List proteinPosEnds); - - // TODO: cleanup once fusion/structural data is fixed in database - List getFusionsInMultipleMolecularProfiles(List molecularProfileIds, List sampleIds, - List entrezGeneIds, String projection, Integer pageSize, Integer pageNumber, String sortBy, - String direction); - - List getFusionsInMultipleMolecularProfilesByGeneQueries(List molecularProfileIds, List sampleIds, - List geneQueries, - String projection, Integer pageSize, Integer pageNumber, - String sortBy, String direction); - - // TODO: cleanup once fusion/structural data is fixed in database } diff --git a/service/src/main/java/org/cbioportal/service/impl/AlterationCountServiceImpl.java b/service/src/main/java/org/cbioportal/service/impl/AlterationCountServiceImpl.java index 9e1affac937..0c08a4f1bbb 100644 --- a/service/src/main/java/org/cbioportal/service/impl/AlterationCountServiceImpl.java +++ b/service/src/main/java/org/cbioportal/service/impl/AlterationCountServiceImpl.java @@ -37,11 +37,10 @@ public Pair, Long> getSampleAlterationCounts(List entrezGeneIds, boolean includeFrequency, boolean includeMissingAlterationsFromGenePanel, - QueryElement searchFusions, AlterationFilter alterationFilter) { Function, List> dataFetcher = profileCaseIdentifiers -> - alterationRepository.getSampleAlterationCounts(new TreeSet<>(profileCaseIdentifiers), entrezGeneIds, searchFusions, alterationFilter); + alterationRepository.getSampleAlterationCounts(new TreeSet<>(profileCaseIdentifiers), entrezGeneIds, alterationFilter); BiFunction, List, Long> includeFrequencyFunction = (a, b) -> alterationEnrichmentUtil.includeFrequencyForSamples(a, b, includeMissingAlterationsFromGenePanel); @@ -61,11 +60,10 @@ public Pair, Long> getPatientAlterationCounts(List entrezGeneIds, boolean includeFrequency, boolean includeMissingAlterationsFromGenePanel, - QueryElement searchFusions, AlterationFilter alterationFilter) { Function, List> dataFetcher = profileCaseIdentifiers -> - alterationRepository.getPatientAlterationCounts(profileCaseIdentifiers, entrezGeneIds, searchFusions, alterationFilter); + alterationRepository.getPatientAlterationCounts(profileCaseIdentifiers, entrezGeneIds, alterationFilter); BiFunction, List, Long> includeFrequencyFunction = (a, b) -> alterationEnrichmentUtil.includeFrequencyForPatients(a, b, includeMissingAlterationsFromGenePanel); @@ -90,7 +88,6 @@ public Pair, Long> getSampleMutationCounts(List, Long> getPatientMutationCounts(List, Long> getSampleStructuralVariantCounts( entrezGeneIds, includeFrequency, includeMissingAlterationsFromGenePanel, - QueryElement.ACTIVE, alterationFilter ); } @@ -134,7 +129,6 @@ public Pair, Long> getPatientStructuralVariantCounts entrezGeneIds, includeFrequency, includeMissingAlterationsFromGenePanel, - QueryElement.ACTIVE, alterationFilter ); } @@ -226,12 +220,7 @@ private Pair, Long> getAlterationCount if (molecularProfileCaseIdentifiers.isEmpty()) { alterationCountByGenes = Collections.emptyList(); } else { - Set updatedProfileCaseIdentifiers = molecularProfileCaseIdentifiers - .stream() - .peek(molecularProfileCaseIdentifier -> molecularProfileCaseIdentifier.setMolecularProfileId(molecularProfileUtil.replaceFusionProfileWithMutationProfile(molecularProfileCaseIdentifier.getMolecularProfileId()))) - .collect(Collectors.toSet()); - - Set molecularProfileIds = updatedProfileCaseIdentifiers + Set molecularProfileIds = molecularProfileCaseIdentifiers .stream() .map(MolecularProfileCaseIdentifier::getMolecularProfileId) .collect(Collectors.toSet()); @@ -242,7 +231,7 @@ private Pair, Long> getAlterationCount Map totalResult = new HashMap<>(); - updatedProfileCaseIdentifiers + molecularProfileCaseIdentifiers .stream() .collect(Collectors .groupingBy(identifier -> molecularProfileIdStudyIdMap.get(identifier.getMolecularProfileId()))) diff --git a/service/src/main/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImpl.java b/service/src/main/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImpl.java index f75472999f2..2ceb6e5b6f7 100644 --- a/service/src/main/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImpl.java +++ b/service/src/main/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImpl.java @@ -52,7 +52,6 @@ public Map, Long>> getAlterationCountsb Select.all(), true, true, - QueryElement.PASS, alterationFilter); } else { return alterationCountService @@ -61,7 +60,6 @@ public Map, Long>> getAlterationCountsb Select.all(), true, true, - QueryElement.PASS, alterationFilter); } })); diff --git a/service/src/main/java/org/cbioportal/service/impl/GenePanelServiceImpl.java b/service/src/main/java/org/cbioportal/service/impl/GenePanelServiceImpl.java index 42e9ab6f63a..c2d9533986b 100644 --- a/service/src/main/java/org/cbioportal/service/impl/GenePanelServiceImpl.java +++ b/service/src/main/java/org/cbioportal/service/impl/GenePanelServiceImpl.java @@ -32,9 +32,7 @@ public class GenePanelServiceImpl implements GenePanelService { private MolecularProfileUtil molecularProfileUtil; private final String SEQUENCED_LIST_SUFFIX = "_sequenced"; - //TODO: remove once fusions are migrated to SV - //temporary case list to fix profiled fusions for genie study - private final String FUSION_LIST_SUFFIX = "_fusion"; + private final Function SAMPLE_IDENTIFIER_GENERATOR = d -> d.getMolecularProfileId() + d.getSampleId(); private final Function PATIENT_IDENTIFIER_GENERATOR = d -> d.getMolecularProfileId() + d.getPatientId(); @@ -96,26 +94,12 @@ public List fetchGenePanels(List genePanelIds, String project public List getGenePanelData(String molecularProfileId, String sampleListId) throws MolecularProfileNotFoundException { - // replace fusion profile id with mutation, as all the fusions are in mutation table - // and are imported with mutation profile id - // TODO: remove replacing logic once the fusions are migrated to structural variant in database - MolecularProfile molecularProfile = molecularProfileService - .getMolecularProfile(molecularProfileUtil.replaceFusionProfileWithMutationProfile(molecularProfileId)); + MolecularProfile molecularProfile = molecularProfileService.getMolecularProfile(molecularProfileId); List genePanelData = genePanelRepository .getGenePanelDataBySampleListId(molecularProfile.getStableId(), sampleListId); - genePanelData = annotateDataFromSequencedSampleLists(genePanelData, molecularProfile); - - // TODO: remove this block after fusion are migrated to structural variant in database - if (molecularProfileId.endsWith(molecularProfileUtil.FUSION_PROFILE_SUFFIX)) { - genePanelData = genePanelData - .stream() - .map(datum -> transformMutationToFusionPanelData(molecularProfileId, datum)) - .collect(toList()); - } - - return genePanelData; + return annotateDataFromSequencedSampleLists(genePanelData, molecularProfile); } @Override @@ -135,13 +119,10 @@ public List fetchGenePanelDataByMolecularProfileIds(Set m List molecularProfiles = molecularProfileService .getMolecularProfiles(molecularProfileIds, "SUMMARY"); - - // replace fusion profile id with mutation, as all the fusions are in mutation table - // and are imported with mutation profile id - // TODO: remove replacing logic once the fusions are migrated to structural variant in database + Set uniqueMolecularProfileIds = molecularProfiles .stream() - .map(profile -> molecularProfileUtil.replaceFusionProfileWithMutationProfile(profile.getStableId())) + .map(MolecularProfile::getStableId) .collect(toSet()); Map> molecularProfileIdToGenePanelDataMap = uniqueMolecularProfileIds @@ -157,18 +138,8 @@ public List fetchGenePanelDataByMolecularProfileIds(Set m return molecularProfileIds .stream() .flatMap(profileId -> { - List genePanelData; - // TODO: remove replacing logic once the fusions are migrated to structural variant in database - if (profileId.endsWith(molecularProfileUtil.FUSION_PROFILE_SUFFIX)) { - genePanelData = molecularProfileIdToGenePanelDataMap - .getOrDefault(molecularProfileUtil.replaceFusionProfileWithMutationProfile(profileId), new ArrayList<>()) - .stream() - .map(datum -> transformMutationToFusionPanelData(profileId, datum)) - .collect(toList()); - } else { - genePanelData = molecularProfileIdToGenePanelDataMap - .getOrDefault(profileId, new ArrayList<>()); - } + List genePanelData = molecularProfileIdToGenePanelDataMap + .getOrDefault(profileId, new ArrayList<>()); if(CollectionUtils.isNotEmpty(genePanelData)) { genePanelData = annotateDataFromSequencedSampleLists(genePanelData, molecularProfileIdMap.get(profileId)); } @@ -210,7 +181,7 @@ private List getGenePanelData(List getGenePanelData(List annotateDataFromSequencedSampleLists(List genePanelData, MolecularProfile molecularProfile) { - // This is a temporary logic until fusions are completely migrated to SV - // If it is fusion profile - use "_fusion" case-lists if it exists - // If case-lists does not exists then use data from mutation profile - //TODO: update once fusions are migrated to SV - if(MolecularProfile.MolecularAlterationType.FUSION.equals(molecularProfile.getMolecularAlterationType())|| - (MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT.equals(molecularProfile.getMolecularAlterationType()) && - molecularProfile.getDatatype().equalsIgnoreCase("FUSION"))) { - try { - SampleList sampleList = sampleListService.getSampleList(molecularProfile.getCancerStudyIdentifier() + FUSION_LIST_SUFFIX); - Map sampleSequencedBySampleList = sampleList - .getSampleIds() - .stream() - .collect(toMap(Function.identity(), d -> true)); - return genePanelData - .stream() - .peek(datum -> { - datum.setProfiled(sampleSequencedBySampleList.getOrDefault(datum.getSampleId(), false)); - }) - .collect(toList()); - - } catch (SampleListNotFoundException ignored) {} - } - - if (MolecularProfile.MolecularAlterationType.MUTATION_EXTENDED.equals(molecularProfile.getMolecularAlterationType()) || - MolecularProfile.MolecularAlterationType.FUSION.equals(molecularProfile.getMolecularAlterationType()) || - (MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT.equals(molecularProfile.getMolecularAlterationType()) && - molecularProfile.getDatatype().equalsIgnoreCase("FUSION"))) { + if (MolecularProfile.MolecularAlterationType.MUTATION_EXTENDED.equals(molecularProfile.getMolecularAlterationType())) { try { SampleList sampleList = sampleListService.getSampleList(molecularProfile.getCancerStudyIdentifier() + SEQUENCED_LIST_SUFFIX); Map sampleSequencedBySampleList = sampleList @@ -266,15 +211,4 @@ private List annotateDataFromSequencedSampleLists(List getFusionsInMultipleMolecularProfiles(List molecularProfileIds, - List sampleIds, List entrezGeneIds, String projection, Integer pageSize, - Integer pageNumber, String sortBy, String direction) { - - List mutationList = mutationRepository.getFusionsInMultipleMolecularProfiles(molecularProfileIds, - sampleIds, entrezGeneIds, projection, pageSize, pageNumber, sortBy, direction); - - return mutationList; - } - - @Override - public List getFusionsInMultipleMolecularProfilesByGeneQueries(List molecularProfileIds, List sampleIds, - List geneQueries, String projection, - Integer pageSize, Integer pageNumber, - String sortBy, String direction) { - - List mutationList = mutationRepository.getFusionsInMultipleMolecularProfilesByGeneQueries(molecularProfileIds, sampleIds, - geneQueries, projection, pageSize, pageNumber, sortBy, direction); - - return mutationList; - } - // TODO: cleanup once fusion/structural data is fixed in database } diff --git a/service/src/main/java/org/cbioportal/service/impl/SampleServiceImpl.java b/service/src/main/java/org/cbioportal/service/impl/SampleServiceImpl.java index 2cc62eddc31..7d66d873b70 100644 --- a/service/src/main/java/org/cbioportal/service/impl/SampleServiceImpl.java +++ b/service/src/main/java/org/cbioportal/service/impl/SampleServiceImpl.java @@ -227,21 +227,6 @@ private void processSamples(List samples, String projection) { sample.setSequenced(sequencedSampleIdsMap.get(sample.getCancerStudyIdentifier()) .contains(sample.getStableId())); sample.setCopyNumberSegmentPresent(samplesWithCopyNumberSegMap.contains(sample.getInternalId())); - if (studiesProfiledWithSVs.contains(sample.getCancerStudyIdentifier())) { - if (!structuralVariantSampleIdsMap.get(sample.getCancerStudyIdentifier()).isEmpty()) { - sample.setProfiledForFusions(structuralVariantSampleIdsMap.get(sample.getCancerStudyIdentifier()).contains(sample.getStableId())); - } else { - /* - * TODO: Eventually all studies with STRUCTURAL_VARIANT data should have case lists, - * so there should always be an entry in `structuralVariantSampleIdsMap`. This case is - * to support old `FUSION` data in the mutations table that don't have case lists. In that - * case we assume any sample that has been sequenced to have been profiled for fusions as well - */ - sample.setProfiledForFusions(sequencedSampleIdsMap.get(sample.getCancerStudyIdentifier()).contains(sample.getStableId())); - } - } else { - sample.setProfiledForFusions(false); - } }); } } diff --git a/service/src/main/java/org/cbioportal/service/impl/StructuralVariantServiceImpl.java b/service/src/main/java/org/cbioportal/service/impl/StructuralVariantServiceImpl.java index 2469244699d..d984f55a501 100644 --- a/service/src/main/java/org/cbioportal/service/impl/StructuralVariantServiceImpl.java +++ b/service/src/main/java/org/cbioportal/service/impl/StructuralVariantServiceImpl.java @@ -23,102 +23,28 @@ package org.cbioportal.service.impl; -import org.apache.commons.collections4.CollectionUtils; import org.cbioportal.model.GeneFilterQuery; import org.cbioportal.model.StructuralVariant; -import org.cbioportal.persistence.MutationRepository; import org.cbioportal.persistence.StructuralVariantRepository; import org.cbioportal.service.StructuralVariantService; -import org.cbioportal.service.util.MolecularProfileUtil; -import org.cbioportal.service.util.MutationMapperUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.cbioportal.model.MolecularProfile; -import org.cbioportal.persistence.MolecularProfileRepository; + +import java.util.List; @Service public class StructuralVariantServiceImpl implements StructuralVariantService { @Autowired private StructuralVariantRepository structuralVariantRepository; - @Autowired - private MutationRepository mutationRepository; - @Autowired - private MutationMapperUtils mutationMapperUtils; - @Autowired - private MolecularProfileUtil molecularProfileUtil; - @Autowired - private MolecularProfileRepository molecularProfileRepository; @Override public List fetchStructuralVariants(List molecularProfileIds, List sampleIds, List entrezGeneIds) { - List structuralVariantMolecularProfileIds = new ArrayList<>(); - List structuralVariantSampleIds = new ArrayList<>(); - - List fusionVariantMolecularProfileIds = new ArrayList<>(); - List fusionVariantSampleIds = new ArrayList<>(); - Map molecularProfileIdReplaceMap = new HashMap<>(); - - // TODO: Remove once fusions are removed from mutation table - Map molecularProfileMap = new HashMap<>(); - - // TODO: Remove once fusions are removed from mutation table - for (int i = 0; i < molecularProfileIds.size(); i++) { - String molecularProfileId = molecularProfileIds.get(i); - if (molecularProfileId.endsWith(molecularProfileUtil.STRUCTURAL_VARIANT_PROFILE_SUFFIX)) { - structuralVariantMolecularProfileIds.add(molecularProfileId); - if (CollectionUtils.isNotEmpty(sampleIds)) { - structuralVariantSampleIds.add(sampleIds.get(i)); - } - } else if (molecularProfileId.endsWith(molecularProfileUtil.FUSION_PROFILE_SUFFIX)) { - String mutationMolecularProfileId = molecularProfileUtil.replaceFusionProfileWithMutationProfile(molecularProfileId); - molecularProfileIdReplaceMap.put(mutationMolecularProfileId, molecularProfileId); - fusionVariantMolecularProfileIds.add(mutationMolecularProfileId); - if (CollectionUtils.isNotEmpty(sampleIds)) { - fusionVariantSampleIds.add(sampleIds.get(i)); - } - } else if (molecularProfileId.endsWith(molecularProfileUtil.MUTATION_PROFILE_SUFFIX)) { - if (!molecularProfileMap.containsKey(molecularProfileId)) { - molecularProfileMap.put(molecularProfileId, - molecularProfileRepository.getMolecularProfile(molecularProfileId)); - } - MolecularProfile mp = molecularProfileMap.get(molecularProfileId); - if (mp.getDatatype().equals(molecularProfileUtil.FUSIONS_AS_MUTATIONS_DATATYPE)) { - String mutationMolecularProfileId = molecularProfileUtil.replaceFusionProfileWithMutationProfile(molecularProfileId); - molecularProfileIdReplaceMap.put(mutationMolecularProfileId, molecularProfileId); - fusionVariantMolecularProfileIds.add(mutationMolecularProfileId); - if (CollectionUtils.isNotEmpty(sampleIds)) { - fusionVariantSampleIds.add(sampleIds.get(i)); - } - } - } - } - - List structuralVariants = new ArrayList<>(); - List variantsFromMutationtable = new ArrayList<>(); - - if (CollectionUtils.isNotEmpty(structuralVariantMolecularProfileIds)) { - structuralVariants = structuralVariantRepository.fetchStructuralVariants( - structuralVariantMolecularProfileIds, structuralVariantSampleIds, entrezGeneIds); - } - - if (CollectionUtils.isNotEmpty(fusionVariantMolecularProfileIds)) { - variantsFromMutationtable = mutationMapperUtils.mapFusionsToStructuralVariants( - mutationRepository.getFusionsInMultipleMolecularProfiles(fusionVariantMolecularProfileIds, - fusionVariantSampleIds, entrezGeneIds, "DETAILED", null, null, null, null), - molecularProfileIdReplaceMap, CollectionUtils.isEmpty(entrezGeneIds)); - } - - // TODO: Remove once fusions are removed from mutation table - - return Stream.concat(structuralVariants.stream(), variantsFromMutationtable.stream()) - .collect(Collectors.toList()); + return structuralVariantRepository.fetchStructuralVariants( + molecularProfileIds, sampleIds, entrezGeneIds); } @Override @@ -126,67 +52,8 @@ public List fetchStructuralVariantsByGeneQueries(List List sampleIds, List geneQueries) { - List structuralVariantMolecularProfileIds = new ArrayList(); - List structuralVariantSampleIds = new ArrayList(); - - List fusionVariantMolecularProfileIds = new ArrayList(); - List fusionVariantSampleIds = new ArrayList(); - Map molecularProfileIdReplaceMap = new HashMap<>(); - - // TODO: Remove once fusions are removed from mutation table - Map molecularProfileMap = new HashMap<>(); - - // TODO: Remove once fusions are removed from mutation table - for (int i = 0; i < molecularProfileIds.size(); i++) { - String molecularProfileId = molecularProfileIds.get(i); - if (molecularProfileId.endsWith(molecularProfileUtil.STRUCTURAL_VARIANT_PROFILE_SUFFIX)) { - structuralVariantMolecularProfileIds.add(molecularProfileId); - if (CollectionUtils.isNotEmpty(sampleIds)) { - structuralVariantSampleIds.add(sampleIds.get(i)); - } - } else if (molecularProfileId.endsWith(molecularProfileUtil.FUSION_PROFILE_SUFFIX)) { - String mutationMolecularProfileId = molecularProfileUtil.replaceFusionProfileWithMutationProfile(molecularProfileId); - molecularProfileIdReplaceMap.put(mutationMolecularProfileId, molecularProfileId); - fusionVariantMolecularProfileIds.add(molecularProfileId); - if (CollectionUtils.isNotEmpty(sampleIds)) { - fusionVariantSampleIds.add(sampleIds.get(i)); - } - } else if (molecularProfileId.endsWith(molecularProfileUtil.MUTATION_PROFILE_SUFFIX)) { - if (!molecularProfileMap.containsKey(molecularProfileId)) { - molecularProfileMap.put(molecularProfileId, - molecularProfileRepository.getMolecularProfile(molecularProfileId)); - } - MolecularProfile mp = molecularProfileMap.get(molecularProfileId); - if (mp.getDatatype().equals(molecularProfileUtil.FUSIONS_AS_MUTATIONS_DATATYPE)) { - String mutationMolecularProfileId = molecularProfileUtil.replaceFusionProfileWithMutationProfile(molecularProfileId); - molecularProfileIdReplaceMap.put(mutationMolecularProfileId, molecularProfileId); - fusionVariantMolecularProfileIds.add(mutationMolecularProfileId); - if (CollectionUtils.isNotEmpty(sampleIds)) { - fusionVariantSampleIds.add(sampleIds.get(i)); - } - } - } - } - - List structuralVariants = new ArrayList<>(); - List variantsFromMutationtable = new ArrayList<>(); - - if (CollectionUtils.isNotEmpty(structuralVariantMolecularProfileIds)) { - structuralVariants = structuralVariantRepository.fetchStructuralVariantsByGeneQueries( - structuralVariantMolecularProfileIds, structuralVariantSampleIds, geneQueries); - } - - if (CollectionUtils.isNotEmpty(fusionVariantMolecularProfileIds)) { - variantsFromMutationtable = mutationMapperUtils.mapFusionsToStructuralVariants( - mutationRepository.getFusionsInMultipleMolecularProfilesByGeneQueries(fusionVariantMolecularProfileIds, - fusionVariantSampleIds, geneQueries, "DETAILED", null, null, null, null), - molecularProfileIdReplaceMap, CollectionUtils.isEmpty(geneQueries)); - } - - // TODO: Remove once fusions are removed from mutation table - - return Stream.concat(structuralVariants.stream(), variantsFromMutationtable.stream()) - .collect(Collectors.toList()); + return structuralVariantRepository.fetchStructuralVariantsByGeneQueries( + molecularProfileIds, sampleIds, geneQueries); } } diff --git a/service/src/main/java/org/cbioportal/service/util/MolecularProfileUtil.java b/service/src/main/java/org/cbioportal/service/util/MolecularProfileUtil.java index f71a330e87a..cfd80d4f28d 100644 --- a/service/src/main/java/org/cbioportal/service/util/MolecularProfileUtil.java +++ b/service/src/main/java/org/cbioportal/service/util/MolecularProfileUtil.java @@ -15,16 +15,10 @@ public class MolecularProfileUtil { public final String MUTATION_PROFILE_SUFFIX = "_mutations"; - public final String FUSION_PROFILE_SUFFIX = "_fusion"; public final String STRUCTURAL_VARIANT_PROFILE_SUFFIX = "_structural_variants"; - public final String FUSIONS_AS_MUTATIONS_DATATYPE = "FUSION"; - // TODO: Remove once fusions are removed from mutation table public Predicate isStructuralVariantMolecularProfile = - m -> m.getMolecularAlterationType().equals(MolecularProfile.MolecularAlterationType.FUSION) || - m.getMolecularAlterationType().equals(MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT) || - (m.getMolecularAlterationType().equals(MolecularProfile.MolecularAlterationType.MUTATION_EXTENDED) - && m.getDatatype().equals(FUSIONS_AS_MUTATIONS_DATATYPE)); + m -> m.getMolecularAlterationType().equals(MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT); public Predicate isDiscreteCNAMolecularProfile = m -> m.getMolecularAlterationType().equals(MolecularProfile.MolecularAlterationType.COPY_NUMBER_ALTERATION) && @@ -73,42 +67,8 @@ private Map> getFilteredMolecularProfilesByStudyI if (profileFilter.isPresent()) { molecularProfileStream = molecularProfileStream.filter(profileFilter.get()); } - Map> studyMolecularProfilesSet = molecularProfileStream - .collect(Collectors.groupingBy(MolecularProfile::getCancerStudyIdentifier)) - .entrySet().stream().collect(Collectors.toMap( - Map.Entry::getKey, - entry -> { - List profilesToReturn = new ArrayList<>(); - MolecularProfile structuralVariantProfile = null; - for (MolecularProfile molecularProfile : entry.getValue()) { - if (molecularProfile.getMolecularAlterationType().equals(MolecularProfile.MolecularAlterationType.FUSION) - || molecularProfile.getMolecularAlterationType() - .equals(MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT)) { - if (structuralVariantProfile == null) { - structuralVariantProfile = molecularProfile; - } else if (!(molecularProfile.getMolecularAlterationType() - .equals(MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT) - && molecularProfile.getDatatype().equals("SV"))) { - // replace structural variant profile with - // mutation profile having fusion data - structuralVariantProfile = molecularProfile; - } - } else { - profilesToReturn.add(molecularProfile); - } - } - - if (structuralVariantProfile != null) { - profilesToReturn.add(structuralVariantProfile); - } - - return profilesToReturn; - })); - return studyMolecularProfilesSet; - } - - public String replaceFusionProfileWithMutationProfile(String profileId) { - return profileId.replace(FUSION_PROFILE_SUFFIX, MUTATION_PROFILE_SUFFIX); + return molecularProfileStream + .collect(Collectors.groupingBy(MolecularProfile::getCancerStudyIdentifier)); } } diff --git a/service/src/main/java/org/cbioportal/service/util/MutationMapperUtils.java b/service/src/main/java/org/cbioportal/service/util/MutationMapperUtils.java deleted file mode 100644 index 20ec85bb844..00000000000 --- a/service/src/main/java/org/cbioportal/service/util/MutationMapperUtils.java +++ /dev/null @@ -1,191 +0,0 @@ -package org.cbioportal.service.util; - -import org.apache.commons.lang3.EnumUtils; -import org.apache.commons.lang3.tuple.Triple; -import org.cbioportal.model.Gene; -import org.cbioportal.model.Mutation; -import org.cbioportal.model.StructuralVariant; -import org.cbioportal.service.GeneService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.*; -import java.util.function.Function; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -@Component -public class MutationMapperUtils { - - // gene symbols containing "-" is not considered in the pattern - private final String PROTEIN_CHANGE_REGEX = "^([a-zA-Z0-9_.]+)(?:(?:-|_|\\s)([a-zA-Z0-9_.]+)(?:\\s+(\\w+))?)?$"; - private final Pattern PROTEIN_CHANGE_PATTERN = Pattern.compile(PROTEIN_CHANGE_REGEX); - @Autowired - private GeneService geneService; - - public List mapFusionsToStructuralVariants(List fusions, - Map molecularProfileIdReplaceMap, Boolean filterByProteinChange) { - - List filteredFusions = fusions; - - if (filterByProteinChange) { - Map uniqueFusionMap = new HashMap(); - fusions.forEach(fusion -> { - String uniqueKey = fusion.getStudyId() + fusion.getSampleId() + fusion.getProteinChange(); - // Only consider unique protein changes for the study-sample and - // also first preference for fusions where protein change starts - // with the gene as there are duplicate records for both the genes in protein changes. - if (!uniqueFusionMap.containsKey(uniqueKey) - || fusion.getProteinChange().toUpperCase().startsWith(fusion.getGene().getHugoGeneSymbol())) { - uniqueFusionMap.put(uniqueKey, fusion); - } - }); - filteredFusions = uniqueFusionMap.values().stream().collect(Collectors.toList()); - } - - Set geneSymbolsFromProteinChange = filteredFusions - .stream() - .filter(fusion -> fusion.getProteinChange() != null && - !fusion.getProteinChange().equalsIgnoreCase("Fusion") && - !fusion.getProteinChange().equalsIgnoreCase("SV")) - .flatMap(fusion -> { - Triple result = extractInformationFromProteinChange(fusion.getProteinChange()); - List symbols = new ArrayList<>(); - if (result.getLeft() != null) { - symbols.add(result.getLeft()); // add gene1 - } - if (result.getMiddle() != null) { - symbols.add(result.getMiddle()); // add gene2 - } - return symbols.stream(); - }) - .collect(Collectors.toSet()); - - Map geneByHugoGeneSymbol = geneService - .fetchGenes(new ArrayList<>(geneSymbolsFromProteinChange), "HUGO_GENE_SYMBOL", null) - .stream() - .collect(Collectors.toMap(gene -> gene.getHugoGeneSymbol().toUpperCase(), Function.identity())); - - geneSymbolsFromProteinChange - .stream() - .filter(geneSymbol -> !geneByHugoGeneSymbol.containsKey(geneSymbol)) - .forEach(geneSymbol -> { - // check if geneSymbol is an alias - List aliasGenes = geneService.getAllGenes(null, geneSymbol, "null", - null, null, null, null); - if (!aliasGenes.isEmpty()) { - geneByHugoGeneSymbol.put(geneSymbol, aliasGenes.get(0)); - } - }); - - return filteredFusions.stream().map(fusion -> { - StructuralVariant structuralVariant = new StructuralVariant(); - - // Sample details - structuralVariant.setPatientId(fusion.getPatientId()); - structuralVariant.setSampleId(fusion.getSampleId()); - structuralVariant.setStudyId(fusion.getStudyId()); - structuralVariant.setMolecularProfileId(molecularProfileIdReplaceMap - .getOrDefault(fusion.getMolecularProfileId(), fusion.getMolecularProfileId())); - - // Fusion details - structuralVariant.setSite1EntrezGeneId(fusion.getEntrezGeneId()); - structuralVariant.setSite1HugoSymbol(fusion.getGene().getHugoGeneSymbol()); - structuralVariant.setSite1Chromosome(fusion.getChr()); - structuralVariant.setCenter(fusion.getCenter()); - structuralVariant.setSite1Position(fusion.getStartPosition().intValue()); - structuralVariant.setComments(fusion.getKeyword()); - structuralVariant.setNcbiBuild(fusion.getNcbiBuild()); - structuralVariant.setVariantClass(fusion.getMutationType()); - structuralVariant.setEventInfo(fusion.getProteinChange()); - if (fusion.getProteinChange() != null) { - String proteinChange = fusion.getProteinChange(); - // only parse proteinChange when its not Fusion or SV - if (!(proteinChange.equalsIgnoreCase("Fusion") || proteinChange.equalsIgnoreCase("SV"))) { - - Matcher matcher = PROTEIN_CHANGE_PATTERN.matcher(proteinChange); - Triple result = extractInformationFromProteinChange(fusion.getProteinChange()); - String site1GeneSymbol = result.getLeft(); - String site2GeneSymbol = result.getMiddle(); - VariantType variantType = result.getRight(); - - // only set site2Gene if its not null - if (site2GeneSymbol != null) { - if (fusion.getGene().getHugoGeneSymbol().equalsIgnoreCase(site1GeneSymbol) || - fusion.getGene().getHugoGeneSymbol().equalsIgnoreCase(site2GeneSymbol)) { - if (site1GeneSymbol.equalsIgnoreCase(site2GeneSymbol)) { - structuralVariant.setSite2EntrezGeneId(fusion.getEntrezGeneId()); - structuralVariant.setSite2HugoSymbol(fusion.getGene().getHugoGeneSymbol()); - } else { - Gene site1Gene = geneByHugoGeneSymbol.get(site1GeneSymbol); - // we need to pick the right gene since the fusion gene has been assigned to structural variant site1 - Gene pickedGene = null; - if (site1Gene != null && !site1Gene.getEntrezGeneId().equals(fusion.getEntrezGeneId())) { - pickedGene = site1Gene; - } else { - Gene site2Gene = geneByHugoGeneSymbol.get(site2GeneSymbol); - if (site2Gene != null && !site2Gene.getEntrezGeneId().equals(fusion.getEntrezGeneId())) { - pickedGene = site2Gene; - } - } - if (pickedGene != null) { - structuralVariant.setSite2EntrezGeneId(pickedGene.getEntrezGeneId()); - structuralVariant.setSite2HugoSymbol(pickedGene.getHugoGeneSymbol()); - } - } - } else { // if the queried gene is as alias gene in protein change - Gene site1Gene = geneByHugoGeneSymbol.get(site1GeneSymbol); - Gene site2Gene = geneByHugoGeneSymbol.get(site2GeneSymbol); - if (site1Gene != null && site2Gene != null) { // set site2Gene when both genes are valid - // and one of the site genes should match fusion gene - if (fusion.getGene().getHugoGeneSymbol().equalsIgnoreCase(site1Gene.getHugoGeneSymbol())) { - structuralVariant.setSite2EntrezGeneId(site2Gene.getEntrezGeneId()); - structuralVariant.setSite2HugoSymbol(site2Gene.getHugoGeneSymbol()); - } else if (fusion.getGene().getHugoGeneSymbol().equalsIgnoreCase(site2Gene.getHugoGeneSymbol())) { - structuralVariant.setSite2EntrezGeneId(site1Gene.getEntrezGeneId()); - structuralVariant.setSite2HugoSymbol(site1Gene.getHugoGeneSymbol()); - } - } - } - } - - if (variantType != null) { - structuralVariant.setVariantClass(variantType.getVariantType()); - } - } - } - return structuralVariant; - }).collect(Collectors.toList()); - } - - public Triple extractInformationFromProteinChange(String proteinChange) { - - Matcher matcher = PROTEIN_CHANGE_PATTERN.matcher(proteinChange.toUpperCase()); - String site1GeneSymbol = null; - String site2GeneSymbol = null; - VariantType variantType = null; - - if (matcher.find()) { - if (EnumUtils.isValidEnum(VariantType.class, matcher.group(1))) { - // if protein change contains only variant type. ex: INTRAGENIC - variantType = EnumUtils.getEnum(VariantType.class, matcher.group(1)); - - } else if (EnumUtils.isValidEnum(VariantType.class, matcher.group(2))) { - // this is in format of -. ex: TUFT1-intragenic - site1GeneSymbol = matcher.group(1); - variantType = EnumUtils.getEnum(VariantType.class, matcher.group(2)); - } else { - // this is in format of --. ex. - // ZSWIM4-SLC1A6 or ZNF595-TERT fusion - site1GeneSymbol = matcher.group(1); - site2GeneSymbol = matcher.group(2); - if (matcher.group(3) != null) { - variantType = EnumUtils.getEnum(VariantType.class, matcher.group(3)); - } - } - } - return Triple.of(site1GeneSymbol, site2GeneSymbol, variantType); - } - -} diff --git a/service/src/main/java/org/cbioportal/service/util/VariantType.java b/service/src/main/java/org/cbioportal/service/util/VariantType.java deleted file mode 100644 index 35aee484ac3..00000000000 --- a/service/src/main/java/org/cbioportal/service/util/VariantType.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.cbioportal.service.util; - -public enum VariantType { - FUSION("Fusion"), - TRUNCATION("Deletion"),//TRUNCATION is of type deletion in oncokb - TRANSLOCATION("Translocation"), - INVERSION("Inversion"), - DELETION("Deletion"), - DUPLICATION("Duplication"), - INTRAGENIC("Deletion");//INTRAGENIC is of type deletion in oncokb - - private String variantType; - - public String toString() { - return variantType; - } - - VariantType(String variantType) { - this.variantType = variantType; - } - - public String getVariantType() { - return variantType; - } -} diff --git a/service/src/test/java/org/cbioportal/service/impl/AlterationCountServiceImplTest.java b/service/src/test/java/org/cbioportal/service/impl/AlterationCountServiceImplTest.java index cfe64d4bc03..9a213c7efd9 100644 --- a/service/src/test/java/org/cbioportal/service/impl/AlterationCountServiceImplTest.java +++ b/service/src/test/java/org/cbioportal/service/impl/AlterationCountServiceImplTest.java @@ -88,7 +88,6 @@ public void getSampleAlterationCounts() { when(alterationRepository.getSampleAlterationCounts( new HashSet<>(caseIdentifiers), entrezGeneIds, - QueryElement.PASS, alterationFilter)).thenReturn(expectedCountByGeneList); Pair, Long> result = alterationCountService.getSampleAlterationCounts( @@ -96,7 +95,6 @@ public void getSampleAlterationCounts() { entrezGeneIds, includeFrequency, includeMissingAlterationsFromGenePanel, - QueryElement.PASS, alterationFilter); verify(alterationEnrichmentUtil, times(1)).includeFrequencyForSamples(anyList(), anyList(), anyBoolean()); @@ -110,7 +108,6 @@ public void getPatientAlterationCounts() { when(alterationRepository.getPatientAlterationCounts( caseIdentifiers, entrezGeneIds, - QueryElement.PASS, alterationFilter)).thenReturn(expectedCountByGeneList); Pair, Long> result = alterationCountService.getPatientAlterationCounts( @@ -118,7 +115,6 @@ public void getPatientAlterationCounts() { entrezGeneIds, includeFrequency, includeMissingAlterationsFromGenePanel, - QueryElement.PASS, alterationFilter); verify(alterationEnrichmentUtil, times(1)).includeFrequencyForPatients(anyList(), anyList(), anyBoolean()); @@ -131,7 +127,6 @@ public void getSampleMutationCounts() { when(alterationRepository.getSampleAlterationCounts( new HashSet<>(caseIdentifiers), entrezGeneIds, - QueryElement.INACTIVE, alterationFilter)).thenReturn(expectedCountByGeneList); Pair, Long> result = alterationCountService.getSampleMutationCounts( @@ -152,7 +147,6 @@ public void getPatientMutationCounts() throws MolecularProfileNotFoundException when(alterationRepository.getPatientAlterationCounts( caseIdentifiers, entrezGeneIds, - QueryElement.INACTIVE, alterationFilter)).thenReturn(expectedCountByGeneList); Pair, Long> result = alterationCountService.getPatientMutationCounts( @@ -166,51 +160,6 @@ public void getPatientMutationCounts() throws MolecularProfileNotFoundException } - @Test - public void getSampleFusionCounts() { - - QueryElement searchFusions = QueryElement.ACTIVE; - - // this mock tests correct argument types - when(alterationRepository.getSampleAlterationCounts( - new HashSet<>(caseIdentifiers), - entrezGeneIds, - searchFusions, - alterationFilter - )).thenReturn(expectedCountByGeneList); - - Pair, Long> result = alterationCountService.getSampleStructuralVariantCounts( - caseIdentifiers, - entrezGeneIds, - includeFrequency, - includeMissingAlterationsFromGenePanel, - alterationFilter); - - Assert.assertEquals(expectedCountByGeneList, result.getFirst()); - } - - @Test - public void getPatientFusionCounts() { - - QueryElement searchFusions = QueryElement.ACTIVE; - - // this mock tests correct argument types - when(alterationRepository.getPatientAlterationCounts( - caseIdentifiers, - entrezGeneIds, - searchFusions, - alterationFilter)).thenReturn(expectedCountByGeneList); - - Pair, Long> result = alterationCountService.getPatientStructuralVariantCounts( - caseIdentifiers, - entrezGeneIds, - includeFrequency, - includeMissingAlterationsFromGenePanel, - alterationFilter); - - Assert.assertEquals(expectedCountByGeneList, result.getFirst()); - } - @Test public void getSampleCnaCounts() { diff --git a/service/src/test/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImplTest.java b/service/src/test/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImplTest.java index 882fdc7198b..45d8740e8ae 100644 --- a/service/src/test/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImplTest.java +++ b/service/src/test/java/org/cbioportal/service/impl/AlterationEnrichmentServiceImplTest.java @@ -73,7 +73,7 @@ public void getAlterationEnrichments() throws Exception { for (String molecularProfileId : groupMolecularProfileCaseSets.keySet()) { Mockito.when(alterationCountService.getSampleAlterationCounts( groupMolecularProfileCaseSets.get(molecularProfileId), - Select.all(), true, true, QueryElement.PASS, alterationFilter) + Select.all(), true, true, alterationFilter) ).thenReturn(alterationSampleCountByGeneList); } diff --git a/service/src/test/java/org/cbioportal/service/impl/StructuralVariantServiceImplTest.java b/service/src/test/java/org/cbioportal/service/impl/StructuralVariantServiceImplTest.java index 729060f984b..5935a04b387 100644 --- a/service/src/test/java/org/cbioportal/service/impl/StructuralVariantServiceImplTest.java +++ b/service/src/test/java/org/cbioportal/service/impl/StructuralVariantServiceImplTest.java @@ -46,9 +46,6 @@ public class StructuralVariantServiceImplTest extends BaseServiceImplTest { @Mock private StructuralVariantRepository structuralVariantRepository; - @Spy - @InjectMocks - private MolecularProfileUtil molecularProfileUtil; @Test public void getStructuralVariants() throws Exception { diff --git a/service/src/test/java/org/cbioportal/service/util/MolecularProfileUtilTest.java b/service/src/test/java/org/cbioportal/service/util/MolecularProfileUtilTest.java index 84441a29feb..ffa0d9c4eac 100644 --- a/service/src/test/java/org/cbioportal/service/util/MolecularProfileUtilTest.java +++ b/service/src/test/java/org/cbioportal/service/util/MolecularProfileUtilTest.java @@ -34,12 +34,6 @@ public void getFilteredMolecularProfileCaseIdentifiers() { structuralVariantMolecularProfile.setMolecularAlterationType(MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT); structuralVariantMolecularProfile.setDatatype("SV"); - MolecularProfile fusionMolecularProfile = new MolecularProfile(); - fusionMolecularProfile.setCancerStudyIdentifier(BaseServiceImplTest.STUDY_ID); - fusionMolecularProfile.setStableId(BaseServiceImplTest.STUDY_ID + "_fusion"); - fusionMolecularProfile.setMolecularAlterationType(MolecularProfile.MolecularAlterationType.STRUCTURAL_VARIANT); - fusionMolecularProfile.setDatatype("FUSION"); - MolecularProfile discreteCNAMolecularProfile = new MolecularProfile(); discreteCNAMolecularProfile.setCancerStudyIdentifier(BaseServiceImplTest.STUDY_ID); discreteCNAMolecularProfile.setStableId(BaseServiceImplTest.STUDY_ID + "_gistic"); @@ -74,7 +68,6 @@ public void getFilteredMolecularProfileCaseIdentifiers() { List allMolecularProfiles = Arrays.asList(mutationMolecularProfile, structuralVariantMolecularProfile, - fusionMolecularProfile, discreteCNAMolecularProfile, linearCNAMolecularProfile, continuousMRNAMolecularProfile, @@ -82,7 +75,6 @@ public void getFilteredMolecularProfileCaseIdentifiers() { result = molecularProfileUtil.getFilteredMolecularProfileCaseIdentifiers(allMolecularProfiles, studyIds, sampleIds, Optional.empty()); // all molecular profiles // return would 18(6 profiles X 3 samples) instead of 24(8 profiles X 3 samples) - // because only one from structural variant and fusion profiles is considered Assert.assertEquals("all profiles", 18, result.size()); //filtered mutation profile case identifiers @@ -93,9 +85,9 @@ public void getFilteredMolecularProfileCaseIdentifiers() { result = molecularProfileUtil.getFilteredMolecularProfileCaseIdentifiers(allMolecularProfiles, studyIds, sampleIds, Optional.of(molecularProfileUtil.isDiscreteCNAMolecularProfile)); Assert.assertEquals("discrete CNA profile case identifiers", 3, result.size()); - //filtered structural variant/fusion profile case identifiers + //filtered structural variant profile case identifiers result = molecularProfileUtil.getFilteredMolecularProfileCaseIdentifiers(allMolecularProfiles, studyIds, sampleIds, Optional.of(molecularProfileUtil.isStructuralVariantMolecularProfile)); - Assert.assertEquals("structural variant/fusion profile case identifiers", 3, result.size()); + Assert.assertEquals("structural variant profile case identifiers", 3, result.size()); } } diff --git a/service/src/test/java/org/cbioportal/service/util/MutationMapperUtilsTest.java b/service/src/test/java/org/cbioportal/service/util/MutationMapperUtilsTest.java deleted file mode 100644 index 3e02f2a32d0..00000000000 --- a/service/src/test/java/org/cbioportal/service/util/MutationMapperUtilsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.cbioportal.service.util; - -import org.apache.commons.lang3.tuple.Triple; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.junit.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class MutationMapperUtilsTest { - - @InjectMocks - private MutationMapperUtils mutationMapperUtils; - - @Test - public void validateRegex() { - Triple result; - - // when only gene is present. ex: ALK - result = mutationMapperUtils.extractInformationFromProteinChange("ALK"); - Assert.assertEquals("ALK", result.getLeft()); - Assert.assertNull(result.getMiddle()); - Assert.assertNull(result.getRight()); - - // when only variant type is present. ex: DELETION - result = mutationMapperUtils.extractInformationFromProteinChange("DELETION"); - Assert.assertNull(result.getLeft()); - Assert.assertNull(result.getMiddle()); - Assert.assertEquals(VariantType.DELETION, result.getRight()); - - // when 2 genes is present. ex: ALK-TP53 - result = mutationMapperUtils.extractInformationFromProteinChange("ALK-TP53"); - Assert.assertEquals("ALK", result.getLeft()); - Assert.assertEquals("TP53", result.getMiddle()); - Assert.assertNull(result.getRight()); - - // when gene and variant type is present. ex: ALK-intragenic - result = mutationMapperUtils.extractInformationFromProteinChange("ALK-intragenic"); - Assert.assertEquals("ALK", result.getLeft()); - Assert.assertNull(result.getMiddle()); - Assert.assertEquals(VariantType.INTRAGENIC, result.getRight()); - - // when 2 genes and variant type is present. ex: ALK-TP53 INVERSION - result = mutationMapperUtils.extractInformationFromProteinChange("ALK-TP53 INVERSION"); - Assert.assertEquals("ALK", result.getLeft()); - Assert.assertEquals("TP53", result.getMiddle()); - Assert.assertEquals(VariantType.INVERSION, result.getRight()); - } -} diff --git a/web/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java b/web/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java index d6a62eb3d00..724fe7954c5 100644 --- a/web/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java +++ b/web/src/main/java/org/cbioportal/web/util/StudyViewFilterApplier.java @@ -530,17 +530,6 @@ private void splitGeneFiltersByMolecularAlterationType(List genefilt .map(molecularProfileMap::get) .collect(Collectors.toList()); - // TODO: Remove once fusions are removed from mutation table - // determine whether a fusions profile was imported as mutations - Boolean fusionsImportedAsMutations = Boolean.FALSE; - for (MolecularProfile mp : filteredMolecularProfiles) { - if (mp.getStableId().endsWith("mutations") - && mp.getDatatype().equals("FUSION")) { - fusionsImportedAsMutations = Boolean.TRUE; - break; - } - } - Set alterationTypes = filteredMolecularProfiles.stream() .map(MolecularProfile::getMolecularAlterationType) .collect(Collectors.toSet()); @@ -557,9 +546,7 @@ private void splitGeneFiltersByMolecularAlterationType(List genefilt if (alterationTypes.size() == 1) { MolecularAlterationType alterationType = alterationTypes.iterator().next(); - if (alterationType.equals(MolecularAlterationType.STRUCTURAL_VARIANT) || - alterationType.equals(MolecularProfile.MolecularAlterationType.FUSION) || - fusionsImportedAsMutations) { + if (alterationType.equals(MolecularAlterationType.STRUCTURAL_VARIANT)) { structuralVariantGeneFilters.add(genefilter); } else if (alterationType == MolecularAlterationType.MUTATION_EXTENDED) { mutatedGeneFilters.add(genefilter); diff --git a/web/src/test/java/org/cbioportal/web/StudyViewControllerTest.java b/web/src/test/java/org/cbioportal/web/StudyViewControllerTest.java index 9c0776fb00c..8194008e751 100644 --- a/web/src/test/java/org/cbioportal/web/StudyViewControllerTest.java +++ b/web/src/test/java/org/cbioportal/web/StudyViewControllerTest.java @@ -308,7 +308,7 @@ public void fetchMutatedGenes() throws Exception { } @Test - public void fetchFusionGenes() throws Exception { + public void fetchStructuralVariantGenes() throws Exception { List filteredSampleIdentifiers = new ArrayList<>(); SampleIdentifier sampleIdentifier = new SampleIdentifier(); @@ -317,25 +317,25 @@ public void fetchFusionGenes() throws Exception { filteredSampleIdentifiers.add(sampleIdentifier); Mockito.when(studyViewFilterApplier.apply(any())).thenReturn(filteredSampleIdentifiers); - List fusionCounts = new ArrayList<>(); - AlterationCountByGene fusionCount1 = new AlterationCountByGene(); - fusionCount1.setEntrezGeneId(TEST_ENTREZ_GENE_ID_1); - fusionCount1.setHugoGeneSymbol(TEST_HUGO_GENE_SYMBOL_1); - fusionCount1.setNumberOfAlteredCases(1); - fusionCount1.setTotalCount(1); - fusionCounts.add(fusionCount1); - AlterationCountByGene fusionCount2 = new AlterationCountByGene(); - fusionCount2.setEntrezGeneId(TEST_ENTREZ_GENE_ID_2); - fusionCount2.setHugoGeneSymbol(TEST_HUGO_GENE_SYMBOL_2); - fusionCount2.setNumberOfAlteredCases(2); - fusionCount2.setTotalCount(2); - fusionCounts.add(fusionCount2); + List structuralVariantCounts = new ArrayList<>(); + AlterationCountByGene structuralVariantCount1 = new AlterationCountByGene(); + structuralVariantCount1.setEntrezGeneId(TEST_ENTREZ_GENE_ID_1); + structuralVariantCount1.setHugoGeneSymbol(TEST_HUGO_GENE_SYMBOL_1); + structuralVariantCount1.setNumberOfAlteredCases(1); + structuralVariantCount1.setTotalCount(1); + structuralVariantCounts.add(structuralVariantCount1); + AlterationCountByGene structuralVariantCount2 = new AlterationCountByGene(); + structuralVariantCount2.setEntrezGeneId(TEST_ENTREZ_GENE_ID_2); + structuralVariantCount2.setHugoGeneSymbol(TEST_HUGO_GENE_SYMBOL_2); + structuralVariantCount2.setNumberOfAlteredCases(2); + structuralVariantCount2.setTotalCount(2); + structuralVariantCounts.add(structuralVariantCount2); Mockito.when(studyViewService.getStructuralVariantAlterationCountByGenes( eq(Arrays.asList(TEST_STUDY_ID)), eq(Arrays.asList(TEST_SAMPLE_ID_1)), any(AlterationFilter.class))) - .thenReturn(fusionCounts); + .thenReturn(structuralVariantCounts); StudyViewFilter studyViewFilter = new StudyViewFilter(); studyViewFilter.setStudyIds(Arrays.asList(TEST_STUDY_ID)); From 4ed00e2c80269e436b4ab00ba0d1708669f87fb9 Mon Sep 17 00:00:00 2001 From: Manda Wilson <1458628+mandawilson@users.noreply.github.com> Date: Fri, 14 Jan 2022 11:23:39 -0500 Subject: [PATCH 02/16] - unit test for structural variant - bug fix in TabDelimitedFileUtil.java parseInt was using Float.parseFloat and the casting to int and losing precision (string "138536968" was converted to int 138536960) --- .../mskcc/cbio/maf/TabDelimitedFileUtil.java | 10 +- .../portal/scripts/TestImportProfileData.java | 102 ++++++++++++++++++ .../resources/meta_structural_variants.txt | 8 ++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 core/src/test/resources/meta_structural_variants.txt diff --git a/core/src/main/java/org/mskcc/cbio/maf/TabDelimitedFileUtil.java b/core/src/main/java/org/mskcc/cbio/maf/TabDelimitedFileUtil.java index 3298d678b38..4153194b394 100644 --- a/core/src/main/java/org/mskcc/cbio/maf/TabDelimitedFileUtil.java +++ b/core/src/main/java/org/mskcc/cbio/maf/TabDelimitedFileUtil.java @@ -141,11 +141,19 @@ public static Long getPartLong(int index, String[] parts) { } } + // This method does not call Integer.parseInt() as one might expect. + // Presumably this is to allow the convertion of strings like "6.2" to "6". + // The method previously called (int)Float.parseFloat() but floats + // reserve 23 bits for the mantissa and ints are 32 bits so precision + // was lost parsing "138536968" which was converted to 138536960. + // Now we call (int)Double.parseDouble() because double allocates + // 52 bits for the mantissa. Note getPartLong calls Long.parseLong() + // when this does not call Integer.parseInt() which seems inconsistent. public static Integer getPartInt(int index, String[] parts) { try { String part = parts[index]; - return (int)(Float.parseFloat(part)); + return (int)(Double.parseDouble(part)); } catch (ArrayIndexOutOfBoundsException e) { return NA_INT; } catch (NumberFormatException e) { diff --git a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java index 442f4be2687..2c12b0b6224 100644 --- a/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java +++ b/core/src/test/java/org/mskcc/cbio/portal/scripts/TestImportProfileData.java @@ -49,6 +49,7 @@ import org.mskcc.cbio.portal.dao.DaoPatient; import org.mskcc.cbio.portal.dao.DaoSample; import org.mskcc.cbio.portal.dao.DaoSampleProfile; +import org.mskcc.cbio.portal.dao.DaoStructuralVariant; import org.mskcc.cbio.portal.dao.MySQLbulkLoader; import org.mskcc.cbio.portal.model.CancerStudy; import org.mskcc.cbio.portal.model.CanonicalGene; @@ -60,6 +61,7 @@ import org.mskcc.cbio.portal.model.GeneticAlterationType; import org.mskcc.cbio.portal.model.Patient; import org.mskcc.cbio.portal.model.Sample; +import org.mskcc.cbio.portal.model.StructuralVariant; import org.mskcc.cbio.portal.util.ConsoleUtil; import org.mskcc.cbio.portal.util.ProgressMonitor; @@ -94,6 +96,11 @@ public void cleanUp() throws DaoException { DaoGeneticProfile.deleteGeneticProfile(geneticProfile); assertNull(DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_breast_mutations")); } + geneticProfile = DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_sv"); + if (geneticProfile != null) { + DaoGeneticProfile.deleteGeneticProfile(geneticProfile); + assertNull(DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_sv")); + } } @Rule @@ -255,6 +262,101 @@ public void testImportGermlineOnlyFile() throws Exception { assertNull(DaoGeneticProfile.getGeneticProfileByStableId(studyStableId + "_breast_mutations")); } + @Test + public void testImportStructuralVariantFile() throws Exception { + String[] sampleIds = {"TCGA-A1-A0SD-01", "TCGA-A1-A0SB-01"}; + String studyStableId = "study_tcga_pub"; + CancerStudy study = DaoCancerStudy.getCancerStudyByStableId(studyStableId); + int studyId = study.getInternalId(); + String testSampleStableId = "TCGA-A1-A0SB-01"; + int testSampleId = -1; + // we need the internal sample id + for (String sampleId : sampleIds) { + String patientId = sampleId.substring(0, 12); + Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(studyId, patientId); + Integer patientIdInt = patient.getInternalId(); + Sample sample = DaoSample.getSampleByPatientAndSampleId(patientIdInt, sampleId); + Integer sampleIdInt = sample.getInternalId(); + if (testSampleStableId.equals(sample.getStableId())) { + testSampleId = sampleIdInt.intValue(); + } + } + + assertNotEquals(-1, testSampleId); + + String[] args = { + "--data","src/test/resources/data_structural_variants.txt", + "--meta","src/test/resources/meta_structural_variants.txt" , + "--noprogress", + "--loadMode", "bulkLoad" + }; + + try { + ImportProfileData runner = new ImportProfileData(args); + runner.run(); + } catch (Throwable e) { + //useful info for when this fails: + ConsoleUtil.showMessages(); + throw e; + } + + GeneticProfile geneticProfile = DaoGeneticProfile.getGeneticProfileByStableId("study_tcga_pub_sv"); + assertNotNull(geneticProfile); + + int countStructuralVariantsInProfile = 0; + boolean foundTestSample = false; + + List structuralVariants = DaoStructuralVariant.getAllStructuralVariants(); + for (StructuralVariant structuralVariant : structuralVariants) { + if (geneticProfile.getGeneticProfileId() == structuralVariant.getGeneticProfileId()) { + countStructuralVariantsInProfile += 1; + if (testSampleId == structuralVariant.getSampleIdInternal()) { + foundTestSample = true; + DaoGeneOptimized daoGene = DaoGeneOptimized.getInstance(); + CanonicalGene canonicalGene = daoGene.getGene("KIAA1549"); + assertNotNull(canonicalGene); + assertEquals(canonicalGene.getEntrezGeneId(), (long) structuralVariant.getSite1EntrezGeneId()); + assertEquals("ENST00000242365", structuralVariant.getSite1EnsemblTranscriptId()); + assertEquals(15, structuralVariant.getSite1Exon()); + assertEquals("7", structuralVariant.getSite1Chromosome()); + assertEquals(138536968, structuralVariant.getSite1Position()); + assertEquals("KIAA1549-BRAF.K16B10.COSF509_1", structuralVariant.getSite1Description()); + canonicalGene = daoGene.getGene("BRAF"); + assertNotNull(canonicalGene); + assertEquals(canonicalGene.getEntrezGeneId(), (long) structuralVariant.getSite2EntrezGeneId()); + assertEquals("ENST00000288602", structuralVariant.getSite2EnsemblTranscriptId()); + assertEquals(10, structuralVariant.getSite2Exon()); + assertEquals("7", structuralVariant.getSite2Chromosome()); + assertEquals(140482957, structuralVariant.getSite2Position()); + assertEquals("KIAA1549-BRAF.K16B10.COSF509_2", structuralVariant.getSite2Description()); + assertEquals("NA", structuralVariant.getSite2EffectOnFrame()); + assertEquals("GRCh37", structuralVariant.getNcbiBuild()); + assertEquals("no", structuralVariant.getDnaSupport()); + assertEquals("yes", structuralVariant.getRnaSupport()); + assertEquals(-1, structuralVariant.getNormalReadCount()); + assertEquals(1000, structuralVariant.getTumorReadCount()); + assertEquals(-1, structuralVariant.getNormalVariantCount()); + assertEquals(900, structuralVariant.getTumorVariantCount()); + assertEquals(-1, structuralVariant.getNormalPairedEndReadCount()); + assertEquals(-1, structuralVariant.getTumorPairedEndReadCount()); + assertEquals(-1, structuralVariant.getNormalSplitReadCount()); + assertEquals(-1, structuralVariant.getTumorSplitReadCount()); + assertEquals("KIAA1549-BRAF.K16B10.COSF509", structuralVariant.getAnnotation()); + assertEquals("NA", structuralVariant.getBreakpointType()); + assertEquals("NA", structuralVariant.getCenter()); + assertEquals("NA", structuralVariant.getConnectionType()); + assertEquals("Fusion", structuralVariant.getEventInfo()); + assertEquals("NA", structuralVariant.getVariantClass()); + assertEquals(-1, structuralVariant.getLength()); + assertEquals("Gain-of-Function", structuralVariant.getComments()); + assertEquals("COSMIC:COSF509", structuralVariant.getExternalAnnotation()); + } + } + } + assertEquals(2, countStructuralVariantsInProfile); + assertEquals(true, foundTestSample); + } + @Test public void testImportCNAFile() throws Exception { //genes in this test: diff --git a/core/src/test/resources/meta_structural_variants.txt b/core/src/test/resources/meta_structural_variants.txt new file mode 100644 index 00000000000..5618ed54fbb --- /dev/null +++ b/core/src/test/resources/meta_structural_variants.txt @@ -0,0 +1,8 @@ +cancer_study_identifier: study_tcga_pub +genetic_alteration_type: STRUCTURAL_VARIANT +datatype: SV +data_filename: data_structural_variants.txt +stable_id: sv +show_profile_in_analysis_tab: true +profile_description: Test structural variant data +profile_name: Test structural variant data From c19f199703be6f4ee438f2653219cce8caf3bf32 Mon Sep 17 00:00:00 2001 From: averyniceday Date: Tue, 8 Feb 2022 10:22:19 -0800 Subject: [PATCH 03/16] update mybatis xml (#24) - fix sv gene counts (now using unique identifier instead of stable id) - prevent double counting of sv records where SITE1 and SITE2 genes are the same Co-authored-by: Avery Wang --- .../persistence/mybatis/AlterationCountsMapper.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml index c412a09c61d..ab8a00e6bd1 100644 --- a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml +++ b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/AlterationCountsMapper.xml @@ -401,12 +401,13 @@ INNER JOIN genetic_profile ON structural_variant.GENETIC_PROFILE_ID = genetic_profile.GENETIC_PROFILE_ID INNER JOIN sample ON structural_variant.SAMPLE_ID = sample.INTERNAL_ID INNER JOIN patient ON sample.PATIENT_ID = patient.INTERNAL_ID - INNER JOIN gene ON structural_variant.SITE2_ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID) as combinedResults + INNER JOIN gene ON structural_variant.SITE2_ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + WHERE structural_variant.SITE2_ENTREZ_GENE_ID != structural_variant.SITE1_ENTREZ_GENE_ID) as combinedResults - + @@ -462,6 +463,10 @@ caseStableId + + caseUniqueId + +