@Override
 protected boolean runTest(DatabaseRegistryEntry dbre) {
   boolean result = true;
   for (Map.Entry<String, String[]> method_tags : getMandatoryTags().entrySet()) {
     Vector<String> quoted_tags = new Vector<String>();
     for (String t : method_tags.getValue()) {
       quoted_tags.add(String.format("'%s'", t));
     }
     List<String> mlsss =
         getTemplate(dbre)
             .queryForDefaultObjectList(
                 String.format(
                     QUERY,
                     StringUtils.join(quoted_tags, ","),
                     method_tags.getKey(),
                     method_tags.getValue().length),
                 String.class);
     if (mlsss.size() > 0) {
       ReportManager.problem(
           this,
           dbre.getConnection(),
           "MLSSs for "
               + method_tags.getKey()
               + " found with no statistics: "
               + StringUtils.join(mlsss, ","));
       result = false;
     } else {
       ReportManager.correct(this, dbre.getConnection(), "PASSED ");
     }
   }
   return result;
 }
  public boolean checkTreeStatsArePresent(final DatabaseRegistryEntry dbre) {
    Connection con = dbre.getConnection();

    if (!tableHasRows(con, "species_tree_root")) {
      return true;
    }

    int n_tags_root =
        DBUtils.getRowCount(
            con, "SELECT COUNT(*) FROM species_tree_node_tag WHERE tag LIKE 'root\\_%'");
    int n_tags_genes =
        DBUtils.getRowCount(
            con, "SELECT COUNT(*) FROM species_tree_node_tag WHERE tag LIKE 'nb%\\_genes%'");

    boolean result = true;
    if (n_tags_root == 0) {
      ReportManager.problem(
          this,
          con,
          "There are no species_tree_node_tags to describe properties of the root nodes");
      result = false;
    } else if (n_tags_genes == 0) {
      ReportManager.problem(
          this, con, "There are no species_tree_node_tags to summarize the gene counts");
      result = false;
    }
    return result;
  }
  /**
   * Test various things about ditag features.
   *
   * @param dbre The database to use.
   * @return Result.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    int rows =
        DBUtils.getRowCount(
            con, "SELECT COUNT(*) FROM identity_xref WHERE cigar_line REGEXP '^[MDI]'");

    if (rows > 0) {

      ReportManager.problem(
          this,
          con,
          rows + " cigar lines in identity_xref appear to be in the wrong format (number first)");
      result = false;

    } else {

      ReportManager.correct(
          this, con, "All cigar lines in identity_xref are in the correct format");
    }

    return result;
  }
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    int rows =
        DBUtils.getRowCount(
            con,
            "SELECT COUNT(*) FROM external_db WHERE db_display_name IS NULL OR db_display_name LIKE ' %'");

    if (rows > 0) {

      ReportManager.problem(
          this,
          con,
          rows
              + " rows in external_db have null or blank db_display_name - this will mean their label is missing on the web page");
      result = false;

    } else {

      ReportManager.correct(this, con, "No blank db_display_name fields in external_db");
    }

    return result;
  } // run
  /**
   * 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;
  }
  private boolean checkCodingCountAttributes(final DatabaseRegistryEntry dbre) {
    boolean result = true;

    Connection con = dbre.getConnection();
    String code = (dbre.getType() == DatabaseType.SANGER_VEGA) ? "KnwnPCCount" : "coding_cnt";

    SqlTemplate t = DBUtils.getSqlTemplate(dbre);
    String sql =
        "select distinct g.seq_region_id from gene g where g.biotype = ? and g.seq_region_id not in (select distinct g.seq_region_id from gene g, seq_region_attrib sa, attrib_type at where g.seq_region_id = sa.seq_region_id and sa.attrib_type_id = at.attrib_type_id and at.code in (?,?))";
    List<String> toplevel =
        t.queryForDefaultObjectList(sql, String.class, "protein_coding", "LRG", "non_ref");

    sql =
        "select distinct g.seq_region_id from gene g, seq_region_attrib sa, attrib_type at where g.seq_region_id = sa.seq_region_id and sa.attrib_type_id = at.attrib_type_id and code =? ";
    List<String> known = t.queryForDefaultObjectList(sql, String.class, code);

    Set<String> missing = new HashSet<String>(toplevel);
    missing.removeAll(known);

    if (missing.isEmpty()) {
      ReportManager.correct(
          this,
          con,
          "All seq_regions with protein_coding genes have a coding_cnt attribute associated with them");
    } else {
      String msg =
          String.format(
              "%s regions with protein_coding genes do not have the coding_cnt attribute associated",
              missing.size());
      ReportManager.problem(this, con, msg);
      result = false;
    }

    return result;
  }
  @Override
  protected boolean runTest(DatabaseRegistryEntry dbre) {

    List<Integer> numRepeatFeaturesList =
        getTemplate(dbre)
            .queryForDefaultObjectList("select count(*) from repeat_feature;", Integer.class);

    Integer numRepeatFeatures = numRepeatFeaturesList.get(0);

    if (numRepeatFeatures == 0) {

      ReportManager.problem(this, dbre.getConnection(), "No repeat features found!");

      return false;
    }
    if (numRepeatFeatures < 100) {

      ReportManager.problem(
          this,
          dbre.getConnection(),
          "Number of repeat features (" + numRepeatFeatures + ") is suspiciously low!");

      return false;
    }

    return true;
  }
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    // list of transcript analysis logic_names which are allowed to not have supporting features
    String allowed = "'" + StringUtils.join(allowedNoSupporting, "','") + "'";

    String sql =
        String.format(
            "SELECT COUNT(*),t.analysis_id FROM transcript t LEFT JOIN transcript_supporting_feature tsf ON t.transcript_id = tsf.transcript_id JOIN analysis a ON a.analysis_id=t.analysis_id WHERE a.analysis_id=t.analysis_id and tsf.transcript_id IS NULL AND a.logic_name NOT IN (%s) group by t.analysis_id",
            allowed);

    int rows = DBUtils.getRowCount(con, sql);

    if (rows > 0) {

      ReportManager.problem(
          this,
          con,
          rows
              + " transcripts which should have transcript_supporting_features do not have them\nUseful SQL: "
              + sql);
      result = false;

    } else {

      ReportManager.correct(
          this, con, "All transcripts that require supporting features have them");
    }

    return result;
  } // run
  /** Check that all priorities are greater than a certain threshold. */
  private boolean checkMarkerPriorities(Connection con) {

    boolean result = true;

    int count =
        DBUtils.getRowCount(
            con, "SELECT COUNT(*) FROM marker WHERE priority > " + MARKER_PRIORITY_THRESHOLD);

    if (count == 0) {

      ReportManager.problem(
          this,
          con,
          " No marker features have priorities greater than the threshold ("
              + MARKER_PRIORITY_THRESHOLD
              + ")");
      result = false;

    } else {

      ReportManager.correct(
          this,
          con,
          "Some marker features have priorities greater than " + MARKER_PRIORITY_THRESHOLD);
    }

    return result;
  }
  private boolean checkFeaturesAndMapWeights(Connection con) {

    boolean result = true;

    int rowCount = DBUtils.getRowCount(con, "SELECT COUNT(*) FROM marker_feature");

    if (rowCount == 0) {
      ReportManager.problem(
          this, con, "No marker features in database even though markers are present");
      result = false;
    }

    int badWeightCount =
        DBUtils.getRowCount(
            con,
            "SELECT marker_id, COUNT(*) AS correct, map_weight FROM marker_feature GROUP BY marker_id HAVING map_weight != correct");

    if (badWeightCount > 0) {
      ReportManager.problem(
          this,
          con,
          badWeightCount + " marker features have not been assigned correct map weights");
      result = false;
    }

    if (result) {
      ReportManager.correct(this, con, "Marker features appear to be ok");
    }

    return result;
  } // checkFeaturesAndMapWeights
 /**
  * @param dbre
  * @param template
  * @return
  */
 private boolean checkAssembly(DatabaseRegistryEntry dbre, SqlTemplate template, int speciesId) {
   boolean passes = true;
   // 1. get assembly.default
   String assDef = template.queryForDefaultObject(META_QUERY, String.class, ASS_DEF, speciesId);
   if (StringUtils.isEmpty(assDef)) {
     passes = false;
     ReportManager.problem(
         this,
         dbre.getConnection(),
         "Meta value for " + ASS_DEF + " is not set for species " + speciesId);
   }
   if (passes) {
     // 2. check to see if it matches the default coord_system version
     String version =
         template.queryForDefaultObject(COORD_VERSION_QUERY, String.class, speciesId, speciesId);
     if (!assDef.equals(version)) {
       passes = false;
       ReportManager.problem(
           this,
           dbre.getConnection(),
           "Meta value for "
               + ASS_DEF
               + " ("
               + assDef
               + ") does not match min rank coord_system version "
               + version
               + " for species "
               + speciesId);
     }
   }
   return passes;
 }
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    if (tableHasRows(con, "method_link_species_set")) {

      /* Check if have both BLASTZ_NET and LASTZ_NET entries for the same species set */
      int numOfBLASTZ_LASTZSpeciesSets =
          DBUtils.getRowCount(
              con,
              "SELECT species_set_id, count(*) FROM method_link_species_set JOIN method_link USING (method_link_id) WHERE TYPE in ('BLASTZ_NET', 'LASTZ_NET') GROUP BY species_set_id HAVING count(*) > 1");
      if (numOfBLASTZ_LASTZSpeciesSets > 0) {
        ReportManager.problem(
            this,
            con,
            "FAILED method_link_species_set table contains "
                + numOfBLASTZ_LASTZSpeciesSets
                + " entries with a BLASTZ_NET and LASTZ_NET entry for the same species_set");
        ReportManager.problem(
            this,
            con,
            "USEFUL SQL: SELECT species_set_id, count(*) FROM method_link_species_set JOIN method_link USING (method_link_id) WHERE TYPE in ('BLASTZ_NET', 'LASTZ_NET') GROUP BY species_set_id HAVING count(*) > 1");
        result = false;
      }

      // Everything below will be ignored on the master database
      if (isMasterDB(dbre.getConnection())) {
        return result;
      }
      /* Check method_link_species_set <-> synteny_region */
      /* All method_link for syntenies must have an internal ID between 101 and 199 */
      result &=
          checkForOrphansWithConstraint(
              con,
              "method_link_species_set",
              "method_link_species_set_id",
              "synteny_region",
              "method_link_species_set_id",
              "method_link_id >= 101 and method_link_id < 200");
      result &=
          checkForOrphans(
              con,
              "synteny_region",
              "method_link_species_set_id",
              "method_link_species_set",
              "method_link_species_set_id");

    } else {

      ReportManager.correct(
          this, con, "NO ENTRIES in method_link_species_set table, so nothing to test IGNORED");
    }

    return result;
  }
