Java Examples for de.uni_luebeck.inb.krabbenhoeft.eQTL.server.helpers.persistence.GeoBoxHelper
The following java examples will help you to understand the usage of de.uni_luebeck.inb.krabbenhoeft.eQTL.server.helpers.persistence.GeoBoxHelper. These source code samples are taken from different open source projects.
Example 1
Project: eQTL-GWT-Cassandra-master File: DataRetrievalService.java View source code |
public ExpressionQtlTrackEntry2D[] work(Transaction transaction, Session session) throws Exception { DataSetLayer dsl = (DataSetLayer) session.load(DataSetLayer.class, dataSetLayerKey); ColumnForDataSetLayer[] columns = dsl.getColumns().toArray(new ColumnForDataSetLayer[0]); ColumnForDataSetLayer lodColumn = null; ColumnForDataSetLayer locationColumnX = null; ColumnForDataSetLayer locationColumnY = null; for (ColumnForDataSetLayer col : columns) { if (col.getName().equals("lodScore")) lodColumn = col; if (col.getName().equals(positionColumnX)) locationColumnX = col; if (col.getName().equals(positionColumnY)) locationColumnY = col; } long rangeLen = Math.max(genomeRangeX.toBP - genomeRangeX.fromBP, genomeRangeY.toBP - genomeRangeY.fromBP); int shiftToUse; for (shiftToUse = GeoBoxHelper.minShift; shiftToUse < GeoBoxHelper.maxShift; shiftToUse++) { final long boxSize = GeoBoxHelper.getSizeForBox(shiftToUse); if (boxSize >= rangeLen) break; } CassandraSession cassandra = new CassandraSession(); StreamingEntityRead read = new StreamingEntityRead(cassandra, dsl); final List<ExpressionQtlTrackEntry2D> output = new ArrayList<ExpressionQtlTrackEntry2D>(); final long boxX = GeoBoxHelper.getBoxForValue(shiftToUse, genomeRangeX.fromBP); final long boxY = GeoBoxHelper.getBoxForValue(shiftToUse, genomeRangeY.fromBP); final Iterator<HajoEntity> reader = read.getEntitiesFromGeobox2D(positionColumnX, positionColumnY, shiftToUse, genomeRangeX.chromosome, boxX, boxY); while (reader.hasNext()) { final HajoEntity entity = reader.next(); final ExpressionQtlTrackEntry2D addme = new ExpressionQtlTrackEntry2D(); addme.positionXStart = entity.getLocation(positionColumnX); if (addme.positionXStart > genomeRangeX.toBP) continue; final String indexRangeEndField = locationColumnX.getIndexRangeEndField(); if (indexRangeEndField == null) addme.positionXEnd = addme.positionXStart; else addme.positionXEnd = entity.getLocation(indexRangeEndField); if (addme.positionXEnd < genomeRangeX.fromBP) continue; addme.positionYStart = entity.getLocation(positionColumnY); if (addme.positionYStart > genomeRangeY.toBP) continue; final String indexRangeEndField2 = locationColumnY.getIndexRangeEndField(); if (indexRangeEndField2 == null) addme.positionYEnd = addme.positionYStart; else addme.positionYEnd = entity.getLocation(indexRangeEndField2); if (addme.positionYEnd < genomeRangeY.fromBP) continue; addme.locusId = entity.getName("locusId"); addme.traitId = entity.getName("traitId"); addme.lodScore = entity.getNumerical("lodScore"); addme.lodScoreInMinMaxRange = (addme.lodScore - lodColumn.getMin()) / (lodColumn.getMax() - lodColumn.getMin()); output.add(addme); } cassandra.close(); return output.toArray(new ExpressionQtlTrackEntry2D[0]); }