Skip to content

Commit

Permalink
Merge pull request #64 from ebi-uniprot/dev
Browse files Browse the repository at this point in the history
esm score endpoint
  • Loading branch information
prabh-t authored Apr 26, 2024
2 parents 6cdc8eb + 6ad4eab commit d19f546
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,21 @@ public ResponseEntity<List<ConservScore>> getConservScoresByAccAndPos(
List<ConservScore> scores = protVarDataRepo.getConservScores(accession, position);
return new ResponseEntity<>(scores, HttpStatus.OK);
}

/**
* Get ESM score.
*
* @param accession UniProt accession
* @param position Amino acid position
* @return <code>ESMScore</code> information on accession
*/
@Operation(summary = "Retrieve ESM1v scores for accession and position")
@GetMapping(value = "/esm/{accession}/{position}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ESMScore>> getEsmScores(
@Parameter(example = "Q9NUW8") @PathVariable String accession,
@Parameter(example = "493") @PathVariable Integer position) {

List<ConservScore> scores = protVarDataRepo.getConservScores(accession, position);
return new ResponseEntity<>(scores, HttpStatus.OK);
}
}
16 changes: 16 additions & 0 deletions src/main/java/uk/ac/ebi/protvar/model/data/ESMScore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package uk.ac.ebi.protvar.model.data;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;


@AllArgsConstructor
@Getter
@Setter
public class ESMScore {
private String accession;
private Integer position;
private String mtAA;
private Double score;
}
4 changes: 4 additions & 0 deletions src/main/java/uk/ac/ebi/protvar/repo/ProtVarDataRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public interface ProtVarDataRepo {

// Conservation score
List<ConservScore> getConservScores(String acc, Integer pos);

// ESM score
List<ESMScore> getEsmScores(String acc, Integer pos);

}
29 changes: 24 additions & 5 deletions src/main/java/uk/ac/ebi/protvar/repo/ProtVarDataRepoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ INNER JOIN (VALUES :accPosSet) AS t(acc,pos)
private static final String SELECT_INTERACTION_MODEL = "SELECT pdb_model FROM af2complexes_interaction WHERE a=:a AND b=:b";
private static final String SELECT_INTERACTION_MODEL_NEW = "SELECT pdb_model FROM interaction_v2 WHERE a=:a AND b=:b";

private static final String SELECT_CONSERV_SCORES = """
private static final String SELECT_FROM_CONSERV_SCORE = """
SELECT * FROM CONSERV_SCORE
WHERE acc=:acc AND pos=:pos
""";
private static final String SELECT_FROM_ESM = """
SELECT * FROM esm
WHERE accession=:acc AND position=:pos
""";

private NamedParameterJdbcTemplate jdbcTemplate;

Expand Down Expand Up @@ -400,11 +404,26 @@ private List<Integer> getResidueList(ResultSet rs, String fieldName) throws SQLE
public List<ConservScore> getConservScores(String acc, Integer pos) {
SqlParameterSource parameters = new MapSqlParameterSource("acc", acc)
.addValue("pos", pos);
return jdbcTemplate.query(SELECT_CONSERV_SCORES, parameters, (rs, rowNum) -> createConservScore(rs));
return jdbcTemplate.query(SELECT_FROM_CONSERV_SCORE,
parameters,
(rs, rowNum) ->
new ConservScore(rs.getString("acc"),
rs.getString("aa"),
rs.getInt("pos"),
rs.getDouble("score"))
);
}

private ConservScore createConservScore(ResultSet rs) throws SQLException {
return new ConservScore(rs.getString("acc"), rs.getString("aa"),
rs.getInt("pos"), rs.getDouble("score"));
public List<ESMScore> getEsmScores(String acc, Integer pos) {
SqlParameterSource parameters = new MapSqlParameterSource("acc", acc)
.addValue("pos", pos);
return jdbcTemplate.query(SELECT_FROM_ESM,
parameters,
(rs, rowNum) ->
new ESMScore(rs.getString("accession"),
rs.getInt("position"),
rs.getString("mt_aa"),
rs.getDouble("score"))
);
}
}

0 comments on commit d19f546

Please sign in to comment.