/**
   * Check that any _rna_edit attribute represents a substitution rather than an insertion or
   * deletion
   */
  private boolean checkRnaEditAttributes(final DatabaseRegistryEntry dbre) {
    boolean ok = true;

    RowMapper<Attrib> mapper =
        new RowMapper<Attrib>() {
          public Attrib mapRow(ResultSet rs, int row) throws SQLException {
            return new Attrib(rs.getString(1), rs.getLong(2), rs.getString(3));
          }
        };

    String sql =
        "select sr.name, sr.seq_region_id, sra.value "
            + "from seq_region sr join seq_region_attrib sra using (seq_region_id) "
            + "join attrib_type at using (attrib_type_id) where at.code =?";

    List<Attrib> attributes = getSqlTemplate(dbre).queryForList(sql, mapper, "_rna_edit");

    for (Attrib a : attributes) {
      if (!a.isOk()) {
        ReportManager.warning(this, dbre.getConnection(), a.toString());
        ok = false;
      }
    }
    if (!ok) {
      ReportManager.problem(
          this,
          dbre.getConnection(),
          "Detected sequence regions with incorrectly formatted _rna_edit attributes. Check warnings");
    }

    return ok;
  }
Exemple #2
0
  /** Check that the schema_version in the meta table is present and matches the database name. */
  private boolean checkSchemaVersionDBName(DatabaseRegistryEntry dbre) {

    boolean result = true;
    // get version from database name
    String dbNameVersion = dbre.getSchemaVersion();
    logger.finest("Schema version from database name: " + dbNameVersion);

    // get version from meta table
    Connection con = dbre.getConnection();

    if (dbNameVersion == null) {
      ReportManager.warning(this, con, "Can't deduce schema version from database name.");
      return false;
    }

    String schemaVersion =
        DBUtils.getRowColumnValue(
            con, "SELECT meta_value FROM meta WHERE meta_key='schema_version'");
    logger.finest("schema_version from meta table: " + schemaVersion);

    if (schemaVersion == null || schemaVersion.length() == 0) {

      ReportManager.problem(this, con, "No schema_version entry in meta table");
      return false;

    } else if (!schemaVersion.matches("[0-9]+")) {

      ReportManager.problem(this, con, "Meta schema_version " + schemaVersion + " is not numeric");
      return false;

    } else if (!dbNameVersion.equals(schemaVersion) && !isSangerVega) { // do
      // not
      // report
      // for
      // sangervega

      ReportManager.problem(
          this,
          con,
          "Meta schema_version "
              + schemaVersion
              + " does not match version inferred from database name ("
              + dbNameVersion
              + ")");
      return false;

    } else {

      ReportManager.correct(
          this,
          con,
          "schema_version " + schemaVersion + " matches database name version " + dbNameVersion);
    }
    return result;
  }