private void cacheTypeDescriptor(SpaceTypeDescriptor typeDescriptor) {

    if (typeDescriptor == null)
      throw new IllegalArgumentException("typeDescriptor can not be null");

    if (!types.containsKey(typeDescriptor.getTypeName())) introduceType(typeDescriptor);

    types.put(typeDescriptor.getTypeName(), new SpaceTypeDescriptorContainer(typeDescriptor));
  }
  private Map<String, List<String>> processSamplesGT(Map<String, String> options) {
    Map<String, List<String>> samplesGenotypes = new LinkedHashMap<>(10);
    List<String> genotypesList;

    String key, val;
    for (Map.Entry<String, String> entry : options.entrySet()) {
      key = entry.getKey();
      val = entry.getValue();

      if (key.startsWith("sampleGT_")) {
        String sampleName = key.replace("sampleGT_", "").replace("[]", "");
        String[] genotypes = val.split(",");

        if (samplesGenotypes.containsKey(sampleName)) {
          genotypesList = samplesGenotypes.get(sampleName);
        } else {

          genotypesList = new ArrayList<>();
          samplesGenotypes.put(sampleName, genotypesList);
        }

        for (int i = 0; i < genotypes.length; i++) {

          genotypesList.add(genotypes[i]);
        }
      }
    }
    return samplesGenotypes;
  }
Пример #3
0
  // --------------------------------------------------------------------------------
  private void drawItem(String parentFieldName, TreeItem parentItem, List data, boolean expand) {
    for (int i = 0; i < data.size(); ++i) {
      TreeItem newItem = new TreeItem(parentItem, SWT.NONE);
      Object value = data.get(i);
      newItem.setText(1, getClassName(value));

      String fieldName = parentFieldName + "." + i;
      if (fieldName.startsWith(".")) {
        fieldName = fieldName.substring(1);
      }
      newItem.setData("fieldName", fieldName);
      newItem.setData("value", value);
      fieldNameTreeItemMap.put(fieldName, newItem);

      if (value instanceof Map) {
        newItem.setText("[" + i + "]");
        newItem.setImage(mapImage);
        drawItem(fieldName, newItem, (Map) value, expand);
      } else if (value instanceof List) {
        newItem.setText("[" + i + "]");
        newItem.setImage(listImage);
        drawItem(fieldName, newItem, (List) value, expand);
      } else {
        setItemInfo(newItem, "[" + i + "]", value);
      }

      if (expand) {
        parentItem.setExpanded(expand);
        newItem.setExpanded(expand);
      }
    }
  }
Пример #4
0
  // --------------------------------------------------------------------------------
  private void onEditField(final MEditFieldAction action) {
    MSystemUtil.sleep(100);

    final String fieldName = action.getFieldName();
    editingFieldName = fieldName;
    final TreeItem item = (TreeItem) fieldNameTreeItemMap.get(fieldName);
    if (item == null) {
      debug("item not found");
      // debug( fieldNameTreeItemMap );
      return;
    }
    // Object document = dataManager.getLastEditedDocument();

    final MDocumentEditor view = this;

    shell
        .getDisplay()
        .asyncExec(
            new Runnable() {
              public void run() { // *****

                if (action.getOriginView() != view) {
                  tree.select(item);
                }

                if (fieldName.equals("_id")) {
                  valueText.setEditable(false);
                  valueText.setEnabled(true);
                  typeCombo.setEnabled(false);
                  nameText.setText(fieldName);
                  editingData = item.getData("value");
                  valueText.setText(editingData + "");
                  typeCombo.select(
                      ((Integer) typeComboIndexMap.get(editingData.getClass())).intValue());
                  updateButton.setEnabled(false);
                } else {
                  valueText.setEditable(true);
                  valueText.setEnabled(true);
                  typeCombo.setEnabled(true);
                  nameText.setText(fieldName);
                  editingData = item.getData("value");
                  valueText.setText(editingData + "");
                  if (editingData == null) {
                    typeCombo.select(11);
                    verifyData();
                  } else {
                    typeCombo.select(
                        ((Integer) typeComboIndexMap.get(editingData.getClass())).intValue());
                    verifyData();
                  }
                }
              }
            }); // ********

    // valueText.setText( docum )
  }
  @BeforeMethod(groups = {"dev"})
  public static void setup() throws UnknownHostException {
    mongo = new Mongo("localhost", 27017);

    Map<String, String> ctxMap = new HashMap<String, String>();
    ctxMap.put(MongoSink.HOST, "localhost");
    ctxMap.put(MongoSink.PORT, "27017");
    ctxMap.put(MongoSink.DB_NAME, "test_events");
    ctxMap.put(MongoSink.COLLECTION, "test_log");
    ctxMap.put(MongoSink.BATCH_SIZE, "100");

    ctx.putAll(ctxMap);

    Context channelCtx = new Context();
    channelCtx.put("capacity", "1000000");
    channelCtx.put("transactionCapacity", "1000000");
    channel = new MemoryChannel();
    Configurables.configure(channel, channelCtx);
  }
