From c702a8bc80f2b123911e7cb28c1bc3a9948e1c93 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Tue, 28 May 2024 16:18:14 +0200 Subject: [PATCH 1/5] Remove not needed spring context initialisation that caused different errors to occur --- .../mskcc/cbio/portal/dao/DaoCancerStudy.java | 23 ++++++++--- .../cbio/portal/dao/DaoGeneticProfile.java | 16 +++++--- .../cbio/portal/dao/DaoReferenceGenome.java | 13 +++--- .../cbio/portal/scripts/AddCaseList.java | 9 ++-- .../portal/scripts/ImportCancerStudy.java | 8 ++-- .../portal/scripts/ImportClinicalData.java | 41 +++++++++++++++---- .../scripts/ImportCopyNumberSegmentData.java | 32 +++++++++++---- .../cbio/portal/scripts/ImportCosmicData.java | 23 +++++++---- .../cbio/portal/scripts/ImportDrugs.java | 13 ++++-- .../cbio/portal/scripts/ImportGeneData.java | 37 ++++++++++++----- .../scripts/ImportGenePanelProfileMap.java | 32 +++++++++++---- .../cbio/portal/scripts/ImportGisticData.java | 18 ++++---- .../mskcc/cbio/portal/scripts/ImportHprd.java | 14 +++++-- .../portal/scripts/ImportMicroRNAIDs.java | 19 ++++++--- .../cbio/portal/scripts/ImportMutSigData.java | 11 ++--- .../scripts/ImportPathwayCommonsExtSif.java | 14 +++++-- .../portal/scripts/ImportProfileData.java | 18 ++++---- .../portal/scripts/ImportReferenceGenome.java | 27 +++++++----- .../portal/scripts/ImportResourceData.java | 40 +++++++++++++----- .../scripts/ImportResourceDefinition.java | 30 ++++++++++---- .../cbio/portal/scripts/ImportSampleList.java | 24 ++++++++--- .../mskcc/cbio/portal/scripts/ImportSif.java | 18 +++++--- .../portal/scripts/ImportTimelineData.java | 23 +++++++---- .../portal/scripts/ImportTypesOfCancers.java | 3 -- .../cbio/portal/scripts/ImportUsers.java | 19 +++++---- .../scripts/NormalizeExpressionLevels.java | 18 ++++++-- .../portal/scripts/RemoveCancerStudy.java | 5 +-- .../cbio/portal/scripts/ResetDatabase.java | 23 +++++++++-- .../scripts/TransactionalScriptRunner.java | 8 ++-- .../portal/scripts/UpdateCancerStudy.java | 5 +-- .../cbio/portal/scripts/UpdateMetaData.java | 7 ++-- 31 files changed, 405 insertions(+), 186 deletions(-) diff --git a/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java b/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java index 4073dbbb..64e9ca59 100644 --- a/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java +++ b/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java @@ -32,12 +32,24 @@ package org.mskcc.cbio.portal.dao; -import java.sql.*; -import java.text.*; -import java.util.*; import org.apache.commons.lang3.StringUtils; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.CancerStudyTags; +import org.mskcc.cbio.portal.model.ReferenceGenome; +import org.mskcc.cbio.portal.model.TypeOfCancer; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; /** * Analogous to and replaces the old DaoCancerType. A CancerStudy has a NAME and @@ -61,7 +73,6 @@ public static enum Status { private static final Map byInternalId = new HashMap(); static { - SpringUtil.initDataSource(); reCacheAll(); } diff --git a/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneticProfile.java b/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneticProfile.java index 0326fb2f..baf5f530 100644 --- a/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneticProfile.java +++ b/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneticProfile.java @@ -32,10 +32,17 @@ package org.mskcc.cbio.portal.dao; -import java.sql.*; -import java.util.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.SpringUtil; +import org.mskcc.cbio.portal.model.GeneticAlterationType; +import org.mskcc.cbio.portal.model.GeneticProfile; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Analogous to and replaces the old DaoCancerType. A CancerStudy has a NAME and @@ -52,7 +59,6 @@ private DaoGeneticProfile() {} private static final Map> byStudy = new HashMap>(); static { - SpringUtil.initDataSource(); reCache(); } diff --git a/src/main/java/org/mskcc/cbio/portal/dao/DaoReferenceGenome.java b/src/main/java/org/mskcc/cbio/portal/dao/DaoReferenceGenome.java index 1d9bb499..9f33d7e4 100644 --- a/src/main/java/org/mskcc/cbio/portal/dao/DaoReferenceGenome.java +++ b/src/main/java/org/mskcc/cbio/portal/dao/DaoReferenceGenome.java @@ -17,11 +17,15 @@ package org.mskcc.cbio.portal.dao; -import java.sql.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.SpringUtil; +import org.mskcc.cbio.portal.model.ReferenceGenome; -import java.util.*; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashMap; +import java.util.Map; /** @@ -36,7 +40,6 @@ public final class DaoReferenceGenome { private static final Map genomeInternalIds = new HashMap(); static { - SpringUtil.initDataSource(); reCache(); } diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/AddCaseList.java b/src/main/java/org/mskcc/cbio/portal/scripts/AddCaseList.java index acc067c6..e91ebef4 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/AddCaseList.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/AddCaseList.java @@ -23,9 +23,6 @@ package org.mskcc.cbio.portal.scripts; -import java.util.ArrayList; -import java.util.List; - import org.mskcc.cbio.portal.dao.DaoCancerStudy; import org.mskcc.cbio.portal.dao.DaoSample; import org.mskcc.cbio.portal.dao.DaoSampleList; @@ -33,9 +30,10 @@ import org.mskcc.cbio.portal.model.Sample; import org.mskcc.cbio.portal.model.SampleList; import org.mskcc.cbio.portal.model.SampleListCategory; -import org.mskcc.cbio.portal.util.ConsoleUtil; import org.mskcc.cbio.portal.util.ProgressMonitor; -import org.mskcc.cbio.portal.util.SpringUtil; + +import java.util.ArrayList; +import java.util.List; /** * Command Line tool to Add new case lists by generating them based on some rules. @@ -131,7 +129,6 @@ public void run() { throw new UsageException(progName, null, argSpec, "cancer_study_identifier is not specified."); } - SpringUtil.initDataSource(); CancerStudy theCancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyIdentifier); if (theCancerStudy == null) { throw new IllegalArgumentException("cancer study identified by cancer_study_identifier '" diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportCancerStudy.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportCancerStudy.java index 03372dbb..75ab1f91 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportCancerStudy.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportCancerStudy.java @@ -32,8 +32,11 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.model.*; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.CancerStudyTags; +import org.mskcc.cbio.portal.util.CancerStudyReader; +import org.mskcc.cbio.portal.util.CancerStudyTagsReader; +import org.mskcc.cbio.portal.util.ProgressMonitor; import java.io.File; @@ -53,7 +56,6 @@ public void run() { } File file = new File(args[0]); - SpringUtil.initDataSource(); CancerStudy cancerStudy = CancerStudyReader.loadCancerStudy(file); CancerStudyTags cancerStudyTags = CancerStudyTagsReader.loadCancerStudyTags(file, cancerStudy); String message = "Loaded the following cancer study:" + diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportClinicalData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportClinicalData.java index 0e37c9e0..d15beed6 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportClinicalData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportClinicalData.java @@ -32,16 +32,40 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import org.apache.commons.collections4.map.MultiKeyMap; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoClinicalAttributeMeta; +import org.mskcc.cbio.portal.dao.DaoClinicalData; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoPatient; +import org.mskcc.cbio.portal.dao.DaoSample; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.ClinicalAttribute; +import org.mskcc.cbio.portal.model.Patient; +import org.mskcc.cbio.portal.model.Sample; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; +import org.mskcc.cbio.portal.util.StableIdUtil; +import org.mskcc.cbio.portal.util.SurvivalAttributeUtil; import org.mskcc.cbio.portal.util.SurvivalAttributeUtil.SurvivalStatusAttributes; -import java.io.*; -import joptsimple.*; -import java.util.*; -import java.util.regex.*; -import org.apache.commons.collections4.map.MultiKeyMap; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.regex.Matcher; public class ImportClinicalData extends ConsoleRunnable { @@ -677,7 +701,6 @@ public void run() { overwriteExisting = true; } - SpringUtil.initDataSource(); CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyStableId); if (cancerStudy == null) { throw new IllegalArgumentException("Unknown cancer study: " + cancerStudyStableId); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportCopyNumberSegmentData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportCopyNumberSegmentData.java index 1c876a75..92343aa3 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportCopyNumberSegmentData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportCopyNumberSegmentData.java @@ -32,15 +32,30 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.model.*; - -import joptsimple.*; - -import java.io.*; +import joptsimple.OptionSet; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoCopyNumberSegment; +import org.mskcc.cbio.portal.dao.DaoCopyNumberSegmentFile; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoSample; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.CopyNumberSegment; +import org.mskcc.cbio.portal.model.CopyNumberSegmentFile; +import org.mskcc.cbio.portal.model.ReferenceGenome; +import org.mskcc.cbio.portal.model.Sample; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; +import org.mskcc.cbio.portal.util.StableIdUtil; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; import java.math.BigDecimal; -import java.util.*; +import java.util.Properties; /** * Import Segment data into database. @@ -118,7 +133,6 @@ public void run() { ProgressMonitor.setCurrentMessage("Reading data from: " + dataFile); - SpringUtil.initDataSource(); CancerStudy cancerStudy = getCancerStudy(properties); if (segmentDataExistsForCancerStudy(cancerStudy)) { diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportCosmicData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportCosmicData.java index cea48b84..3cb549c8 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportCosmicData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportCosmicData.java @@ -32,16 +32,26 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.model.*; +import org.mskcc.cbio.portal.dao.DaoCosmicData; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.CanonicalGene; +import org.mskcc.cbio.portal.model.CosmicMutationFrequency; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.MutationKeywordUtils; +import org.mskcc.cbio.portal.util.ProgressMonitor; import org.springframework.util.Assert; -import java.io.*; - +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.util.HashMap; import java.util.Map; -import java.util.regex.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.IntStream; public class ImportCosmicData { @@ -180,7 +190,6 @@ public static void main(String[] args) throws Exception { System.out.println("command line usage: importCosmicData.pl "); return; } - SpringUtil.initDataSource(); DaoCosmicData.deleteAllRecords(); ProgressMonitor.setConsoleMode(true); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportDrugs.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportDrugs.java index a819b0de..17e03c2e 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportDrugs.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportDrugs.java @@ -32,11 +32,17 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.dao.*; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; import org.mskcc.cbio.portal.model.CanonicalGene; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; /** * Command Line tool to import background drug information. @@ -79,7 +85,6 @@ public static void main(String[] args) throws Exception { return; } ProgressMonitor.setConsoleMode(true); - SpringUtil.initDataSource(); File file = new File(args[0]); System.out.println("Reading drug data from: " + file.getAbsolutePath()); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportGeneData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportGeneData.java index cc3300c0..80a062c6 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportGeneData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportGeneData.java @@ -32,19 +32,36 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.CanonicalGene; -import org.mskcc.cbio.portal.model.ReferenceGenome; -import org.mskcc.cbio.portal.model.ReferenceGenomeGene; -import org.mskcc.cbio.portal.util.*; - import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; - -import java.io.*; -import java.util.*; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.DaoReferenceGenome; +import org.mskcc.cbio.portal.dao.DaoReferenceGenomeGene; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.CanonicalGene; +import org.mskcc.cbio.portal.model.ReferenceGenome; +import org.mskcc.cbio.portal.model.ReferenceGenomeGene; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.EntrezValidator; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.GlobalProperties; +import org.mskcc.cbio.portal.util.ProgressMonitor; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * Command Line Tool to Import Background Gene Data. @@ -684,8 +701,6 @@ static void importSuppGeneData(File suppGeneFile, String referenceGenomeBuild) t @Override public void run() { try { - SpringUtil.initDataSource(); - String description = "Update gene / gene alias tables "; // using a real options parser, helps avoid bugs diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportGenePanelProfileMap.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportGenePanelProfileMap.java index 8e0d77c4..483fa7c2 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportGenePanelProfileMap.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportGenePanelProfileMap.java @@ -32,13 +32,30 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; - -import java.io.*; -import joptsimple.*; -import java.util.*; +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoGenePanel; +import org.mskcc.cbio.portal.dao.DaoGeneticProfile; +import org.mskcc.cbio.portal.dao.DaoSample; +import org.mskcc.cbio.portal.dao.DaoSampleProfile; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.GenePanel; +import org.mskcc.cbio.portal.model.GeneticProfile; +import org.mskcc.cbio.portal.model.Sample; +import org.mskcc.cbio.portal.util.ProgressMonitor; +import org.mskcc.cbio.portal.util.StableIdUtil; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; /** * @@ -96,7 +113,6 @@ public void run() { } setFile(genePanel_f); - SpringUtil.initDataSource(); importData(); } catch (RuntimeException e) { throw e; diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportGisticData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportGisticData.java index e35a9ed6..f575202e 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportGisticData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportGisticData.java @@ -32,15 +32,19 @@ package org.mskcc.cbio.portal.scripts; -import java.io.*; -import java.util.ArrayList; - +import joptsimple.OptionSet; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGistic; import org.mskcc.cbio.portal.model.Gistic; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.dao.*; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.GisticReader; +import org.mskcc.cbio.portal.util.ProgressMonitor; import org.mskcc.cbio.portal.validate.validationException; -import joptsimple.OptionSet; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; /** @@ -57,8 +61,6 @@ public void run () { String dataFile = (String) options.valueOf("data"); String studyId = (String) options.valueOf("study"); - SpringUtil.initDataSource(); - File gistic_f = new File(dataFile); int cancerStudyInternalId = ValidationUtils.getInternalStudyId(studyId); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportHprd.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportHprd.java index 1cbe26aa..1102d618 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportHprd.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportHprd.java @@ -32,11 +32,18 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.dao.*; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; import org.mskcc.cbio.portal.model.CanonicalGene; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; /** * Command Line to Import HPRD Interactions. @@ -122,7 +129,6 @@ public static void main(String[] args) { return; } ProgressMonitor.setConsoleModeAndParseShowProgress(args); - SpringUtil.initDataSource(); try { File geneFile = new File(args[0]); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportMicroRNAIDs.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportMicroRNAIDs.java index 929565fe..66b639c1 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportMicroRNAIDs.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportMicroRNAIDs.java @@ -32,11 +32,21 @@ package org.mskcc.cbio.portal.scripts; -import java.io.*; -import java.util.*; -import org.mskcc.cbio.portal.dao.*; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; import org.mskcc.cbio.portal.model.CanonicalGene; -import org.mskcc.cbio.portal.util.*; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * Command Line Tool to Import Background Gene Data. @@ -48,7 +58,6 @@ public static void importData(File geneFile) throws IOException, DaoException { FileReader reader = new FileReader(geneFile); BufferedReader buf = new BufferedReader(reader); String line = buf.readLine(); // skip first line - SpringUtil.initDataSource(); DaoGeneOptimized daoGene = DaoGeneOptimized.getInstance(); List mirnas = new ArrayList(); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportMutSigData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportMutSigData.java index f03f751f..7c0f80ac 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportMutSigData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportMutSigData.java @@ -32,10 +32,12 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.DaoException; -import org.mskcc.cbio.portal.util.*; - import joptsimple.OptionSet; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.MutSigReader; +import org.mskcc.cbio.portal.util.ProgressMonitor; import java.io.File; import java.io.IOException; @@ -54,8 +56,7 @@ public void run() { OptionSet options = ConsoleUtil.parseStandardDataAndStudyOptions(args, description); String dataFile = (String) options.valueOf("data"); String studyId = (String) options.valueOf("study"); - SpringUtil.initDataSource(); - + File mutSigFile = new File(dataFile); ProgressMonitor.setCurrentMessage( "Reading data from: " + mutSigFile.getAbsolutePath()); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportPathwayCommonsExtSif.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportPathwayCommonsExtSif.java index a17f783b..73a864c8 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportPathwayCommonsExtSif.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportPathwayCommonsExtSif.java @@ -32,11 +32,18 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.dao.*; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; import org.mskcc.cbio.portal.model.CanonicalGene; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; /** * Command Line to Import HPRD Interactions. @@ -119,7 +126,6 @@ public static void main(String[] args) { return; } ProgressMonitor.setConsoleMode(true); - SpringUtil.initDataSource(); try { File sifFile = new File(args[0]); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java index 0e1ff058..193b7cf5 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportProfileData.java @@ -32,14 +32,17 @@ package org.mskcc.cbio.portal.scripts; -import java.io.*; -import java.util.Set; - -import joptsimple.*; +import joptsimple.OptionSet; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.DaoGeneticAlteration; +import org.mskcc.cbio.portal.model.GeneticAlterationType; +import org.mskcc.cbio.portal.model.GeneticProfile; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.GeneticProfileReader; +import org.mskcc.cbio.portal.util.ProgressMonitor; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; +import java.io.File; +import java.util.Set; import static org.cbioportal.model.MolecularProfile.ImportType.DISCRETE_LONG; @@ -70,7 +73,6 @@ public void run() { updateInfo = true; } boolean overwriteExisting = options.has("overwrite-existing"); - SpringUtil.initDataSource(); ProgressMonitor.setCurrentMessage("Reading data from: " + dataFile.getAbsolutePath()); // Load genetic profile and gene panel GeneticProfile geneticProfile = null; diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportReferenceGenome.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportReferenceGenome.java index 1230608a..0e3b032e 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportReferenceGenome.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportReferenceGenome.java @@ -17,20 +17,27 @@ package org.mskcc.cbio.portal.scripts; -import org.apache.commons.lang3.StringUtils; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.ReferenceGenome; -import org.mskcc.cbio.portal.util.*; - import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; import joptsimple.OptionSpec; - -import java.io.*; -import java.util.*; -import java.text.SimpleDateFormat; +import org.apache.commons.lang3.StringUtils; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoReferenceGenome; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.ReferenceGenome; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.HashSet; +import java.util.Set; /** * Command Line Tool to Import Reference Genome Used by Molecular Profiling. @@ -108,8 +115,6 @@ private static void addReferenceGenomesToDB(Set referenceGenome @Override public void run() { try { - SpringUtil.initDataSource(); - String description = "Update reference_genome table "; // using a real options parser, helps avoid bugs diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceData.java index 147d59d9..ea1e3730 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceData.java @@ -1,16 +1,37 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; - -import java.io.*; -import joptsimple.*; -import java.util.*; -import java.util.stream.Collectors; - +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; import org.apache.commons.collections4.map.MultiKeyMap; import org.cbioportal.model.ResourceType; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoPatient; +import org.mskcc.cbio.portal.dao.DaoResourceData; +import org.mskcc.cbio.portal.dao.DaoResourceDefinition; +import org.mskcc.cbio.portal.dao.DaoSample; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.Patient; +import org.mskcc.cbio.portal.model.ResourceDefinition; +import org.mskcc.cbio.portal.model.Sample; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.MissingValues; +import org.mskcc.cbio.portal.util.ProgressMonitor; +import org.mskcc.cbio.portal.util.StableIdUtil; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.stream.Collectors; public class ImportResourceData extends ConsoleRunnable { @@ -437,7 +458,6 @@ public void run() { relaxed = true; } - SpringUtil.initDataSource(); CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyStableId); if (cancerStudy == null) { throw new IllegalArgumentException("Unknown cancer study: " + cancerStudyStableId); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceDefinition.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceDefinition.java index 5811ee44..a4b7b7ec 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceDefinition.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportResourceDefinition.java @@ -1,13 +1,28 @@ package org.mskcc.cbio.portal.scripts; +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; import org.cbioportal.model.ResourceType; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.*; - -import java.io.*; -import joptsimple.*; -import java.util.*; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoResourceDefinition; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.ResourceDefinition; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.MissingValues; +import org.mskcc.cbio.portal.util.ProgressMonitor; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; public class ImportResourceDefinition extends ConsoleRunnable { @@ -290,7 +305,6 @@ public void run() { relaxed = true; } - SpringUtil.initDataSource(); CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyStableId); if (cancerStudy == null) { throw new IllegalArgumentException("Unknown cancer study: " + cancerStudyStableId); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportSampleList.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportSampleList.java index 356471e7..ea85fe03 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportSampleList.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportSampleList.java @@ -32,13 +32,26 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.util.*; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoPatient; +import org.mskcc.cbio.portal.dao.DaoSample; +import org.mskcc.cbio.portal.dao.DaoSampleList; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.model.Patient; +import org.mskcc.cbio.portal.model.Sample; +import org.mskcc.cbio.portal.model.SampleList; +import org.mskcc.cbio.portal.model.SampleListCategory; +import org.mskcc.cbio.portal.util.CaseList; +import org.mskcc.cbio.portal.util.CaseListReader; +import org.mskcc.cbio.portal.util.ProgressMonitor; +import org.mskcc.cbio.portal.util.StableIdUtil; import org.mskcc.cbio.portal.validate.CaseListValidator; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; /** * Command Line tool to Import Sample Lists. @@ -50,7 +63,6 @@ public static void importSampleList(File dataFile) throws IOException, DaoExcept CaseList caseList = CaseListReader.readFile(dataFile); CaseListValidator.validateAll(caseList); - SpringUtil.initDataSource(); CancerStudy theCancerStudy = DaoCancerStudy.getCancerStudyByStableId(caseList.getCancerStudyIdentifier()); if (theCancerStudy == null) { throw new IllegalArgumentException("cancer study identified by cancer_study_identifier '" diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportSif.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportSif.java index 75589416..6763e41c 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportSif.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportSif.java @@ -32,12 +32,20 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; -import org.mskcc.cbio.portal.dao.*; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; import org.mskcc.cbio.portal.model.CanonicalGene; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.FileUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; -import java.io.*; -import java.util.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; /** * Command Line to Import SIF Interactions. @@ -151,8 +159,6 @@ public static void main(String[] args) { } ProgressMonitor.setConsoleMode(true); - SpringUtil.initDataSource(); - try { File geneFile = new File(args[0]); String dataSource = args[1]; diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportTimelineData.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportTimelineData.java index 0b5b182b..4b12a431 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportTimelineData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportTimelineData.java @@ -32,14 +32,24 @@ package org.mskcc.cbio.portal.scripts; -import java.io.*; -import java.util.*; -import joptsimple.*; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; +import joptsimple.OptionSet; +import org.mskcc.cbio.portal.dao.DaoClinicalEvent; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoPatient; +import org.mskcc.cbio.portal.dao.MySQLbulkLoader; +import org.mskcc.cbio.portal.model.ClinicalEvent; +import org.mskcc.cbio.portal.model.Patient; import org.mskcc.cbio.portal.util.ConsoleUtil; import org.mskcc.cbio.portal.util.ProgressMonitor; -import org.mskcc.cbio.portal.util.SpringUtil; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; /** * Imports timeline data for display in patient view @@ -50,7 +60,6 @@ public class ImportTimelineData extends ConsoleRunnable { private static void importData(String dataFile, int cancerStudyId) throws IOException, DaoException { MySQLbulkLoader.bulkLoadOn(); - SpringUtil.initDataSource(); ProgressMonitor.setCurrentMessage("Reading file " + dataFile); FileReader reader = new FileReader(dataFile); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportTypesOfCancers.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportTypesOfCancers.java index 9e119f03..4fb17193 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportTypesOfCancers.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportTypesOfCancers.java @@ -37,10 +37,8 @@ import org.mskcc.cbio.portal.dao.DaoException; import org.mskcc.cbio.portal.dao.DaoTypeOfCancer; import org.mskcc.cbio.portal.model.TypeOfCancer; -import org.mskcc.cbio.portal.scripts.ConsoleRunnable; import org.mskcc.cbio.portal.util.ConsoleUtil; import org.mskcc.cbio.portal.util.ProgressMonitor; -import org.mskcc.cbio.portal.util.SpringUtil; /** * Load all the types of cancer and their names from a file. @@ -76,7 +74,6 @@ public void run() { public static void load(File file, boolean clobber) throws IOException, DaoException { ProgressMonitor.setCurrentMessage("Loading cancer types..."); List typeOfCancerList = parseCancerTypesFromFile(file); - SpringUtil.initDataSource(); if (clobber) { ProgressMonitor.setCurrentMessage("Deleting all previous cancer types..."); DaoTypeOfCancer.deleteAllRecords(); //TODO - remove this option - foreign key constraints may mean large cascade effects (possibly the deletion of all studies) - instead, change the option to 'deleteTypeOfCancerIfNotPresent' and add a loop through existing typeOfCancer records, removing those which are not in the parsed typeOfCancerList diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ImportUsers.java b/src/main/java/org/mskcc/cbio/portal/scripts/ImportUsers.java index c886c8b8..7a3ed177 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ImportUsers.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ImportUsers.java @@ -33,12 +33,19 @@ package org.mskcc.cbio.portal.scripts; // imports -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.util.*; -import java.io.*; -import java.util.*; +import org.mskcc.cbio.portal.dao.DaoUser; +import org.mskcc.cbio.portal.dao.DaoUserAuthorities; +import org.mskcc.cbio.portal.model.User; +import org.mskcc.cbio.portal.model.UserAuthorities; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.ProgressMonitor; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.Arrays; +import java.util.List; /** * Import a file of users and their authorities. @@ -62,8 +69,6 @@ public static void main(String[] args) throws Exception { ProgressMonitor.setConsoleMode(true); - SpringUtil.initDataSource(); - File file = new File(args[0]); FileReader reader = new FileReader(file); BufferedReader buf = new BufferedReader(reader); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/NormalizeExpressionLevels.java b/src/main/java/org/mskcc/cbio/portal/scripts/NormalizeExpressionLevels.java index a5c8d642..d2214c93 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/NormalizeExpressionLevels.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/NormalizeExpressionLevels.java @@ -32,14 +32,25 @@ package org.mskcc.cbio.portal.scripts; -import java.io.*; -import java.util.*; import org.mskcc.cbio.portal.dao.DaoGeneOptimized; import org.mskcc.cbio.portal.model.CanonicalGene; -import org.mskcc.cbio.portal.util.SpringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; + /** * * Given expression and CNV data for a set of samples generate normalized expression values. @@ -110,7 +121,6 @@ public class NormalizeExpressionLevels{ public static void main (String[]args) { try { - SpringUtil.initDataSource(); // init dao gene daoGeneOptimized = DaoGeneOptimized.getInstance(); driver(args); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/RemoveCancerStudy.java b/src/main/java/org/mskcc/cbio/portal/scripts/RemoveCancerStudy.java index ad515683..8ededd3a 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/RemoveCancerStudy.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/RemoveCancerStudy.java @@ -32,9 +32,9 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; import org.mskcc.cbio.portal.dao.DaoCancerStudy; import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.util.ProgressMonitor; /** * Command Line Tool to Remove a Single Cancer Study. @@ -51,8 +51,7 @@ public void run() { ""); } String cancerStudyIdentifier = args[0]; - - SpringUtil.initDataSource(); + ProgressMonitor.setCurrentMessage( "Checking if Cancer study with identifier " + cancerStudyIdentifier + diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/ResetDatabase.java b/src/main/java/org/mskcc/cbio/portal/scripts/ResetDatabase.java index 82cad899..43c0b95d 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/ResetDatabase.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/ResetDatabase.java @@ -32,8 +32,26 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.util.*; +import org.mskcc.cbio.portal.dao.DaoCancerStudy; +import org.mskcc.cbio.portal.dao.DaoClinicalData; +import org.mskcc.cbio.portal.dao.DaoClinicalEvent; +import org.mskcc.cbio.portal.dao.DaoCopyNumberSegmentFile; +import org.mskcc.cbio.portal.dao.DaoException; +import org.mskcc.cbio.portal.dao.DaoGeneOptimized; +import org.mskcc.cbio.portal.dao.DaoGeneset; +import org.mskcc.cbio.portal.dao.DaoGeneticAlteration; +import org.mskcc.cbio.portal.dao.DaoGeneticProfile; +import org.mskcc.cbio.portal.dao.DaoGeneticProfileSamples; +import org.mskcc.cbio.portal.dao.DaoInfo; +import org.mskcc.cbio.portal.dao.DaoMutSig; +import org.mskcc.cbio.portal.dao.DaoMutation; +import org.mskcc.cbio.portal.dao.DaoPatient; +import org.mskcc.cbio.portal.dao.DaoSample; +import org.mskcc.cbio.portal.dao.DaoSampleList; +import org.mskcc.cbio.portal.dao.DaoSampleProfile; +import org.mskcc.cbio.portal.dao.DaoTypeOfCancer; +import org.mskcc.cbio.portal.dao.DaoUser; +import org.mskcc.cbio.portal.dao.DaoUserAuthorities; /** * Empty the database. @@ -91,7 +109,6 @@ public static void resetDatabase() throws DaoException { } public static void main(String[] args) throws DaoException { - SpringUtil.initDataSource(); StatDatabase.statDb(); ResetDatabase.resetDatabase(); System.err.println("Database Cleared and Reset."); diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/TransactionalScriptRunner.java b/src/main/java/org/mskcc/cbio/portal/scripts/TransactionalScriptRunner.java index 7ee8d94a..b7124de0 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/TransactionalScriptRunner.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/TransactionalScriptRunner.java @@ -1,14 +1,13 @@ package org.mskcc.cbio.portal.scripts; -import java.io.File; - -import org.mskcc.cbio.portal.util.SpringUtil; import org.mskcc.cbio.portal.util.TransactionalScripts; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionTemplate; +import java.io.File; + /** * A high-level script runner than can be used to run a batch of scripts within a * transactional context. It's handy loading a batch of data of different types. @@ -69,8 +68,7 @@ public void run () { // Inject the context into SpringUtil, so we don't need to initialize again. // This ensures that the XML files from the command line provide a complete // context and we don't get data sources later from anywhere else. - SpringUtil.initDataSource(context); - + // Set up the transaction template transactionTemplate = (TransactionTemplate) context.getBean("scriptTransactionTemplate"); if (transactionTemplate == null) { diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCancerStudy.java b/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCancerStudy.java index af8a5ba9..00bcbf69 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCancerStudy.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/UpdateCancerStudy.java @@ -23,10 +23,10 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.util.*; import org.mskcc.cbio.portal.dao.DaoCancerStudy; import org.mskcc.cbio.portal.dao.DaoException; -import org.mskcc.cbio.portal.model.*; +import org.mskcc.cbio.portal.model.CancerStudy; +import org.mskcc.cbio.portal.util.ProgressMonitor; /** @@ -58,7 +58,6 @@ public void run() { "Invalid study status parameter: " + cancerStudyStatus); } - SpringUtil.initDataSource(); CancerStudy theCancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyIdentifier); if (theCancerStudy == null) { throw new IllegalArgumentException("cancer study identified by cancer_study_identifier '" diff --git a/src/main/java/org/mskcc/cbio/portal/scripts/UpdateMetaData.java b/src/main/java/org/mskcc/cbio/portal/scripts/UpdateMetaData.java index d9669ed5..8235ed3a 100644 --- a/src/main/java/org/mskcc/cbio/portal/scripts/UpdateMetaData.java +++ b/src/main/java/org/mskcc/cbio/portal/scripts/UpdateMetaData.java @@ -32,9 +32,11 @@ package org.mskcc.cbio.portal.scripts; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.util.*; +import org.mskcc.cbio.portal.dao.DaoGeneticProfile; import org.mskcc.cbio.portal.model.GeneticProfile; +import org.mskcc.cbio.portal.util.ConsoleUtil; +import org.mskcc.cbio.portal.util.GeneticProfileReader; +import org.mskcc.cbio.portal.util.ProgressMonitor; import java.io.File; @@ -51,7 +53,6 @@ public static void main(String[] args) throws Exception { } ProgressMonitor.setConsoleMode(true); - SpringUtil.initDataSource(); File descriptorFile = new File(args[0]); GeneticProfile geneticProfile = GeneticProfileReader.loadGeneticProfileFromMeta(descriptorFile); From 0ff7031efc1153fde8cbaf9d5aa003184b59a7b9 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Tue, 28 May 2024 16:19:26 +0200 Subject: [PATCH 2/5] Make error message more informative when gene panel is not found Do not throw NPE, but NSEE with error message that mentions panel id --- .../java/org/mskcc/cbio/portal/util/GeneticProfileUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileUtil.java b/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileUtil.java index 16ab5098..3e27de9f 100644 --- a/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileUtil.java +++ b/src/main/java/org/mskcc/cbio/portal/util/GeneticProfileUtil.java @@ -87,6 +87,9 @@ public static boolean outlierExpressionSelected(HashSet geneticProfileId public static int getGenePanelId(String panelId) { GenePanel genePanel = DaoGenePanel.getGenePanelByStableId(panelId); + if (genePanel == null) { + throw new NoSuchElementException("No gene panel with id " + genePanel); + } return genePanel.getInternalId(); } From 54cc04e94ec58f414994061d390cb73e578b84f6 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Tue, 28 May 2024 16:27:44 +0200 Subject: [PATCH 3/5] Add more genes to the mini seed to load study_es_0 --- src/test/resources/seed_mini.sql | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/test/resources/seed_mini.sql b/src/test/resources/seed_mini.sql index 552db83e..1fa9d4e1 100644 --- a/src/test/resources/seed_mini.sql +++ b/src/test/resources/seed_mini.sql @@ -199,6 +199,69 @@ INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYP INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); SET @max_entity_id = (Select MAX(ID) from genetic_entity); INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,2261,'FGFR3','protein-coding'); + +-- missing genes for study_es_0 +-- additional genes for CNA data +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,116983,'ACAP3','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,2073,'ERCC5','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,219293,'ATAD3C','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,375790,'AGRN','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,54998,'AURKAIP1','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,55210,'ATAD3A','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,83858,'ATAD3B','protein-coding'); +-- genes for data_methylation_hm27.txt +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,24145,'PANX1','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,283234,'CCDC88B','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,3232,'HOXD3','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,3613,'IMPA2','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,389,'RHOC','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,487,'ATP2A1','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,7871,'SLMAP','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,8148,'TAF15','protein-coding'); +-- gene panels +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,55,'ACP3','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,81061,'OR11H1','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,388946,'TMEM247','protein-coding'); +INSERT INTO "genetic_entity" ("ENTITY_TYPE") VALUES ('GENE'); +SET @max_entity_id = (Select MAX(ID) from genetic_entity); +INSERT INTO "gene" ("GENETIC_ENTITY_ID","ENTREZ_GENE_ID","HUGO_GENE_SYMBOL","TYPE") VALUES (@max_entity_id,7157,'TP53','protein-coding'); + -- Generic genetic entities INSERT INTO "genetic_entity" ("ENTITY_TYPE", "STABLE_ID") VALUES ('GENERIC_ASSAY', 'Erlotinib'); INSERT INTO "genetic_entity" ("ENTITY_TYPE", "STABLE_ID") VALUES ('GENERIC_ASSAY', 'Irinotecan'); From a022aabd66725e1bc4c3d8d593a03925ea715b50 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Tue, 28 May 2024 16:29:01 +0200 Subject: [PATCH 4/5] Make study_es_0_inc data pass validation --- tests/test_data/study_es_0_inc/data_cna_discrete.txt | 1 - tests/test_data/study_es_0_inc/data_cna_log2.txt | 1 - tests/test_data/study_es_0_inc/data_cna_pd_annotations.txt | 5 +++++ tests/test_data/study_es_0_inc/data_expression_median.txt | 1 - tests/test_data/study_es_0_inc/data_methylation_hm27.txt | 1 - tests/test_data/study_es_0_inc/data_treatment_ic50.txt | 1 - 6 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 tests/test_data/study_es_0_inc/data_cna_pd_annotations.txt diff --git a/tests/test_data/study_es_0_inc/data_cna_discrete.txt b/tests/test_data/study_es_0_inc/data_cna_discrete.txt index 7915f45b..518b727c 100644 --- a/tests/test_data/study_es_0_inc/data_cna_discrete.txt +++ b/tests/test_data/study_es_0_inc/data_cna_discrete.txt @@ -4,7 +4,6 @@ ACAP3 116983 0 0 -1 ATAD3A 55210 0 0 -2 ATAD3B 83858 -2 -1 0 ATAD3C 219293 0 0 0 -#AURKAIP1 54998 ERCC5 2073 0 -1 -2 ACP3 55 0 0 0 TP53 -1 0 -2 diff --git a/tests/test_data/study_es_0_inc/data_cna_log2.txt b/tests/test_data/study_es_0_inc/data_cna_log2.txt index 0eb820a7..bb0fdb32 100644 --- a/tests/test_data/study_es_0_inc/data_cna_log2.txt +++ b/tests/test_data/study_es_0_inc/data_cna_log2.txt @@ -4,7 +4,6 @@ ACAP3 116983 0.751 0.533 0.114 ATAD3A 55210 0.487 0.695 0.364 ATAD3B 83858 0.150 0.492 0.300 ATAD3C 219293 0.995 0.170 0.654 -#AURKAIP1 54998 ERCC5 2073 0.816 0.514 0.165 ACP3 55 0.252 0.713 0.513 TP53 0.360 0.538 0.891 diff --git a/tests/test_data/study_es_0_inc/data_cna_pd_annotations.txt b/tests/test_data/study_es_0_inc/data_cna_pd_annotations.txt new file mode 100644 index 00000000..53d372d2 --- /dev/null +++ b/tests/test_data/study_es_0_inc/data_cna_pd_annotations.txt @@ -0,0 +1,5 @@ +SAMPLE_ID Entrez_Gene_Id cbp_driver cbp_driver_annotation cbp_driver_tiers cbp_driver_tiers_annotation +TCGA-A1-A0SB-01 116983 Putative_Passenger Test passenger Class 2 Class annotation +TCGA-A1-A0SB-01 375790 Putative_Driver Test driver Class 1 Class annotation +TCGA-A1-A0SB-03 219293 Putative_Passenger Test passenger +TCGA-BH-NEW 2073 Putative_Driver Test driver diff --git a/tests/test_data/study_es_0_inc/data_expression_median.txt b/tests/test_data/study_es_0_inc/data_expression_median.txt index d5c4a9a0..7e1f5a4b 100644 --- a/tests/test_data/study_es_0_inc/data_expression_median.txt +++ b/tests/test_data/study_es_0_inc/data_expression_median.txt @@ -4,7 +4,6 @@ ACAP3 116983 0.096 0.826 0.032 ATAD3A 55210 0.569 0.189 0.266 ATAD3B 83858 0.829 0.473 0.611 ATAD3C 219293 0.307 0.445 0.045 -#AURKAIP1 54998 ERCC5 2073 0.171 0.766 0.590 ACP3 55 0.422 0.870 0.745 TP53 0.179 0.694 0.808 diff --git a/tests/test_data/study_es_0_inc/data_methylation_hm27.txt b/tests/test_data/study_es_0_inc/data_methylation_hm27.txt index d2c67abc..3db35409 100644 --- a/tests/test_data/study_es_0_inc/data_methylation_hm27.txt +++ b/tests/test_data/study_es_0_inc/data_methylation_hm27.txt @@ -4,7 +4,6 @@ ACAP3 116983 0.022 0.681 0.790 ATAD3A 55210 0.229 0.946 0.439 ATAD3B 83858 0.885 0.707 0.664 ATAD3C 219293 0.660 0.315 0.694 -#AURKAIP1 54998 ERCC5 2073 0.436 0.749 0.345 ACP3 55 0.622 0.396 0.029 TP53 0.563 0.686 0.607 diff --git a/tests/test_data/study_es_0_inc/data_treatment_ic50.txt b/tests/test_data/study_es_0_inc/data_treatment_ic50.txt index 2a507cef..806799de 100644 --- a/tests/test_data/study_es_0_inc/data_treatment_ic50.txt +++ b/tests/test_data/study_es_0_inc/data_treatment_ic50.txt @@ -6,6 +6,5 @@ AZD6244 Name of AZD6244 Desc of AZD6244 Url of AZD6244 >8 >8 >8 Erlotinib Name of Erlotinib Desc of Erlotinib Url of Erlotinib >8 >8 >8 Irinotecan Name of Irinotecan Desc of Irinotecan Url of Irinotecan NA 0.083 NA L-685458 Name of L-685458 Desc of L-685458 Url of L-685458 >8 >8 3.267752409 -#Lapatinib Name of Lapatinib Desc of Lapatinib Url of Lapatinib LBW242 Name of LBW242 Desc of LBW242 Url of LBW242 NA >8 >8 Nilotinib Name of Nilotinib Desc of Nilotinib Url of Nilotinib >8 >8 NA From 90cc928a22eb4ea8846ce9d6a71bac2271500727 Mon Sep 17 00:00:00 2001 From: Ruslan Forostianov Date: Tue, 28 May 2024 16:29:53 +0200 Subject: [PATCH 5/5] Document in README how to load study_es_0 study --- README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 51ccaf64..2acafd19 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,36 @@ Build docker image with: docker build -t cbioportal-core . ``` -Example of how to start loading of the whole study: +### Example of how to load `study_es_0` study + +Import gene panels + +```bash +docker run -it -v $(pwd)/tests/test_data/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core \ +perl importGenePanel.pl --data /data/study_es_0/data_gene_panel_testpanel1.txt +docker run -it -v $(pwd)/tests/test_data/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core \ +perl importGenePanel.pl --data /data/study_es_0/data_gene_panel_testpanel2.txt +``` + +Import gene sets and supplementary data + +```bash +docker run -it -v $(pwd)/src/test/resources/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core \ +perl importGenesetData.pl --data /data/genesets/study_es_0_genesets.gmt --new-version msigdb_7.5.1 --supp /data/genesets/study_es_0_supp-genesets.txt +``` + +Import gene set hierarchy data + +```bash +docker run -it -v $(pwd)/src/test/resources/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core \ +perl importGenesetHierarchy.pl --data /data/genesets/study_es_0_tree.yaml +``` + +Import study + ```bash -docker run -it -v $(pwd)/data/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core python importer/metaImport.py -s /data/study_es_0 -p /data/api_json -o +docker run -it -v $(pwd)/tests/test_data/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core \ +python importer/metaImport.py -s /data/study_es_0 -p /data/api_json_system_tests -o ``` ### Incremental upload of data