Exemple #13
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;
  }
Exemple #14
0
  private boolean checkTableExists(Connection con) {

    boolean result = true;

    if (!DBUtils.checkTableExists(con, "meta")) {
      result = false;
      ReportManager.problem(this, con, "Meta table not present");
    } else {
      ReportManager.correct(this, con, "Meta table present");
    }

    return result;
  }
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    Map tableToLetter = new HashMap();

    tableToLetter.put("gene", "G");
    tableToLetter.put("transcript", "T");
    tableToLetter.put("translation", "P");

    Iterator it = tableToLetter.keySet().iterator();

    while (it.hasNext()) {

      String table = (String) it.next();
      String letter = (String) tableToLetter.get(table);

      String regexp = "EST" + letter + "[0-9]+";

      String sql =
          "SELECT COUNT(*) FROM "
              + table
              + " x, analysis a WHERE a.analysis_id=x.analysis_id "
              + "AND a.logic_name LIKE '%est%' AND x.stable_id NOT REGEXP '"
              + regexp
              + "'";
      if (table.equals("translation")) {
        // need extra join to transcript table
        sql =
            "SELECT COUNT(*) FROM translation x, transcript t, analysis a WHERE a.analysis_id=t.analysis_id AND x.transcript_id=t.transcript_id AND a.logic_name LIKE '%est%' AND x.stable_id NOT REGEXP 'ESTP[0-9]+'";
      }

      int rows = DBUtils.getRowCount(con, sql);

      if (rows > 0) {

        ReportManager.problem(
            this, con, rows + " " + table + " stable IDs do not contain EST" + letter);
        result = false;

      } else {

        ReportManager.correct(this, con, "All stable IDs contain EST" + letter);
      }
    }

    return result;
  } // run
