/**
  * @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;
 }
  @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;
  }
  /**
   * 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;
  }
 @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;
 }
  /**
   * Test various things about marker features.
   *
   * @param dbre The database to use.
   * @return Result.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    // only check for human, mouse, rat and zebrafish
    Species s = dbre.getSpecies();
    if ((dbre.getType() != DatabaseType.SANGER_VEGA
            && (s.equals(Species.HOMO_SAPIENS)
                || s.equals(Species.MUS_MUSCULUS)
                || s.equals(Species.RATTUS_NORVEGICUS)))
        || s.equals(Species.DANIO_RERIO)) { // for
      // sangervega
      // only
      // run
      // the
      // test
      // for
      // zebrafish

      result &= checkFeaturesAndMapWeights(con);

      result &= checkMarkerPriorities(con);

      result &= checkAllChromosomesHaveMarkers(con);
    }

    return result;
  } // run
Example #6
0
  /**
   * Check that the meta table exists and has data and the entries correspond to the database name.
   *
   * @param dbre The database to check.
   * @return True if the test passed.
   */
  public boolean run(final DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    Species species = dbre.getSpecies();

    result &= checkTableExists(con);

    result &= tableHasRows(con);

    result &= checkSchemaVersionDBName(dbre);

    if (species == Species.ANCESTRAL_SEQUENCES) {
      // The rest of the tests are not relevant for the ancestral
      // sequences DB
      return result;
    }

    if (dbre.getType() == DatabaseType.CORE) {
      result &= checkKeysPresent(con);
    }

    // -------------------------------------------

    result &= checkDuplicates(dbre);

    // -------------------------------------------

    result &= checkArrays(dbre);

    return result;
  } // run
  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;
  }
  /**
   * 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;
  }
Example #9
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;
  }
  /**
   * 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;
  }
  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;
  }
  public boolean run(DatabaseRegistryEntry dbre) {
    Connection con = dbre.getConnection();

    boolean result = true;

    result &=
        checkForOrphans(con, "gene_align_member", "gene_align_id", "gene_align", "gene_align_id");
    result &=
        checkForOrphans(con, "gene_align_member", "gene_align_id", "gene_align", "gene_align_id");
    result &=
        checkForOrphans(con, "gene_align_member", "seq_member_id", "seq_member", "seq_member_id");
    result &=
        checkOptionalRelation(
            con, "gene_tree_root", "gene_align_id", "gene_align", "gene_align_id");
    result &=
        checkForOrphansWithConstraint(
            con,
            "gene_tree_root_attr",
            "mcoffee_scores_gene_align_id",
            "gene_align",
            "gene_align_id",
            "mcoffee_scores_gene_align_id IS NOT NULL");

    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();

    // 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
  /**
   * 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
  /**
   * 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
  protected void init(DatabaseRegistryEntry dbre) {

    super.init();

    testDbConn = dbre.getConnection();
    sqlTemplateTestDb = getSqlTemplate(testDbConn);

    setTeamResponsible(Team.ENSEMBL_GENOMES);
  }
 /**
  * @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;
 }
 /**
  * Override of the test method which makes sure we only test those tables which are required by
  * the schema. If a table appears in the list specified by {@link #notRequiredTables()}.
  */
 @Override
 protected boolean compareTable(Connection master, DatabaseRegistryEntry targetDbre, String table)
     throws SQLException {
   Species species = targetDbre.getSpecies();
   Set<String> notRequired = getSets(notRequiredTables(), species);
   Set<String> required = getSets(requiredTables(), species);
   if (notRequired.contains(table) || required.contains(table)) {
     return true;
   }
   return super.compareTable(master, targetDbre, table);
 }
 protected boolean runTest(DatabaseRegistryEntry dbre) {
   SqlTemplate template = getTemplate(dbre);
   boolean passes = true;
   for (int speciesId : dbre.getSpeciesIds()) {
     // 2. check genebuild start date is set
     passes &= checkGeneBuild(dbre, template, speciesId);
     // 3. check that assembly.default matches version for rank 1
     // coordsystem
     passes &= checkAssembly(dbre, template, speciesId);
   }
   return passes;
 }
Example #20
0
 /*
  * (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;
 }
Example #21
0
  /**
   * 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;
  }
  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;
  }
  /**
   * 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
 /*
  * (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;
 }
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

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

    result &= checkLowCoverageMLSSAreLinkedToHighCoverageMLSS(dbre);

    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;
  }
  /**
   * Run the test.
   *
   * @param dbre The database to use.
   * @return true if all foreign key relationships are valid.
   */
  public boolean run(DatabaseRegistryEntry dbre) {

    boolean result = true;

    Connection con = dbre.getConnection();

    result &=
        checkForOrphansWithConstraint(
            con,
            "seq_region",
            "seq_region_id",
            "dna",
            "seq_region_id",
            "coord_system_id = (SELECT coord_system_id FROM coord_system WHERE attrib LIKE '%sequence_level%')");

    return result;
  }
Example #28
0
  /**
   * 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;
  }
  public boolean run(DatabaseRegistryEntry dbre) {
    Connection con = dbre.getConnection();

    boolean result = true;
    result &= checkForOrphansSameTable(con, "species_tree_node", "root_id", "node_id", false);
    result &= checkForOrphansSameTable(con, "species_tree_node", "parent_id", "node_id", true);
    result &=
        checkForOrphans(con, "species_tree_node_tag", "node_id", "species_tree_node", "node_id");
    result &= checkForOrphans(con, "species_tree_root", "root_id", "species_tree_node", "node_id");
    result &=
        checkOptionalRelation(
            con, "species_tree_node", "genome_db_id", "genome_db", "genome_db_id");
    result &=
        checkOptionalRelation(con, "species_tree_node", "taxon_id", "ncbi_taxa_node", "taxon_id");
    result &=
        checkOptionalRelation(con, "species_tree_node", "taxon_id", "ncbi_taxa_name", "taxon_id");
    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;
  }