diff --git a/.circleci/config.yml b/.circleci/config.yml
index f118e3591a9..a0658a7878e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -6,7 +6,7 @@ version: 2
jobs:
build_backend:
docker:
- - image: maven:3-openjdk-11
+ - image: maven:3-eclipse-temurin-21
working_directory: /tmp/repos/cbioportal
steps:
- checkout
@@ -18,10 +18,10 @@ jobs:
- v1-mvn-dependencies-{{ checksum "poms_combined" }}
- v1-mvn-dependencies-
- run:
- name: Build and unzip war
+ name: Build and unzip jar
command: |
- mvn -DskipTests clean install && \
- unzip portal/target/cbioportal*.war -d portal/target/war-exploded
+ cp src/main/resources/application.properties.EXAMPLE src/main/resources/application.properties && \
+ mvn -DskipTests clean package
- save_cache:
paths:
- ~/.m2
@@ -39,12 +39,12 @@ jobs:
- run:
name: Pull frontend code
command: |
- export FRONTEND_VERSION=$(grep 'frontend\.version' pom.xml | sed 's///g' | sed 's|||' | tr -d '[:blank:]') && \
+ export FRONTEND_VERSION=$(grep '' pom.xml | sed 's///g' | sed 's|||' | tr -d '[:blank:]') && \
export FRONTEND_ORG=$(grep 'frontend\.groupId' pom.xml | sed 's///g' | sed 's|||' | tr -d '[:blank:]' | cut -d. -f3) && \
git clone https://github.com/$FRONTEND_ORG/cbioportal-frontend.git && \
cd cbioportal-frontend && \
git fetch --tags && \
- git checkout ${FRONTEND_VERSION}
+ git checkout demo-rfc72
- persist_to_workspace:
root: /tmp/repos
paths:
@@ -145,11 +145,6 @@ jobs:
command: |
$TEST_HOME/docker_compose/setup.sh
no_output_timeout: 25m
- - run:
- name: Generate checksum of data that populates the test database
- command: |
- bash -x $TEST_HOME/runtime-config/db_content_fingerprint.sh | tee /tmp/db_data_md5key
- no_output_timeout: 25m
- run:
name: Create MySQL data directory
command: |
@@ -219,7 +214,7 @@ jobs:
- store_artifacts:
path: /tmp/repos/cbioportal-frontend/end-to-end-test/local/junit/errors/
destination: /errors
-
+
environment:
PORTAL_SOURCE_DIR: /tmp/repos/cbioportal-frontend/
TEST_HOME: /tmp/repos/cbioportal-frontend/end-to-end-test/local
diff --git a/.github/workflows/core-test.yml b/.github/workflows/core-test.yml
index 91db17f33b7..9664fa7d31e 100644
--- a/.github/workflows/core-test.yml
+++ b/.github/workflows/core-test.yml
@@ -17,10 +17,11 @@ jobs:
uses: actions/checkout@v2
with:
path: ./cbioportal
- - name: 'Set up JDK 11'
- uses: actions/setup-java@v1
+ - name: 'Set up JDK 21'
+ uses: oracle-actions/setup-java@v1
with:
- java-version: 11
+ website: oracle.com
+ release: 21
- name: 'Cache Maven packages'
uses: actions/cache@v1
with:
@@ -40,6 +41,10 @@ jobs:
run: |
mkdir -p ~/.m2 && \
cp .github/settings.xml ~/.m2
+ - name: 'Create application.properties'
+ working-directory: ./cbioportal
+ run: |
+ cp src/main/resources/application.properties.EXAMPLE src/main/resources/application.properties
- name: 'Build cBioPortal once without tests'
working-directory: ./cbioportal
run: |
diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml
index 70ee5e1c6b0..2da139728e5 100644
--- a/.github/workflows/dockerimage.yml
+++ b/.github/workflows/dockerimage.yml
@@ -18,7 +18,9 @@ jobs:
steps:
- name: Checkout git repo
uses: actions/checkout@v3
-
+ - name: 'Create application.properties'
+ run: |
+ cp src/main/resources/application.properties.EXAMPLE src/main/resources/application.properties
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
@@ -30,19 +32,19 @@ jobs:
type=ref,event=branch
type=semver,pattern={{version}}
- # The following two actions are required to build multi-platform images
- # buildx is an extension of docker build, QUEM is used to convert the binary to varies architecture
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v2
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
-
- name: Login to DockerHub
- uses: docker/login-action@v2
+ uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
+ # The following two actions are required to build multi-platform images
+ # buildx is an extension of docker build, QUEM is used to convert the binary to varies architecture
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
- name: Publish Docker Image on Tag
uses: docker/build-push-action@v3
with:
@@ -60,7 +62,9 @@ jobs:
steps:
- name: Checkout git repo
uses: actions/checkout@v3
-
+ - name: 'Create application.properties'
+ run: |
+ cp src/main/resources/application.properties.EXAMPLE src/main/resources/application.properties
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
@@ -75,19 +79,19 @@ jobs:
type=ref,event=branch
type=semver,pattern={{version}}
- # The following two actions are required to build multi-platform images
- # buildx is an extension of docker build, QUEM is used to convert the binary to varies architecture
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v2
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
-
- name: Login to DockerHub
- uses: docker/login-action@v2
+ uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
+ # The following two actions are required to build multi-platform images
+ # buildx is an extension of docker build, QUEM is used to convert the binary to varies architecture
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v3
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
- name: Publish Docker Image on Tag
uses: docker/build-push-action@v3
with:
diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml
index 57ca628fc14..eb1ddd60dee 100644
--- a/.github/workflows/integration-test.yml
+++ b/.github/workflows/integration-test.yml
@@ -19,16 +19,21 @@ jobs:
sudo apt-get install python3-setuptools && \
pip3 install -U wheel && \
pip3 install -r ./requirements.txt
- - name: 'Set up JDK 11'
- uses: actions/setup-java@v1
+ - name: 'Set up JDK 21'
+ uses: oracle-actions/setup-java@v1
with:
- java-version: 11
+ website: oracle.com
+ release: 21
- name: 'Cache Maven packages'
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
+ - name: 'Copy application.properties'
+ working-directory: ./cbioportal
+ run: |
+ cp src/main/resources/application.properties.EXAMPLE src/main/resources/application.properties
- name: 'Build cbioportal'
working-directory: ./cbioportal
run: |
@@ -37,21 +42,30 @@ jobs:
uses: actions/checkout@master
with:
repository: cbioportal/cbioportal-docker-compose
+ ref: demo-rfc72
path: ./cbioportal-docker-compose
- name: 'Initialize cbioportal-docker-compose'
working-directory: ./cbioportal-docker-compose
run: |
cd ./data && ./init.sh && rm -rf ./studies/* && cd ../config && \
- cat $PORTAL_SOURCE_DIR/portal/target/classes/portal.properties | \
- sed 's|db.host=.*||' | \
- sed 's|db.portal_db_name=.*||' | \
- sed 's|db.use_ssl=.*||' | \
- sed 's|db.connection_string=.*|db.connection_string=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false\&allowPublicKeyRetrieval=true|' \
- > portal.properties && more portal.properties
+ cat $PORTAL_SOURCE_DIR/src/main/resources/application.properties | \
+ sed 's|spring.datasource.url=.*|spring.datasource.url=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false|' | \
+ sed 's|spring.datasource.username=.*|spring.datasource.username=cbio_user|' | \
+ sed 's|spring.datasource.password=.*|spring.datasource.password=somepassword|' \
+ > application.properties && \
+ echo "db.user=cbio_user" >> application.properties && \
+ echo "db.password=somepassword" >> application.properties && \
+ echo "db.connection_string=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false" >> application.properties && \
+ echo "db.driver=com.mysql.jdbc.Driver" >> application.properties
+ - name: 'Copy cgds.sql file into Docker Compose'
+ run: cp ./cbioportal/src/main/resources/db-scripts/cgds.sql ./cbioportal-docker-compose/data/.
+ - name: 'Dump Properties'
+ working-directory: ./cbioportal-docker-compose
+ run: cat config/application.properties
- name: 'Start cbioportal-docker-compose'
working-directory: ./cbioportal-docker-compose
run: |
- docker-compose -f docker-compose.yml -f $PORTAL_SOURCE_DIR/test/integration/docker-compose-localbuild.yml up -d
+ export DOCKER_IMAGE_CBIOPORTAL=cbioportal/cbioportal:demo-rfc72-squash && docker-compose -f docker-compose.yml -f $PORTAL_SOURCE_DIR/test/integration/docker-compose-localbuild.yml up -d
- name: 'Wait for cbioportal to initialize ...'
id: startup
uses: nev7n/wait_for_response@v1
@@ -60,6 +74,10 @@ jobs:
responseCode: 200
timeout: 900000
interval: 30000
+ - name: Log cBioPortal Service
+ if: ${{ failure() && steps.startup.conclusion == 'failure' }}
+ working-directory: ./cbioportal-docker-compose
+ run: docker-compose logs cbioportal
- name: 'TEST - Validate and load study_es_0'
if: steps.startup.conclusion == 'success'
working-directory: ./cbioportal-docker-compose
@@ -67,10 +85,9 @@ jobs:
$PORTAL_SOURCE_DIR/test/integration/test_load_study.sh
- name: 'TEST - Add OncoKB annotations to study'
if: steps.startup.conclusion == 'success'
- working-directory: ./cbioportal
+ working-directory: ./cbioportal-docker-compose
run: |
- export PYTHONPATH=$PORTAL_SOURCE_DIR/core/src/main/scripts && \
- $PORTAL_SOURCE_DIR/test/integration/integration_test_oncokb_import.sh
+ $PORTAL_SOURCE_DIR/test/integration/test_integration_test_oncokb_import.sh
- name: 'TEST - Update OncoKB annotations'
if: steps.startup.conclusion == 'success'
working-directory: ./cbioportal-docker-compose
diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
index bcb38a958e8..bc6dc12004f 100644
--- a/.github/workflows/sonarcloud.yml
+++ b/.github/workflows/sonarcloud.yml
@@ -13,10 +13,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- - name: Set up JDK 11
+ - name: Set up JDK 21
uses: actions/setup-java@v1
with:
- java-version: 11
+ java-version: 21
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
@@ -29,6 +29,9 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
+ - name: 'Create application.properties'
+ run: |
+ cp src/main/resources/application.properties.EXAMPLE src/main/resources/application.properties
- name: Build and analyze
env:
SONAR_TOKEN: de1b5cc660cd210dde840f492c371da6cc801763
diff --git a/.github/workflows/validate-data.yml b/.github/workflows/validate-data.yml
index 05aabca2f21..80fc0e1818f 100644
--- a/.github/workflows/validate-data.yml
+++ b/.github/workflows/validate-data.yml
@@ -9,13 +9,18 @@ jobs:
uses: actions/checkout@v2
with:
path: ./cbioportal
+ - name: 'Checkout core module'
+ uses: actions/checkout@v4
+ with:
+ path: ./cbioportal/core
+ repository: cBioPortal/cbioportal-core
- name: 'Validate tests'
working-directory: ./cbioportal
run: |
docker run -v ${PWD}:/cbioportal python:3.6 /bin/sh -c '
cd /cbioportal &&
pip install -r requirements.txt &&
- export PYTHONPATH=/cbioportal/core/src/main/scripts &&
+ export PYTHONPATH=/cbioportal/core/src/main/resources/scripts &&
cd /cbioportal/core/src/test/scripts/ &&
python unit_tests_validate_data.py &&
python system_tests_validate_data.py &&
diff --git a/.gitignore b/.gitignore
index 96a94a77245..4dda110d9ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,21 @@
+liftover/target/*
+target/
+portal/target/*
+core/target/*
+annotator/target/*
+importer/target/*
+business/target/*
+model/target/*
+scripts/target
+persistence/persistence-api/target/*
+persistence/persistence-mybatis/target/*
+persistence/persistence-mybatis-test/target/*
+service/target/*
+mutation-assessor/target/*
+cbioportal-client/target/*
+mondrian-cy3-app/target/*
+utils/target/*
+web/target/*
nb-configuration.xml
nbactions-private.xml
oncotator/src/main/resources/db.properties
@@ -55,6 +73,7 @@ portal/src/main/webapp/WEB-INF/logback.xml
!src/main/resource/*.EXAMPLE
firehose-importer/reference_data/gene_info
portal.properties
+application.properties
importer.properties
log4j.properties
build.properties
@@ -64,21 +83,6 @@ syntax: glob
*.swp
importer/*.log
firehose-importer/*.txt
-portal/target/*
-liftover/target/*
-core/target/*
-annotator/target/*
-importer/target/*
-business/target/*
-model/target/*
-persistence/persistence-api/target/*
-persistence/persistence-mybatis/target/*
-persistence/persistence-mybatis-test/target/*
-service/target/*
-web/target/*
-mutation-assessor/target/*
-cbioportal-client/target/*
-mondrian-cy3-app/target/*
nbactions.xml
*/*.iml
*.iml
@@ -93,18 +97,16 @@ dependency-reduced-pom.xml
/core/nbactions-private.xml
.profile.d/
Procfile
-scripts/target
node_modules/
-target/
-portal/META-INF/*
-portal/reactapp/*
package.json
.vscode/
*.tramp_history
pom.version.*
pom.xml.*
-db-scripts/src/main/resources/cgds-test.sql
pom.xml.*
Dockerfile.local
.factorypath
-.retype
\ No newline at end of file
+.retype
+security.properties
+*.crt
+*.key
diff --git a/README.md b/README.md
index 37ce2550b3f..afdcf952879 100644
--- a/README.md
+++ b/README.md
@@ -13,17 +13,59 @@ See [https://docs.cbioportal.org](https://docs.cbioportal.org)
See [LICENSE](./LICENSE)
## 💻 Run Backend
-cBioPortal consists of several components, please read the [Architecture docs](https://docs.cbioportal.org/2.1-deployment/architecture-overview) to figure out what repo would be relevant to edit. If you e.g. only want to make frontend changes, one can directly edit [the frontend repo](https://github.com/cbioportal/cbioportal-frontend) instead. Read the instructions in that repo for more info on how to do frontend development. This repo only contains the backend part. Before editing the backend, it's good to read the [backend code organization](docs/Backend-Code-Organization.md). For development of the backend repo one should first set up a database. Please follow the [Docker deployment documentation](https://docs.cbioportal.org/2.1.1-deploy-with-docker-recommended/docker) to do so. Change the [docker-compose](https://github.com/cBioPortal/cbioportal-docker-compose/blob/5da068f0eb9b4f42db52ab5e91321b26a1826d7a/docker-compose.yml#L6) file to use your image instead:
+cBioPortal consists of several components, please read the [Architecture docs](https://docs.cbioportal.org/architecture-overview/) to figure out what repo would be relevant to edit. If you e.g. only want to make frontend changes, one can directly edit [the frontend repo](https://github.com/cbioportal/cbioportal-frontend) instead. Read the instructions in that repo for more info on how to do frontend development. This repo only contains the backend part. Before editing the backend, it's good to read the [backend code organization](docs/Backend-Code-Organization.md).
+
+### Local Development
+#### What MySQL database to use
+We recommend to set up a MySQL database using [Docker Compose](https://github.com/cBioPortal/cbioportal-docker-compose). It's useful to know how to do this as it allows you to import any dataset of your choice. For debugging production issues, we also have a database available with all the data on https://cbioportal.org that one can connect to directly. Please reach out on slack to get the credentials.
+
+#### Command Line
+If you want to run the cBioPortal web app from the command line please follow these instructions. First, we want to make sure that all ports are open for the services set up through [docker compose](https://github.com/cBioPortal/cbioportal-docker-compose) (i.e. not just accessible to other containers within the same Docker Compose file). To do so, in the [docker compose repo](https://github.com/cBioPortal/cbioportal-docker-compose) run:
+
+```
+docker compose -f docker-compose.yml -f open-ports.yml up
+```
+This should open the ports. Now we are ready to run the cBioPortal web app locally. You can compile the backend code with:
+```
+export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/ && mvn -DskipTests clean install
+```
+Note: change `JAVA_HOME` to point to a JDK 11 version. If everything compiles correctly you can then run the app like this:
+```
+java -Xms2g -Xmx4g \
+ -Dauthenticate=noauthsessionservice \
+ -Dsession.service.url=http://localhost:5000/api/sessions/my_portal/ \
+ -Dsession.service.origin='*' \
+ -Dspring.datasource.username=cbio_user \
+ -Dspring.datasource.password=somepassword \
+ -Dspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver \
+ -Dspring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect \
+ -Dspring.datasource.url='jdbc:mysql://cbio_user:somepassword@localhost:3306/cbioportal?useSSL=false&allowPublicKeyRetrieval=true' \
+ -Dshow.civic=true \
+ -Dskin.footer='' \
+ -Dapp.name='my-portal' \
+ -Ddbconnector=dbcp \
+ -cp "$PWD:$PWD/BOOT-INF/lib/*" \
+ org.cbioportal.PortalApplication
+```
+The app should now show up at http://localhost:8080.
+
+#### Deploy your development image inside Docker Compose
+Another option is to deploy your development image directly into the [docker-compose](https://github.com/cBioPortal/cbioportal-docker-compose/blob/5da068f0eb9b4f42db52ab5e91321b26a1826d7a/docker-compose.yml#L6) file. First build the image like this
```
docker build -t cbioportal/cbioportal:my-dev-cbioportal-image -f docker/web-and-data/Dockerfile .
```
+Then change the [env file](https://github.com/cBioPortal/cbioportal-docker-compose/blob/master/.env) to use `cbioportal/cbioportal:my-dev-cbioportal-image`.
+
+### Local Development
+
+
Note: internally we have a dev database available with the public data set that one can connect to directly. Please reach out on slack to get the credentials. It is usually best to use a small test dataset, but if a copy of the production database is necessary for e.g. fixing a bug specific to production data that can be useful.
### 🕵️♀️ Debugging
-If you want to attach a debugger you can change the `docker-compose.yml` file to include the paramaters: `-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005`. Make sure to expose that port by adding `5005:5005` in the ports section of the cbioportal container.
+If you want to attach a debugger you can change the `docker-compose.yml` file to include the paramaters: `-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005` (make sure to expose the debug port by adding `5005:5005` in the ports section of the cbioportal container). If you are running the java app outside of docker you can add the same parameters to the java command line arguments instead.
You can then use a JAVA IDE to connect to that port. E.g. in [VSCode](https://code.visualstudio.com/), one would add the following configuration to `launch.json` to connect:
diff --git a/app.json b/app.json
deleted file mode 100644
index ecaf1edf5f4..00000000000
--- a/app.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "stack": "heroku-18",
- "name": "cBioPortal",
- "description":"The cBioPortal for Cancer Genomics provides visualization, analysis and download of large-scale cancer genomics data sets.",
- "repository":"https://github.com/cbioportal/cbioportal",
- "logo":"https://www.cbioportal.org/images/cbioportal_logo.png",
- "keywords": [
- "java",
- "tomcat",
- "javascript",
- "cancer",
- "genomics"
- ],
- "env": {
- "JAVA_OPTS": {
- "description":"options for jvm",
- "value": "-Xmx300m -Xms300m -XX:+UseCompressedOops"
- },
- "MAVEN_CUSTOM_OPTS": {
- "description":"set heroku profile for mvn",
- "value":"-Pheroku,public -DskipTests -Dtomcat.catalina.scope=runtime -Dfinal.war.name=cbioportal"
- },
- "SPRING_OPTS": {
- "description":"set spring properties with e.g. -Dshow.civic=true (TODO: not all props work atm)",
- "value":"-Dauthenticate=false -Dtomcat.catalina.scope=runtime -Ddb.user=cbio_user -Ddb.password=cbio_pass -Ddb.portal_db_name=cgds_public -Ddb.connection_string=jdbc:mysql://devdb.cbioportal.org:3306/ -Ddb.host=devdb.cbioportal.org -Dshow.civic=true -Dsuppress_schema_version_mismatch_errors=true -Dsession.service.url=https://cbioportal-session-service.herokuapp.com/session_service/api/sessions/heroku_portal/"
- },
- "WEBAPP_RUNNER_OPTIONS": {
- "description":"set webapp runner options",
- "value":"--enable-compression"
- }
- },
- "buildpacks": [
- {
- "url": "https://github.com/inodb/cbioportal-buildpack"
- },
- {
- "url": "https://github.com/heroku/heroku-buildpack-java"
- }
- ]
-}
diff --git a/core/pom.xml b/core/pom.xml
deleted file mode 100644
index bf4c618d7d1..00000000000
--- a/core/pom.xml
+++ /dev/null
@@ -1,358 +0,0 @@
-
-
-
-
- master
- org.mskcc.cbio
-
- 0-unknown-version-SNAPSHOT
-
- 4.0.0
- core
- Portal Core
- Core libraries shared among other modules
-
-
-
- org.mskcc.cbio
- persistence-connections
-
-
- org.mskcc.cbio
- security-spring
-
-
-
- org.mskcc.cbio
- db-scripts
- test
-
-
- org.mskcc.cbio
- service
-
-
-
- org.owasp
- antisamy
-
-
-
-
- org.antlr
- antlr-runtime
-
-
-
-
- org.apache.commons
- commons-collections4
-
-
- org.apache.geronimo.bundles
- commons-discovery
-
-
- org.apache.commons
- commons-dbcp2
-
-
- commons-fileupload
- commons-fileupload
-
-
- commons-io
- commons-io
-
-
- commons-httpclient
- commons-httpclient
-
-
- org.apache.httpcomponents
- httpcore
-
-
- commons-cli
- commons-cli
-
-
- org.apache.commons
- commons-text
-
-
-
-
- com.fasterxml.jackson.core
- jackson-core
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-yaml
-
-
-
-
- javax.servlet
- javax.servlet-api
-
-
-
-
- net.sf.jopt-simple
- jopt-simple
-
-
-
-
- com.googlecode.json-simple
- json-simple
-
-
-
-
- net.sf.jung
- jung-api
-
-
- net.sf.jung
- jung-graph-impl
-
-
-
-
- net.sf.opencsv
- opencsv
-
-
-
-
- org.mockito
- mockito-core
-
-
- commons-codec
- commons-codec
-
-
-
- batik
- batik
-
-
- batik
- batik-rasterizer
-
-
- org.apache.xmlgraphics
- batik-codec
-
-
- xalan
- xalan
-
-
-
-
- org.apache.xmlgraphics
- fop
-
-
- xerces
- xercesImpl
-
-
-
- dom4j
- dom4j
-
-
- jaxen
- jaxen
-
-
- org.springframework
- spring-tx
-
-
- org.springframework
- spring-test
-
-
- org.easymock
- easymock
-
-
- org.mskcc.cbio
- web
-
-
- com.vlkan.hrrs
- hrrs-servlet-filter-base64
-
-
- junit
- junit
-
-
- org.mskcc.cbio
- maf
- 0-unknown-version-SNAPSHOT
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- always
- true
-
-
- log4j.configuration
- file:${project.parent.basedir}/src/main/resources/log4j.properties
-
-
-
- ${project.parent.basedir}/src/main/resources/
-
-
- **/Test*.java
-
-
-
-
- integration-test
-
- test
-
- integration-test
-
-
- none
-
-
- **/Test*.java
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- unpack-dependencies
- pre-integration-test
-
- unpack-dependencies
-
-
- cgds-test.sql
- ${project.build.testOutputDirectory}
- db-scripts
-
-
-
-
-
-
- org.codehaus.mojo
- sql-maven-plugin
-
-
- pre-integration-test
-
- execute
-
-
-
- settingsKey
- ${db.test.driver}
- ${db.test.url}
- ${db.test.username}
- ${db.test.password}
- SET default_storage_engine=InnoDB
- SET SESSION sql_mode = 'ANSI_QUOTES'
-
- ${project.build.testOutputDirectory}/cgds-test.sql
- src/test/resources/seed_mini.sql
-
-
- UTF-8
- characterEncoding=utf8, connectionCollation=utf8_general_ci
-
- ${skipTests}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
-
-
- copy-parent-resources
- process-sources
-
- copy-resources
-
-
- ${project.build.directory}/classes
-
-
- ${project.parent.basedir}/portal/src/main/webapp/WEB-INF
- true
-
- logback.xml
-
-
-
- ${project.parent.basedir}/src/main/resources
-
- **/*.properties
-
-
- **/portal.properties.*
- **/maven.properties.*
- **/git.properties.*
- **/*.EXAMPLE
-
-
-
-
-
-
-
-
-
-
-
-
- src/main/resources
-
- sample_data/**
- micrornas.tsv
-
-
-
- ../src/main/resources
- true
-
- **/portal.properties
- **/maven.properties
-
-
-
-
-
diff --git a/core/src/main/java/org/mskcc/cbio/io/WebFileConnect.java b/core/src/main/java/org/mskcc/cbio/io/WebFileConnect.java
deleted file mode 100644
index ea6b1b58e8b..00000000000
--- a/core/src/main/java/org/mskcc/cbio/io/WebFileConnect.java
+++ /dev/null
@@ -1,131 +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.io;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * Web/File Connect Utility Class.
- *
- * @author Ethan Cerami.
- */
-public class WebFileConnect
-{
- public static final String TAB = "\t";
- public static final String NEW_LINE = "\n";
-
- /**
- * Retrieves the Content from the Specified File.
- *
- * @param file File Object.
- * @return String Object containing the full Document Content.
- * @throws IOException Read Error.
- */
- public static String retrieveDocument(File file) throws IOException {
- BufferedReader in = new BufferedReader(new FileReader(file));
- return readFile(in);
- }
-
- /**
- * Retrieves the Matrix Content from the Specified File.
- *
- * @param file File Object.
- * @return Matrix of Strings.
- * @throws IOException Read Error.
- */
- public static String[][] retrieveMatrix(File file) throws IOException {
- BufferedReader in = new BufferedReader(new FileReader(file));
- String content = readFile(in);
- return prepareMatrix(content);
- }
-
- /**
- * Parses Matrix Content from the Specified String.
- *
- * @param content Tab-Delim String.
- * @return Matrix of Strings.
- * @throws IOException Read Error.
- */
- public static String[][] parseMatrix(String content) throws IOException {
- return prepareMatrix(content);
- }
-
- private static String[][] prepareMatrix(String content) {
- String rawLines[] = content.split(NEW_LINE);
-
- // Ignore all lines starting with # sign; these are comments or warnings, not data.
- ArrayList finalLines = new ArrayList();
- for (String currentLine: rawLines) {
- if (!currentLine.startsWith("#")) {
- finalLines.add(currentLine);
- }
- }
-
- String lines[] = finalLines.toArray(new String[finalLines.size()]);
- String matrix[][] = null;
- int numRows = lines.length;
- int numCols = 0;
- if (lines.length > 0) {
- String firstLine = lines[0];
- String parts[] = firstLine.split(TAB);
- numCols = parts.length;
- }
- if (numRows > 0 && numCols > 0) {
- matrix = new String[numRows][numCols];
- for (int i = 0; i < lines.length; i++) {
- String parts[] = lines[i].split(TAB,numCols);
- for (int j = 0; j < parts.length; j++) {
- matrix[i][j] = parts[j];
- }
- }
- }
- return matrix;
- }
-
- /**
- * Reads Content from a Buffered Reader.
- */
- public static String readFile(BufferedReader in) throws IOException {
- StringBuffer buf = new StringBuffer();
- String str;
- while ((str = in.readLine()) != null) {
- buf.append(str + "\n");
- }
- in.close();
- return buf.toString();
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoAlleleSpecificCopyNumber.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoAlleleSpecificCopyNumber.java
deleted file mode 100644
index 115d1717cce..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoAlleleSpecificCopyNumber.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2019 - 2020 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.dao;
-
-import org.mskcc.cbio.portal.model.*;
-
-/**
- * Data access object for Mutation table
- */
-public final class DaoAlleleSpecificCopyNumber {
-
- public static int addAlleleSpecificCopyNumber(AlleleSpecificCopyNumber ascn) throws DaoException {
- if (!MySQLbulkLoader.isBulkLoad()) {
- throw new DaoException("You have to turn on MySQLbulkLoader in order to insert allele specific copy numbers");
- } else {
- int result = 1;
- MySQLbulkLoader.getMySQLbulkLoader("allele_specific_copy_number").insertRecord(
- resolveValueToString(ascn.getMutationEventId()),
- resolveValueToString(ascn.getGeneticProfileId()),
- resolveValueToString(ascn.getSampleId()),
- resolveValueToString(ascn.getAscnIntegerCopyNumber()),
- ascn.getAscnMethod(),
- resolveValueToString(ascn.getCcfExpectedCopiesUpper()),
- resolveValueToString(ascn.getCcfExpectedCopies()),
- ascn.getClonal(),
- resolveValueToString(ascn.getMinorCopyNumber()),
- resolveValueToString(ascn.getExpectedAltCopies()),
- resolveValueToString(ascn.getTotalCopyNumber()));
- return result;
- }
- }
-
- private static String resolveValueToString(Object value) {
- if (value != null) {
- return String.valueOf(value);
- }
- return null;
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java
deleted file mode 100644
index 4073dbbb059..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * Copyright (c) 2015 - 2017 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.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.*;
-
-/**
- * Analogous to and replaces the old DaoCancerType. A CancerStudy has a NAME and
- * DESCRIPTION. If PUBLIC is true a CancerStudy can be accessed by anyone,
- * otherwise can only be accessed through access control.
- *
- * @author Ethan Cerami
- * @author Arthur Goldberg goldberg@cbio.mskcc.org
- * @author Ersin Ciftci
- */
-public final class DaoCancerStudy {
-
- public static enum Status {
- UNAVAILABLE,
- AVAILABLE
- }
-
- private static final Map cacheDateByStableId = new HashMap();
- private static final Map cacheDateByInternalId = new HashMap();
- private static final Map byStableId = new HashMap();
- private static final Map byInternalId = new HashMap();
-
- static {
- SpringUtil.initDataSource();
- reCacheAll();
- }
-
- private DaoCancerStudy() {}
-
- public static synchronized void reCacheAll() {
- System.out.println("Recaching... ");
- DaoCancerStudy.reCache();
- DaoGeneticProfile.reCache();
- DaoPatient.reCache();
- DaoSample.reCache();
- DaoClinicalData.reCache();
- DaoInfo.setVersion();
- System.out.println("Finished recaching... ");
- }
-
- private static synchronized void reCache() {
- cacheDateByStableId.clear();
- cacheDateByInternalId.clear();
- byStableId.clear();
- byInternalId.clear();
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("SELECT * FROM cancer_study");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- CancerStudy cancerStudy = extractCancerStudy(rs);
- cacheCancerStudy(cancerStudy, new java.util.Date());
- }
- } catch (SQLException | DaoException e) {
- e.printStackTrace();
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- private static void cacheCancerStudy(CancerStudy study, java.util.Date importDate) {
- cacheDateByStableId.put(study.getCancerStudyStableId(), importDate);
- cacheDateByInternalId.put(study.getInternalId(), importDate);
- byStableId.put(study.getCancerStudyStableId(), study);
- byInternalId.put(study.getInternalId(), study);
- }
-
- /**
- * Removes the cancer study from cache
- * @param internalCancerStudyId Internal cancer study ID
- */
- private static void removeCancerStudyFromCache(int internalCancerStudyId) {
- String stableId = byInternalId.get(internalCancerStudyId).getCancerStudyStableId();
- cacheDateByStableId.remove(stableId);
- cacheDateByInternalId.remove(internalCancerStudyId);
- byStableId.remove(stableId);
- byInternalId.remove(internalCancerStudyId);
- }
-
- public static void setStatus(Status status, String stableCancerStudyId, Integer ... internalId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- if (internalId.length > 0) {
- pstmt = con.prepareStatement("UPDATE cancer_study set status = ? where cancer_study_id = ?");
- pstmt.setInt(1, status.ordinal());
- pstmt.setInt(2, internalId[0]);
- } else {
- pstmt = con.prepareStatement("UPDATE cancer_study set status = ? where cancer_study_identifier = ?");
- pstmt.setInt(1, status.ordinal());
- pstmt.setString(2, stableCancerStudyId);
- }
- pstmt.executeUpdate();
- } catch (SQLException e) {
- if (!e.getMessage().toLowerCase().contains("unknown column")) {
- throw new DaoException(e);
- }
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- public static Status getStatus(String stableCancerStudyId, Integer ... internalId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- if (internalId.length > 0) {
- pstmt = con.prepareStatement("SELECT status FROM cancer_study where cancer_study_id = ?");
- pstmt.setInt(1, internalId[0]);
- } else {
- pstmt = con.prepareStatement("SELECT status FROM cancer_study where cancer_study_identifier = ?");
- pstmt.setString(1, stableCancerStudyId);
- }
- rs = pstmt.executeQuery();
- if (rs.next()) {
- Integer status = rs.getInt(1);
- if (rs.wasNull()) {
- return Status.AVAILABLE;
- }
- if (status>=Status.values().length) {
- return Status.AVAILABLE;
- }
- return Status.values()[status];
- } else {
- return Status.AVAILABLE;
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- private static Integer getStudyCount() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("SELECT count(*) from cancer_study");
- rs = pstmt.executeQuery();
- if (rs.next()) {
- return rs.getInt(1);
- } else {
- return 0;
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- public static void setImportDate(Integer internalId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("UPDATE cancer_study set IMPORT_DATE = NOW() where cancer_study_id = ?");
- pstmt.setInt(1, internalId);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- if (e.getMessage().toLowerCase().contains("unknown column")) {
- return;
- }
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- public static java.util.Date getImportDate(String stableCancerStudyId, Integer ... internalId) throws DaoException, ParseException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- if (internalId.length > 0) {
- pstmt = con.prepareStatement("SELECT IMPORT_DATE FROM cancer_study where cancer_study_id = ?");
- pstmt.setInt(1, internalId[0]);
- } else {
- pstmt = con.prepareStatement("SELECT IMPORT_DATE FROM cancer_study where cancer_study_identifier = ?");
- pstmt.setString(1, stableCancerStudyId);
- }
- rs = pstmt.executeQuery();
- if (rs.next()) {
- java.sql.Timestamp importDate = rs.getTimestamp(1);
- if (rs.wasNull()) {
- return new SimpleDateFormat("yyyyMMdd").parse("19180511");
- } else {
- return importDate;
- }
- } else {
- return new SimpleDateFormat("yyyyMMdd").parse("19180511");
- }
- } catch (SQLException e) {
- if (e.getMessage().toLowerCase().contains("unknown column")) {
- return new SimpleDateFormat("yyyyMMdd").parse("19180511");
- }
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- /**
- * Adds a cancer study to the Database.
- * Updates cancerStudy with its auto incremented uid, in studyID.
- *
- * @param cancerStudy Cancer Study Object.
- * @throws DaoException Database Error.
- */
- public static void addCancerStudy(CancerStudy cancerStudy) throws DaoException {
- addCancerStudy(cancerStudy, false);
- }
-
- /**
- * Adds a cancer study to the Database.
- * @param cancerStudy
- * @param overwrite if true, overwrite if exist.
- * @throws DaoException
- */
- public static void addCancerStudy(CancerStudy cancerStudy, boolean overwrite) throws DaoException {
- // make sure that cancerStudy refers to a valid TypeOfCancerId
- // TODO: have a foreign key constraint do this; why not?
- TypeOfCancer aTypeOfCancer = DaoTypeOfCancer.getTypeOfCancerById(cancerStudy.getTypeOfCancerId());
- if (null == aTypeOfCancer) {
- throw new DaoException("cancerStudy.getTypeOfCancerId() '" + cancerStudy.getTypeOfCancerId() + "' does not refer to a TypeOfCancer.");
- }
- // CANCER_STUDY_IDENTIFIER cannot be null
- String stableId = cancerStudy.getCancerStudyStableId();
- if (stableId == null) {
- throw new DaoException("Cancer study stable ID cannot be null.");
- }
- CancerStudy existing = getCancerStudyByStableId(stableId);
- if (existing!=null) {
- if (overwrite) {
- //setStatus(Status.UNAVAILABLE, stableId);
- deleteCancerStudy(existing.getInternalId());
- } else {
- throw new DaoException("Cancer study " + stableId + "is already imported.");
- }
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("INSERT INTO cancer_study " +
- "( `CANCER_STUDY_IDENTIFIER`, `NAME`, "
- + "`DESCRIPTION`, `PUBLIC`, `TYPE_OF_CANCER_ID`, "
- + "`PMID`, `CITATION`, `GROUPS`, `STATUS`,`REFERENCE_GENOME_ID`, `IMPORT_DATE` ) VALUES (?,?,?,?,?,?,?,?,?,?,NOW())",
- Statement.RETURN_GENERATED_KEYS);
- pstmt.setString(1, stableId);
- pstmt.setString(2, cancerStudy.getName());
- pstmt.setString(3, cancerStudy.getDescription());
- pstmt.setBoolean(4, cancerStudy.isPublicStudy());
- pstmt.setString(5, cancerStudy.getTypeOfCancerId());
- pstmt.setString(6, cancerStudy.getPmid());
- pstmt.setString(7, cancerStudy.getCitation());
- Set groups = cancerStudy.getGroups();
- if (groups==null) {
- pstmt.setString(8, null);
- } else {
- pstmt.setString(8, StringUtils.join(groups, ";"));
- }
- //status is UNAVAILABLE until other data is loaded for this study. Once all is loaded, the
- //data loading process can set this to AVAILABLE:
- //TODO - use this field in parts of the system that build up the list of studies to display in home page:
- pstmt.setInt(9, Status.UNAVAILABLE.ordinal());
- try {
- ReferenceGenome referenceGenome = DaoReferenceGenome.getReferenceGenomeByGenomeName(cancerStudy.getReferenceGenome());
- pstmt.setInt(10, referenceGenome.getReferenceGenomeId());
- }
- catch (NullPointerException e) {
- throw new DaoException("Unsupported reference genome");
- }
- pstmt.executeUpdate();
- rs = pstmt.getGeneratedKeys();
- if (rs.next()) {
- int autoId = rs.getInt(1);
- cancerStudy.setInternalId(autoId);
- }
- cacheCancerStudy(cancerStudy, new java.util.Date());
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- reCacheAll();
- }
-
- public static void addCancerStudyTags(CancerStudyTags cancerStudyTags) throws DaoException {
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("INSERT INTO cancer_study_tags " +
- "( `CANCER_STUDY_ID`,`TAGS` ) VALUES (?,?)");
- pstmt.setInt(1, cancerStudyTags.getCancerStudyId());
- pstmt.setString(2, cancerStudyTags.getTags());
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- /**
- * Return the cancerStudy identified by the internal cancer study ID, if it exists.
- *
- * @param internalId Internal (int) Cancer Study ID.
- * @return Cancer Study Object, or null if there's no such study.
- */
- public static CancerStudy getCancerStudyByInternalId(int internalId) throws DaoException {
- return byInternalId.get(internalId);
- }
-
- /**
- * Returns the cancerStudy identified by the stable identifier, if it exists.
- *
- * @param stableId Cancer Study Stable ID.
- * @return the CancerStudy, or null if there's no such study.
- */
- public static CancerStudy getCancerStudyByStableId(String stableId) throws DaoException {
- return byStableId.get(stableId);
- }
-
- /**
- * Indicates whether the cancerStudy identified by the stable ID exists.
- *
- * @param cancerStudyStableId Cancer Study Stable ID.
- * @return true if the CancerStudy exists, otherwise false
- */
- public static boolean doesCancerStudyExistByStableId(String cancerStudyStableId) {
- return byStableId.containsKey(cancerStudyStableId);
- }
-
- /**
- * Indicates whether the cancerStudy identified by internal study ID exist.
- * does no access control, so only returns a boolean.
- *
- * @param internalCancerStudyId Internal Cancer Study ID.
- * @return true if the CancerStudy exists, otherwise false
- */
- public static boolean doesCancerStudyExistByInternalId(int internalCancerStudyId) {
- return byInternalId.containsKey(internalCancerStudyId);
- }
-
- /**
- * Returns all the cancerStudies.
- *
- * @return ArrayList of all CancerStudy Objects.
- */
- public static ArrayList getAllCancerStudies() {
- return new ArrayList(byStableId.values());
- }
-
- /**
- * Gets Number of Cancer Studies.
- * @return number of cancer studies.
- */
- public static int getCount() {
- return byStableId.size();
- }
-
- /**
- * Deletes all Cancer Studies.
- * @throws DaoException Database Error.
- *
- * @deprecated this should not be used. Use deleteCancerStudy(cancerStudyStableId) instead
- */
- public static void deleteAllRecords() throws DaoException {
- cacheDateByStableId.clear();
- cacheDateByInternalId.clear();
- byStableId.clear();
- byInternalId.clear();
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- JdbcUtil.disableForeignKeyCheck(con);
- pstmt = con.prepareStatement("TRUNCATE TABLE cancer_study");
- pstmt.executeUpdate();
- JdbcUtil.enableForeignKeyCheck(con);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- /**
- *
- * @param cancerStudyStableId
- * @throws DaoException
- * @deprecated
- */
- public static void deleteCancerStudy(String cancerStudyStableId) throws DaoException {
- CancerStudy study = getCancerStudyByStableId(cancerStudyStableId);
- if (study != null){
- //setStatus(Status.UNAVAILABLE, cancerStudyStableId);
- deleteCancerStudy(study.getInternalId());
- }
- }
-
- public static Set getFreshGroups(int internalCancerStudyId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("SELECT * FROM cancer_study where cancer_study_id = ?");
- pstmt.setInt(1, internalCancerStudyId);
- rs = pstmt.executeQuery();
- if (rs.next()) {
- CancerStudy cancerStudy = extractCancerStudy(rs);
- return cancerStudy.getGroups();
- } else {
- return Collections.emptySet();
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- /**
- * Calls deleteCancerStudyByCascade() if cancer study exists by stable id.
- * @param cancerStudyStableId
- * @throws DaoException
- */
- public static void deleteCancerStudyByCascade(String cancerStudyStableId) throws DaoException {
- CancerStudy study = getCancerStudyByStableId(cancerStudyStableId);
- if (study != null) {
- deleteCancerStudyByCascade(study.getInternalId());
- }
- }
-
- /**
- * Deletes a cancer study by internal id from db with foreign key constraints enforced.
- * @param internalCancerStudyId
- * @throws DaoException
- */
- public static void deleteCancerStudyByCascade(int internalCancerStudyId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- pstmt = con.prepareStatement("DELETE FROM cancer_study WHERE cancer_study_id = ?");
- pstmt.setInt(1, internalCancerStudyId);
- int rows = pstmt.executeUpdate();
- // throw dao exception if no rows affected by update
- if (rows == 0) {
- throw new DaoException("deleteCancerStudyByCascade() failed: No rows affected");
- }
- removeCancerStudyFromCache(internalCancerStudyId);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- purgeUnreferencedRecordsAfterDeletionOfStudy();
- reCacheAll();
- System.out.println("deleted study:\nID: "+internalCancerStudyId);
- }
-
- /**
- * Deletes the Specified Cancer Study.
- * This method uses a large set of database operations to progressively delete all associated
- * data for a cancer study (including the study itself). A cleaner alternative based on
- * foreign key constraints and the cascade of delete operations is also available
- * (see deleteCancerStudyByCascade(int internalCancerStudyId)).
- *
- * Note to maintainers: Although deprecated, this method must be maintained for use in
- * environments where foreign key constraints are not in use, so remember to update the
- * implementation of this method if new tables are added or existing tables are changed.
- *
- * @param internalCancerStudyId Internal Cancer Study ID.
- * @throws DaoException Database Error.
- * @deprecated
- */
- public static void deleteCancerStudy(int internalCancerStudyId) throws DaoException {
- String[] deleteStudyStatements = {
- "DELETE FROM sample_cna_event WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM genetic_alteration WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM genetic_profile_samples WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM sample_profile WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM mutation WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM alteration_driver_annotation WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM mutation_count_by_keyword WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM clinical_attribute_meta WHERE CANCER_STUDY_ID=?",
- "DELETE FROM resource_definition WHERE CANCER_STUDY_ID=?",
- "DELETE FROM resource_study WHERE INTERNAL_ID=?",
- "DELETE FROM clinical_event_data WHERE CLINICAL_EVENT_ID IN (SELECT CLINICAL_EVENT_ID FROM clinical_event WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?))",
- "DELETE FROM clinical_event WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM sample_list_list WHERE LIST_ID IN (SELECT LIST_ID FROM sample_list WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM clinical_sample WHERE INTERNAL_ID IN (SELECT INTERNAL_ID FROM sample WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?))",
- "DELETE FROM resource_sample WHERE INTERNAL_ID IN (SELECT INTERNAL_ID FROM sample WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?))",
- "DELETE FROM copy_number_seg WHERE CANCER_STUDY_ID=?",
- "DELETE FROM copy_number_seg_file WHERE CANCER_STUDY_ID=?",
- "DELETE FROM sample WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM clinical_patient WHERE INTERNAL_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM resource_patient WHERE INTERNAL_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM patient WHERE CANCER_STUDY_ID=?",
- "DELETE FROM sample_list WHERE CANCER_STUDY_ID=?",
- "DELETE FROM structural_variant WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM genetic_profile_link WHERE REFERRED_GENETIC_PROFILE_ID IN (select GENETIC_PROFILE_ID FROM genetic_profile where CANCER_STUDY_ID=?)",
- "DELETE FROM genetic_profile WHERE CANCER_STUDY_ID=?",
- "DELETE FROM gistic_to_gene WHERE GISTIC_ROI_ID IN (SELECT GISTIC_ROI_ID FROM gistic WHERE CANCER_STUDY_ID=?)",
- "DELETE FROM gistic WHERE CANCER_STUDY_ID=?",
- "DELETE FROM mut_sig WHERE CANCER_STUDY_ID=?",
- "DELETE FROM cancer_study WHERE CANCER_STUDY_ID=?;"
- };
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- // check whether should delete generic assay meta profile by profile
- DaoGenericAssay.checkAndDeleteGenericAssayMetaInStudy(internalCancerStudyId);
-
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- for (String statementString : deleteStudyStatements) {
- pstmt = con.prepareStatement(statementString);
- if (statementString.contains("?")) {
- pstmt.setInt(1, internalCancerStudyId);
- }
- pstmt.executeUpdate();
- pstmt.close();
- }
- removeCancerStudyFromCache(internalCancerStudyId);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- purgeUnreferencedRecordsAfterDeletionOfStudy();
- reCacheAll();
- System.out.println("deleted study:\nID: "+internalCancerStudyId);
- }
-
- /**
- * Cleans up unreferenced records after cancer study deletion
- * @throws DaoException
- */
- public static void purgeUnreferencedRecordsAfterDeletionOfStudy() throws DaoException {
- String[] deleteStudyStatements = {
- "DELETE FROM cna_event WHERE NOT EXISTS (SELECT * FROM sample_cna_event WHERE sample_cna_event.CNA_EVENT_ID = cna_event.CNA_EVENT_ID)",
- "DELETE FROM mutation_event WHERE NOT EXISTS (SELECT * FROM mutation WHERE mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID)"
- };
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCancerStudy.class);
- for (String statementString : deleteStudyStatements) {
- pstmt = con.prepareStatement(statementString);
- pstmt.executeUpdate();
- pstmt.close();
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCancerStudy.class, con, pstmt, rs);
- }
- }
-
- /**
- * Extracts Cancer Study JDBC Results.
- */
- private static CancerStudy extractCancerStudy(ResultSet rs) throws DaoException {
- try {
- CancerStudy cancerStudy = new CancerStudy(rs.getString("NAME"),
- rs.getString("DESCRIPTION"),
- rs.getString("CANCER_STUDY_IDENTIFIER"),
- rs.getString("TYPE_OF_CANCER_ID"),
- rs.getBoolean("PUBLIC"));
- cancerStudy.setPmid(rs.getString("PMID"));
- cancerStudy.setCitation(rs.getString("CITATION"));
- cancerStudy.setGroupsInUpperCase(rs.getString("GROUPS"));
- cancerStudy.setInternalId(rs.getInt("CANCER_STUDY_ID"));
- cancerStudy.setImportDate(rs.getDate("IMPORT_DATE"));
- cancerStudy.setReferenceGenome(DaoReferenceGenome.getReferenceGenomeByInternalId(
- rs.getInt("REFERENCE_GENOME_ID")).getGenomeName());
- return cancerStudy;
- } catch (SQLException e) {
- throw new DaoException(e);
- }
- }
-
- private static boolean studyNeedsRecaching(String stableId, Integer ... internalId) {
- if (cacheOutOfSyncWithDb()) {
- return true;
- }
- try {
- java.util.Date importDate = null;
- java.util.Date cacheDate = null;
- if (internalId.length > 0) {
- importDate = getImportDate(null, internalId[0]);
- cacheDate = cacheDateByInternalId.get(internalId[0]);
- } else {
- if (stableId.equals(org.mskcc.cbio.portal.util.AccessControl.ALL_CANCER_STUDIES_ID)) {
- return false;
- }
- importDate = getImportDate(stableId);
- cacheDate = cacheDateByStableId.get(stableId);
- }
- return (importDate == null || cacheDate == null) ? false : cacheDate.before(importDate);
- } catch (ParseException e) {
- return false;
- } catch (DaoException e) {
- return false;
- }
- }
-
- private static boolean cacheOutOfSyncWithDb() {
- try {
- return getStudyCount() != byStableId.size();
- } catch (DaoException e) {
- }
- return false;
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalAttributeMeta.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalAttributeMeta.java
deleted file mode 100644
index 4a725c41c96..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalAttributeMeta.java
+++ /dev/null
@@ -1,252 +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.dao;
-
-import org.mskcc.cbio.portal.model.*;
-
-import com.google.inject.internal.Join;
-import org.apache.commons.lang3.StringUtils;
-
-import java.sql.*;
-import java.util.*;
-import org.mskcc.cbio.portal.util.InternalIdUtil;
-
-/**
- * Data Access Object for `clinical_attribute_meta` table
- *
- * @author Gideon Dresdner
- */
-public class DaoClinicalAttributeMeta {
-
- public static int addDatum(ClinicalAttribute attr) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalAttributeMeta.class);
- pstmt = con.prepareStatement
- ("INSERT INTO clinical_attribute_meta(" +
- "`ATTR_ID`," +
- "`DISPLAY_NAME`," +
- "`DESCRIPTION`," +
- "`DATATYPE`," +
- "`PATIENT_ATTRIBUTE`," +
- "`PRIORITY`," +
- "`CANCER_STUDY_ID`)" +
- " VALUES(?,?,?,?,?,?,?)");
- pstmt.setString(1, attr.getAttrId());
- pstmt.setString(2, attr.getDisplayName());
- pstmt.setString(3, attr.getDescription());
- pstmt.setString(4, attr.getDatatype());
- pstmt.setBoolean(5, attr.isPatientAttribute());
- pstmt.setString(6, attr.getPriority());
- pstmt.setInt(7, attr.getCancerStudyId());
- return pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalAttributeMeta.class, con, pstmt, rs);
- }
- }
-
- private static ClinicalAttribute unpack(ResultSet rs) throws SQLException {
- return new ClinicalAttribute(rs.getString("ATTR_ID"),
- rs.getString("DISPLAY_NAME"),
- rs.getString("DESCRIPTION"),
- rs.getString("DATATYPE"),
- rs.getBoolean("PATIENT_ATTRIBUTE"),
- rs.getString("PRIORITY"),
- rs.getInt("CANCER_STUDY_ID"));
- }
-
- public static ClinicalAttribute getDatum(String attrId, Integer cancerStudyId) throws DaoException {
- List attrs = getDatum(Arrays.asList(attrId), cancerStudyId);
- if (attrs.isEmpty()) {
- return null;
- }
-
- return attrs.get(0);
- }
-
- public static List getDatum(Collection attrIds, Integer cancerStudyId) throws DaoException {
- if(attrIds == null || attrIds.isEmpty() ) {
- return Collections.emptyList();
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalAttributeMeta.class);
-
- pstmt = con.prepareStatement("SELECT * FROM clinical_attribute_meta WHERE ATTR_ID IN ('"
- + StringUtils.join(attrIds,"','")+"') AND CANCER_STUDY_ID=" + String.valueOf(cancerStudyId));
-
- rs = pstmt.executeQuery();
-
- List list = new ArrayList();
- while (rs.next()) {
- list.add(unpack(rs));
- }
-
- return list;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalAttributeMeta.class, con, pstmt, rs);
- }
- }
-
- public static List getDatum(Collection attrIds) throws DaoException {
- if(attrIds == null || attrIds.isEmpty() ) {
- return Collections.emptyList();
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalAttributeMeta.class);
-
- pstmt = con.prepareStatement("SELECT * FROM clinical_attribute_meta WHERE ATTR_ID IN ('"
- + StringUtils.join(attrIds,"','")+"')");
-
- rs = pstmt.executeQuery();
-
- List list = new ArrayList();
- while (rs.next()) {
- list.add(unpack(rs));
- }
-
- return list;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalAttributeMeta.class, con, pstmt, rs);
- }
- }
-
- public static List getDataByStudy(int cancerStudyId) throws DaoException
- {
- List attrs = new ArrayList();
- attrs.addAll(getDataByCancerStudyId(cancerStudyId));
-
- return attrs;
- }
-
- /**
- * Gets all the clinical attributes for a particular set of samples
- * Looks in the clinical table for all records associated with any of the samples, extracts and uniques
- * the attribute ids, then finally uses the attribute ids to fetch the clinical attributes from the db.
- *
- * @param sampleIdSet
- * @return
- * @throws DaoException
- */
- private static List getDataByCancerStudyId(int cancerStudyId) throws DaoException {
-
- Connection con = null;
- ResultSet rs = null;
- PreparedStatement pstmt = null;
-
- String sql = ("SELECT DISTINCT ATTR_ID FROM clinical_attribute_meta"
- + " WHERE CANCER_STUDY_ID = " + String.valueOf(cancerStudyId));
-
- Set attrIds = new HashSet();
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalAttributeMeta.class);
- pstmt = con.prepareStatement(sql);
- rs = pstmt.executeQuery();
-
- while(rs.next()) {
- attrIds.add(rs.getString("ATTR_ID"));
- }
-
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalAttributeMeta.class, con, pstmt, rs);
- }
-
- return getDatum(attrIds, cancerStudyId);
- }
-
- private static Collection getAll() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- Collection all = new ArrayList();
-
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalAttributeMeta.class);
- pstmt = con.prepareStatement("SELECT * FROM clinical_attribute_meta");
- rs = pstmt.executeQuery();
-
- while (rs.next()) {
- all.add(unpack(rs));
- }
-
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalAttributeMeta.class, con, pstmt, rs);
- }
- return all;
- }
-
- public static Map getAllMap() throws DaoException {
-
- HashMap toReturn = new HashMap();
- for (ClinicalAttribute clinicalAttribute : DaoClinicalAttributeMeta.getAll()) {
- toReturn.put(clinicalAttribute.getAttrId(), clinicalAttribute.getDisplayName());
- }
- return toReturn;
- }
-
- /**
- * Deletes all Records.
- * @throws DaoException DAO Error.
- */
- public static void deleteAllRecords() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalAttributeMeta.class);
- pstmt = con.prepareStatement("TRUNCATE TABLE clinical_attribute_meta");
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalAttributeMeta.class, con, pstmt, rs);
- }
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalData.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalData.java
deleted file mode 100755
index f626d9f4c1a..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalData.java
+++ /dev/null
@@ -1,663 +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.dao;
-
-import org.mskcc.cbio.portal.model.*;
-import org.mskcc.cbio.portal.util.InternalIdUtil;
-
-import org.apache.commons.lang3.StringUtils;
-
-import java.sql.*;
-import java.util.*;
-
-/**
- * Data Access Object for `clinical` table
- *
- * @author Gideon Dresdner dresdnerg@cbio.mskcc.org
- */
-public final class DaoClinicalData {
-
- public static final String SAMPLE_TABLE = "clinical_sample";
- public static final String PATIENT_TABLE = "clinical_patient";
-
- private static final String SAMPLE_INSERT = "INSERT INTO " + SAMPLE_TABLE + "(`INTERAL_ID`,`ATTR_ID`,`ATTR_VALUE` VALUES(?,?,?)";
- private static final String PATIENT_INSERT = "INSERT INTO " + PATIENT_TABLE + "(`INTERNAL_ID`,`ATTR_ID`,`ATTR_VALUE` VALUES(?,?,?)";
-
- private static final Map sampleAttributes = new HashMap();
- private static final Map patientAttributes = new HashMap();
-
- private DaoClinicalData() {}
-
- public static synchronized void reCache()
- {
- clearCache();
- cacheAttributes(SAMPLE_TABLE, sampleAttributes);
- cacheAttributes(PATIENT_TABLE, patientAttributes);
- }
-
- private static void clearCache()
- {
- sampleAttributes.clear();
- patientAttributes.clear();
- }
-
- private static void cacheAttributes(String table, Map cache)
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- pstmt = con.prepareStatement("SELECT * FROM " + table);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- cache.put(rs.getString("ATTR_ID"), rs.getString("ATTR_ID"));
- }
- }
- catch (SQLException e) {
- e.printStackTrace();
- }
- finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- }
-
- public static int addSampleDatum(int internalSampleId, String attrId, String attrVal) throws DaoException
- {
- sampleAttributes.put(attrId, attrId);
- return addDatum(SAMPLE_INSERT, SAMPLE_TABLE, internalSampleId, attrId, attrVal);
- }
-
- public static int addPatientDatum(int internalPatientId, String attrId, String attrVal) throws DaoException
- {
- patientAttributes.put(attrId, attrId);
- return addDatum(PATIENT_INSERT, PATIENT_TABLE, internalPatientId, attrId, attrVal);
- }
-
- public static int addDatum(String query, String tableName,
- int internalId, String attrId, String attrVal) throws DaoException
- {
- if (MySQLbulkLoader.isBulkLoad()) {
- MySQLbulkLoader.getMySQLbulkLoader(tableName).insertRecord(Integer.toString(internalId),
- attrId,
- attrVal);
- return 1;
- }
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
-
- pstmt = con.prepareStatement(query);
- pstmt.setInt(1, internalId);
- pstmt.setString(2, attrId);
- pstmt.setString(3, attrVal);
- int toReturn = pstmt.executeUpdate();
-
- if (tableName.equals(PATIENT_TABLE)) {
- patientAttributes.put(attrId, attrId);
- }
- else {
- sampleAttributes.put(attrId, attrId);
- }
-
- return toReturn;
- }
- catch (SQLException e) {
- throw new DaoException(e);
- }
- finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- }
-
- public static ClinicalData getDatum(String cancerStudyId, String patientId, String attrId) throws DaoException
- {
- int internalCancerStudyId = getInternalCancerStudyId(cancerStudyId);
- String table = getAttributeTable(attrId);
- if (table==null) {
- return null;
- }
- return getDatum(internalCancerStudyId,
- table,
- DaoPatient.getPatientByCancerStudyAndPatientId(internalCancerStudyId, patientId).getInternalId(),
- attrId);
- }
-
- private static int getInternalCancerStudyId(String cancerStudyId) throws DaoException
- {
- return DaoCancerStudy.getCancerStudyByStableId(cancerStudyId).getInternalId();
- }
-
-
- private static String getAttributeTable(String attrId) throws DaoException
- {
- if (sampleAttributes.containsKey(attrId)) {
- return SAMPLE_TABLE;
- }
- else if (patientAttributes.containsKey(attrId)) {
- return (PATIENT_TABLE);
- }
- else {
- return null;
- }
- }
-
- private static ClinicalData getDatum(int internalCancerStudyId, String table, int internalId, String attrId) throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
-
- pstmt = con.prepareStatement("SELECT * FROM " + table +
- " WHERE INTERNAL_ID=? AND ATTR_ID=?");
- pstmt.setInt(1, internalId);
- pstmt.setString(2, attrId);
-
- rs = pstmt.executeQuery();
- if (rs.next()) {
- return extract(table, internalCancerStudyId, rs);
- }
- else {
- return null;
- }
- }
- catch (SQLException e) {
- throw new DaoException(e);
- }
- finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- }
-
- public static List getDataByPatientId(int cancerStudyId, String patientId) throws DaoException
- {
- List internalIds = new ArrayList();
- internalIds.add(DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudyId, patientId).getInternalId());
- return getDataByInternalIds(cancerStudyId, PATIENT_TABLE, internalIds);
- }
-
- private static List getDataByInternalIds(int internalCancerStudyId, String table, List internalIds) throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- List clinicals = new ArrayList();
- String sql = ("SELECT * FROM " + table + " WHERE `INTERNAL_ID` IN " +
- "(" + generateIdsSql(internalIds) + ")");
-
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- pstmt = con.prepareStatement(sql);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- clinicals.add(extract(table, internalCancerStudyId, rs));
- }
- }
- catch (SQLException e) {
- throw new DaoException(e);
- }
- finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
-
- return clinicals;
- }
-
- public static List getData(String cancerStudyId) throws DaoException
- {
- return getData(getInternalCancerStudyId(cancerStudyId));
- }
- public static List getData(int cancerStudyId) throws DaoException
- {
-
- return getDataByInternalIds(cancerStudyId, PATIENT_TABLE, getPatientIdsByCancerStudy(cancerStudyId));
- }
-
- private static List getPatientIdsByCancerStudy(int cancerStudyId)
- {
- List patientIds = new ArrayList();
- for (Patient patient : DaoPatient.getPatientsByCancerStudyId(cancerStudyId)) {
- patientIds.add(patient.getInternalId());
- }
- return patientIds;
- }
-
- private static List getSampleIdsByCancerStudy(int cancerStudyId)
- {
- List sampleIds = new ArrayList();
- for (Patient patient : DaoPatient.getPatientsByCancerStudyId(cancerStudyId)) {
- for (Sample s : DaoSample.getSamplesByPatientId(patient.getInternalId())) {
- sampleIds.add(s.getInternalId());
- }
- }
- return sampleIds;
- }
-
- public static List getData(String cancerStudyId, Collection patientIds) throws DaoException
- {
- return getData(getInternalCancerStudyId(cancerStudyId), patientIds);
- }
- public static List getData(int cancerStudyId, Collection patientIds) throws DaoException
- {
- List patientIdsInt = new ArrayList();
- for (String patientId : patientIds) {
- patientIdsInt.add(DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudyId, patientId).getInternalId());
- }
-
- return getDataByInternalIds(cancerStudyId, PATIENT_TABLE, patientIdsInt);
- }
-
- public static List getSampleAndPatientData(int cancerStudyId, Collection sampleIds) throws DaoException
- {
- List sampleIdsInt = new ArrayList();
- List patientIdsInt = new ArrayList();
- Map> mapPatientIdSampleIds = new HashMap>();
- for (String sampleId : sampleIds) {
- Sample sample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudyId, sampleId);
- sampleIdsInt.add(sample.getInternalId());
- int patientIdInt = sample.getInternalPatientId();
- String patientIdStable = DaoPatient.getPatientById(patientIdInt).getStableId();
- patientIdsInt.add(patientIdInt);
- Set sampleIdsForPatient = mapPatientIdSampleIds.get(patientIdStable);
- if (sampleIdsForPatient==null) {
- sampleIdsForPatient = new HashSet();
- mapPatientIdSampleIds.put(patientIdStable, sampleIdsForPatient);
- }
- sampleIdsForPatient.add(sampleId);
- }
- List sampleClinicalData = getDataByInternalIds(cancerStudyId, SAMPLE_TABLE, sampleIdsInt);
-
- List patientClinicalData = getDataByInternalIds(cancerStudyId, PATIENT_TABLE, patientIdsInt);
- for (ClinicalData cd : patientClinicalData) {
- String stablePatientId = cd.getStableId();
- Set sampleIdsForPatient = mapPatientIdSampleIds.get(stablePatientId);
- for (String sampleId : sampleIdsForPatient) {
- ClinicalData cdSample = new ClinicalData(cd);
- cdSample.setStableId(sampleId);
- sampleClinicalData.add(cdSample);
- }
- }
-
- return sampleClinicalData;
- }
-
- public static List getSampleAndPatientData(int cancerStudyId, Collection sampleIds, ClinicalAttribute attr) throws DaoException
- {
- List sampleIdsInt = new ArrayList();
- List patientIdsInt = new ArrayList();
- Map> mapPatientIdSampleIds = new HashMap>();
- for (String sampleId : sampleIds) {
- Sample sample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudyId, sampleId);
- sampleIdsInt.add(sample.getInternalId());
- int patientIdInt = sample.getInternalPatientId();
- String patientIdStable = DaoPatient.getPatientById(patientIdInt).getStableId();
- patientIdsInt.add(patientIdInt);
- Set sampleIdsForPatient = mapPatientIdSampleIds.get(patientIdStable);
- if (sampleIdsForPatient==null) {
- sampleIdsForPatient = new HashSet();
- mapPatientIdSampleIds.put(patientIdStable, sampleIdsForPatient);
- }
- sampleIdsForPatient.add(sampleId);
- }
- List sampleClinicalData = getDataByInternalIds(cancerStudyId, SAMPLE_TABLE, sampleIdsInt, Collections.singletonList(attr.getAttrId()));
-
- List patientClinicalData = getDataByInternalIds(cancerStudyId, PATIENT_TABLE, patientIdsInt, Collections.singletonList(attr.getAttrId()));
- for (ClinicalData cd : patientClinicalData) {
- String stablePatientId = cd.getStableId();
- Set sampleIdsForPatient = mapPatientIdSampleIds.get(stablePatientId);
- for (String sampleId : sampleIdsForPatient) {
- ClinicalData cdSample = new ClinicalData(cd);
- cdSample.setStableId(sampleId);
- sampleClinicalData.add(cdSample);
- }
- }
-
- return sampleClinicalData;
- }
-
- public static List getSampleData(int cancerStudyId, Collection sampleIds, ClinicalAttribute attr) throws DaoException
- {
- List sampleIdsInt = new ArrayList();
- for (String sampleId : sampleIds) {
- Sample _sample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudyId, sampleId);
- if (_sample != null) {
- sampleIdsInt.add(_sample.getInternalId());
- }
- }
- return getDataByInternalIds(cancerStudyId, SAMPLE_TABLE, sampleIdsInt, Collections.singletonList(attr.getAttrId()));
- }
-
- public static List getSampleData(int cancerStudyId, Collection sampleIds) throws DaoException
- {
- List sampleIdsInt = new ArrayList();
- for (String sampleId : sampleIds) {
- sampleIdsInt.add(DaoSample.getSampleByCancerStudyAndSampleId(cancerStudyId, sampleId).getInternalId());
- }
- return getDataByInternalIds(cancerStudyId, SAMPLE_TABLE, sampleIdsInt);
- }
-
- public static List getData(String cancerStudyId, Collection patientIds, ClinicalAttribute attr) throws DaoException
- {
- int internalCancerStudyId = getInternalCancerStudyId(cancerStudyId);
- List patientIdsInt = new ArrayList();
- for (String patientId : patientIds) {
- patientIdsInt.add(DaoPatient.getPatientByCancerStudyAndPatientId(internalCancerStudyId, patientId).getInternalId());
- }
-
- return getDataByInternalIds(internalCancerStudyId, PATIENT_TABLE, patientIdsInt, Collections.singletonList(attr.getAttrId()));
- }
-
- private static List getDataByInternalIds(int internalCancerStudyId, String table, List internalIds, Collection attributeIds) throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- List clinicals = new ArrayList();
-
- String sql = ("SELECT * FROM " + table + " WHERE `INTERNAL_ID` IN " +
- "(" + generateIdsSql(internalIds) + ") " +
- " AND ATTR_ID IN ('"+ StringUtils.join(attributeIds, "','")+"') ");
-
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- pstmt = con.prepareStatement(sql);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- clinicals.add(extract(table, internalCancerStudyId, rs));
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- }
- finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- return clinicals;
- }
-
- public static List getDataByAttributeIds(int internalCancerStudyId, Collection attributeIds) throws DaoException {
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- List clinicals = new ArrayList();
-
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
-
- pstmt = con.prepareStatement("SELECT * FROM clinical_patient WHERE" +
- " ATTR_ID IN ('" + StringUtils.join(attributeIds, "','") +"') ");
-
- List patients = getPatientIdsByCancerStudy(internalCancerStudyId);
-
- rs = pstmt.executeQuery();
- while(rs.next()) {
- Integer patientId = rs.getInt("INTERNAL_ID");
- if (patients.contains(patientId)) {
- clinicals.add(extract(PATIENT_TABLE, internalCancerStudyId, rs));
- }
- }
- }
- catch (SQLException e) {
- throw new DaoException(e);
- }
- finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
-
- return clinicals;
- }
-
- private static ClinicalData extract(String table, int internalCancerStudyId, ResultSet rs) throws SQLException {
- // get
- String stableId = getStableIdFromInternalId(table, rs.getInt("INTERNAL_ID"));
- return new ClinicalData(internalCancerStudyId,
- stableId,
- rs.getString("ATTR_ID"),
- rs.getString("ATTR_VALUE"));
- }
-
- private static String getStableIdFromInternalId(String table, int internalId)
- {
- if (table.equals(SAMPLE_TABLE)) {
- return DaoSample.getSampleById(internalId).getStableId();
- }
- else {
- return DaoPatient.getPatientById(internalId).getStableId();
- }
- }
-
- private static String generateIdsSql(Collection ids) {
- return "'" + StringUtils.join(ids, "','") + "'";
- }
-
- public static void deleteAllRecords() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- pstmt = con.prepareStatement("TRUNCATE TABLE clinical_patient");
- pstmt.executeUpdate();
- pstmt = con.prepareStatement("TRUNCATE TABLE clinical_sample");
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- reCache();
- }
-
- /*********************************************************
- * Previous DaoClinicalData class methods (accessors only)
- *********************************************************/
-
- /**
- * Returns the survival data for the given patientSet, NOT necessarily in the
- * same order as the patientSet.
- *
- * @param cancerStudyId: the cancerstudy internal id
- * @param patientSet: set of patient ids
- * @return
- * @throws DaoException
- */
- public static List getSurvivalData(int cancerStudyId, Collection patientSet) throws DaoException {
- CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByInternalId(cancerStudyId);
- List data = getData(cancerStudyId, patientSet);
- Map> clinicalData = new LinkedHashMap>();
- for (ClinicalData cd : data) {
- String patientId = cd.getStableId();
- Map msc = clinicalData.get(cd.getStableId());
- if (msc==null) {
- msc = new HashMap();
- clinicalData.put(patientId, msc);
- }
- msc.put(cd.getAttrId(), cd);
- }
-
- ArrayList toReturn = new ArrayList();
- for (Map.Entry> entry : clinicalData.entrySet()) {
- Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudyId, entry.getKey());
- toReturn.add(new Patient(cancerStudy, patient.getStableId(), patient.getInternalId(), entry.getValue()));
- }
- return toReturn;
- }
-
- /**************************************************************
- * Previous DaoClinicalFreeForm class methods (accessors only)
- *************************************************************/
-
- public static List getDataSlice(int cancerStudyId, Collection attributeIds) throws DaoException {
-
- Map> mapAttrStableIdValue = new HashMap>();
- for (ClinicalData cd : getDataByAttributeIds(cancerStudyId, attributeIds)) {
-
- String attrId = cd.getAttrId();
- String value = cd.getAttrVal();
- String stableId = cd.getStableId();
-
- if (value.isEmpty() || value.equals(ClinicalAttribute.NA)) {
- continue;
- }
-
- Map mapStableIdValue = mapAttrStableIdValue.get(attrId);
- if (mapStableIdValue == null) {
- mapStableIdValue = new HashMap();
- mapAttrStableIdValue.put(attrId, mapStableIdValue);
- }
- mapStableIdValue.put(stableId, value);
- }
-
- List maps = new ArrayList();
- for (Map.Entry> entry : mapAttrStableIdValue.entrySet()) {
- maps.add(new ClinicalParameterMap(entry.getKey(), entry.getValue()));
- }
-
- return maps;
- }
-
- public static HashSet getDistinctParameters(int cancerStudyId) throws DaoException {
-
- HashSet toReturn = new HashSet();
- for (ClinicalData clinicalData : DaoClinicalData.getData(cancerStudyId)) {
- toReturn.add(clinicalData.getAttrId());
- }
-
- return toReturn;
- }
- public static HashSet getAllPatients(int cancerStudyId) throws DaoException {
-
- HashSet toReturn = new HashSet();
- for (ClinicalData clinicalData : getData(cancerStudyId)) {
- toReturn.add(clinicalData.getStableId());
- }
-
- return toReturn;
- }
- public static List getDataByCancerStudy(int cancerStudyId) throws DaoException {
-
- return DaoClinicalData.getData(cancerStudyId);
- }
-
- public static List getDataByPatientIds(int cancerStudyId, List patientIds) throws DaoException {
-
- return DaoClinicalData.getData(cancerStudyId, patientIds);
- }
-
- public static List getPatientsByAttribute(int cancerStudy, String paramName, String paramValue) throws DaoException
- {
- List ids = getIdsByAttribute(cancerStudy, paramName, paramValue, PATIENT_TABLE);
- return InternalIdUtil.getPatientsById(ids);
- }
-
- public static List getSamplesByAttribute(int cancerStudy, String paramName, String paramValue) throws DaoException
- {
- List ids = getIdsByAttribute(cancerStudy, paramName, paramValue, SAMPLE_TABLE);
- return InternalIdUtil.getSamplesById(ids);
- }
-
-
- private static List getIdsByAttribute(int cancerStudyId, String paramName, String paramValue, String tableName) throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try{
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- pstmt = con.prepareStatement ("SELECT INTERNAL_ID FROM `" + tableName + "`"
- + " WHERE ATTR_ID=? AND ATTR_VALUE=?");
- pstmt.setString(1, paramName);
- pstmt.setString(2, paramValue);
- rs = pstmt.executeQuery();
-
- List ids = new ArrayList();
-
- while (rs.next())
- {
- ids.add(rs.getInt("INTERNAL_ID"));
- }
-
- return ids;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- }
-
- // get cancerType from the clinical_sample table to determine whether we have multiple cancer types
- // for given samples
- public static Map> getCancerTypeInfoBySamples(List samplesList) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
-
- try{
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- pstmt = con.prepareStatement("select " +
- "distinct ATTR_VALUE as attributeValue, " +
- "ATTR_ID as attributeID from clinical_sample " +
- "where ATTR_ID in (?, ?) and INTERNAL_ID in (" +
- "select INTERNAL_ID from sample where STABLE_ID in ('"
- + StringUtils.join(samplesList,"','")+"'))");
- pstmt.setString(1, ClinicalAttribute.CANCER_TYPE);
- pstmt.setString(2, ClinicalAttribute.CANCER_TYPE_DETAILED);
- rs = pstmt.executeQuery();
-
- // create a map for the results
- Map> result = new LinkedHashMap>();
- result.put( ClinicalAttribute.CANCER_TYPE, new HashSet());
- result.put( ClinicalAttribute.CANCER_TYPE_DETAILED, new HashSet());
- while (rs.next())
- {
- result.get(rs.getString("attributeID")).add(rs.getString("attributeValue"));
- }
-
- return result;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalEvent.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalEvent.java
deleted file mode 100644
index 21722902701..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoClinicalEvent.java
+++ /dev/null
@@ -1,224 +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.dao;
-
-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;
-import org.apache.commons.lang3.StringUtils;
-import org.mskcc.cbio.portal.model.ClinicalEvent;
-
-/**
- *
- * @author gaoj
- */
-public final class DaoClinicalEvent {
- private DaoClinicalEvent() {}
-
- public static int addClinicalEvent(ClinicalEvent clinicalEvent) {
- if (!MySQLbulkLoader.isBulkLoad()) {
- throw new IllegalStateException("Only buld load mode is allowed for importing clinical events");
- }
-
- MySQLbulkLoader.getMySQLbulkLoader("clinical_event").insertRecord(
- Long.toString(clinicalEvent.getClinicalEventId()),
- Integer.toString(clinicalEvent.getPatientId()),
- clinicalEvent.getStartDate().toString(),
- clinicalEvent.getStopDate()==null?null:clinicalEvent.getStopDate().toString(),
- clinicalEvent.getEventType()
- );
- return 1+addClinicalEventData(clinicalEvent);
- }
-
- private static int addClinicalEventData(ClinicalEvent clinicalEvent) {
- long eventId = clinicalEvent.getClinicalEventId();
- for (Map.Entry entry : clinicalEvent.getEventData().entrySet()) {
- MySQLbulkLoader.getMySQLbulkLoader("clinical_event_data").insertRecord(
- Long.toString(eventId),
- entry.getKey(),
- entry.getValue()
- );
- }
- return 1;
-
- }
-
- public static List getClinicalEvent(int patientId) throws DaoException {
- return getClinicalEvent(patientId, null);
- }
-
- public static List getClinicalEvent(int patientId, String eventType) throws DaoException {
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalEvent.class);
-
- // get events first
- if (eventType==null) {
- pstmt = con.prepareStatement("SELECT * FROM clinical_event WHERE PATIENT_ID=?");
- } else {
- pstmt = con.prepareStatement("SELECT * FROM clinical_event WHERE PATIENT_ID=? AND EVENT_TYPE=?");
- }
- pstmt.setInt(1, patientId);
- if (eventType!=null) {
- pstmt.setString(2, eventType);
- }
-
- rs = pstmt.executeQuery();
- Map clinicalEvents = new HashMap();
- while (rs.next()) {
- ClinicalEvent clinicalEvent = extractClinicalEvent(rs);
- clinicalEvents.put(clinicalEvent.getClinicalEventId(), clinicalEvent);
- }
-
- rs.close();
-
- // get data then
- if (!clinicalEvents.isEmpty()) {
- pstmt = con.prepareStatement("SELECT * FROM clinical_event_data WHERE CLINICAL_EVENT_ID IN ("
- + StringUtils.join(clinicalEvents.keySet(), ",") + ")");
-
- rs = pstmt.executeQuery();
- while (rs.next()) {
- long eventId = rs.getLong("CLINICAL_EVENT_ID");
- clinicalEvents.get(eventId).addEventDatum(rs.getString("KEY"), rs.getString("VALUE"));
- }
- }
-
- return new ArrayList(clinicalEvents.values());
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalEvent.class, con, pstmt, rs);
- }
- }
-
- private static ClinicalEvent extractClinicalEvent(ResultSet rs) throws SQLException {
- ClinicalEvent clinicalEvent = new ClinicalEvent();
- clinicalEvent.setClinicalEventId(rs.getLong("CLINICAL_EVENT_ID"));
- clinicalEvent.setPatientId(rs.getInt("PATIENT_ID"));
- clinicalEvent.setStartDate(JdbcUtil.readLongFromResultSet(rs, "START_DATE"));
- clinicalEvent.setStopDate(JdbcUtil.readLongFromResultSet(rs, "STOP_DATE"));
- clinicalEvent.setEventType(rs.getString("EVENT_TYPE"));
- return clinicalEvent;
- }
-
- public static long getLargestClinicalEventId() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalEvent.class);
- pstmt = con.prepareStatement
- ("SELECT MAX(`CLINICAL_EVENT_ID`) FROM `clinical_event`");
- rs = pstmt.executeQuery();
- return rs.next() ? rs.getLong(1) : 0;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalEvent.class, con, pstmt, rs);
- }
- }
-
- /**
- *
- * @param cancerStudyId
- * @param caseId
- * @return true if timeline data exist for the case
- * @throws DaoException
- */
- public static boolean timeEventsExistForPatient(int patientId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegment.class);
- pstmt = con.prepareStatement("SELECT EXISTS(SELECT 1 FROM `clinical_event` WHERE `PATIENT_ID`=?)");
- pstmt.setInt(1, patientId);
- rs = pstmt.executeQuery();
- return rs.next() && rs.getInt(1)==1;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-
- public static void deleteByCancerStudyId(int cancerStudyId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalEvent.class);
-
- pstmt = con.prepareStatement("DELETE FROM clinical_event_data WHERE CLINICAL_EVENT_ID IN "
- + "(SELECT CLINICAL_EVENT_ID FROM clinical_event WHERE PATIENT_ID in (SELECT INTERNAL_ID FROM patient where CANCER_STUDY_ID=?))");
- pstmt.setInt(1, cancerStudyId);
- pstmt.executeUpdate();
-
- pstmt = con.prepareStatement("DELETE FROM clinical_event WHERE PATIENT_ID in (SELECT INTERNAL_ID FROM patient where CANCER_STUDY_ID=?)");
- pstmt.setInt(1, cancerStudyId);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalEvent.class, con, pstmt, rs);
- }
- }
-
- public static void deleteAllRecords() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoClinicalData.class);
- JdbcUtil.disableForeignKeyCheck(con);
- pstmt = con.prepareStatement("TRUNCATE TABLE clinical_event_data");
- pstmt.executeUpdate();
- pstmt = con.prepareStatement("TRUNCATE TABLE clinical_event");
- pstmt.executeUpdate();
- JdbcUtil.enableForeignKeyCheck(con);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoClinicalData.class, con, pstmt, rs);
- }
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCnaEvent.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCnaEvent.java
deleted file mode 100644
index e7785d4f6c6..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCnaEvent.java
+++ /dev/null
@@ -1,356 +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.dao;
-
-import org.apache.commons.lang3.StringUtils;
-import org.mskcc.cbio.portal.model.CnaEvent;
-import org.mskcc.cbio.portal.model.Sample;
-
-import java.sql.*;
-import java.util.*;
-
-/**
- *
- * @author jgao
- */
-public final class DaoCnaEvent {
- private DaoCnaEvent() {}
-
- public static void addCaseCnaEvent(CnaEvent cnaEvent, boolean newCnaEvent) throws DaoException {
- if (!MySQLbulkLoader.isBulkLoad()) {
- throw new DaoException("You have to turn on MySQLbulkLoader in order to insert sample_cna_event");
- }
- else {
- long eventId = cnaEvent.getEventId();
- if (newCnaEvent) {
- eventId = addCnaEventDirectly(cnaEvent);
- // update object based on new DB id (since this object is locally cached after this):
- cnaEvent.setEventId(eventId);
- }
-
- MySQLbulkLoader.getMySQLbulkLoader("sample_cna_event").insertRecord(
- Long.toString(eventId),
- Integer.toString(cnaEvent.getSampleId()),
- Integer.toString(cnaEvent.getCnaProfileId()),
- cnaEvent.getAnnotationJson()
- );
-
- if ((cnaEvent.getDriverFilter() != null
- && !cnaEvent.getDriverFilter().isEmpty()
- && !cnaEvent.getDriverFilter().toLowerCase().equals("na"))
- ||
- (cnaEvent.getDriverTiersFilter() != null
- && !cnaEvent.getDriverTiersFilter().isEmpty()
- && !cnaEvent.getDriverTiersFilter().toLowerCase().equals("na"))
- ) {
- MySQLbulkLoader
- .getMySQLbulkLoader("alteration_driver_annotation")
- .insertRecord(
- Long.toString(eventId),
- Integer.toString(cnaEvent.getCnaProfileId()),
- Integer.toString(cnaEvent.getSampleId()),
- cnaEvent.getDriverFilter(),
- cnaEvent.getDriverFilterAnnotation(),
- cnaEvent.getDriverTiersFilter(),
- cnaEvent.getDriverTiersFilterAnnotation()
- );
- }
- }
- }
-
- /**
- * Add new event directly and return the auto increment value.
- *
- * @param cnaEvent
- * @return
- * @throws DaoException
- */
- private static long addCnaEventDirectly(CnaEvent cnaEvent) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- pstmt = con.prepareStatement
- ("INSERT INTO cna_event (" +
- "`ENTREZ_GENE_ID`," +
- "`ALTERATION` )" +
- " VALUES(?,?)", Statement.RETURN_GENERATED_KEYS);
- pstmt.setLong(1, cnaEvent.getEntrezGeneId());
- pstmt.setShort(2, cnaEvent.getAlteration().getCode());
- pstmt.executeUpdate();
- rs = pstmt.getGeneratedKeys();
- rs.next();
- long newId = rs.getLong(1);
- return newId;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-
- public static Map> getSamplesWithAlterations(
- Collection eventIds) throws DaoException {
- return getSamplesWithAlterations(StringUtils.join(eventIds, ","));
- }
-
- public static Map> getSamplesWithAlterations(String concatEventIds)
- throws DaoException {
- if (concatEventIds.isEmpty()) {
- return Collections.emptyMap();
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- String sql = "SELECT * FROM sample_cna_event"
- + " WHERE `CNA_EVENT_ID` IN ("
- + concatEventIds + ")";
- pstmt = con.prepareStatement(sql);
-
- Map> map = new HashMap> ();
- rs = pstmt.executeQuery();
- while (rs.next()) {
- Sample sample = DaoSample.getSampleById(rs.getInt("SAMPLE_ID"));
- long eventId = rs.getLong("CNA_EVENT_ID");
- Set events = map.get(sample);
- if (events == null) {
- events = new HashSet();
- map.put(sample, events);
- }
- events.add(eventId);
- }
- return map;
- } catch (NullPointerException e) {
- throw new DaoException(e);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-
- public static List getCnaEvents(List sampleIds, Collection entrezGeneIds , int profileId, Collection cnaLevels) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- pstmt = con.prepareStatement
- ("SELECT sample_cna_event.CNA_EVENT_ID,"
- + " sample_cna_event.SAMPLE_ID,"
- + " sample_cna_event.GENETIC_PROFILE_ID,"
- + " ENTREZ_GENE_ID,"
- + " ALTERATION,"
- + " alteration_driver_annotation.DRIVER_FILTER,"
- + " alteration_driver_annotation.DRIVER_FILTER_ANNOTATION,"
- + " alteration_driver_annotation.DRIVER_TIERS_FILTER,"
- + " alteration_driver_annotation.DRIVER_TIERS_FILTER_ANNOTATION"
- + " FROM sample_cna_event"
- + " LEFT JOIN alteration_driver_annotation ON"
- + " sample_cna_event.GENETIC_PROFILE_ID = alteration_driver_annotation.GENETIC_PROFILE_ID"
- + " and sample_cna_event.SAMPLE_ID = alteration_driver_annotation.SAMPLE_ID"
- + " and sample_cna_event.CNA_EVENT_ID = alteration_driver_annotation.ALTERATION_EVENT_ID,"
- + " cna_event"
- + " WHERE sample_cna_event.GENETIC_PROFILE_ID=?"
- + " AND sample_cna_event.CNA_EVENT_ID=cna_event.CNA_EVENT_ID"
- + (entrezGeneIds==null?"":" AND ENTREZ_GENE_ID IN(" + StringUtils.join(entrezGeneIds,",") + ")")
- + " AND ALTERATION IN (" + StringUtils.join(cnaLevels,",") + ")"
- + " AND sample_cna_event.SAMPLE_ID in ('"+StringUtils.join(sampleIds, "','")+"')");
- pstmt.setInt(1, profileId);
- rs = pstmt.executeQuery();
- List events = new ArrayList();
- while (rs.next()) {
- events.add(extractCnaEvent(rs));
- }
- return events;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-
- private static CnaEvent extractCnaEvent(ResultSet rs) throws SQLException {
- CnaEvent cnaEvent = new CnaEvent(rs.getInt("SAMPLE_ID"),
- rs.getInt("GENETIC_PROFILE_ID"),
- rs.getLong("ENTREZ_GENE_ID"),
- rs.getShort("ALTERATION"));
- cnaEvent.setEventId(rs.getLong("CNA_EVENT_ID"));
- cnaEvent.setDriverFilter(rs.getString("DRIVER_FILTER"));
- cnaEvent.setDriverFilterAnnotation(rs.getString("DRIVER_FILTER_ANNOTATION"));
- cnaEvent.setDriverTiersFilter(rs.getString("DRIVER_TIERS_FILTER"));
- cnaEvent.setDriverTiersFilterAnnotation(rs.getString("DRIVER_TIERS_FILTER_ANNOTATION"));
- return cnaEvent;
- }
-
- public static List getAllCnaEvents() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM cna_event");
- rs = pstmt.executeQuery();
- List events = new ArrayList();
- while (rs.next()) {
- try {
- CnaEvent.Event event = new CnaEvent.Event();
- event.setEventId(rs.getLong("CNA_EVENT_ID"));
- event.setEntrezGeneId(rs.getLong("ENTREZ_GENE_ID"));
- event.setAlteration(rs.getShort("ALTERATION"));
- events.add(event);
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- }
- }
- return events;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-
- public static Map> countSamplesWithCNAGenes(
- Collection entrezGeneIds, int profileId) throws DaoException {
- return countSamplesWithCNAGenes(StringUtils.join(entrezGeneIds, ","), profileId);
- }
-
- public static Map> countSamplesWithCNAGenes(
- String concatEntrezGeneIds, int profileId) throws DaoException {
- if (concatEntrezGeneIds.isEmpty()) {
- return Collections.emptyMap();
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- String sql = "SELECT `ENTREZ_GENE_ID`, `ALTERATION`, count(*)"
- + " FROM sample_cna_event, cna_event"
- + " WHERE `GENETIC_PROFILE_ID`=" + profileId
- + " and sample_cna_event.`CNA_EVENT_ID`=cna_event.`CNA_EVENT_ID`"
- + " and `ENTREZ_GENE_ID` IN ("
- + concatEntrezGeneIds
- + ") GROUP BY `ENTREZ_GENE_ID`, `ALTERATION`";
- pstmt = con.prepareStatement(sql);
-
- Map> map = new HashMap>();
- rs = pstmt.executeQuery();
- while (rs.next()) {
- Long entrez = rs.getLong(1);
- Integer alt = rs.getInt(2);
- Integer count = rs.getInt(3);
- Map mapII = map.get(entrez);
- if (mapII==null) {
- mapII = new HashMap();
- map.put(entrez, mapII);
- }
- mapII.put(alt, count);
- }
- return map;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-
- public static Map countSamplesWithCnaEvents(Collection eventIds,
- int profileId) throws DaoException {
- return countSamplesWithCnaEvents(StringUtils.join(eventIds, ","), profileId);
- }
-
- public static Map countSamplesWithCnaEvents(String concatEventIds,
- int profileId) throws DaoException {
- if (concatEventIds.isEmpty()) {
- return Collections.emptyMap();
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- String sql = "SELECT `CNA_EVENT_ID`, count(*) FROM sample_cna_event"
- + " WHERE `GENETIC_PROFILE_ID`=" + profileId
- + " and `CNA_EVENT_ID` IN ("
- + concatEventIds
- + ") GROUP BY `CNA_EVENT_ID`";
- pstmt = con.prepareStatement(sql);
-
- Map map = new HashMap();
- rs = pstmt.executeQuery();
- while (rs.next()) {
- map.put(rs.getLong(1), rs.getInt(2));
- }
- return map;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-
- public static Set getAlteredGenes(String concatEventIds)
- throws DaoException {
- if (concatEventIds.isEmpty()) {
- return Collections.emptySet();
- }
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCnaEvent.class);
- String sql = "SELECT DISTINCT ENTREZ_GENE_ID FROM cna_event "
- + "WHERE CNA_EVENT_ID in ("
- + concatEventIds
- + ")";
- pstmt = con.prepareStatement(sql);
-
- Set set = new HashSet();
- rs = pstmt.executeQuery();
- while (rs.next()) {
- set.add(rs.getLong(1));
- }
- return set;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCnaEvent.class, con, pstmt, rs);
- }
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCoexpression.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCoexpression.java
deleted file mode 100644
index 57adc14d596..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCoexpression.java
+++ /dev/null
@@ -1,93 +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.dao;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.*;
-
-import org.apache.commons.lang3.StringUtils;
-import org.mskcc.cbio.portal.model.Coexpression;
-
-/**
- *
- * @author jgao
- */
-public class DaoCoexpression {
- public static int addCoexpression(Coexpression coexpression) throws DaoException {
- if (!MySQLbulkLoader.isBulkLoad()) {
- throw new DaoException("You have to turn on MySQLbulkLoader in order to insert Coexpression data");
- } else {
- // use this code if bulk loading
- // write to the temp file maintained by the MySQLbulkLoader
- MySQLbulkLoader.getMySQLbulkLoader("coexpression").insertRecord(
- Long.toString(coexpression.getGene1()),
- Long.toString(coexpression.getGene2()),
- Integer.toString(coexpression.getProfileId()),
- Double.toString(coexpression.getPearson()),
- Double.toString(coexpression.getSpearman()));
- return 1;
- }
- }
-
- public static ArrayList getCoexpression(Collection queryGenes, int geneticProfileId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCoexpression.class);
- ArrayList result = new ArrayList();
- pstmt = con.prepareStatement("SELECT * FROM coexpression WHERE " +
- "GENETIC_PROFILE_ID='" + geneticProfileId + "' AND " +
- "(GENE_1 in ('" + StringUtils.join(queryGenes, "','") + "')" + " OR " +
- " GENE_2 in ('" + StringUtils.join(queryGenes, "','") + "'));");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- int gene1Id = Integer.parseInt(rs.getString("GENE_1"));
- int gene2Id = Integer.parseInt(rs.getString("GENE_2"));
- //int geneticProfileId = Integer.parseInt(rs.getString("GENETIC_PROFILE_ID"));
- float pearson = Float.parseFloat(rs.getString("PEARSON"));
- float spearman = Float.parseFloat(rs.getString("SPEARMAN"));
- result.add(new Coexpression(gene1Id, gene2Id, geneticProfileId, pearson, spearman));
- }
- return result;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCoexpression.class, con, pstmt, rs);
- }
- }
-
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCopyNumberSegment.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCopyNumberSegment.java
deleted file mode 100644
index a0113a44123..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCopyNumberSegment.java
+++ /dev/null
@@ -1,286 +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.dao;
-
-import org.mskcc.cbio.portal.model.*;
-import org.apache.commons.lang3.StringUtils;
-
-import java.sql.*;
-import java.util.*;
-
-/**
- *
- * @author jgao
- */
-public final class DaoCopyNumberSegment {
-
- private static final double FRACTION_GENOME_ALTERED_CUTOFF = 0.2;
- private static final String FRACTION_GENOME_ALTERED_ATTR_ID = "FRACTION_GENOME_ALTERED";
-
- private DaoCopyNumberSegment() {}
-
- public static int addCopyNumberSegment(CopyNumberSegment seg) throws DaoException {
- if (!MySQLbulkLoader.isBulkLoad()) {
- throw new DaoException("You have to turn on MySQLbulkLoader in order to insert mutations");
- } else {
- MySQLbulkLoader.getMySQLbulkLoader("copy_number_seg").insertRecord(
- Long.toString(seg.getSegId()),
- Integer.toString(seg.getCancerStudyId()),
- Integer.toString(seg.getSampleId()),
- seg.getChr(),
- Long.toString(seg.getStart()),
- Long.toString(seg.getEnd()),
- Integer.toString(seg.getNumProbes()),
- Double.toString(seg.getSegMean())
- );
- return 1;
- }
- }
-
- public static void createFractionGenomeAlteredClinicalData(int cancerStudyId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegment.class);
- pstmt = con.prepareStatement(
- "SELECT `SAMPLE_ID`, IF((SELECT SUM(`END`-`START`) FROM copy_number_seg " +
- "AS c2 WHERE c2.`CANCER_STUDY_ID` = c1.`CANCER_STUDY_ID` AND c2.`SAMPLE_ID` = c1.`SAMPLE_ID` AND " +
- "ABS(c2.`SEGMENT_MEAN`) >= 0.2) IS NULL, 0, (SELECT SUM(`END`-`START`) FROM copy_number_seg " +
- "AS c2 WHERE c2.`CANCER_STUDY_ID` = c1.`CANCER_STUDY_ID` AND c2.`SAMPLE_ID` = c1.`SAMPLE_ID` AND " +
- "ABS(c2.`SEGMENT_MEAN`) >= 0.2) / SUM(`END`-`START`)) AS `VALUE` FROM `copy_number_seg` AS c1 , `cancer_study` " +
- "WHERE c1.`CANCER_STUDY_ID` = cancer_study.`CANCER_STUDY_ID` AND cancer_study.`CANCER_STUDY_ID`=? " +
- "GROUP BY cancer_study.`CANCER_STUDY_ID` , `SAMPLE_ID` HAVING SUM(`END`-`START`) > 0;");
- pstmt.setInt(1, cancerStudyId);
- Map fractionGenomeAltereds = new HashMap();
- rs = pstmt.executeQuery();
- while (rs.next()) {
- fractionGenomeAltereds.put(rs.getInt(1), rs.getString(2));
- }
-
- ClinicalAttribute clinicalAttribute = DaoClinicalAttributeMeta.getDatum(FRACTION_GENOME_ALTERED_ATTR_ID, cancerStudyId);
- if (clinicalAttribute == null) {
- ClinicalAttribute attr = new ClinicalAttribute(FRACTION_GENOME_ALTERED_ATTR_ID, "Fraction Genome Altered", "Fraction Genome Altered", "NUMBER",
- false, "20", cancerStudyId);
- DaoClinicalAttributeMeta.addDatum(attr);
- }
-
- for (Map.Entry fractionGenomeAltered : fractionGenomeAltereds.entrySet()) {
- DaoClinicalData.addSampleDatum(fractionGenomeAltered.getKey(), FRACTION_GENOME_ALTERED_ATTR_ID, fractionGenomeAltered.getValue());
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-
- public static long getLargestId() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoMutation.class);
- pstmt = con.prepareStatement
- ("SELECT MAX(`SEG_ID`) FROM `copy_number_seg`");
- rs = pstmt.executeQuery();
- return rs.next() ? rs.getLong(1) : 0;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoMutation.class, con, pstmt, rs);
- }
- }
-
- public static List getSegmentForASample(
- int sampleId, int cancerStudyId) throws DaoException {
- return getSegmentForSamples(Collections.singleton(sampleId),cancerStudyId);
- }
-
- public static List getSegmentForSamples(
- Collection sampleIds, int cancerStudyId) throws DaoException {
- if (sampleIds.isEmpty()) {
- return Collections.emptyList();
- }
- String concatSampleIds = "('"+StringUtils.join(sampleIds, "','")+"')";
-
- List segs = new ArrayList();
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegment.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM copy_number_seg"
- + " WHERE `SAMPLE_ID` IN "+ concatSampleIds
- + " AND `CANCER_STUDY_ID`="+cancerStudyId);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- CopyNumberSegment seg = new CopyNumberSegment(
- rs.getInt("CANCER_STUDY_ID"),
- rs.getInt("SAMPLE_ID"),
- rs.getString("CHR"),
- rs.getLong("START"),
- rs.getLong("END"),
- rs.getInt("NUM_PROBES"),
- rs.getDouble("SEGMENT_MEAN"));
- seg.setSegId(rs.getLong("SEG_ID"));
- segs.add(seg);
- }
- return segs;
- } catch (NullPointerException e) {
- throw new DaoException(e);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-
- public static double getCopyNumberActeredFraction(int sampleId,
- int cancerStudyId, double cutoff) throws DaoException {
- Double d = getCopyNumberActeredFraction(Collections.singleton(sampleId), cancerStudyId, cutoff)
- .get(sampleId);
- return d==null ? Double.NaN : d;
- }
-
- public static Map getCopyNumberActeredFraction(Collection sampleIds,
- int cancerStudyId, double cutoff) throws DaoException {
- Map alteredLength = getCopyNumberAlteredLength(sampleIds, cancerStudyId, cutoff);
- Map measuredLength = getCopyNumberAlteredLength(sampleIds, cancerStudyId, 0);
- Map fraction = new HashMap(alteredLength.size());
- for (Integer sampleId : sampleIds) {
- Long ml = measuredLength.get(sampleId);
- if (ml==null || ml==0) {
- continue;
- }
- Long al = alteredLength.get(sampleId);
- if (al==null) {
- al = (long) 0;
- }
- fraction.put(sampleId, 1.0*al/ml);
- }
- return fraction;
- }
-
- private static Map getCopyNumberAlteredLength(Collection sampleIds,
- int cancerStudyId, double cutoff) throws DaoException {
- Map map = new HashMap();
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- String sql;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegment.class);
- if (cutoff>0) {
- sql = "SELECT `SAMPLE_ID`, SUM(`END`-`START`)"
- + " FROM `copy_number_seg`"
- + " WHERE `CANCER_STUDY_ID`="+cancerStudyId
- + " AND ABS(`SEGMENT_MEAN`)>=" + cutoff
- + " AND `SAMPLE_ID` IN ('" + StringUtils.join(sampleIds,"','") +"')"
- + " GROUP BY `SAMPLE_ID`";
- } else {
- sql = "SELECT `SAMPLE_ID`, SUM(`END`-`START`)"
- + " FROM `copy_number_seg`"
- + " WHERE `CANCER_STUDY_ID`="+cancerStudyId
- + " AND `SAMPLE_ID` IN ('" + StringUtils.join(sampleIds,"','") +"')"
- + " GROUP BY `SAMPLE_ID`";
- }
-
- pstmt = con.prepareStatement(sql);
- rs = pstmt.executeQuery();
- while (rs.next()) {
- map.put(rs.getInt(1), rs.getLong(2));
- }
-
- return map;
- } catch (NullPointerException e) {
- throw new DaoException(e);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-
- /**
- *
- * @param cancerStudyId
- * @return true if segment data exist for the cancer study
- * @throws DaoException
- */
- public static boolean segmentDataExistForCancerStudy(int cancerStudyId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegment.class);
- pstmt = con.prepareStatement("SELECT EXISTS (SELECT 1 FROM `copy_number_seg` WHERE `CANCER_STUDY_ID`=?)");
- pstmt.setInt(1, cancerStudyId);
- rs = pstmt.executeQuery();
- return rs.next() && rs.getInt(1)==1;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-
- /**
- *
- * @param cancerStudyId
- * @param sampleId
- * @return true if segment data exist for the case
- * @throws DaoException
- */
- public static boolean segmentDataExistForSample(int cancerStudyId, int sampleId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegment.class);
- pstmt = con.prepareStatement("SELECT EXISTS(SELECT 1 FROM `copy_number_seg`"
- + " WHERE `CANCER_STUDY_ID`=? AND `SAMPLE_ID`=?");
- pstmt.setInt(1, cancerStudyId);
- pstmt.setInt(2, sampleId);
- rs = pstmt.executeQuery();
- return rs.next() && rs.getInt(1)==1;
- } catch (NullPointerException e) {
- throw new DaoException(e);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCopyNumberSegmentFile.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCopyNumberSegmentFile.java
deleted file mode 100644
index ef0011a4c8a..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCopyNumberSegmentFile.java
+++ /dev/null
@@ -1,116 +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.dao;
-
-import org.mskcc.cbio.portal.model.CopyNumberSegmentFile;
-
-import org.apache.commons.lang3.StringUtils;
-
-import java.sql.*;
-import java.util.*;
-
-public final class DaoCopyNumberSegmentFile {
- private DaoCopyNumberSegmentFile() {}
-
- public static int addCopyNumberSegmentFile(CopyNumberSegmentFile copySegFile) throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegmentFile.class);
- pstmt = con.prepareStatement
- ("INSERT INTO copy_number_seg_file (`CANCER_STUDY_ID`, `REFERENCE_GENOME_ID`, `DESCRIPTION`,`FILENAME`)"
- + " VALUES (?,?,?,?)", Statement.RETURN_GENERATED_KEYS);
- pstmt.setInt(1, copySegFile.cancerStudyId);
- pstmt.setString(2, copySegFile.referenceGenomeId.toString());
- pstmt.setString(3, copySegFile.description);
- pstmt.setString(4, copySegFile.filename);
- pstmt.executeUpdate();
- rs = pstmt.getGeneratedKeys();
- if (rs.next()) {
- return rs.getInt(1);
- }
- return -1;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegment.class, con, pstmt, rs);
- }
- }
-
- public static CopyNumberSegmentFile getCopyNumberSegmentFile(int cancerStudyId) throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegmentFile.class);
- pstmt = con.prepareStatement("SELECT * from copy_number_seg_file WHERE `CANCER_STUDY_ID` = ?");
- pstmt.setInt(1, cancerStudyId);
- rs = pstmt.executeQuery();
- if (rs.next()) {
- CopyNumberSegmentFile cnsf = new CopyNumberSegmentFile();
- cnsf.segFileId = rs.getInt("SEG_FILE_ID");
- cnsf.cancerStudyId = cancerStudyId;
- cnsf.referenceGenomeId = CopyNumberSegmentFile.ReferenceGenomeId.valueOf(rs.getString("REFERENCE_GENOME_ID"));
- cnsf.description = rs.getString("DESCRIPTION");
- cnsf.filename = rs.getString("FILENAME");
- return cnsf;
- }
- return null;
- }
- catch(SQLException e) {
- throw new DaoException(e);
- }
- finally {
- JdbcUtil.closeAll(DaoCopyNumberSegmentFile.class, con, pstmt, rs);
- }
- }
-
- public static void deleteAllRecords() throws DaoException
- {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCopyNumberSegmentFile.class);
- pstmt = con.prepareStatement("TRUNCATE TABLE copy_number_seg_file");
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCopyNumberSegmentFile.class, con, pstmt, rs);
- }
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCosmicData.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCosmicData.java
deleted file mode 100644
index 24a8209e64b..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCosmicData.java
+++ /dev/null
@@ -1,188 +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.dao;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.commons.lang3.StringUtils;
-import org.mskcc.cbio.portal.model.CosmicMutationFrequency;
-import org.mskcc.cbio.portal.model.ExtendedMutation;
-
-/**
- *
- * @author jgao
- */
-public class DaoCosmicData {
- public static int addCosmic(CosmicMutationFrequency cosmic) throws DaoException {
- if (!MySQLbulkLoader.isBulkLoad()) {
- throw new DaoException("You have to turn on MySQLbulkLoader in order to insert mutations");
- } else {
-
- // use this code if bulk loading
- // write to the temp file maintained by the MySQLbulkLoader
- MySQLbulkLoader.getMySQLbulkLoader("cosmic_mutation").insertRecord(
- cosmic.getId(),
- cosmic.getChr(),
- Long.toString(cosmic.getStartPosition()),
- cosmic.getReferenceAllele(),
- cosmic.getTumorSeqAllele(),
- cosmic.getStrand(),
- cosmic.getCds(),
- Long.toString(cosmic.getEntrezGeneId()),
- cosmic.getAminoAcidChange(),
- Integer.toString(cosmic.getFrequency()),
- cosmic.getKeyword());
-
- return 1;
- }
- }
-
- /**
- *
- * @param mutations
- * @return Map of event id to map of aa change to count
- * @throws DaoException
- */
- public static Map> getCosmicForMutationEvents(
- List mutations) throws DaoException {
- Set mutKeywords = new HashSet();
- for (ExtendedMutation mut : mutations) {
- mutKeywords.add(mut.getKeyword());
- }
-
- Map> map =
- DaoCosmicData.getCosmicDataByKeyword(mutKeywords);
- Map> ret
- = new HashMap>(map.size());
- for (ExtendedMutation mut : mutations) {
- String keyword = mut.getKeyword();
- Set cmfs = filterTruncatingCosmicByPosition(mut, map.get(keyword));
-
- if (cmfs==null || cmfs.isEmpty()) {
- continue;
- }
-
- ret.put(mut.getMutationEventId(), cmfs);
- }
- return ret;
- }
-
- private static Set filterTruncatingCosmicByPosition(
- ExtendedMutation mut, Set cmfs) {
- if (mut.getKeyword()==null || !mut.getKeyword().endsWith("truncating") || cmfs==null) {
- return cmfs;
- }
-
- Set ret = new HashSet();
- Pattern p = Pattern.compile("[0-9]+");
- int mutPos = mut.getProteinPosStart();
- for (CosmicMutationFrequency cmf : cmfs) {
- String aa = cmf.getAminoAcidChange();
- Matcher m = p.matcher(aa);
- if (m.find()) {
- int cmfPos = Integer.parseInt(m.group());
- if (mutPos==cmfPos) {
- ret.add(cmf);
- }
- }
- }
- return ret;
- }
-
- /**
- *
- * @param keywordS
- * @return Map>
- * @throws DaoException
- */
- public static Map> getCosmicDataByKeyword(Collection keywordS) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCosmicData.class);
- pstmt = con.prepareStatement("SELECT * FROM cosmic_mutation "
- + " WHERE KEYWORD in ('" + StringUtils.join(keywordS, "','") + "')");
- rs = pstmt.executeQuery();
- Map> ret = new HashMap>();
- while (rs.next()) {
- CosmicMutationFrequency cmf = extractCosmic(rs);
- Set cmfs = ret.get(cmf.getKeyword());
- if (cmfs==null) {
- cmfs = new HashSet();
- ret.put(cmf.getKeyword(), cmfs);
- }
- cmfs.add(cmf);
- }
- return ret;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCosmicData.class, con, pstmt, rs);
- }
- }
-
- private static CosmicMutationFrequency extractCosmic(ResultSet rs) throws SQLException {
- String id = rs.getString("COSMIC_MUTATION_ID");
- long entrez = rs.getLong("ENTREZ_GENE_ID");
- String aa = rs.getString("PROTEIN_CHANGE");
- String keyword = rs.getString("KEYWORD");
- int count = rs.getInt("COUNT");
- return new CosmicMutationFrequency(id, entrez, aa, keyword, count);
- }
-
- public static void deleteAllRecords() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoCosmicData.class);
- pstmt = con.prepareStatement("TRUNCATE TABLE cosmic_mutation");
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoCosmicData.class, con, pstmt, rs);
- }
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoException.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoException.java
deleted file mode 100644
index 32fe17dd6ee..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoException.java
+++ /dev/null
@@ -1,71 +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.dao;
-
-/**
- * Exception Occurred while reading/writing data to database.
- *
- * @author Ethan Cerami
- */
-public class DaoException extends Exception {
- private final String msg;
-
- /**
- * Constructor.
- *
- * @param throwable Throwable Object containing root cause.
- */
- public DaoException(Throwable throwable) {
- super(throwable);
- this.msg = throwable.getMessage();
- }
-
- /**
- * Constructor.
- *
- * @param msg Error Message.
- */
- public DaoException(String msg) {
- super();
- this.msg = msg;
- }
-
- /**
- * Gets Error Message.
- *
- * @return Error Message String.I
- */
- public String getMessage() {
- return msg;
- }
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGene.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGene.java
deleted file mode 100644
index be8862eb881..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGene.java
+++ /dev/null
@@ -1,498 +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.dao;
-
-import org.cbioportal.model.EntityType;
-import org.cbioportal.model.GeneticEntity;
-import org.mskcc.cbio.portal.model.CanonicalGene;
-import org.mskcc.cbio.portal.util.ProgressMonitor;
-
-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.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Data Access Object to Gene Table.
- * For faster access, consider using DaoGeneOptimized.
- *
- * @author Ethan Cerami.
- */
-final class DaoGene {
-
- /**
- * Private Constructor to enforce Singleton Pattern.
- */
- private DaoGene() {
- }
-
- private static int fakeEntrezId = 0;
- private static synchronized int getNextFakeEntrezId() throws DaoException {
- while (getGene(--fakeEntrezId)!=null);
- return fakeEntrezId;
- }
-
- public static synchronized int addGeneWithoutEntrezGeneId(CanonicalGene gene) throws DaoException {
- CanonicalGene existingGene = getGene(gene.getHugoGeneSymbolAllCaps());
- gene.setEntrezGeneId(existingGene==null?getNextFakeEntrezId():existingGene.getEntrezGeneId());
- return addOrUpdateGene(gene);
- }
-
- /**
- * Update Gene Record in the Database.
- */
- public static int updateGene(CanonicalGene gene) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- boolean setBulkLoadAtEnd = false;
- try {
- //this method only works well with bulk load off, especially
- //when it is called in a process that may update a gene more than once
- //(e.g. the ImportGeneData updates some of the fields based on one
- // input file and other fields based on another input file):
- setBulkLoadAtEnd = MySQLbulkLoader.isBulkLoad();
- MySQLbulkLoader.bulkLoadOff();
-
- int rows = 0;
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("UPDATE gene SET `HUGO_GENE_SYMBOL`=?, `TYPE`=? WHERE `ENTREZ_GENE_ID`=?");
- pstmt.setString(1, gene.getHugoGeneSymbolAllCaps());
- pstmt.setString(2, gene.getType());
- pstmt.setLong(3, gene.getEntrezGeneId());
- rows += pstmt.executeUpdate();
- if (rows != 1) {
- ProgressMonitor.logWarning("No change for " + gene.getEntrezGeneId() + " " + gene.getHugoGeneSymbolAllCaps() + "? Code " + rows);
- }
-
- return rows;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- if (setBulkLoadAtEnd) {
- //reset to original state:
- MySQLbulkLoader.bulkLoadOn();
- }
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
-
-}
-
- /**
- * Adds a new Gene Record to the Database OR updates the given gene object
- * with the geneticEntityId found in the DB for this gene.
- * If it is a new gene, it will generate a new genetic entity id and
- * update the given CanonicalGene with the generated
- * geneticEntityId.
- *
- * Adds a new Gene Record to the Database.
- *
- * @param gene Canonical Gene Object.
- * @return number of records successfully added.
- * @throws DaoException Database Error.
- */
- public static int addOrUpdateGene(CanonicalGene gene) throws DaoException {
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- int rows = 0;
- CanonicalGene existingGene = getGene(gene.getEntrezGeneId());
- if (existingGene == null) {
- //new gene, so add genetic entity first:
- GeneticEntity geneticEntity = DaoGeneticEntity.addNewGeneticEntity(new GeneticEntity(EntityType.GENE.name()));
- int geneticEntityId = geneticEntity.getId();
- //update the Canonical gene as well:
- gene.setGeneticEntityId(geneticEntityId); //TODO can we find a better way for this, to avoid this side effect?
- //add gene, referring to this genetic entity
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("INSERT INTO gene (`GENETIC_ENTITY_ID`, `ENTREZ_GENE_ID`,`HUGO_GENE_SYMBOL`,`TYPE`) "
- + "VALUES (?,?,?,?)");
- pstmt.setInt(1, geneticEntityId);
- pstmt.setLong(2, gene.getEntrezGeneId());
- pstmt.setString(3, gene.getHugoGeneSymbolAllCaps());
- pstmt.setString(4, gene.getType());
- rows += pstmt.executeUpdate();
-
- } else {
- if (gene.getGeneticEntityId() == -1) {
- //update the Canonical gene //TODO can we find a better way for this, to avoid this side effect?
- gene.setGeneticEntityId(existingGene.getGeneticEntityId());
- } else {
- //check correctness...normally this error would not occur unless there is an invalid use of CanonicalGene
- if (gene.getGeneticEntityId() != existingGene.getGeneticEntityId())
- throw new RuntimeException("Unexpected error. Invalid genetic entity id for gene: " + gene.getHugoGeneSymbolAllCaps() + " (" + gene.getGeneticEntityId() + ")");
- }
- }
-
- rows += addGeneAliases(gene);
-
- return rows;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Add gene_alias records.
- * @param gene Canonical Gene Object.
- * @return number of records successfully added.
- * @throws DaoException Database Error.
- */
- public static int addGeneAliases(CanonicalGene gene) throws DaoException {
- if (MySQLbulkLoader.isBulkLoad()) {
- // write to the temp file maintained by the MySQLbulkLoader
- Set aliases = gene.getAliases();
- for (String alias : aliases) {
- MySQLbulkLoader.getMySQLbulkLoader("gene_alias").insertRecord(
- Long.toString(gene.getEntrezGeneId()),
- alias);
-
- }
- // return 1 because normal insert will return 1 if no error occurs
- return 1;
- }
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- Set aliases = gene.getAliases();
- Set existingAliases = getAliases(gene.getEntrezGeneId());
- int rows = 0;
- for (String alias : aliases) {
- if (!existingAliases.contains(alias)) {
- pstmt = con.prepareStatement("INSERT INTO gene_alias "
- + "(`ENTREZ_GENE_ID`,`GENE_ALIAS`) VALUES (?,?)");
- pstmt.setLong(1, gene.getEntrezGeneId());
- pstmt.setString(2, alias);
- rows += pstmt.executeUpdate();
- }
- }
-
- return rows;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Gets the Gene with the Specified Entrez Gene ID.
- * For faster access, consider using DaoGeneOptimized.
- *
- * @param entrezGeneId Entrez Gene ID.
- * @return Canonical Gene Object.
- * @throws DaoException Database Error.
- */
- private static CanonicalGene getGene(long entrezGeneId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM gene WHERE ENTREZ_GENE_ID = ?");
- pstmt.setLong(1, entrezGeneId);
- rs = pstmt.executeQuery();
- if (rs.next()) {
- return extractGene(rs);
- } else {
- return null;
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Gets aliases for all genes.
- * @return map from entrez gene id to a set of aliases.
- * @throws DaoException Database Error.
- */
- private static Set getAliases(long entrezGeneId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM gene_alias WHERE ENTREZ_GENE_ID = ?");
- pstmt.setLong(1, entrezGeneId);
- rs = pstmt.executeQuery();
- Set aliases = new HashSet();
- while (rs.next()) {
- aliases.add(rs.getString("GENE_ALIAS"));
- }
- return aliases;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- private static Map> getAllAliases() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM gene_alias");
- rs = pstmt.executeQuery();
- Map> map = new HashMap>();
- while (rs.next()) {
- Long entrez = rs.getLong("ENTREZ_GENE_ID");
- Set aliases = map.get(entrez);
- if (aliases==null) {
- aliases = new HashSet();
- map.put(entrez, aliases);
- }
- aliases.add(rs.getString("GENE_ALIAS"));
- }
- return map;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Gets all Genes in the Database.
- *
- * @return ArrayList of Canonical Genes.
- * @throws DaoException Database Error.
- */
- public static ArrayList getAllGenes() throws DaoException {
- Map> mapAliases = getAllAliases();
- ArrayList geneList = new ArrayList();
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM gene");
- rs = pstmt.executeQuery();
- while (rs.next()) {
- int geneticEntityId = rs.getInt("GENETIC_ENTITY_ID");
- long entrezGeneId = rs.getInt("ENTREZ_GENE_ID");
- Set aliases = mapAliases.get(entrezGeneId);
- CanonicalGene gene = new CanonicalGene(geneticEntityId, entrezGeneId,
- rs.getString("HUGO_GENE_SYMBOL"), aliases);
- gene.setType(rs.getString("TYPE"));
- geneList.add(gene);
- }
- return geneList;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Gets the Gene with the Specified HUGO Gene Symbol.
- * For faster access, consider using DaoGeneOptimized.
- *
- * @param hugoGeneSymbol HUGO Gene Symbol.
- * @return Canonical Gene Object.
- * @throws DaoException Database Error.
- */
- private static CanonicalGene getGene(String hugoGeneSymbol) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("SELECT * FROM gene WHERE HUGO_GENE_SYMBOL = ?");
- pstmt.setString(1, hugoGeneSymbol);
- rs = pstmt.executeQuery();
- if (rs.next()) {
- return extractGene(rs);
- } else {
- return null;
- }
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- private static CanonicalGene extractGene(ResultSet rs) throws SQLException, DaoException {
- int geneticEntityId = rs.getInt("GENETIC_ENTITY_ID");
- long entrezGeneId = rs.getInt("ENTREZ_GENE_ID");
- Set aliases = getAliases(entrezGeneId);
- CanonicalGene gene = new CanonicalGene(geneticEntityId, entrezGeneId,
- rs.getString("HUGO_GENE_SYMBOL"), aliases);
- gene.setType(rs.getString("TYPE"));
-
- return gene;
- }
-
- /**
- * Gets the Number of Gene Records in the Database.
- *
- * @return number of gene records.
- * @throws DaoException Database Error.
- */
- public static int getCount() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement
- ("SELECT COUNT(*) FROM gene");
- rs = pstmt.executeQuery();
- if (rs.next()) {
- return rs.getInt(1);
- }
- return 0;
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Deletes the Gene Record that has the Entrez Gene ID in the Database.
- *
- * @param entrezGeneId
- */
- public static void deleteGene(long entrezGeneId) throws DaoException {
- deleteGeneAlias(entrezGeneId);
-
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement("DELETE FROM gene WHERE ENTREZ_GENE_ID=?");
- pstmt.setLong(1, entrezGeneId);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Deletes the Gene Alias Record(s) that has/have the Entrez Gene ID in the Database.
- *
- * @param entrezGeneId
- */
- public static void deleteGeneAlias(long entrezGeneId) throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement("DELETE FROM gene_alias WHERE ENTREZ_GENE_ID=?");
- pstmt.setLong(1, entrezGeneId);
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
- /**
- * Deletes all Gene Records in the Database.
- *
- * @throws DaoException Database Error.
- *
- * @deprecated only used by deprecated code, so deprecating this as well.
- */
- public static void deleteAllRecords() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- JdbcUtil.disableForeignKeyCheck(con);
- pstmt = con.prepareStatement("TRUNCATE TABLE gene");
- pstmt.executeUpdate();
- JdbcUtil.enableForeignKeyCheck(con);
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- deleteAllAliasRecords();
- }
-
- /**
- *
- * @throws DaoException
- *
- * @deprecated only used by deprecated code, so deprecating this as well.
- */
- private static void deleteAllAliasRecords() throws DaoException {
- Connection con = null;
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- con = JdbcUtil.getDbConnection(DaoGene.class);
- pstmt = con.prepareStatement("TRUNCATE TABLE gene_alias");
- pstmt.executeUpdate();
- } catch (SQLException e) {
- throw new DaoException(e);
- } finally {
- JdbcUtil.closeAll(DaoGene.class, con, pstmt, rs);
- }
- }
-
-}
diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneOptimized.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneOptimized.java
deleted file mode 100644
index 1f58acb7bd9..00000000000
--- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoGeneOptimized.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (c) 2015 - 2019 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.dao;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.mskcc.cbio.portal.model.CanonicalGene;
-import org.mskcc.cbio.portal.util.ProgressMonitor;
-
-/**
- * A Utility Class that speeds access to Gene Info.
- *
- * @author Ethan Cerami
- */
-public class DaoGeneOptimized {
- private static final String GENE_SYMBOL_DISAMBIGUATION_FILE = "/gene_symbol_disambiguation.txt";
-
- private static final DaoGeneOptimized daoGeneOptimized = new DaoGeneOptimized();
- //nb: make sure any map is also cleared in clearCache() method below:
- private final HashMap geneSymbolMap = new HashMap ();
- private final HashMap entrezIdMap = new HashMap ();
- private final HashMap geneticEntityMap = new HashMap();
- private final HashMap> geneAliasMap = new HashMap