Skip to content

Commit

Permalink
working version
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsPon committed Dec 9, 2024
1 parent 5e0f5bc commit f28bb81
Show file tree
Hide file tree
Showing 11 changed files with 458 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{java,py}]
indent_style = space
indent_size = 4
4 changes: 4 additions & 0 deletions dev/data_single_cell_expression.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sample_Id Entrez_Gene_Id Hugo_Symbol Cell_Type Tissue Expression_Value
SHAH_H000004_T09_01_WG01 TP53 CELLTYPE TISSUE 57.4
SHAH_H000004_T09_01_WG01 7157 CELLTYPE2 TISSUE 57.4
SAMPLE1 7157 TP53 CELLTYPE2 TISSUE 57.4
8 changes: 8 additions & 0 deletions dev/meta_single_cell_expression.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cancer_study_identifier: msk_spectrum_tme_2022
genetic_alteration_type: SINGLE_CELL_EXPRESSION
datatype: SINGLE_CELL_EXPRESSION
stable_id: single_cell_expression
show_profile_in_analysis_tab: false
profile_name: single cell expression
profile_description: single cell expression test
data_filename: data_single_cell_expression.txt
1 change: 1 addition & 0 deletions scripts/importer/allowed_data_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ GENERIC_ASSAY LIMIT-VALUE *
GENERIC_ASSAY BINARY *
GENERIC_ASSAY CATEGORICAL *
STRUCTURAL_VARIANT SV structural_variants
SINGLE_CELL_EXPRESSION SINGLE_CELL_EXPRESSION *
17 changes: 16 additions & 1 deletion scripts/importer/cbioportal_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class MetaFileTypes(object):
CNA_CONTINUOUS = 'meta_contCNA'
SEG = 'meta_segment'
EXPRESSION = 'meta_expression'
SINGLE_CELL_EXPRESSION = 'meta_single_cell_expression'
MUTATION = 'meta_mutations_extended'
MUTATION_UNCALLED = 'meta_mutations_uncalled'
METHYLATION = 'meta_methylation'
Expand Down Expand Up @@ -214,6 +215,18 @@ class MetaFileTypes(object):
'data_filename': True,
'gene_panel': False
},
MetaFileTypes.SINGLE_CELL_EXPRESSION: {
'cancer_study_identifier': True,
'genetic_alteration_type': True,
'datatype': True,
'stable_id': True,
'source_stable_id': False,
'show_profile_in_analysis_tab': True,
'profile_name': True,
'profile_description': True,
'data_filename': True,
'gene_panel': False
},
MetaFileTypes.METHYLATION: {
'cancer_study_identifier': True,
'genetic_alteration_type': True,
Expand Down Expand Up @@ -399,6 +412,7 @@ class MetaFileTypes(object):
MetaFileTypes.CNA_CONTINUOUS: "org.mskcc.cbio.portal.scripts.ImportProfileData",
MetaFileTypes.SEG: "org.mskcc.cbio.portal.scripts.ImportCopyNumberSegmentData",
MetaFileTypes.EXPRESSION: "org.mskcc.cbio.portal.scripts.ImportProfileData",
MetaFileTypes.SINGLE_CELL_EXPRESSION: "org.mskcc.cbio.portal.scripts.ImportProfileData",
MetaFileTypes.MUTATION: "org.mskcc.cbio.portal.scripts.ImportProfileData",
MetaFileTypes.MUTATION_UNCALLED: "org.mskcc.cbio.portal.scripts.ImportProfileData",
MetaFileTypes.METHYLATION: "org.mskcc.cbio.portal.scripts.ImportProfileData",
Expand Down Expand Up @@ -692,7 +706,8 @@ def get_meta_file_type(meta_dictionary, logger, filename):
("GENESET_SCORE", "P-VALUE"): MetaFileTypes.GSVA_PVALUES,
("GENERIC_ASSAY", "LIMIT-VALUE"): MetaFileTypes.GENERIC_ASSAY_CONTINUOUS,
("GENERIC_ASSAY", "BINARY"): MetaFileTypes.GENERIC_ASSAY_BINARY,
("GENERIC_ASSAY", "CATEGORICAL"): MetaFileTypes.GENERIC_ASSAY_CATEGORICAL
("GENERIC_ASSAY", "CATEGORICAL"): MetaFileTypes.GENERIC_ASSAY_CATEGORICAL,
("SINGLE_CELL_EXPRESSION", "SINGLE_CELL_EXPRESSION"): MetaFileTypes.SINGLE_CELL_EXPRESSION
}
result = None
if 'genetic_alteration_type' in meta_dictionary and 'datatype' in meta_dictionary:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ public static void deleteCancerStudy(int internalCancerStudyId) throws DaoExcept
"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 single_cell_expression 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=?)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2024 The Hyve B.V.
* This code is licensed under the GNU Affero General Public License (AGPL),
* version 3, or (at your option) any later version.
*/

