@@ -0,0 +1,2650 @@
+/*%0A * Copyright (C) 2004 EBI, GRL%0A * %0A * This library is free software; you can redistribute it and/or modify it under the%0A * terms of the GNU Lesser General Public License as published by the Free Software%0A * Foundation; either version 2.1 of the License, or (at your option) any later version.%0A * %0A * This library is distributed in the hope that it will be useful, but WITHOUT ANY%0A * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A%0A * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.%0A * %0A * You should have received a copy of the GNU Lesser General Public License along with%0A * this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place,%0A * Suite 330, Boston, MA 02111-1307 USA%0A */%0A%0Apackage org.ensembl.healthcheck.testcase.generic;%0A%0Aimport java.sql.Connection;%0A%0Aimport org.ensembl.healthcheck.DatabaseRegistryEntry;%0Aimport org.ensembl.healthcheck.ReportManager;%0Aimport org.ensembl.healthcheck.testcase.Priority;%0Aimport org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;%0A%0A/**%0A * Check for newlines & tabs in gene descriptions - causes problems for TSV dumping.%0A */%0Apublic class DescriptionNewlines extends SingleDatabaseTestCase %7B%0A%0A%09/**%0A%09 * Creates a new instance of DescriptionNewlines.%0A%09 */%0A%09public DescriptionNewlines() %7B%0A%0A%09%09addToGroup(%22post_genebuild%22);%0A%09%09addToGroup(%22release%22);%0A%0A%09%09setDescription(%22Check for newlines and tabs in gene descriptions.%22);%0A%0A%09%09setPriority(Priority.AMBER);%0A%09%09setEffect(%22Will cause problems for TSV file dumping and importing%22);%0A%09%09setFix(%22Remove newlines and tabs; useful SQL for identifying affected genes:%5CnSELECT g.gene_id, gsi.stable_id, g.description FROM gene g, gene_stable_id gsi WHERE g.gene_id=gsi.gene_id AND (LOCATE('%5C%5Cn', g.description) %3E 0 or LOCATE('%5C%5Ct', g.description) %3E 0);%22);%0A%0A%09%7D%0A%0A%09/**%0A%09 * Run the test.%0A%09 * %0A%09 * @param dbre%0A%09 *          The database to use.%0A%09 * @return true if the test passed.%0A%09 * %0A%09 */%0A%09public boolean run(DatabaseRegistryEntry dbre) %7B%0A%0A%09%09boolean result = true;%0A%0A%09%09Connection con = dbre.getConnection();%0A%0A%09%09int rows = getRowCount(con, %22SELECT COUNT(*) FROM gene g, gene_stable_id gsi WHERE g.gene_id=gsi.gene_id AND (LOCATE('%5Cn', g.description) %3E 0 OR LOCATE('%5Ct', g.description) %3E 0)%22);%0A%09%09%0A%09%09if (rows %3E 0) %7B%0A%09%09%09%0A%09%09%09result = false;%0A%09%09%09ReportManager.problem(this, con, rows + %22 genes have newlines and/or tabs in their descriptions%22);%0A%09%09%09%0A%09%09%7D else %7B%0A%09%09%09%0A%09%09%09ReportManager.correct(this, con, %22No genes have newlines or tabs in their descriptions%22);%0A%09%09%09%0A%09%09%7D%0A%09%09return result;%0A%0A%09%7D // run%0A%0A%09// -------------------------------------------------------------------------%0A%0A%7D // DescriptionNewlines%0A

Check for newlines & tabs in gene descriptions - causes problems for TSV dumping.