Пример #6
0
  // --------------------------------------------------------------------------------
  private void drawItem(String parentFieldName, TreeItem parentItem, Map data, boolean expand) {
    Iterator p = data.keySet().iterator();
    while (p.hasNext()) {
      String key = (String) p.next();
      if (!data.containsKey(key)) {
        continue;
      }
      Object value = data.get(key);

      TreeItem newItem = new TreeItem(parentItem, SWT.NONE);
      newItem.setText(1, getClassName(value));

      String fieldName = parentFieldName + "." + key;
      if (fieldName.startsWith(".")) {
        fieldName = fieldName.substring(1);
      }
      newItem.setData("fieldName", fieldName);
      newItem.setData("value", value);
      fieldNameTreeItemMap.put(fieldName, newItem);

      if (value == null) {
        newItem.setText(key + " : null");
        newItem.setImage(nullImage);
      } else if (value instanceof Map) {
        newItem.setText(key);
        newItem.setImage(mapImage);
        drawItem(fieldName, newItem, (Map) value, expand);
      } else if (value instanceof List) {
        newItem.setText(key);
        newItem.setImage(listImage);
        drawItem(fieldName, newItem, (List) value, expand);
      } else {
        setItemInfo(newItem, key, value);
      }

      if (expand) {
        parentItem.setExpanded(expand);
        newItem.setExpanded(expand);
      }
    }
  }
  public void performBatch(List<BatchUnit> rows) {
    if (logger.isTraceEnabled()) {
      logger.trace("MongoClientWrapper.performBatch(" + rows + ")");
      logger.trace("Batch size to be performed is " + rows.size());
    }
    // List<Future<? extends Number>> pending = new ArrayList<Future<? extends Number>>();

    for (BatchUnit row : rows) {
      SpaceDocument spaceDoc = row.getSpaceDocument();
      SpaceTypeDescriptor typeDescriptor = types.get(row.getTypeName()).getTypeDescriptor();
      SpaceDocumentMapper<DBObject> mapper = getMapper(typeDescriptor);

      DBObject obj = mapper.toDBObject(spaceDoc);

      DBCollection col = getCollection(row.getTypeName());
      switch (row.getDataSyncOperationType()) {
        case WRITE:
        case UPDATE:
          col.save(obj);
          break;
        case PARTIAL_UPDATE:
          DBObject query =
              BasicDBObjectBuilder.start()
                  .add(Constants.ID_PROPERTY, obj.get(Constants.ID_PROPERTY))
                  .get();

          DBObject update = normalize(obj);
          col.update(query, update);
          break;
          // case REMOVE_BY_UID: // Not supported by this implementation
        case REMOVE:
          col.remove(obj);
          break;
        default:
          throw new IllegalStateException(
              "Unsupported data sync operation type: " + row.getDataSyncOperationType());
      }
    }

    /*long totalCount = waitFor(pending);

    if (logger.isTraceEnabled()) {
    	logger.trace("total accepted replies is: " + totalCount);
    }*/
  }
Пример #8
0
  // --------------------------------------------------------------------------------
  private void drawTreeRoot(Tree _tree, DBObject data) {
    // reset tree
    _tree.removeAll();

    if (data != null) {
      TreeItem root = new TreeItem(_tree, SWT.NONE);
      root.setText(data.get("_id") + "");
      root.setImage(documentImage);
      root.setData("fieldName", "");
      root.setData("value", data.get("_id"));
      fieldNameTreeItemMap.put("", root);

      boolean expand = (data.keySet().size() < 35);
      drawItem("", root, data.toMap(), expand);
    }

    nameText.setText("");
    typeCombo.select(0);
    typeCombo.setEnabled(false);
    valueText.setText("");
    updateButton.setEnabled(false);
  }
Пример #9
0
    public TaskWrite(Map map1, Map m_max, Map m_min, DBCollection coll, ModbusSlaveSet slave) {

      try {
        synchronized (slave) {
          Calendar calener = Calendar.getInstance();
          Date d1 = calener.getTime();
          Date d2 = new Date(calener.getTime().getTime() - 5000);
          BasicDBObject b2 = new BasicDBObject();
          b2.put("$gte", d2);
          b2.put("$lte", d1);
          DBCursor cursor =
              coll.find(new BasicDBObject("_id", b2)).sort(new BasicDBObject("_id", -1)).limit(1);
          while (cursor.hasNext()) {
            DBObject dbo = cursor.next();
            Set set1 = map1.entrySet();
            Iterator it1 = set1.iterator();
            while (it1.hasNext()) {
              Map.Entry<String, Map<String, String>> entry =
                  (Map.Entry<String, Map<String, String>>) it1.next();
              Map<String, String> map2 = entry.getValue();
              for (Iterator it2 = map2.entrySet().iterator(); it2.hasNext(); ) {
                Map.Entry<String, String> entry2 = (Map.Entry<String, String>) it2.next();
                String name = entry2.getKey().toString();
                String paramAddr = entry2.getValue().toString();
                int fun = (int) (Double.parseDouble(paramAddr));
                if (paramAddr.substring(0, 1).equals("4")) {
                  double value = Double.parseDouble(dbo.get(name).toString());
                  double dmax = (Double) m_max.get(name);
                  double dmin = (Double) m_min.get(name);
                  double dValue = 0;
                  if (value > dmax || value < dmin) {
                    if (value >= 0) {
                      dValue = 32000 * (int) (value / dmax);
                    }
                    if (value < 0) {
                      dValue = -32000 * (int) (value / dmin);
                    }
                    // slave.getProcessImage(3).setInputRegister(fun % 10000, (short) dValue);
                  } else { /// 参数超限报警
                    JOptionPane.showMessageDialog(null, "参数超限");
                    slave.stop();
                  }
                }
                if (paramAddr.substring(0, 1).equals("3")) {
                  double value = Double.parseDouble(dbo.get(name).toString());
                  double dmax = (Double) m_max.get(name);
                  double dmin = (Double) m_min.get(name);
                  double dValue = 0;
                  if (value > dmax || value < dmin) {
                    if (value >= 0) {
                      dValue = 32000 * (int) (value / dmax);
                    }
                    if (value < 0) {
                      dValue = -32000 * (int) (value / dmin);
                    }
                    // slave.getProcessImage(3).setHoldingRegister(fun % 10000, (short) dValue);
                  } else { /// 参数超限报警
                    JOptionPane.showMessageDialog(null, "参数超限");
                    slave.stop();
                  }
                  ;
                }
                if (paramAddr.substring(0, 1).equals("2")) {
                  String value = dbo.get(name).toString();
                  /// slave.getProcessImage(4).setInput(fun % 10000, Boolean.valueOf(value));
                }
                if (paramAddr.substring(0, 1).equals("1")) {
                  String value = dbo.get(name).toString();
                  // slave.getProcessImage(4).setCoil(fun % 10000, Boolean.valueOf(value));
                }
              }
            }
          }
        }
      } catch (Exception ex) {
      }
    }