/*
* 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 <http://www.gnu.org/licenses/>.
*/

/*
* @author Matthijs Pon
*/

package org.mskcc.cbio.portal.dao;

import java.sql.*;
import org.mskcc.cbio.portal.model.*;

public class DaoSingleCellExpression {

private DaoSingleCellExpression() {
}

public static void addSingleCellExpression(SingleCellExpression singleCellExpression) throws DaoException {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;

try {
// Open connection to database
connection = JdbcUtil.getDbConnection(DaoGeneticProfileLink.class);

// Prepare SQL statement
preparedStatement = connection.prepareStatement("INSERT INTO single_cell_expression "
+ "(GENETIC_PROFILE_ID, SAMPLE_ID, TISSUE, CELL_TYPE, ENTREZ_GENE_ID, EXPRESSION_VALUE) VALUES (?,?,?,?,?,?)");
// Fill in statement
preparedStatement.setInt(1, singleCellExpression.getGeneticProfileId());
preparedStatement.setInt(2, singleCellExpression.getSampleId());
preparedStatement.setString(3, singleCellExpression.getTissue());
preparedStatement.setString(4, singleCellExpression.getCellType());
preparedStatement.setLong(5, singleCellExpression.getGene().getEntrezGeneId());
preparedStatement.setString(6, singleCellExpression.getExpressionValue());

// Execute statement
preparedStatement.execute();
} catch (SQLException e) {
throw new DaoException(e);
} finally {
JdbcUtil.closeAll(DaoGeneticProfileLink.class, connection, preparedStatement, resultSet);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ public enum GeneticAlterationType {
PROTEIN_ARRAY_PROTEIN_LEVEL,
PROTEIN_ARRAY_PHOSPHORYLATION,
GENESET_SCORE,
GENERIC_ASSAY
GENERIC_ASSAY,
SINGLE_CELL_EXPRESSION
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.mskcc.cbio.portal.model;

public class SingleCellExpression {
private int sampleId;
private int geneticProfileId;
private CanonicalGene gene;
private String cellType;
private String tissue;
private String expressionValue;

public SingleCellExpression(int sampleId, int geneticProfileId, CanonicalGene gene, String cellType, String tissue,
String expressionValue) {
this.sampleId = sampleId;
this.geneticProfileId = geneticProfileId;
this.gene = gene;
this.cellType = cellType;
this.tissue = tissue;
this.expressionValue = expressionValue;
}

public int getSampleId() {
return sampleId;
}

public void setSampleId(int sampleId) {
this.sampleId = sampleId;
}

public int getGeneticProfileId() {
return geneticProfileId;
}

public void setGeneticProfileId(int geneticProfileId) {
this.geneticProfileId = geneticProfileId;
}

public CanonicalGene getGene() {
return gene;
}

public void setGene(CanonicalGene gene) {
this.gene = gene;
}

public String getCellType() {
return cellType;
}

public void setCellType(String cellType) {
this.cellType = cellType;
}

public String getTissue() {
return tissue;
}

public void setTissue(String tissue) {
this.tissue = tissue;
}

public String getExpressionValue() {
return expressionValue;
}

public void setExpressionValue(String expressionValue) {
this.expressionValue = expressionValue;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public void run() {
);
genericAssayProfileImporter.importData();
}
} else if(
}
else if(
geneticProfile.getGeneticAlterationType() == GeneticAlterationType.COPY_NUMBER_ALTERATION
&& DISCRETE_LONG.name().equals(geneticProfile.getOtherMetaDataField("datatype"))
) {
Expand All @@ -150,7 +151,15 @@ public void run() {
overwriteExisting
);
importer.importData();
} else if (geneticProfile.getGeneticAlterationType() == GeneticAlterationType.SINGLE_CELL_EXPRESSION) {
ImportSingleCellExpressionData importer = new ImportSingleCellExpressionData(
dataFile,
geneticProfile.getGeneticProfileId(),
daoGene
);
importer.importData();
} else {
// All other files go through this
ImportTabDelimData importer = new ImportTabDelimData(
dataFile,
geneticProfile.getTargetLine(),
Expand Down
Loading

0 comments on commit f28bb81

Please sign in to comment.