<commit_before>/*
 Copyright (C) 2003 EBI, GRL

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.ensembl.healthcheck.testcase.generic;

import java.sql.Connection;

import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.ReportManager;
import org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;

/**
 * Check for repeat features that have repeat_start > repeat_end. Note that seq_region_start/end are checked in FeatureCoords.
 */

public class RepeatFeature extends SingleDatabaseTestCase {

    /**
     * Create a new RepeatFeature testcase.
     */
    public RepeatFeature() {

        addToGroup("post_genebuild");
        addToGroup("release");
        setDescription("Check that repeat_start is not greater than repeat_end in repeat_feature");

    }

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

        boolean result = true;
        String sql = "SELECT COUNT(*) FROM repeat_feature WHERE repeat_start > repeat_end";
        Connection con = dbre.getConnection();
        int rows = getRowCount(con, sql);
        if (rows == 0) {
            ReportManager.correct(this, con, "All repeat_feature_start < repeat_feature end");
        } else if (rows > 0) {
            ReportManager.problem(this, con, rows + " rows in repeat_feature have repeat_start > repeat_end");
            result = false;
        }

        return result;

    } // run

} // RepeatFeature
<commit_msg>Added a check for repeat_start < 1 or repeat_end < 1 (also a symptom of RepeatMasker)<commit_after>/*
 Copyright (C) 2003 EBI, GRL

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package org.ensembl.healthcheck.testcase.generic;

import java.sql.Connection;

import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.ReportManager;
import org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;

/**
 * Check for repeat features that have repeat_start > repeat_end, or start or end < 1. Note that seq_region_start/end are checked in FeatureCoords.
 */

public class RepeatFeature extends SingleDatabaseTestCase {

    /**
     * Create a new RepeatFeature testcase.
     */
    public RepeatFeature() {

        addToGroup("post_genebuild");
        addToGroup("release");
        setDescription("Check that repeat_start and repeat_end in repeat_feature make sense.");

    }

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

        boolean result = true;
        
        // check that start < end
        String sql = "SELECT COUNT(*) FROM repeat_feature WHERE repeat_start > repeat_end";
        Connection con = dbre.getConnection();
        int rows = getRowCount(con, sql);
        if (rows == 0) {
            ReportManager.correct(this, con, "All repeat_feature_start < repeat_feature end");
        } else if (rows > 0) {
            ReportManager.problem(this, con, rows + " rows in repeat_feature have repeat_start > repeat_end");
            result = false;
        }

        // check start and end not < 1
        sql = "SELECT COUNT(*) FROM repeat_feature WHERE repeat_start < 1 OR repeat_end < 1";
        rows = getRowCount(con, sql);
        if (rows == 0) {
            ReportManager.correct(this, con, "All repeat_feature repeat_start and repeat_end < 1");
        } else if (rows > 0) {
            ReportManager.problem(this, con, rows + " rows in repeat_feature have repeat_start or repeat_end < 1");
            result = false;
        }
        return result;

    } // run

} // RepeatFeature

{'fraction_non_alphanumeric': 0.07677204005497743, 'fraction_numerical': 0.010602788140585117, 'mean_word_length': 2.9488372093023254, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6540422', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1323, 'n_words': 543}