Пример #10
0
    public TaskRead(Map map1, Map m_max, Map m_min, DBCollection coll, ModbusSlaveSet slave) {
      try {
        //// 此处只要点击开始就能保存数据
        /// 方案:利用数据源发送单个布尔型变量(1,0)交替,链接成功,先判断是否链接成功,然后在保存数据
        synchronized (slave) {
          Map map = new HashMap();
          Set set1 = map1.entrySet();
          Iterator it1 = set1.iterator();
          while (it1.hasNext()) {
            Map.Entry<String, Map<String, String>> entry =
                (Map.Entry<String, Map<String, String>>) it1.next();
            Map<String, String> map2 = entry.getValue();
            for (Iterator it2 = map2.entrySet().iterator(); it2.hasNext(); ) {
              Map.Entry<String, String> entry2 = (Map.Entry<String, String>) it2.next();
              String name = entry2.getKey().toString();
              String paramAddr = entry2.getValue().toString();
              int fun = (int) (Double.parseDouble(paramAddr));
              if (paramAddr.substring(0, 1).equals("4")) {
                Short d4 = slave.getProcessImage(1).getInputRegister(fun % 10000);
                double dmax = (Double) m_max.get(name);
                double dmin = (Double) m_min.get(name);
                double dValue = 0;
                if (d4 >= 0) {
                  dValue = dmax * d4 / 32000;
                } else {
                  dValue = dmin * d4 / (-32000);
                }
                map.put(name, dValue);
              }
              if (paramAddr.substring(0, 1).equals("3")) {
                Short d3 = slave.getProcessImage(1).getHoldingRegister(fun % 10000);
                double dmax = (Double) m_max.get(name);
                double dmin = (Double) m_min.get(name);
                double dValue = 0;

                if (d3 >= 0) {
                  dValue = dmax * d3 / 32000;
                } else {
                  dValue = dmin * d3 / (-32000);
                }
                map.put(name, dValue);
              }
              if (paramAddr.substring(0, 1).equals("2")) {
                map.put(name, slave.getProcessImage(2).getInput(fun % 10000));
              }
              if (paramAddr.substring(0, 1).equals("1")) {
                Boolean a = slave.getProcessImage(2).getCoil(fun % 10000 - 1);
                map.put(name, a);
              }
            }
          }

          Calendar calendar = Calendar.getInstance();
          Date dd = calendar.getTime();

          BasicDBObject doc = new BasicDBObject();
          doc.put("_id", dd);

          Set set = map.entrySet();
          Iterator it = set.iterator();
          while (it.hasNext()) {
            Map.Entry<String, String> entry1 = (Map.Entry<String, String>) it.next();
            doc.put(entry1.getKey(), entry1.getValue());
          }
          coll.insert(doc);
        }
      } catch (Exception ex) {
      }
    }