Exemple #16
0
  private boolean tableHasRows(Connection con) {

    boolean result = true;

    int rows = DBUtils.countRowsInTable(con, "meta");
    if (rows == 0) {
      result = false;
      ReportManager.problem(this, con, "meta table is empty");
    } else {
      ReportManager.correct(this, con, "meta table has data");
    }

    return result;
  }
  public boolean checkLowCoverageMLSSAreLinkedToHighCoverageMLSS(final DatabaseRegistryEntry dbre) {
    Connection con = dbre.getConnection();
    String sql =
        "SELECT mlss1.method_link_species_set_id, tag, value, mlss2.method_link_species_set_id, ml2.type"
            + " FROM method_link_species_set mlss1 JOIN method_link ml1 USING (method_link_id)"
            + " LEFT JOIN method_link_species_set_tag mlsst ON mlsst.method_link_species_set_id = mlss1.method_link_species_set_id AND tag = 'high_coverage_mlss_id'"
            + " LEFT JOIN (method_link_species_set mlss2 JOIN method_link ml2 USING (method_link_id)) ON value = mlss2.method_link_species_set_id"
            + " WHERE ml1.type = 'EPO_LOW_COVERAGE'";

    List<String[]> all_rows = DBUtils.getRowValuesList(con, sql);
    boolean result = true;
    for (String[] row : all_rows) {
      // Check all the potential errors
      if (row[1] == null) {
        ReportManager.problem(
            this,
            con,
            String.format("The MLSS ID %s is missing its 'high_coverage_mlss_id' tag", row[0]));
      } else if (row[2] == null) {
        ReportManager.problem(
            this,
            con,
            String.format(
                "The 'high_coverage_mlss_id' tag for MLSS ID %s has a NULL value", row[0]));
      } else if (row[3] == null) {
        ReportManager.problem(
            this,
            con,
            String.format(
                "The value of the 'high_coverage_mlss_id' tag for MLSS ID %s does not link to a valid MLSS ID: '%s'",
                row[0], row[2]));
      } else if (!row[4].equals("EPO")) {
        ReportManager.problem(
            this,
            con,
            String.format(
                "The value of the 'high_coverage_mlss_id' tag for MLSS ID %s does not link to a 'EPO' MLSS but '%s' (ID %s)",
                row[0], row[4], row[3]));
      } else {
        // This row is correct: everything is non-NULL, and the EPO_LOW_COVERAGE mlss is linked to a
        // EPO
        continue;
      }
      result = false;
    }
    return result;
  }
  /**
   * Check that the phenotype table does not have empty descriptions
   *
   * @param dbre The database to check.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    Connection con = dbre.getConnection();
    boolean result = true;

    try {
      if (!checkCountIsZero(con, "phenotype", "description is null ")) {
        ReportManager.problem(this, con, "Phenotypes with empty descriptions");
        result = false;
      }

    } catch (Exception e) {
      ReportManager.problem(this, con, "HealthCheck caused an exception: " + e.getMessage());
      result = false;
    }

    return result;
  }
  @Override
  protected boolean runTest(DatabaseRegistryEntry dbre) {

    Connection con = dbre.getConnection();

    boolean passed = true;

    for (String currentTable : table) {

      String currentSql = create_sql_for_table(currentTable);

      try {
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(currentSql);
        if (rs != null) {

          while (rs.next()) {

            int numProblemRows = rs.getInt("c");

            if (numProblemRows > 0) {

              ReportManager.problem(
                  this,
                  con,
                  "The table "
                      + currentTable
                      + " has "
                      + numProblemRows
                      + " rows in which the start or "
                      + "end coordinates are not positive integers.");
              ReportManager.problem(this, con, "USEFUL SQL: " + currentSql);
              passed = false;
            }
          }
        }
        rs.close();
        stmt.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return passed;
  }
 /**
  * @param dbre
  * @param template
  * @return
  */
 private boolean checkGeneBuild(DatabaseRegistryEntry dbre, SqlTemplate template, int speciesId) {
   boolean passes = true;
   String gbStart = template.queryForDefaultObject(META_QUERY, String.class, GB_START, speciesId);
   if (StringUtils.isEmpty(gbStart)) {
     passes = false;
     ReportManager.problem(
         this, dbre.getConnection(), "Meta value for " + GB_START + " is not set ");
   }
   return passes;
 }
