示例#1
0
  @Override
  public Gene[] getTranscripts(String sessID, GeneSet geneSet)
      throws SQLException, SessionExpiredException {

    SelectQuery query =
        MedSavantDatabase.GeneSetTableSchema.where(
                GENOME, geneSet.getReference(), TYPE, geneSet.getType())
            .select(NAME, CHROM, START, END, CODING_START, CODING_END, TRANSCRIPT);
    LOG.debug(query);
    ResultSet rs = ConnectionController.executeQuery(sessID, query.toString());

    Gene[] result = new Gene[geneSet.getSize()];
    int i = 0;
    while (rs.next()) {
      result[i++] =
          new Gene(
              rs.getString(1),
              rs.getString(2),
              rs.getInt(3),
              rs.getInt(4),
              rs.getInt(5),
              rs.getInt(6),
              rs.getString(7));
    }

    return result;
  }
示例#2
0
  @Override
  public Gene[] getGenes(String sessID, GeneSet geneSet)
      throws SQLException, SessionExpiredException {

    TableSchema table = MedSavantDatabase.GeneSetTableSchema;
    SelectQuery query =
        MedSavantDatabase.GeneSetTableSchema.where(
                GENOME, geneSet.getReference(), TYPE, geneSet.getType())
            .groupBy(CHROM)
            .groupBy(NAME)
            .select(NAME, CHROM, "MIN(start)", "MAX(end)", "MIN(codingStart)", "MAX(codingEnd)");
    BinaryCondition dumbChrsCondition =
        BinaryConditionMS.notlike(
            table.getDBColumn(MedSavantDatabase.GeneSetColumns.CHROM), "%\\_%");
    query.addCondition(dumbChrsCondition);
    BinaryCondition dumbNameCondition =
        BinaryConditionMS.notlike(table.getDBColumn(MedSavantDatabase.GeneSetColumns.NAME), "%-%");
    query.addCondition(dumbNameCondition);

    System.out.println(query.toString());

    LOG.info(query);
    ResultSet rs = ConnectionController.executeQuery(sessID, query.toString());

    Gene[] result = new Gene[geneSet.getSize()];
    int i = 0;
    while (rs.next()) {
      Gene g =
          new Gene(
              rs.getString(1),
              rs.getString(2),
              rs.getInt(3),
              rs.getInt(4),
              rs.getInt(5),
              rs.getInt(6),
              null);
      result[i++] = g;
    }
    if (i != result.length) {
      LOG.info("There were " + result.length + " genes, but only " + i + " were loaded.");
    }
    result = Arrays.copyOf(result, i);

    return result;
  }