Пример #11
0
  public void receiveData(
      String ip,
      String paramName,
      String paramNo,
      int paramBote,
      int paramLength,
      int parmParity,
      int parmStopBit,
      int parmDelay) {
    try {
      try {
        m = new Mongo(ip, 27017);
        db = m.getDB(paramName);
        // db.authenticate("test", "123".toCharArray());
      } catch (UnknownHostException ex) {
        ex.printStackTrace();
      } catch (MongoException e) {
        e.printStackTrace();
      }
      final DBCollection coll = db.getCollection("DATAIN");
      final DBCollection collout = db.getCollection("DATAOUT");
      DBCollection meta = db.getCollection("META");

      // 记录数据字段
      final Map map1 = new HashMap();
      final Map map2 = new HashMap();
      Map map00 = new HashMap();
      Map map01 = new HashMap();
      Map map02 = new HashMap();
      Map map03 = new HashMap();

      final Map m_ai_max = new HashMap();
      final Map m_ai_min = new HashMap();
      final Map m_ao_max = new HashMap();
      final Map m_ao_min = new HashMap();

      DBCursor cursor = meta.find();
      while (cursor.hasNext()) {
        // 记录数据类型
        DBObject dbo = cursor.next();
        String name = dbo.get("_id").toString();
        String type = dbo.get("type").toString();
        String addr = dbo.get("addr").toString();
        Double max = (Double) dbo.get("max");
        Double min = (Double) dbo.get("min");
        if (type.equals("AI")) {
          map00.put(name, addr);
          m_ai_max.put(name, max);
          m_ai_min.put(name, min);
        }
        if (type.equals("DI")) {
          map01.put(name, addr);
        }
        if (type.equals("AO")) {
          map02.put(name, addr);
        }
        if (type.equals("DO")) {
          map03.put(name, addr);
        }
      }
      map1.put("AI", map00);
      map1.put("DI", map01);

      map2.put("AO", map02);
      map2.put("DO", map03);

      SerialParameters params = new SerialParameters();
      params.setCommPortId(paramNo);
      params.setBaudRate(paramBote);
      params.setDataBits(paramLength);
      params.setParity(parmParity);
      params.setStopBits(parmStopBit);
      ModbusFactory modbusFactory = new ModbusFactory();
      slave = modbusFactory.createRtuSlave(params);

      slave.addProcessImage(getModscanProcessImage(1, map00, coll));
      slave.addProcessImage(getModscanProcessImage(2, map01, coll));
      slave.addProcessImage(getModscanProcessImage(3, map02, collout));
      slave.addProcessImage(getModscanProcessImage(4, map03, collout));
      new Thread(
              new Runnable() {
                public void run() {
                  try {
                    slave.start();
                    // JOptionPane.showMessageDialog(f, "通讯连接成功!");
                  } catch (ModbusInitException e) {
                    e.printStackTrace();
                  }
                }
              })
          .start();
      ScheduledExecutorService timerRead = Executors.newScheduledThreadPool(1);
      timerRead.scheduleAtFixedRate(
          new Runnable() {
            public void run() {
              new TaskRead(map1, m_ai_max, m_ai_min, coll, slave);
            }
          },
          500,
          parmDelay,
          TimeUnit.MILLISECONDS);
      ScheduledExecutorService timerWrite = Executors.newScheduledThreadPool(2);
      timerWrite.scheduleAtFixedRate(
          new Runnable() {
            public void run() {
              new TaskWrite(map2, m_ao_max, m_ao_min, collout, slave);
            }
          },
          500,
          parmDelay,
          TimeUnit.MILLISECONDS);
    } catch (Exception ex) {
    }
  }
  public QueryResult<VariantInfo> getRecordsMongo(
      int page, int start, int limit, MutableInt count, Map<String, String> options) {

    long startTime = System.currentTimeMillis();
    QueryResult<VariantInfo> queryResult = new QueryResult<>();

    List<VariantInfo> res = new ArrayList<>();
    String sourceId = options.get("studyId");
    DBCollection coll = db.getCollection("variants");

    BasicDBObject elemMatch = new BasicDBObject("sourceId", sourceId);
    DBObject query = new BasicDBObject();
    BasicDBList orList = new BasicDBList();

    Map<String, List<String>> sampleGenotypes = processSamplesGT(options);

    System.out.println("map = " + options);

    if (options.containsKey("region") && !options.get("region").equals("")) {
      String[] regions = options.get("region").split(",");
      Pattern pattern = Pattern.compile("(\\w+):(\\d+)-(\\d+)");
      Matcher matcher, matcherChr;

      for (int i = 0; i < regions.length; i++) {
        String region = regions[i];
        matcher = pattern.matcher(region);
        if (matcher.find()) {
          String chr = matcher.group(1);
          int s = Integer.valueOf(matcher.group(2));
          int e = Integer.valueOf(matcher.group(3));

          DBObject regionClause = new BasicDBObject("chr", chr);
          regionClause.put("pos", new BasicDBObject("$gte", s).append("$lte", e));
          orList.add(regionClause);
        } else {

          Pattern patternChr = Pattern.compile("(\\w+)");
          matcherChr = patternChr.matcher(region);

          if (matcherChr.find()) {
            String chr = matcherChr.group();
            DBObject regionClause = new BasicDBObject("chr", chr);
            orList.add(regionClause);
          }
        }
      }
      query.put("$or", orList);

    } else if (options.containsKey("genes") && !options.get("genes").equals("")) {
      orList = processGeneList(options.get("genes"));
      if (orList.size() > 0) {
        query.put("$or", orList);
      } else {
        queryResult.setWarningMsg("Wrong gene name");
        queryResult.setResult(res);
        queryResult.setNumResults(res.size());
        return queryResult;
      }
    }

    if (options.containsKey("conseq_type") && !options.get("conseq_type").equals("")) {
      String[] cts = options.get("conseq_type").split(",");

      BasicDBList ctList = new BasicDBList();
      for (String ct : cts) {
        ctList.add(ct);
      }
      elemMatch.put("effects", new BasicDBObject("$in", ctList));
    }

    if (sampleGenotypes.size() > 0) {
      for (Map.Entry<String, List<String>> entry : sampleGenotypes.entrySet()) {
        BasicDBList gtList = new BasicDBList();
        for (String gt : entry.getValue()) {
          gtList.add(gt);
        }
        elemMatch.put("samples." + entry.getKey() + ".GT", new BasicDBObject("$in", gtList));
      }
    }

    if (options.containsKey("miss_gt") && !options.get("miss_gt").equalsIgnoreCase("")) {
      Integer val = Integer.valueOf(options.get("miss_gt"));
      Object missGt = getMongoOption(options.get("option_miss_gt"), val);
      elemMatch.put("stats.missGenotypes", missGt);
    }

    BasicDBList andControls = new BasicDBList();

    if (options.containsKey("maf_1000g_controls")
        && !options.get("maf_1000g_controls").equalsIgnoreCase("")) {
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.1000G_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.1000G_maf",
              new BasicDBObject("$lte", options.get("maf_1000g_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }

    if (options.containsKey("maf_1000g_afr_controls")
        && !options.get("maf_1000g_afr_controls").equalsIgnoreCase("")) {
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.1000G_AFR_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.1000G_AFR_maf",
              new BasicDBObject("$lte", options.get("maf_1000g_afr_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }

    if (options.containsKey("maf_1000g_asi_controls")
        && !options.get("maf_1000g_asi_controls").equalsIgnoreCase("")) {
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.1000G_ASI_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.1000G_ASI_maf",
              new BasicDBObject("$lte", options.get("maf_1000g_asi_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }

    if (options.containsKey("maf_1000g_eur_controls")
        && !options.get("maf_1000g_eur_controls").equalsIgnoreCase("")) {
      System.out.print("EUR");
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.1000G_EUR_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.1000G_EUR_maf",
              new BasicDBObject("$lte", options.get("maf_1000g_eur_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }
    if (options.containsKey("maf_1000g_ame_controls")
        && !options.get("maf_1000g_ame_controls").equalsIgnoreCase("")) {
      System.out.print("AME");
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.1000G_AME_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.1000G_AME_maf",
              new BasicDBObject("$lte", options.get("maf_1000g_ame_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }
    if (options.containsKey("maf_evs_controls")
        && !options.get("maf_evs_controls").equalsIgnoreCase("")) {
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.EVS_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.EVS_maf", new BasicDBObject("$lte", options.get("maf_evs_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }

    if (options.containsKey("maf_bier_controls")
        && !options.get("maf_bier_controls").equalsIgnoreCase("")) {
      BasicDBList or = new BasicDBList();
      or.add(new BasicDBObject("attributes.BIER_maf", new BasicDBObject("$exists", false)));
      or.add(
          new BasicDBObject(
              "attributes.BIER_maf", new BasicDBObject("$lte", options.get("maf_bier_controls"))));

      andControls.add(new BasicDBObject("$or", or));
    }

    if (andControls.size() > 0) {
      elemMatch.append("$and", andControls);
    }

    query.put("sources", new BasicDBObject("$elemMatch", elemMatch));

    System.out.println("#############################");
    System.out.println(query);
    System.out.println("#############################");

    long dbStart = System.currentTimeMillis();

    DBObject sort = null;
    DBCursor cursor;

    if (options.containsKey("sort")) {
      sort = getQuerySort(options.get("sort"));
      cursor = coll.find(query).sort(sort).skip(start).limit(limit);
    } else {
      cursor = coll.find(query).skip(start).limit(limit);
    }

    count.setValue(cursor.count());

    queryResult.setDbTime(dbStart - System.currentTimeMillis());

    for (DBObject obj : cursor) {

      BasicDBObject elem = (BasicDBObject) obj;
      VariantInfo vi = new VariantInfo();
      VariantStats vs = new VariantStats();

      String chr = elem.getString("chr");
      int pos = elem.getInt("pos");

      vi.setChromosome(chr);
      vi.setPosition(pos);

      BasicDBList studies = (BasicDBList) elem.get("sources");

      Iterator<Object> it = studies.iterator();
      while (it.hasNext()) {
        BasicDBObject study = (BasicDBObject) it.next();

        if (study.getString("sourceId").equalsIgnoreCase(sourceId)) {

          BasicDBObject stats = (BasicDBObject) study.get("stats");

          String ref = study.getString("ref");
          BasicDBList alt = (BasicDBList) study.get("alt");
          vi.setRef(ref);
          vi.setAlt(Joiner.on(",").join(alt.toArray()));
          vs.setMaf((float) stats.getDouble("maf"));
          vs.setMgf((float) stats.getDouble("mgf"));
          vs.setMafAllele(stats.getString("alleleMaf"));
          vs.setMgfAllele(stats.getString("genotypeMaf"));
          vs.setMissingAlleles(stats.getInt("missAllele"));
          vs.setMissingGenotypes(stats.getInt("missGenotypes"));
          vs.setMendelinanErrors(stats.getInt("mendelErr"));
          vs.setCasesPercentDominant((float) stats.getDouble("casesPercentDominant"));
          vs.setControlsPercentDominant((float) stats.getDouble("controlsPercentDominant"));
          vs.setCasesPercentRecessive((float) stats.getDouble("casesPercentRecessive"));
          vs.setControlsPercentRecessive((float) stats.getDouble("controlsPercentRecessive"));

          BasicDBObject samples = (BasicDBObject) study.get("samples");

          for (String sampleName : samples.keySet()) {

            DBObject sample = (DBObject) samples.get(sampleName);

            if (sample.containsField("GT")) {
              String sampleGT = (String) sample.get("GT");
              vi.addSammpleGenotype(sampleName, sampleGT);
            }
          }

          vi.setSnpid((String) study.get("snpId"));

          if (study.containsField("effects")) {
            BasicDBList conseqTypes = (BasicDBList) study.get("effects");
            conseqTypes.remove("");
            String cts = Joiner.on(",").join(conseqTypes.iterator());
            vi.addConsequenceTypes(cts);
          }

          if (study.containsField("genes")) {
            BasicDBList genesList = (BasicDBList) study.get("genes");
            String genes = Joiner.on(",").join(genesList.iterator());
            vi.addGenes(genes);
          }

          if (study.containsField("attributes")) {

            BasicDBObject attr = (BasicDBObject) study.get("attributes");

            if (attr.containsField("1000G_maf")) {
              vi.addControl("1000G_maf", (String) attr.get("1000G_maf"));
              vi.addControl("1000G_amaf", (String) attr.get("1000G_amaf"));
              vi.addControl("1000G_gt", (String) attr.get("1000G_gt"));
            }

            if (attr.containsField("1000G_ASI_maf")) {
              vi.addControl("1000G-ASI_maf", (String) attr.get("1000G_ASI_maf"));
              vi.addControl("1000G-ASI_amaf", (String) attr.get("1000G_ASI_amaf"));
              vi.addControl("1000G-ASI_gt", (String) attr.get("1000G_ASI_gt"));
            }

            if (attr.containsField("1000G_AFR_maf")) {
              vi.addControl("1000G-AFR_maf", (String) attr.get("1000G_AFR_maf"));
              vi.addControl("1000G-AFR_amaf", (String) attr.get("1000G_AFR_amaf"));
              vi.addControl("1000G-AFR_gt", (String) attr.get("1000G_AFR_gt"));
            }

            if (attr.containsField("1000G_AME_maf")) {
              vi.addControl("1000G-AME_maf", (String) attr.get("1000G_AME_maf"));
              vi.addControl("1000G-AME_amaf", (String) attr.get("1000G_AME_amaf"));
              vi.addControl("1000G-AME_gt", (String) attr.get("1000G_AME_gt"));
            }

            if (attr.containsField("1000G_EUR_maf")) {
              vi.addControl("1000G-EUR_maf", (String) attr.get("1000G_EUR_maf"));
              vi.addControl("1000G-EUR_amaf", (String) attr.get("1000G_EUR_amaf"));
              vi.addControl("1000G-EUR_gt", (String) attr.get("1000G_EUR_gt"));
            }

            if (attr.containsField("EVS_maf")) {
              vi.addControl("EVS_maf", (String) attr.get("EVS_maf"));
              vi.addControl("EVS_amaf", (String) attr.get("EVS_amaf"));
              vi.addControl("EVS_gt", (String) attr.get("EVS_gt"));
            }

            if (attr.containsField("BIER_maf")) {
              vi.addControl("BIER_maf", (String) attr.get("BIER_maf"));
              vi.addControl("BIER_amaf", (String) attr.get("BIER_amaf"));
              vi.addControl("BIER_gt", (String) attr.get("BIER_gt"));
            }

            if (attr.containsField("PolyphenScore")) {
              vi.setPolyphen_score(Double.parseDouble(attr.getString("PolyphenScore")));
              vi.setPolyphen_effect(Integer.parseInt(attr.getString("PolyphenEffect")));
            }

            if (attr.containsField("SIFTScore")) {
              vi.setSift_score(Double.parseDouble(attr.getString("SIFTScore")));
              vi.setSift_effect(Integer.parseInt(attr.getString("SIFTEffect")));
            }
          }
          continue;
        }
      }
      vi.addStats(vs);
      res.add(vi);
    }

    queryResult.setResult(res);
    queryResult.setTime(startTime - System.currentTimeMillis());

    return queryResult;
  }
Пример #13
0
  // --------------------------------------------------------------------------------
  public void init2() {
    parent.setLayout(new FormLayout());

    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);

    tree = new Tree(sashForm, SWT.BORDER | SWT.FULL_SELECTION);
    tree.setHeaderVisible(true);

    FormData d1 = new FormData();
    d1.top = new FormAttachment(0, 1);
    d1.left = new FormAttachment(0, 1);
    d1.right = new FormAttachment(100, -1);
    d1.bottom = new FormAttachment(100, -1);
    tree.setLayoutData(d1);

    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Data Type");

    editorComposite = new Composite(sashForm, SWT.BORDER);
    editorComposite.addControlListener(
        new ControlAdapter() {
          public void controlResized(ControlEvent e) {
            onSashResize();
          }
        });

    FormData fd_composite1 = new FormData();
    fd_composite1.top = new FormAttachment(0, 1);
    fd_composite1.bottom = new FormAttachment(0, 35);
    fd_composite1.right = new FormAttachment(100, -1);
    fd_composite1.left = new FormAttachment(0, 1);
    editorComposite.setLayoutData(fd_composite1);
    editorComposite.setLayout(new FormLayout());
    Label nameLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_nameLabel = new FormData();
    fd_nameLabel.right = new FormAttachment(0, 66);
    fd_nameLabel.bottom = new FormAttachment(0, 32);
    fd_nameLabel.top = new FormAttachment(0, 12);
    fd_nameLabel.left = new FormAttachment(0, 10);
    nameLabel.setLayoutData(fd_nameLabel);
    nameLabel.setText("Name :");
    Label valueLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_valueLabel = new FormData();
    fd_valueLabel.top = new FormAttachment(nameLabel, 15);
    fd_valueLabel.left = new FormAttachment(0, 10);
    fd_valueLabel.bottom = new FormAttachment(nameLabel, 34, SWT.BOTTOM);
    fd_valueLabel.right = new FormAttachment(nameLabel, 0, SWT.RIGHT);
    valueLabel.setLayoutData(fd_valueLabel);
    valueLabel.setText("Value :");

    valueText =
        new Text(
            editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    valueText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            verifyData();
          }
        });
    valueText.setEnabled(false);
    valueText.setEditable(false);
    FormData fd_valueText = new FormData();
    fd_valueText.top = new FormAttachment(nameLabel, 5);
    fd_valueText.bottom = new FormAttachment(100, -80);
    fd_valueText.right = new FormAttachment(100, -20);
    fd_valueText.left = new FormAttachment(valueLabel, 0, SWT.RIGHT);
    valueText.setLayoutData(fd_valueText);

    updateButton = new Button(editorComposite, SWT.NONE);
    updateButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            onUpdateButtonSelect();
          }
        });
    updateButton.setEnabled(false);
    FormData fd_updateButton = new FormData();
    fd_updateButton.left = new FormAttachment(100, -120);
    fd_updateButton.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    updateButton.setLayoutData(fd_updateButton);
    updateButton.setText("Update");

    typeCombo = new Combo(editorComposite, SWT.READ_ONLY);
    fd_updateButton.top = new FormAttachment(typeCombo, 10);
    typeCombo.setEnabled(false);
    FormData fd_typeList = new FormData();
    fd_typeList.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_typeList.top = new FormAttachment(valueText, 5, SWT.BOTTOM);
    // fd_typeList.bottom = new FormAttachment(valueText, 30, SWT.BOTTOM);
    fd_typeList.right = new FormAttachment(valueText, 170, SWT.LEFT);
    typeCombo.setLayoutData(fd_typeList);

    typeCombo.add("Double");
    typeCombo.add("Integer");
    typeCombo.add("Long");
    typeCombo.add("String");
    typeCombo.add("List (BasicDBList)");
    typeCombo.add("Map (BasicDBObject)");
    typeCombo.add("Date");
    typeCombo.add("ObjectId");
    typeCombo.add("JavaScript code");
    typeCombo.add("Binary data");
    typeCombo.add("Boolean");
    typeCombo.add("Null");
    typeCombo.add("Regular expression");
    typeCombo.add("Symbol");
    typeCombo.add("JavaScript code with scope");
    typeCombo.add("Timestamp");
    typeCombo.add("Min key");
    typeCombo.add("Max key");

    typeCombo.addListener(SWT.Selection, this);

    typeComboIndexMap.put(Double.class, new Integer(0));
    typeComboIndexMap.put(Integer.class, new Integer(1));
    typeComboIndexMap.put(Long.class, new Integer(2));
    typeComboIndexMap.put(String.class, new Integer(3));
    typeComboIndexMap.put(com.mongodb.BasicDBList.class, new Integer(4));
    typeComboIndexMap.put(com.mongodb.BasicDBObject.class, new Integer(5));
    typeComboIndexMap.put(java.util.Date.class, new Integer(6));
    typeComboIndexMap.put(org.bson.types.ObjectId.class, new Integer(7));
    typeComboIndexMap.put(org.bson.types.Code.class, new Integer(8));
    typeComboIndexMap.put(byte[].class, new Integer(9));
    typeComboIndexMap.put(Boolean.class, new Integer(10));
    typeComboIndexMap.put(java.util.regex.Pattern.class, new Integer(12));
    typeComboIndexMap.put(org.bson.types.Symbol.class, new Integer(13));
    typeComboIndexMap.put(org.bson.types.CodeWScope.class, new Integer(14));
    typeComboIndexMap.put(org.bson.types.BSONTimestamp.class, new Integer(15));
    typeComboIndexMap.put(org.bson.types.MinKey.class, new Integer(16));
    typeComboIndexMap.put(org.bson.types.MaxKey.class, new Integer(17));

    Label typeLabel = new Label(editorComposite, SWT.NONE);
    FormData fd_typeLabel = new FormData();
    fd_typeLabel.top = new FormAttachment(typeCombo, 3, SWT.TOP);
    fd_typeLabel.left = new FormAttachment(nameLabel, 0, SWT.LEFT);
    typeLabel.setLayoutData(fd_typeLabel);
    typeLabel.setText("Type :");

    nameText = new Text(editorComposite, SWT.READ_ONLY);
    nameText.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
    FormData fd_nameText = new FormData();
    fd_nameText.top = new FormAttachment(nameLabel, -2, SWT.TOP);
    fd_nameText.left = new FormAttachment(valueText, 0, SWT.LEFT);
    fd_nameText.right = new FormAttachment(valueText, 0, SWT.RIGHT);
    nameText.setLayoutData(fd_nameText);

    MSwtUtil.getTreeColumnWidthFromProperties("documentTree", tree, prop, new int[] {150, 150});

    // listeners
    tree.addListener(SWT.MouseDoubleClick, this);
    tree.addListener(SWT.Selection, this);
    tree.addListener(SWT.KeyDown, this);
    MSwtUtil.addListenerToTreeColumns2(tree, this);

    documentImage = MUtil.getImage(parent.getShell().getDisplay(), "table.png");
    oidImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_star.png");
    intImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_blue.png");
    longImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_red.png");
    doubleImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_orange.png");
    stringImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_green.png");
    dateImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_white.png");
    boolImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_yellow.png");
    listImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_blue.png");
    mapImage = MUtil.getImage(parent.getShell().getDisplay(), "stop_green.png");
    nullImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_black.png");
    jsImage = MUtil.getImage(parent.getShell().getDisplay(), "bullet_right.png");

    if (prop.containsKey(DOCUMENT_COMPOSITE_WEIGHT)) {

      (new Thread() {
            public void run() {
              // System.out.println( "e" );
              MSystemUtil.sleep(0);
              // System.out.println( "a" );
              shell
                  .getDisplay()
                  .asyncExec(
                      new Runnable() {
                        public void run() { // ----
                          // debug( "--" + prop.getIntArrayProperty( DOCUMENT_COMPOSITE_WEIGHT )[ 0
                          // ] );
                          sashForm.setWeights(prop.getIntArrayProperty(DOCUMENT_COMPOSITE_WEIGHT));
                        }
                      }); // ----
            }
          })
          .start();

    } else {
      sashForm.setWeights(new int[] {70, 30});
    }
    initializedTime = System.currentTimeMillis();
  }
  @Override
  public QueryResult<Variant> getAllVariantsByRegionAndStudy(
      Region region, String sourceId, QueryOptions options) {
    Long start, end, dbstart, dbend;
    start = System.currentTimeMillis();
    QueryResult<Variant> queryResult =
        new QueryResult<>(
            String.format("%s:%d-%d", region.getChromosome(), region.getStart(), region.getEnd()));
    List<Variant> results = new LinkedList<>();

    boolean includeSamples;
    boolean includeStats;
    boolean includeEffects;
    if (!options.containsKey("samples")
        && !options.containsKey("stats")
        && !options.containsKey("effects")) {
      includeSamples = true;
      includeStats = true;
      includeEffects = true;
    } else {
      includeSamples = options.containsKey("samples") && options.getBoolean("samples");
      includeStats = options.containsKey("stats") && options.getBoolean("stats");
      includeEffects = options.containsKey("effects") && options.getBoolean("effects");
    }

    try {
      String startRow = buildRowkey(region.getChromosome(), Long.toString(region.getStart()));
      String stopRow = buildRowkey(region.getChromosome(), Long.toString(region.getEnd()));
      HTable table = new HTable(admin.getConfiguration(), tableName);
      dbstart = System.currentTimeMillis();
      Scan regionScan = new Scan(startRow.getBytes(), stopRow.getBytes());
      ResultScanner scanres = table.getScanner(regionScan);
      dbend = System.currentTimeMillis();
      queryResult.setDbTime(dbend - dbstart);

      // Iterate over results and, optionally, their samples and statistics
      for (Result result : scanres) {
        String[] rowkeyParts = new String(result.getRow(), CHARSET_UTF_8).split("_");
        String chromosome = rowkeyParts[0].replaceFirst("^0+(?!$)", "");
        int position = Integer.parseInt(rowkeyParts[1]);

        // Get basic result fields from Protocol Buffers message
        NavigableMap<byte[], byte[]> infoMap = result.getFamilyMap("i".getBytes());
        byte[] byteInfo = infoMap.get((sourceId + "_data").getBytes());
        VariantFieldsProtos.VariantInfo protoInfo =
            VariantFieldsProtos.VariantInfo.parseFrom(byteInfo);
        String reference = protoInfo.getReference();
        String alternate = StringUtils.join(protoInfo.getAlternateList(), ",");
        String format = StringUtils.join(protoInfo.getFormatList(), ":");
        Variant variant = new Variant(chromosome, position, position, reference, alternate);

        // Set samples if requested
        if (includeSamples) {
          NavigableMap<byte[], byte[]> sampleMap = result.getFamilyMap("d".getBytes());
          Map<String, Map<String, String>> resultSampleMap = new HashMap<>();

          // Set samples
          for (byte[] s : sampleMap.keySet()) {
            String sampleName = (new String(s, CHARSET_UTF_8)).replaceAll(sourceId + "_", "");
            VariantFieldsProtos.VariantSample sample =
                VariantFieldsProtos.VariantSample.parseFrom(sampleMap.get(s));
            String sample1 = sample.getSample();
            String[] values = sample1.split(":");
            String[] fields = format.split(":");
            Map<String, String> singleSampleMap = new HashMap<>();
            for (int i = 0; i < fields.length; i++) {
              singleSampleMap.put(fields[i], values[i]);
            }
            // TODO
            //                        variant.addSampleData(sampleName, singleSampleMap);
          }
        }

        // Set stats if requested
        if (includeStats) {
          byte[] byteStats = infoMap.get((sourceId + "_stats").getBytes());
          VariantFieldsProtos.VariantStats protoStats =
              VariantFieldsProtos.VariantStats.parseFrom(byteStats);
          VariantStats variantStats =
              new VariantStats(
                  chromosome,
                  position,
                  reference,
                  alternate,
                  protoStats.getMaf(),
                  protoStats.getMgf(),
                  protoStats.getMafAllele(),
                  protoStats.getMgfGenotype(),
                  protoStats.getMissingAlleles(),
                  protoStats.getMissingGenotypes(),
                  protoStats.getMendelianErrors(),
                  protoStats.getIsIndel(),
                  protoStats.getCasesPercentDominant(),
                  protoStats.getControlsPercentDominant(),
                  protoStats.getCasesPercentRecessive(),
                  protoStats.getControlsPercentRecessive());
          variant.setStats(variantStats);
        }

        if (includeEffects) {
          QueryResult<VariantEffect> queryEffects = getEffectsByVariant(variant, options);
          variant.setEffect(queryEffects.getResult());
        }

        results.add(variant);
      }
    } catch (IOException e) {
      System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }
    queryResult.setResult(results);
    queryResult.setNumResults(results.size());
    end = System.currentTimeMillis();
    queryResult.setTime(end - start);
    return queryResult;
  }
  public List<Variant> getRecordSimpleStats(
      String study, int missing_gt, float maf, String maf_allele) {
    BasicDBObject compare =
        new BasicDBObject("studies.stats.allele_maf", maf_allele)
            .append("studies.stats.MAF", maf)
            .append("studies.stats.missing", missing_gt);
    List<Get> hbaseQuery = new ArrayList<>();
    DBCollection collection = db.getCollection("variants");
    Iterator<DBObject> result = collection.find(compare);
    String chromosome = new String();
    while (result.hasNext()) {
      DBObject variant = result.next();
      String position = variant.get("_id").toString();
      // hbase query construction
      Get get = new Get(position.getBytes());
      hbaseQuery.add(get);
    }
    // Complete results, from HBase

    tableName = study;
    effectTableName = tableName + "effect";
    Map<String, Variant> resultsMap = new HashMap<>();

    try {
      HTable table = new HTable(admin.getConfiguration(), tableName);
      HTable effectTable = new HTable(admin.getConfiguration(), effectTableName);
      Result[] hbaseResultEffect = effectTable.get(hbaseQuery);
      Result[] hbaseResultStats = table.get(hbaseQuery);

      //            List<Variant> results = new LinkedList<>();
      for (Result r : hbaseResultStats) {
        String position = new String(r.getRow(), CHARSET_UTF_8);
        String[] aux = position.split("_");
        String inner_position = aux[1];
        String chr = aux[0];
        // position parsing
        if (chr.startsWith("0")) {
          chr = chr.substring(1);
        }
        while (inner_position.startsWith("0")) {
          inner_position = inner_position.substring(1);
        }
        List<VariantFieldsProtos.VariantSample> samples = new LinkedList<>();
        NavigableMap<byte[], byte[]> infoMap = r.getFamilyMap("i".getBytes());
        byte[] byteStats = infoMap.get((study + "_stats").getBytes());
        VariantFieldsProtos.VariantStats stats =
            VariantFieldsProtos.VariantStats.parseFrom(byteStats);
        byte[] byteInfo = infoMap.get((study + "_data").getBytes());
        VariantFieldsProtos.VariantInfo info = VariantFieldsProtos.VariantInfo.parseFrom(byteInfo);
        String alternate = StringUtils.join(info.getAlternateList(), ", ");
        String reference = info.getReference();
        Variant partialResult =
            new Variant(
                chr,
                Integer.parseInt(inner_position),
                Integer.parseInt(inner_position),
                reference,
                alternate);
        String format = StringUtils.join(info.getFormatList(), ":");
        NavigableMap<byte[], byte[]> sampleMap = r.getFamilyMap("d".getBytes());
        Map<String, Map<String, String>> resultSampleMap = new HashMap<>();
        //                StringBuilder sampleRaw = new StringBuilder();
        for (byte[] s : sampleMap.keySet()) {
          String qual = (new String(s, CHARSET_UTF_8)).replaceAll(study + "_", "");
          VariantFieldsProtos.VariantSample sample =
              VariantFieldsProtos.VariantSample.parseFrom(sampleMap.get(s));
          String sample1 = sample.getSample();
          String[] values = sample1.split(":");
          String[] fields = format.split(":");
          Map<String, String> singleSampleMap = new HashMap<>();
          for (int i = 0; i < fields.length; i++) {
            singleSampleMap.put(fields[i], values[i]);
          }
          resultSampleMap.put(qual, singleSampleMap);
        }
        VariantStats variantStats =
            new VariantStats(
                chromosome,
                Integer.parseInt(inner_position),
                reference,
                alternate,
                stats.getMaf(),
                stats.getMgf(),
                stats.getMafAllele(),
                stats.getMgfGenotype(),
                stats.getMissingAlleles(),
                stats.getMissingGenotypes(),
                stats.getMendelianErrors(),
                stats.getIsIndel(),
                stats.getCasesPercentDominant(),
                stats.getControlsPercentDominant(),
                stats.getCasesPercentRecessive(),
                stats.getControlsPercentRecessive());
        partialResult.setStats(variantStats);
        resultsMap.put(new String(r.getRow(), CHARSET_UTF_8), partialResult);
      }

      for (Result r : hbaseResultEffect) {
        if (!r.isEmpty()) {
          NavigableMap<byte[], byte[]> effectMap = r.getFamilyMap("e".getBytes());
          Variant partialResult = resultsMap.get(new String(r.getRow(), CHARSET_UTF_8));
          System.out.println("Recuperado " + partialResult.toString());
          String s = partialResult.getReference() + "_" + partialResult.getAlternate();
          VariantEffectProtos.EffectInfo effectInfo =
              VariantEffectProtos.EffectInfo.parseFrom(effectMap.get(s.getBytes()));
          VariantEffect variantEffect =
              new VariantEffect(
                  partialResult.getChromosome(),
                  (int) partialResult.getStart(),
                  partialResult.getReference(),
                  partialResult.getAlternate(),
                  effectInfo.getFeatureId(),
                  effectInfo.getFeatureName(),
                  effectInfo.getFeatureType(),
                  effectInfo.getFeatureBiotype(),
                  effectInfo.getFeatureChromosome(),
                  effectInfo.getFeatureStart(),
                  effectInfo.getFeatureEnd(),
                  effectInfo.getFeatureStrand(),
                  effectInfo.getSnpId(),
                  effectInfo.getAncestral(),
                  effectInfo.getAlternative(),
                  effectInfo.getGeneId(),
                  effectInfo.getTranscriptId(),
                  effectInfo.getGeneName(),
                  effectInfo.getConsequenceType(),
                  effectInfo.getConsequenceTypeObo(),
                  effectInfo.getConsequenceTypeDesc(),
                  effectInfo.getConsequenceTypeType(),
                  effectInfo.getAaPosition(),
                  effectInfo.getAminoacidChange(),
                  effectInfo.getCodonChange());
          resultsMap.put(new String(r.getRow(), CHARSET_UTF_8), partialResult);
        }
      }
    } catch (InvalidProtocolBufferException e) {
      System.err.println(e.getClass().getName() + ": " + e.getMessage());
    } catch (IOException e) {
      System.err.println(e.getClass().getName() + ": " + e.getMessage());
    }

    List<Variant> results = new ArrayList<>(resultsMap.values());
    return results;
  }