use of org.nextprot.api.commons.constants.AnnotationMapping2Annotation in project nextprot-api by calipho-sib.
the class PeptideMappingDaoImpl method findPeptideAnnotationEvidencesMap.
@Override
public Map<String, List<AnnotationEvidence>> findPeptideAnnotationEvidencesMap(List<String> names, boolean natural) {
String datasourceClause = natural ? " ds.cv_name != 'SRMAtlas'" : " ds.cv_name = 'SRMAtlas'";
final AnnotationMapping2Annotation pmam = natural ? AnnotationMapping2Annotation.PEPTIDE_MAPPING : AnnotationMapping2Annotation.SRM_PEPTIDE_MAPPING;
String sql = sqlDictionary.getSQLQuery("peptide-evidences-by-peptide-names").replace(":datasourceClause", datasourceClause);
Map<String, Object> params = new HashMap<String, Object>();
params.put("names", names);
SqlParameterSource namedParams = new MapSqlParameterSource(params);
List<AnnotationEvidence> evidences = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sql, namedParams, new RowMapper<AnnotationEvidence>() {
@Override
public AnnotationEvidence mapRow(ResultSet resultSet, int row) throws SQLException {
AnnotationEvidence evidence = new AnnotationEvidence();
// set later by service
evidence.setAnnotationId(0);
evidence.setEvidenceId(resultSet.getLong("evidence_id") + IdentifierOffset.PEPTIDE_MAPPING_ANNOTATION_EVIDENCE_OFFSET);
evidence.setAssignedBy(resultSet.getString("assigned_by"));
evidence.setAssignmentMethod(pmam.getAssignmentMethod());
evidence.setEvidenceCodeAC(pmam.getEcoAC());
evidence.setEvidenceCodeOntology(pmam.getEcoOntology());
evidence.setEvidenceCodeName(pmam.getEcoName());
evidence.setExperimentalContextId(null);
evidence.setNegativeEvidence(false);
evidence.setProperties(new ArrayList<AnnotationEvidenceProperty>());
evidence.setQualifierType(pmam.getQualifierType());
evidence.setQualityQualifier(pmam.getQualityQualifier());
evidence.setResourceAccession(resultSet.getString("accession"));
evidence.setResourceAssociationType("evidence");
evidence.setResourceDb(resultSet.getString("database_name"));
// temp value
evidence.setResourceDescription(resultSet.getString("unique_name"));
evidence.setResourceId(resultSet.getLong("resource_id"));
evidence.setResourceType(resultSet.getString("resource_type"));
return evidence;
}
});
// turn this list into a map having the peptide name as the key
Map<String, List<AnnotationEvidence>> result = new HashMap<>();
for (AnnotationEvidence ev : evidences) {
String pepKey = ev.getResourceDescription();
// remove temp value
ev.setResourceDescription(null);
if (!result.containsKey(pepKey))
result.put(pepKey, new ArrayList<AnnotationEvidence>());
result.get(pepKey).add(ev);
}
return result;
}
Aggregations