Exemple #21
0
  private boolean checkKeysPresent(Connection con) {
    boolean result = true;

    // check that certain keys exist
    String[] metaKeys = {
      "assembly.default",
      "assembly.name",
      "assembly.date",
      "assembly.coverage_depth",
      "species.classification",
      "species.common_name",
      "species.display_name",
      "species.production_name",
      "species.scientific_name",
      "species.stable_id_prefix",
      "species.taxonomy_id",
      "species.url",
      "repeat.analysis",
    };
    for (String metaKey : metaKeys) {
      int rows = metaKeyCount(con, metaKey);
      if (rows == 0) {
        result = false;
        ReportManager.problem(this, con, "No entry in meta table for " + metaKey);
      }
    }

    // check that there are some species.alias entries
    int MIN_ALIASES = 3;

    int rows = metaKeyCount(con, "species.alias");
    if (rows < MIN_ALIASES) {
      result = false;
      String msg =
          String.format("Only %d species.alias entries, should be at least %d", rows, MIN_ALIASES);
      ReportManager.problem(this, con, msg);
    } else {
      ReportManager.correct(this, con, rows + " species.alias entries present");
    }

    return result;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.ensembl.healthcheck.testcase.eg_core.AbstractEgCoreTestCase#runTest
  * (org.ensembl.healthcheck.DatabaseRegistryEntry)
  */
 @Override
 protected boolean runTest(DatabaseRegistryEntry dbre) {
   boolean passes = true;
   int n =
       getTemplate(dbre)
           .queryForDefaultObject(
               "Select count(*) from xref where external_db_id=60014", Integer.class);
   if (n > 0) {
     ReportManager.problem(this, dbre.getConnection(), "IGI xrefs found");
   }
   return passes;
 }
  /**
   * Check the data in the assembly_exception table. Note referential integrity checks are done in
   * CoreForeignKeys.
   *
   * @param dbre The database to use.
   * @return Result.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    String qry =
        "select count(*) from gene,transcript,translation "
            + "where gene.biotype like '%pseudogene%'"
            + " and transcript.gene_id=gene.gene_id "
            + " and translation.transcript_id=transcript.transcript_id and gene.biotype!= 'polymorphic_pseudogene' ";
    if (dbre.getType()
        == DatabaseType
            .SANGER_VEGA) { // for sangervega ignore genes that do not have source havana or WU and
                            // allow
      // polymorphic_pseudogene to have translations
      qry += " and (gene.source='havana' or gene.source='WU')";
    }
    if (dbre.getType() == DatabaseType.SANGER_VEGA || dbre.getType() == DatabaseType.VEGA) {
      // Vega allows translations on translated_processed_pseudogene-s
      qry += " and gene.biotype != 'translated_processed_pseudogene'";
    }

    int rows = DBUtils.getRowCount(con, qry);
    if (rows > 0) {
      result = false;
      ReportManager.problem(
          this,
          con,
          "Translation table contains "
              + rows
              + " rows for pseudogene types - should contain none");
    }

    if (result) {
      ReportManager.correct(this, con, "No pseudogenes have translations");
    }

    return result;
  }
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    // --------------------------------
    // MGI - dbprimary_acc should have MGI: prefix
    int rows =
        DBUtils.getRowCount(
            con,
            "SELECT COUNT(*) FROM external_db e, xref x WHERE x.external_db_id=e.external_db_id AND e.db_name='MGI' AND x.dbprimary_acc NOT LIKE 'MGI:%'");

    if (rows > 0) {
      ReportManager.problem(
          this, con, rows + " MGI xrefs do not have MGI: prefixes in the dbprimary_acc column");
      result = false;
    } else {
      ReportManager.correct(this, con, "All MGI xrefs have the correct prefix");
    }

    // --------------------------------
    // GO - dbprimary_acc and display_label should have GO: prefix
    rows =
        DBUtils.getRowCount(
            con,
            "SELECT COUNT(*) FROM external_db e, xref x WHERE x.external_db_id=e.external_db_id AND e.db_name='GO' AND (x.dbprimary_acc NOT LIKE 'GO:%' OR x.display_label NOT LIKE 'GO:%')");

    if (rows > 0) {
      ReportManager.problem(
          this,
          con,
          rows
              + " GO xrefs do not have GO: prefixes in the dbprimary_acc and/or display_label columns");
      result = false;
    } else {
      ReportManager.correct(this, con, "All GO xrefs have the correct prefix");
    }

    // --------------------------------
    // ZFIN - dbprimary_acc should begin with ZDB
    rows =
        DBUtils.getRowCount(
            con,
            "SELECT COUNT(*) FROM external_db e, xref x WHERE x.external_db_id=e.external_db_id AND e.db_name='ZFIN_ID' AND x.dbprimary_acc NOT LIKE 'ZDB%'");

    if (rows > 0) {
      ReportManager.problem(
          this,
          con,
          rows
              + " ZFIN xrefs do not have ZDB: prefixes in the dbprimary_acc and/or display_label columns");
      result = false;
    } else {
      ReportManager.correct(this, con, "All ZFIN xrefs have the correct prefix");
    }

    return result;
  } // run
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if the test passed.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    try {

      Statement stmt = con.createStatement();

      // if this query returns anything then something is wrong
      ResultSet rs =
          stmt.executeQuery(
              "SELECT sr.seq_region_id, sr.name FROM seq_region sr, dna d WHERE sr.seq_region_id=d.seq_region_id AND d.sequence REGEXP '[^ATGCN]'");

      while (rs != null && rs.next()) {

        result = false;

        ReportManager.problem(
            this,
            con,
            String.format(
                "%s (seq_region_id %s) has non GTACN sequence", rs.getString(2), rs.getLong(1)));
      } // while rs

      stmt.close();

    } catch (SQLException e) {
      e.printStackTrace();
    }

    if (result == true) {

      ReportManager.correct(this, con, "No entries in dna table have non-GTACN bases.");
    }

    return result;
  } // run
  @Override
  protected boolean runTest(DatabaseRegistryEntry dbre) {

    Connection con = dbre.getConnection();

    int numRows = DBUtils.getRowCount(con, sql_find_wrong_lengths);

    boolean passed = numRows == 0;

    if (!passed) {

      ReportManager.problem(this, con, error_msg + "\n");

      try {
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(sql_find_wrong_lengths);
        if (rs != null) {

          while (rs.next()) {

            ReportManager.problem(
                this,
                con,
                "update seq_region set length="
                    + rs.getInt("len")
                    + " where seq_region_id="
                    + rs.getInt("seq_region_id")
                    + ";");
          }
        }
        rs.close();
        stmt.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return passed;
  }
  public boolean run(DatabaseRegistryEntry dbre) {

    Connection con = dbre.getConnection();

    if (!DBUtils.checkTableExists(con, "species_tree_node_tag")) {
      ReportManager.problem(this, con, "species_tree_node_tag table not present");
      return false;
    }

    // These methods return false if there is any problem with the test
    boolean result = true;
    result &= checkTreeStatsArePresent(dbre);
    return result;
  }
Exemple #28
0
  /** Check for values containing the text ARRAY(. */
  private boolean checkArrays(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    try {

      Statement stmt = con.createStatement();

      ResultSet rs =
          stmt.executeQuery(
              "SELECT meta_key, meta_value FROM meta WHERE meta_value LIKE 'ARRAY(%'");

      while (rs.next()) {

        ReportManager.problem(
            this,
            con,
            "Meta table entry for key "
                + rs.getString(1)
                + " has value "
                + rs.getString(2)
                + " which is probably incorrect");
        result = false;
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    if (result) {
      ReportManager.correct(this, con, "No duplicates in the meta table");
    }

    return result;
  }
Exemple #29
0
  /** Check for duplicate entries in the meta table. */
  private boolean checkDuplicates(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    try {

      Statement stmt = con.createStatement();

      ResultSet rs =
          stmt.executeQuery(
              "SELECT meta_key, meta_value FROM meta GROUP BY meta_key, meta_value, species_id HAVING COUNT(*)>1");

      while (rs.next()) {

        ReportManager.problem(
            this,
            con,
            "Key/value pair "
                + rs.getString(1)
                + "/"
                + rs.getString(2)
                + " appears more than once in the meta table");
        result = false;
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    if (result) {
      ReportManager.correct(this, con, "No duplicates in the meta table");
    }

    return result;
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.ensembl.healthcheck.testcase.AbstractTemplatedTestCase#runTest(org
  * .ensembl.healthcheck.DatabaseRegistryEntry)
  */
 @Override
 protected boolean runTest(DatabaseRegistryEntry dbre) {
   boolean passes = true;
   for (String name :
       getTemplate(dbre).queryForDefaultObjectList("select name from seq_region", String.class)) {
     if (!name.matches(VALID_NAME)) {
       ReportManager.problem(
           this,
           dbre.getConnection(),
           "Seq_region name " + name + " does not match expected expression " + VALID_NAME);
       passes = false;
     }
   }
   return passes;
 }