Search in sources :

Example 6 with DataIntegrityViolationException

use of uk.ac.ebi.spot.goci.pussycat.exception.DataIntegrityViolationException in project goci by EBISPOT.

the class SparqlAssociationRenderlet method getLocationOfPreviousAssociation.

protected SVGArea getLocationOfPreviousAssociation(RenderletNexus nexus, SparqlTemplate sparqlTemplate, URI association) throws DataIntegrityViolationException {
    BandInformation band = getBandInformation(sparqlTemplate, association);
    if (band != null) {
        BandInformation current = band;
        boolean done = false;
        while (!done) {
            BandInformation previousBand = getPreviousBandMap(nexus, sparqlTemplate).get(current);
            if (previousBand == null) {
                done = true;
                return null;
            }
            if (!previousBand.getChromosome().equals(current.getChromosome())) {
                done = true;
                return null;
            }
            // now find the traits in the previous band
            Set<URI> previousBandAssociations = QueryManager.getCachingInstance().getAssociationsLocatedInCytogeneticBand(sparqlTemplate, previousBand.getBandName(), nexus.getRenderingContext());
            // get first not-null location for an association in the previous band
            for (URI previousBandAssociation : previousBandAssociations) {
                SVGArea prevLocation = nexus.getLocationOfRenderedEntity(previousBandAssociation);
                if (prevLocation != null) {
                    done = true;
                    return prevLocation;
                }
            }
            // if we get to here, no associations are located in the previous region so return null
            getLog().trace("Unable to identify any associations in the previous cytogenetic region '" + previousBand.getBandName() + "'");
            current = previousBand;
        }
        return null;
    } else {
        throw new DataIntegrityViolationException("Unable to identify the cytogenetic region where association '" + association + "' is located");
    }
}
Also used : BandInformation(uk.ac.ebi.spot.goci.pussycat.layout.BandInformation) SVGArea(uk.ac.ebi.spot.goci.pussycat.layout.SVGArea) URI(java.net.URI) DataIntegrityViolationException(uk.ac.ebi.spot.goci.pussycat.exception.DataIntegrityViolationException)

Aggregations

DataIntegrityViolationException (uk.ac.ebi.spot.goci.pussycat.exception.DataIntegrityViolationException)6 SVGArea (uk.ac.ebi.spot.goci.pussycat.layout.SVGArea)4 URI (java.net.URI)3 BandInformation (uk.ac.ebi.spot.goci.pussycat.layout.BandInformation)3 ParameterizedSparqlString (com.hp.hpl.jena.query.ParameterizedSparqlString)2 QuerySolution (com.hp.hpl.jena.query.QuerySolution)2 ResultSet (com.hp.hpl.jena.query.ResultSet)2 SparqlQueryException (uk.ac.ebi.spot.goci.sparql.exception.SparqlQueryException)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1