Skip to content

Commit

Permalink
tidying up catalog import repository and adding logo materials
Browse files Browse the repository at this point in the history
  • Loading branch information
tburdett committed Feb 27, 2015
1 parent c490d0c commit b501dc8
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 81 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/logos/GWAS_Catalog_circle_178x178.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/logos/GWAS_Catalog_logo_160x160.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/logos/GWAS_Catalog_logo_240x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/logos/GWAS_Catalog_logo_31x31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/logos/GWAS_Catalog_logo_48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/logos/GWAS_Catalog_logo_73x73.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class CatalogImportRepository {
private SimpleJdbcInsert insertStudyReport;

private SimpleJdbcInsert insertAssociationReport;
private AssociationReportUpdate updateAssociationReport;

private static final String SELECT_STUDY_REPORTS =
"SELECT ID FROM STUDY_REPORT WHERE STUDY_ID = ?";
Expand All @@ -52,6 +51,17 @@ public class CatalogImportRepository {
private static final String SELECT_ASSOCIATION_REPORTS =
"SELECT ID FROM ASSOCIATION_REPORT WHERE ASSOCIATION_ID = ?";

private static final String UPDATE_ASSOCIATION_REPORTS =
"UPDATE ASSOCIATION_REPORT SET " +
"LAST_UPDATE_DATE = ?, " +
"GENE_ERROR = ?, " +
"SNP_ERROR = ?, " +
"SNP_GENE_ON_DIFF_CHR = ?, " +
"NO_GENE_FOR_SYMBOL = ?, " +
"GENE_NOT_ON_GENOME = ?, " +
"SNP_PENDING = ? " +
"WHERE ID = ?";

private static final String UPDATE_MAPPED_DATA =
"UPDATE CATALOG_SUMMARY_VIEW SET " +
"REGION = ?, " +
Expand All @@ -73,7 +83,6 @@ protected Logger getLog() {
return log;
}


@Autowired(required = false)
public CatalogImportRepository(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
Expand Down Expand Up @@ -101,8 +110,6 @@ public CatalogImportRepository(JdbcTemplate jdbcTemplate) {
"GENE_NOT_ON_GENOME",
"SNP_PENDING")
.usingGeneratedKeyColumns("ID");

this.updateAssociationReport = new AssociationReportUpdate(jdbcTemplate);
}

public void loadNCBIMappedData(String[][] data) {
Expand Down Expand Up @@ -426,28 +433,29 @@ private void addStudyReport(Long studyId,
"trying to add study report with no paper title");
}

Map<String, Object> studyArgs = new HashMap<>();
studyArgs.put("STUDY_ID", studyId);
studyArgs.put("PUBMED_ID_ERROR", pubmedIdError);
studyArgs.put("NCBI_PAPER_TITLE", ncbiPaperTitle);
studyArgs.put("NCBI_FIRST_AUTHOR", ncbiFirstAuthor);
studyArgs.put("NCBI_NORMALIZED_FIRST_AUTHOR", ncbiNormalisedFirstAuthor);
studyArgs.put("NCBI_FIRST_UPDATE_DATE", ncbiFirstUpdateDate);


// Check for an existing id in database
int rows;
try {
Long studyReportIdInDatabase = jdbcTemplate.queryForObject(SELECT_STUDY_REPORTS, Long.class, studyId);
Object[] params = {pubmedIdError, ncbiPaperTitle, ncbiFirstAuthor, ncbiNormalisedFirstAuthor,
ncbiFirstUpdateDate, studyReportIdInDatabase};
jdbcTemplate.update(UPDATE_STUDY_REPORTS, params);

Long studyReportId = jdbcTemplate.queryForObject(SELECT_STUDY_REPORTS, Long.class, studyId);
rows = jdbcTemplate.update(UPDATE_STUDY_REPORTS,
pubmedIdError,
ncbiPaperTitle,
ncbiFirstAuthor,
ncbiNormalisedFirstAuthor,
ncbiFirstUpdateDate,
studyReportId);
}
catch (EmptyResultDataAccessException e) {
insertStudyReport.execute(studyArgs);

Map<String, Object> studyArgs = new HashMap<>();
studyArgs.put("STUDY_ID", studyId);
studyArgs.put("PUBMED_ID_ERROR", pubmedIdError);
studyArgs.put("NCBI_PAPER_TITLE", ncbiPaperTitle);
studyArgs.put("NCBI_FIRST_AUTHOR", ncbiFirstAuthor);
studyArgs.put("NCBI_NORMALIZED_FIRST_AUTHOR", ncbiNormalisedFirstAuthor);
studyArgs.put("NCBI_FIRST_UPDATE_DATE", ncbiFirstUpdateDate);
rows = insertStudyReport.execute(studyArgs);
}

getLog().trace("Adding report for Study ID: " + studyId + " - Updated " + rows + " rows");
}

private void addAssociationReport(Long associationId,
Expand All @@ -458,33 +466,35 @@ private void addAssociationReport(Long associationId,
String noGeneForSymbol,
String geneNotOnGenome) {

Map<String, Object> associationArgs = new HashMap<>();

associationArgs.put("ASSOCIATION_ID", associationId);
associationArgs.put("LAST_UPDATE_DATE", lastUpdateDate);
associationArgs.put("GENE_ERROR", geneError);
associationArgs.put("SNP_ERROR", snpError);
associationArgs.put("SNP_GENE_ON_DIFF_CHR", snpGeneOnDiffChr);
associationArgs.put("NO_GENE_FOR_SYMBOL", noGeneForSymbol);
associationArgs.put("GENE_NOT_ON_GENOME", geneNotOnGenome);
associationArgs.put("SNP_PENDING", null);

System.out.println(associationId + " - " + lastUpdateDate + " - " + geneError + " - " + snpError + " - " +
snpGeneOnDiffChr + " - " + noGeneForSymbol + " - " + geneNotOnGenome);
System.out.println(associationArgs.size());

// Check for an existing id in database
int rows;
try {
Long associationReportIdInDatabase =
Long associationReportId =
jdbcTemplate.queryForObject(SELECT_ASSOCIATION_REPORTS, Long.class, associationId);
associationArgs.put("ID", associationReportIdInDatabase);
updateAssociationReport.updateByNamedParam(associationArgs);
rows = jdbcTemplate.update(UPDATE_ASSOCIATION_REPORTS,
lastUpdateDate,
geneError,
snpError,
snpGeneOnDiffChr,
noGeneForSymbol,
geneNotOnGenome,
null,
associationReportId);
}
catch (EmptyResultDataAccessException e) {
getLog().info("No previous report for association " + associationId);
insertAssociationReport.execute(associationArgs);

Map<String, Object> associationArgs = new HashMap<>();
associationArgs.put("ASSOCIATION_ID", associationId);
associationArgs.put("LAST_UPDATE_DATE", lastUpdateDate);
associationArgs.put("GENE_ERROR", geneError);
associationArgs.put("SNP_ERROR", snpError);
associationArgs.put("SNP_GENE_ON_DIFF_CHR", snpGeneOnDiffChr);
associationArgs.put("NO_GENE_FOR_SYMBOL", noGeneForSymbol);
associationArgs.put("GENE_NOT_ON_GENOME", geneNotOnGenome);
associationArgs.put("SNP_PENDING", null);
rows = insertAssociationReport.execute(associationArgs);
}

getLog().trace("Adding report for Association ID: " + associationId + " - Updated " + rows + " rows");
}

private void addMappedData(Long studyId,
Expand All @@ -511,7 +521,8 @@ private void addMappedData(Long studyId,
isIntergenic,
studyId,
associationId);
System.out.println("Updated " + rows + " rows");
getLog().trace("Adding mapped data for Study ID: " + studyId + " and Association ID: " + associationId + " " +
"- Updated " + rows + " rows");
}

private static <T> T[] extractRange(T[] array, int startIndex) {
Expand Down Expand Up @@ -562,42 +573,4 @@ public AssociationReportUpdate(JdbcTemplate jdbcTemplate) {

}
}

private class MappedDataUpdate extends SqlUpdate {
public MappedDataUpdate(JdbcTemplate jdbcTemplate) {
// String region = null; // REGION
// String chromosomeName = null; // CHROMOSOME_NAME
// String chromosomePosition = null; // CHROMOSOME_POSITION
// String upstreamMappedGene = null; // UPSTREAM_MAPPED_GENE
// String upstreamEntrezGeneId = null; // UPSTREAM_ENTREZ_GENE_ID
// Integer upstreamGeneDistance = null; // UPSTREAM_GENE_DISTANCE
// String downstreamMappedGene = null; // DOWNSTREAM_MAPPED_GENE
// String downstreamEntrezGeneId = null; // DOWNSTREAM_ENTREZ_GENE_ID
// Integer downstreamGeneDistance = null; // DOWNSTREAM_GENE_DISTANCE
// Boolean isIntergenic = null; // IS_INTERGENIC
setJdbcTemplate(jdbcTemplate);
setSql("UPDATE CATALOG_SUMMARY_VIEW SET " +
"REGION = ?," +
"CHROMOSOME_NAME = ?, " +
"CHROMOSOME_POSITION = ?, " +
"UPSTREAM_MAPPED_GENE = ?, " +
"UPSTREAM_ENTREZ_GENE_ID = ?," +
"UPSTREAM_GENE_DISTANCE = ?," +
"DOWNSTREAM_MAPPED_GENE = ?," +
"DOWNSTREAM_GENE_DISTANCE = ?," +
"IS_INTERGENIC = ?" +
"WHERE STUDY_ID = ? AND ASSOCIATION_ID = ?");
declareParameter(new SqlParameter("region", Types.VARCHAR));
declareParameter(new SqlParameter("chromosomeName", Types.VARCHAR));
declareParameter(new SqlParameter("chromosomePosition", Types.VARCHAR));
declareParameter(new SqlParameter("upstreamMappedGene", Types.VARCHAR));
declareParameter(new SqlParameter("upstreamEntrezGeneId", Types.VARCHAR));
declareParameter(new SqlParameter("upstreamGeneDistance", Types.NUMERIC));
declareParameter(new SqlParameter("downstreamMappedGene", Types.VARCHAR));
declareParameter(new SqlParameter("downstreamEntrezGeneId", Types.VARCHAR));
declareParameter(new SqlParameter("downstreamGeneDistance", Types.NUMERIC));
declareParameter(new SqlParameter("isIntergenic", Types.BOOLEAN));
compile();
}
}
}

0 comments on commit b501dc8

Please sign in to comment.