<commit_before>/*
 * Copyright (C) 2004 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.variation;

import java.sql.Connection;

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

/**
 * Check that if the peptide_allele_string of transcript_variation is not >1. 
 * It should out >1, unless it filled with numbers
 */
public class TranscriptVariation extends SingleDatabaseTestCase {

    /**
     * Creates a new instance of Check Transcript Variation
     */
    public TranscriptVariation() {
        addToGroup("variation");
	addToGroup("variation-release");
        setDescription("Check that if the peptide_allele_string of transcript_variation is not >1. It should out >1, unless it filled with numbers");
    }

    /**
     * Find any matching databases that have peptide_allele_string column.
     * @param dbre
     *          The database to use.
     * @return Result.
     */
    public boolean run(DatabaseRegistryEntry dbre) {

        boolean result = true;

	// check peptide_allele_string not filled with numbers

        Connection con = dbre.getConnection();
        int rows = getRowCount(con, "SELECT COUNT(*) FROM transcript_variation WHERE peptide_allele_string >1");
        if (rows >=1) {
            result = false;
            ReportManager.problem(this, con, rows + " with peptide_allele_string >1");
        } else {
      //      ReportManager.info(this, con, "No transcript_variation have peptide_allele_string >1);
        }

	int rows1 = getRowCount(con, "SELECT COUNT(*) FROM transcript_variation WHERE consequence_type=''");
        if (rows1 >=1) {
            result = false;
            ReportManager.problem(this, con, rows1 + " with consequence_type a empty string");
        } else {
      //      ReportManager.info(this, con, "No transcript_variation have consequence_type a empty string");
        }
	
	int rows2 = getRowCount(con, "SELECT COUNT(*) FROM variation_feature vf WHERE NOT EXISTS (SELECT * FROM transcript_variation tv WHERE tv.variation_feature_id = vf.variation_feature_id) AND vf.consequence_type != 'INTERGENIC' AND vf.consequence_type != 'HGMD_MUTATION'");
        if (rows2 >=1) {
	    result = false;
	    ReportManager.problem(this, con, rows2 + " with consequence_type != 'INTERGENIC' and there is no corresponding transcript exists in transcript_variation table");
	}
	if (result){
        	ReportManager.correct(this,con,"transcript_variation have peptide_allele_string >1, indicating column shift, peptide_allele_string become a number or consequence_type a empty string or consequence_type is not a INTERGENIC where there is no transcript exists");
        }

        return result;

    } // run

} // TranscriptVariation<commit_msg>Modified to accommodate new schema changes<commit_after>/*
 * Copyright (C) 2004 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.variation;

import java.sql.Connection;

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

/**
 * Check that if the peptide_allele_string of transcript_variation is not >1. 
 * It should out >1, unless it filled with numbers
 */
public class TranscriptVariation extends SingleDatabaseTestCase {

    /**
     * Creates a new instance of Check Transcript Variation
     */
    public TranscriptVariation() {
        addToGroup("variation");
	addToGroup("variation-release");
        setDescription("Check that if the peptide_allele_string of transcript_variation is not >1. It should out >1, unless it filled with numbers");
    }

    /**
     * Find any matching databases that have peptide_allele_string column.
     * @param dbre
     *          The database to use.
     * @return Result.
     */
    public boolean run(DatabaseRegistryEntry dbre) {

        boolean result = true;

	// check peptide_allele_string not filled with numbers

        Connection con = dbre.getConnection();
        int rows = getRowCount(con, "SELECT COUNT(*) FROM transcript_variation WHERE pep_allele_string >1");
        if (rows >=1) {
            result = false;
            ReportManager.problem(this, con, rows + " with peptide_allele_string >1");
        } else {
      //      ReportManager.info(this, con, "No transcript_variation have peptide_allele_string >1);
        }

	int rows1 = getRowCount(con, "SELECT COUNT(*) FROM transcript_variation WHERE consequence_types=''");
        if (rows1 >=1) {
            result = false;
            ReportManager.problem(this, con, rows1 + " with consequence_types a empty string");
        } else {
      //      ReportManager.info(this, con, "No transcript_variation have consequence_type a empty string");
        }
        
	int rows2 = getRowCount(con, "SELECT COUNT(*) FROM variation_feature vf WHERE NOT FIND_IN_SET('intergenic_variant',vf.consequence_type) AND NOT EXISTS (SELECT * FROM transcript_variation tv WHERE tv.variation_feature_id = vf.variation_feature_id)");
        if (rows2 >=1) {
	    result = false;
	    ReportManager.problem(this, con, rows2 + " with consequence_type != 'intergenic_variant' and there is no corresponding transcript exists in transcript_variation table");
	}
	if (result){
        	ReportManager.correct(this,con,"transcript_variation have peptide_allele_string >1, indicating column shift, peptide_allele_string become a number or consequence_type a empty string or consequence_type is not a intergenic_variant where there is no transcript exists");
        }

        return result;

    } // run

} // TranscriptVariation
{'fraction_non_alphanumeric': 0.07980118735330664, 'fraction_numerical': 0.010216761010630954, 'mean_word_length': 3.4965859714463066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '6962517', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1902, 'n_words': 723}