/*
 * 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 VariationSynonym extends SingleDatabaseTestCase {

    /**
     * Creates a new instance of Check Variation Synonym
     */
    public VariationSynonym() {
        addToGroup("variation");
	addToGroup("variation-release");
        setDescription("Check that Venter and Watson should have 3 million variations");
    }

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

        boolean result = true;
	String[] individualNames = {"Venter","Watson"};
	String individualName;
	// Check that Venter and Watson should have 3 million variations

        Connection con = dbre.getConnection();
	for (int i = 0; i < individualNames.length; i++) {
	    individualName = individualNames[i];
	    int rows = getRowCount(con, "SELECT COUNT(*) FROM variation v, source s WHERE v.source_id=s.source_id and s.name like '%" + individualName + "'");
	    int rows1 = getRowCount(con, "SELECT COUNT(*) FROM variation_synonym vs, source s WHERE vs.source_id=s.source_id and s.name like '%" + individualName + "'");
	    int tot_rows = rows + rows1;
	    if (tot_rows < 3000000) {
		result = false;
		ReportManager.problem(this, con, tot_rows + " with variations for " + individualName);
	    } else {
		//ReportManager.info(this, con, tot_rows + " with variation for " + individualName);
	    }
	}

        if (result){
        	ReportManager.correct(this,con,"Venter/Watson has more then 3 million variations");
        }
        return result;

    } // run

} // VariationSynonym

@@ -1057,16 +1057,56 @@
 estCase;
+%0Aimport org.ensembl.healthcheck.Species;
 %0A%0A/**%0A *
@@ -1957,16 +1957,69 @@
 ion();%0A%09
+if (dbre.getSpecies() == Species.HOMO_SAPIENS)%7B%0A%09    
 for (int
@@ -2062,20 +2062,17 @@
 i++) %7B%0A%09
-    
+%09
 individu
@@ -2101,20 +2101,17 @@
 es%5Bi%5D;%0A%09
-    
+%09
 int rows
@@ -2246,28 +2246,25 @@
 me + %22'%22);%0A%09
-    
+%09
 int rows1 = 
@@ -2410,20 +2410,17 @@
  %22'%22);%0A%09
-    
+%09
 int tot_
@@ -2441,20 +2441,17 @@
 rows1;%0A%09
-    
+%09
 if (tot_
@@ -2470,16 +2470,20 @@
 00) %7B%0A%09%09
+    
 result =
@@ -2492,16 +2492,20 @@
 alse;%0A%09%09
+    
 ReportMa
@@ -2584,20 +2584,17 @@
 Name);%0A%09
-    
+%09
 %7D else %7B
@@ -2596,16 +2596,20 @@
 lse %7B%0A%09%09
+    
 //Report
@@ -2689,19 +2689,22 @@
 e);%0A
+%09%09%7D%0A
 %09    %7D%0A
+
 %09%7D%0A
-%0A
     

check just for human now