Skip to content

Commit

Permalink
Prefix SC tables with SCA_
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsomunozpomer committed Sep 8, 2017
1 parent 1fa64c2 commit 7bc9848
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Table for storing marker gene probabilities
DROP TABLE MARKER_GENES CASCADE;
CREATE TABLE MARKER_GENES (
DROP TABLE SCA_MARKER_GENES CASCADE;
CREATE TABLE SCA_MARKER_GENES (
GENE_ID CHARACTER VARYING (255) NOT NULL,
EXPERIMENT_ACCESSION CHARACTER VARYING (255) NOT NULL,
K INTEGER NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Table for storing single cell expression levels
DROP TABLE SINGLE_CELL_EXPRESSION CASCADE;
CREATE TABLE SINGLE_CELL_EXPRESSION (
DROP TABLE SCA_SINGLE_CELL_EXPRESSION CASCADE;
CREATE TABLE SCA_SINGLE_CELL_EXPRESSION (
EXPERIMENT_ACCESSION VARCHAR(255) NOT NULL,
GENE_ID VARCHAR(255) NOT NULL,
CELL_ID VARCHAR(255) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SingleCellBaselineDao {

// Based on experimentation, see https://www.ebi.ac.uk/seqdb/confluence/display/GXA/Single+Cell+Expression+data
private static final int BATCH_SIZE = 2000;
private static final String SC_EXPRESSION_INSERT = "INSERT INTO SINGLE_CELL_EXPRESSION " +
private static final String SC_EXPRESSION_INSERT = "INSERT INTO sca_single_cell_expression " +
"(EXPERIMENT_ACCESSION, GENE_ID, CELL_ID, EXPRESSION_LEVEL) VALUES (?, ?, ?, ?)";

private final JdbcTemplate jdbcTemplate;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void loadAnalytics(final String experimentAccession, SingleCellBaselineIn

public void deleteAnalytics(String experimentAccession) {
LOGGER.info("delete SingleCellExpression for experiment {}", experimentAccession);
jdbcTemplate.update("DELETE FROM SINGLE_CELL_EXPRESSION WHERE EXPERIMENT_ACCESSION = ?", experimentAccession);
jdbcTemplate.update("DELETE FROM sca_single_cell_expression WHERE EXPERIMENT_ACCESSION = ?", experimentAccession);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public class MarkerGeneDao {
// Based on experimentation, see https://www.ebi.ac.uk/seqdb/confluence/display/GXA/Single+Cell+Expression+data
private static final int BATCH_SIZE = 2000;
private static final String MARKER_GENE_INSERT_STATEMENT =
"INSERT INTO marker_genes " +
"INSERT INTO sca_marker_genes " +
"(gene_id, experiment_accession, k, cluster_id, marker_probability) VALUES (?, ?, ?, ?, ?)";
private static final String MARKER_GENE_SELECT_STATEMENT =
"SELECT * FROM marker_genes WHERE gene_id=? AND marker_probability>?";
"SELECT * FROM sca_marker_genes WHERE gene_id=? AND marker_probability>?";


private final JdbcTemplate jdbcTemplate;
Expand Down Expand Up @@ -85,12 +85,12 @@ public ImmutableList<MarkerGeneProfile> fetchMarkerGenes(String geneId, double c
}

public void deleteAll() {
int rowCount = jdbcTemplate.update("DELETE FROM marker_genes");
int rowCount = jdbcTemplate.update("DELETE FROM sca_marker_genes");
LOGGER.info("{} rows deleted", rowCount);
}

public void delete(String experimentAccession) {
int rowCount = jdbcTemplate.update("DELETE FROM marker_genes WHERE experiment_accession=?", experimentAccession);
int rowCount = jdbcTemplate.update("DELETE FROM sca_marker_genes WHERE experiment_accession=?", experimentAccession);
LOGGER.info("{} rows deleted", rowCount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class MarkerGenesSearchServiceIT {
public void searchIdsOfGenesWithHighProbability() throws Exception {
List<String> fiveMarkerGeneIds =
jdbcTemplate.queryForList(
"SELECT DISTINCT(gene_id) FROM marker_genes WHERE marker_probability>? LIMIT 5",
"SELECT DISTINCT(gene_id) FROM sca_marker_genes WHERE marker_probability>? LIMIT 5",
DEFAULT_P_THRESHOLD).stream()
.map(rowMap -> (String) rowMap.get("gene_id"))
.collect(Collectors.toList());
Expand All @@ -57,8 +57,8 @@ public void searchIdsOfGenesWithHighProbability() throws Exception {
@Test
public void searchIdsOfGenesWithLowProbability() throws Exception {
List<String> fiveNonMarkerGeneIds = jdbcTemplate.queryForList(
"SELECT all_p.gene_id FROM marker_genes all_p LEFT JOIN " +
" (SELECT gene_id, marker_probability FROM marker_genes WHERE marker_probability>?) high_p ON all_p.gene_id=high_p.gene_id " +
"SELECT all_p.gene_id FROM sca_marker_genes all_p LEFT JOIN " +
" (SELECT gene_id, marker_probability FROM sca_marker_genes WHERE marker_probability>?) high_p ON all_p.gene_id=high_p.gene_id " +
"WHERE high_p.gene_id IS NULL LIMIT 5", DEFAULT_P_THRESHOLD).stream()
.map(rowMap -> (String) rowMap.get("gene_id"))
.collect(Collectors.toList());
Expand Down

0 comments on commit 7bc9848

Please sign in to comment.